# \[Question\] The key reason not accept single quotes string in Crystal

**URL:** <https://forum.crystal-lang.org/t/question-the-key-reason-not-accept-single-quotes-string-in-crystal/4606>\
**Category:** Help & Support\
**Created:** [May 5, 2022, 6:03pm UTC](https://forum.crystal-lang.org/t/question-the-key-reason-not-accept-single-quotes-string-in-crystal/4606 "2022-05-05T18:03:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [May 5, 2022, 6:03pm UTC](https://forum.crystal-lang.org/t/question-the-key-reason-not-accept-single-quotes-string-in-crystal/4606/1 "2022-05-05T18:03:22Z")

</div>

I come from ruby, you know, we have many `GOOD` habit, e.g. i always write string use double quotes, unless, we need interpolate or escape like “\n” or “\t”

After i switch to Crystal, the biggest trouble, is, i always write string like this: (rubocop fans)

```nohighlight
string = 'this is a normal string'

```

It okay anyway, just curious, why do this decision? more simple compiler? or just follow others static language, like go, rust ?

Thank you.

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [May 5, 2022, 6:10pm UTC](https://forum.crystal-lang.org/t/question-the-key-reason-not-accept-single-quotes-string-in-crystal/4606/2 "2022-05-05T18:10:48Z")

</div>

> **[Crystal for Rubyists · crystal-lang/crystal Wiki](https://github.com/crystal-lang/crystal/wiki/Crystal-for-Rubyists#single-versus-double-quoted-strings)**
>
> The Crystal Programming Language. Contribute to crystal-lang/crystal development by creating an account on GitHub.

tl;dr to allow single quotes to represent `Char` type characters, while double quote is for `String` type values.

EDIT: Is also some discussion in [Would it be possible for '' to be accepted for Strings as well, as in ruby, or was that already rejected before? · Issue #10640 · crystal-lang/crystal · GitHub](https://github.com/crystal-lang/crystal/issues/10640).

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 5, 2022, 7:11pm UTC](https://forum.crystal-lang.org/t/question-the-key-reason-not-accept-single-quotes-string-in-crystal/4606/3 "2022-05-05T19:11:36Z")

</div>

As an additional note, you can use percent string literals if you don’t want interpolations to be interpreted in a string: [String - Crystal](https://crystal-lang.org/reference/1.4/syntax_and_semantics/literals/string.html#percent-string-literals)

---

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [May 6, 2022, 7:55am UTC](https://forum.crystal-lang.org/t/question-the-key-reason-not-accept-single-quotes-string-in-crystal/4606/4 "2022-05-06T07:55:25Z")

</div>

Thank you for help, i read both links, i guess double quote with interpolation no performance penalty because Crystal is compiled instead interpreter directly in runtime.

anyway, this is not a minimal surprise when switch from Ruby to Crystal, that ok, i consider change my rubocop config to force use double quote instead anyway, thank you emacs, i have a function to do this transform with just a hotkey.

---

<div class="post-metadata">

**Author:** ![Fryguy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fryguy/32/1181_2.png) [@Fryguy](https://forum.crystal-lang.org/u/Fryguy)\
**Post date:** [May 12, 2022, 6:56pm UTC](https://forum.crystal-lang.org/t/question-the-key-reason-not-accept-single-quotes-string-in-crystal/4606/5 "2022-05-12T18:56:21Z")

</div>

> i guess double quote with interpolation no performance penalty because Crystal is compiled instead interpreter directly in runtime.

FWIW, In Ruby there’s also no performance difference between single quote and double quote with string literals.

See for example the disassembly in Ruby for double quotes:

```auto
> puts RubyVM::InstructionSequence.disasm(->() { "Hi" })
0000 nop ( 5)[Bc]
0001 putstring "Hi"[Li]
0003 nop
0004 leave ( 5)[Br]

```

and single quotes:

```auto
> puts RubyVM::InstructionSequence.disasm(->() { 'Hi' })
0000 nop ( 4)[Bc]
0001 putstring "Hi"[Li]
0003 nop
0004 leave ( 4)[Br]

```

---

<div class="post-metadata">

**Author:** ![asterite](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/asterite/32/60_2.png) [@asterite](https://forum.crystal-lang.org/u/asterite)\
**Post date:** [May 12, 2022, 8:51pm UTC](https://forum.crystal-lang.org/t/question-the-key-reason-not-accept-single-quotes-string-in-crystal/4606/6 "2022-05-12T20:51:25Z")

</div>

I think that if there was a performance different it would come from **parsing** the single quote string vs. the double quote string. But I recently read an article that showed that there’s no difference at all.

---

<div class="post-metadata">

**Author:** ![zw963](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/zw963/32/1623_2.png) [@zw963](https://forum.crystal-lang.org/u/zw963)\
**Post date:** [May 13, 2022, 2:28pm UTC](https://forum.crystal-lang.org/t/question-the-key-reason-not-accept-single-quotes-string-in-crystal/4606/7 "2022-05-13T14:28:16Z")

</div>

Yes, i think ruby optimize this since some version.
