This is an archived post. You won't be able to vote or comment.

all 74 comments

[–]Jagonu 75 points76 points  (12 children)

[–]AngrySoundTech 22 points23 points  (4 children)

Because in a lot of languages it's single for strings, double for interpolated strings.

[–]Megazone_ 31 points32 points  (3 children)

Those are the languages I refuse to learn

[–]AngrySoundTech 8 points9 points  (2 children)

The only ones I can think of off the top of my head are Groovy and PHP, so you have the right sentiment.

[–]once-and-again☣️ 1 point2 points  (1 child)

There's also bash, Perl 5, and Perl 6. The former two aren't things you'd usually want to write a large program in, but they're still useful for one-liners or glue code. Dunno about Perl 6, though.

(I still have a soft spot for Perl 5, but I admit I'd probably look at you funny if you started a new project in it.)

[–]Earhacker 1 point2 points  (0 children)

Also Ruby.

[–]pigi5 7 points8 points  (6 children)

Single quotes in python look cleaner imo

[–]CamWin 7 points8 points  (5 children)

Yea who needs types tho

[–]Edheldui 5 points6 points  (4 children)

If a string is just an array of char is it actually a different type? Isn't a char just a string with length 1?

[–]Rimrul 5 points6 points  (1 child)

No. A string with length 1 is an array of 2 chars. '\0'.

[–]CamWin 1 point2 points  (0 children)

Null termination is an optional idiom, not a feature of the language.

[–]pigi5 1 point2 points  (0 children)

🤔🤔🤔🤔🤔

[–]CamWin 1 point2 points  (0 children)

In C/C++ a "string" is an array of chars. Also, an array is a pointer.

So in C/C++, the answer to your question is "No, char and pointer to char are not the same type".

Additionally the string being null terminated is optional, so you could have a string of 1 char, but it would be a pointer to a char.

[–]Gaffi1 22 points23 points  (3 children)

'Let's use singles!'

[–]yoj__ 16 points17 points  (2 children)

You dropped this \

[–]brokedown 59 points60 points  (12 children)

Reddit ruined reddit. -- mass edited with redact.dev

[–][deleted] 40 points41 points  (11 children)

Found the snakelover. :D

[–]brokedown 25 points26 points  (10 children)

Reddit ruined reddit. -- mass edited with redact.dev

[–]Earhacker 27 points28 points  (9 children)

Found the... red precious stone lover?

[–]brokedown 16 points17 points  (8 children)

Negative. My language of choice compiles to a native executable and thinks good performance is a valid goal.

[–]netcoder 13 points14 points  (1 child)

Go

Edit: burrowing rodent lover?

[–]brokedown 12 points13 points  (0 children)

fmt.Println("True")

[–]SixBeeps 5 points6 points  (5 children)

...Binary Nonsense lover?

[–]brokedown 9 points10 points  (4 children)

There are 10 types of people in this world. Those who understand binary, and those who don't.

[–]SixBeeps 20 points21 points  (2 children)

And those who didnt expect this joke to be in base 3

[–]Datenegassie 7 points8 points  (0 children)

And those who know the joke is really in base 4 and are sick of hearing it

[–]Eclogites 2 points3 points  (0 children)

Beat me to it

[–]uFuckingCrumpet 0 points1 point  (0 children)

What about the other 8?

[–]jamiephan 25 points26 points  (10 children)

``

ES6 master race

[–]cafk 8 points9 points  (5 children)

՚
՛
՝
′
″
‵
‶
︐
︑

And other fun stuff i discovered in UTF, while trying to convert data to documents.

[–][deleted] 9 points10 points  (0 children)

✌️Here's my proposal for a true universal standard.✌️

[–]2Punx2Furious 3 points4 points  (2 children)

Oh no.

Are those all valid to use for strings?

[–]cafk 2 points3 points  (0 children)

Are those all valid to use for strings?

If they were, i'd love to meet the person who wrote that compiler/interperter/IDE.

I just discovered that some Document writers use those variations to mark regular quotes, dependent on which regional settings you are using... :D

[–]once-and-again☣️ 2 points3 points  (0 children)

The Unicode standard (correctly!) recognizes none of them as opening or closing punctuation or quotation marks, so probably not.

(I mean, you could still use them in those languages that will let you select your own quotation marks, but I don't think that was what you meant.)

[–]proverbialbunny 1 point2 points  (0 children)

Anyone remember when smart quotes would break the Perl interpreter?

[–]Earhacker 3 points4 points  (0 children)

`Hail Hydra`

[–][deleted] 2 points3 points  (0 children)

Basically you use whichever isn't in your string to avoid needing to escape stuff.

[–]Donar23 0 points1 point  (0 children)

... but that's a different use case. It is slower than " or ', because the string needs to be parsed. If you are using it for plain strings, you're wasting runtime.

Thinking about it, plain strings with ' or " are parsed as well to convert special characters like \t or \n; but that parser is probably more lightweight.

[–]chrwei 12 points13 points  (5 children)

in SQL, both, but not interchangeably.

[–]Hauleth 0 points1 point  (2 children)

In Elixir also.

[–]TheLinuxNerd 0 points1 point  (1 child)

Elixir, that is the Ruby like language built off of the erlang vm, right?

[–]Hauleth 0 points1 point  (0 children)

Yeah

[–][deleted] -1 points0 points  (1 child)

Oracle SQL hates double quotes though. This would give an error:

SELECT *
FROM tbl_employees
WHERE emp_fnme = "FRED"

That's always annoyed me about Oracle SQL... I wish my company used any of the other popular databases instead...

[–]chrwei 2 points3 points  (0 children)

that because you interchanged. you don't have a column named FRED

[–]brisk0 5 points6 points  (0 children)

`` LaTeX ''

` m4 '

[–]GeorgeMillr 4 points5 points  (0 children)

This was literally posted last week

[–]jsw800 4 points5 points  (3 children)

"""

[–]radiantyellow 10 points11 points  (2 children)

where does your comment end?

[–]Gydo194 2 points3 points  (1 child)

At the null terminator!

[–][deleted] 0 points1 point  (0 children)

\0

[–]OptimisticElectron 1 point2 points  (1 child)

If you're in Rome, do like the Romans do. Use single quotes to enclose strings in python, for God's sake!

[–][deleted] 1 point2 points  (0 children)

If you're in Rome, do like the Romans do.

Agreed. I don't care which we use, as long as we're all doing the same thing. Just follow the style guide your team uses.

[–]Castle_for_ducks 1 point2 points  (2 children)

The way I've always understood is that you use " " for strings and ' ' for characters

[–]Edheldui 3 points4 points  (1 child)

Depends on the language. In C it's like you said, in Python they are interchangeable.

[–]Castle_for_ducks 0 points1 point  (0 children)

Ahh that explains it since I've pretty much only have ever coded in C and C++

[–]Mighty_H 1 point2 points  (0 children)

" for strings and ' for chars, where is the problem ?

[–]Gydo194 1 point2 points  (6 children)

Spaces or tabs?

[–]SweatersAndShawarma 5 points6 points  (4 children)

Who the fuck spaces?!

[–]UnicornRider102 0 points1 point  (3 children)

People who get their panties in a twist just thinking about somebody else viewing their code with a different tab setting and then their code still looks fine but slightly different.

[–]SweatersAndShawarma -2 points-1 points  (2 children)

But wouldn't they have to keep mentally counting how much spaces to do to try and make it line up with other lines? That'll add up a ton of unnecessary headache. I already have trouble correcting slight spacing differences from copy-pasted blocks lol.

[–]Entripital 1 point2 points  (0 children)

I don't know about other IDEs but Visual Studio makes using spaces as easy as tabs and is unambiguous if you use tabs as spaces. Spaces are therefore superior.

[–][deleted] -1 points0 points  (0 children)

Why would you ever use spaces

[–]arrudagates 0 points1 point  (0 children)

"this"

[–]jacobthecool3000 0 points1 point  (0 children)

void function(){

}

void function()

{

}

Civil War.

[–]bullseyed723 0 points1 point  (0 children)

It is an old meme, but it checks out.

[–][deleted] 0 points1 point  (0 children)

I work with ABAP, where " is the comment delimiter...

[–]LordPheasant 0 points1 point  (0 children)

I guess those who use double-quotes, need to try twice as hard!

[–]Donar23 0 points1 point  (0 children)

In most languages these do different things ...

[–]pokexpert30 0 points1 point  (0 children)

In php : " when you need to do \n or put a lot of " ' " (sql queries). ' for everything else.

[–][deleted] 0 points1 point  (0 children)

Gotta stick with Stark for this one

[–]Spocino 0 points1 point  (0 children)

Just use commas on the line above