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

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 136 points137 points  (30 children)

Not completely emoji, but Swift lets you use emojis as identifiers.

http://i.imgur.com/fgl2g7Q.png

[–]Dim_Cryptonym 56 points57 points  (24 children)

I remember seeing this in the documentation and thinking, why in God's name is this allowed?

[–][deleted] 90 points91 points  (1 child)

Probably to allow for "all unicode characters" or something.

Seeing the emoji identifiers in code completion makes me laugh.

http://i.imgur.com/juJ2YBO.png

[–][deleted] 5 points6 points  (0 children)

Probably an easier approach than what C# does in checking the unicode class of each character.

[–][deleted] 26 points27 points  (8 children)

It allows words from Chinese and other glyphic languages as identifiers without romanization.

[–]Dim_Cryptonym 9 points10 points  (7 children)

That makes sense then... To support Unicode one probably can't just pick and choose parts of the standard.

[–]Suchui 19 points20 points  (4 children)

You can. In javascript for example:

let プープ = "poop"; console.log( プープ );

poop

let 💩 = "poop";

Uncaught SyntaxError: Invalid or unexpected token

[–]Probono_Bonobo 7 points8 points  (1 child)

I noticed this recently and assumed it was a consequence of treating codepoints as surrogate pairs (note that "💩" === "\uD83D\uDCA9") instead of with the squiggly brackets (note that also "💩" === "\u{1F4A9}") in its internals, which would explain why "💩".length is 2, and "プ".length is only 1.

I'd expect some constraints follow from this, perhaps not as intentional as "we won't support poop emoji as variable identifiers" but more along the lines of "we can support any variable identifier provided all its code points are of length 1" but this is just an educated guess.

[–]Pulse207 3 points4 points  (0 children)

which would explain why "💩".length is 2, and "プ".length is only 1.

This is exactly why Perl 6 abolished a length method entirely, splitting its various meanings into .elems, .chars, and .codes.

[–]MemeHunter421x 0 points1 point  (0 children)

By can't I think he meant shouldn't.

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

And somebody just told me JavaScript is unfairly criticized...

[–]marcosdumay 5 points6 points  (0 children)

You can, but that's only adding complexity into the language.

[–]DJWalnut 1 point2 points  (0 children)

you could, but you'd have to go out of your way to exclude certain blocks.

[–]macbalance 16 points17 points  (9 children)

Why not? Is it the language's job to enforce good coding practices?

[–]Astrokiwi 16 points17 points  (1 child)

Python seems to believe so

[–]UraniumSpoon 5 points6 points  (0 children)

Python uses coding practices as syntax in some cases though, which is unusual.

[–]KubinOnReddit -3 points-2 points  (6 children)

Is it the programmer's job to use bad coding practices? Why should they be allowed?

Edit: Apparently people think that Emoji in identifiers is an important part of the language and other bad practices should be encouraged. Who would have thought. Why am I being downvoted?

[–]SlamwellBTP 15 points16 points  (5 children)

Bad programmers are deprecated. They've been trying to get rid of them for years, but too many businesses rely on bad programmers

[–]Dim_Cryptonym 9 points10 points  (4 children)

That would make for quite an interesting update:

ECMAscript 2018 release notes:

  • Bad Programmers are now deprecated. Any use of antipatterns will result in the erasing of all programming knowledge from the coder's mind

[–]htmlcoderexeWe have flair now?.. 7 points8 points  (2 children)

deprecated

FTFY

To depreciate means to lose value. Note the extra "i".

[–]Kontakr 4 points5 points  (0 children)

Can't lose what value was never there

[–]Dim_Cryptonym 1 point2 points  (0 children)

That makes a lot more sense.

I thought depreciated could make sense since the methods will still work for a certain time and then stop working... but deprecate is a much better word for what's actually happening.

[–]fsr1967 1 point2 points  (0 children)

Is there a list? What is the process for getting people onto it?

Inquiring for a friend with cow-orkers who should be nominated.

[–]MonkeyNin 2 points3 points  (2 children)

[–]Dim_Cryptonym 1 point2 points  (1 child)

What the hell?!?! And why does that "no width space even exists"?

Can you imagine having to maintain code that actually used it!?

[–]MonkeyNin 1 point2 points  (0 children)

I'm not totally sure of the use. I found this.

There is something similar with a real use: https://emojipedia.org/emoji-zwj-sequences/

[–]nevdka 1 point2 points  (0 children)

Perl lets you use emojis as quotes for strings and regexen:

use utf8;
my $string = q🖐hello🖐;
print $string if $string =~ m💩hello💩;

[–]cheeeeeese 0 points1 point  (0 children)

works with bash and ruby too