Live data from Hacker News

The emoji problem (2022)

artofproblemsolving.com

41–50 of 71 posts

Re: The emoji problem (2022)

#42
post #4

It's year 2025, why doesn't the author use actual fruit emoji for variable names?

While current year is 2025, the year the language was made in probably isnt

The early pages of the Swift docs show you can use emojis as variable names, and iirc that was the very first page in the Swift 1.0 handbook. I have a theory that the language design was originally motivated by emojis, because there were also interesting choices around strings, like originally having no ".length" method.

Re: The emoji problem (2022)

#45

Earlier quoted context omitted.

While current year is 2025, the year the language was made in probably isnt

Good or not, many languages choose not to support emoji, even newer ones. The reasons are complicated but, many people prefer unicode normalization so that different forms of what appear to be the same word are considered the same word. People argue whether or not this is important but it can certainly be argued that it would be frustrating to get an error like let café = 1; café += 1; // error, unknown identifier '…

I had an idea the other day to use 64-bit character codes. Then each code can be interpreted as an 8x8 bitmap. Every character would be guaranteed to have a unique bitmap representation. The bitmaps wouldn't bet used for rendering, of course -- but they could be used as a fallback if your font does not define a character. Anyway this would somewhat avoid the problem you describe because two characters that look the same visually would have the same value. Nothing I'll ever implement of course, just a thought experiment.

Re: The emoji problem (2022)

#46

Earlier quoted context omitted.

When trying to understand complex C codebase I've often found it helpful to rename existing variable as emojis. This makes it much easier to track which variables are used where & to take in the pure structure of the code at one glance. An example I posted previously: https://imgur.com/F27ZNfk Unfortunately most modern languages like Rust and JS follow the XID_Start/XID_Continue recommendation (not very well-motivate…

wouldn't writing a parser of sorts that would replace emojis with a valid alphabetical string identifier be trivial?

You're right that writing a preprocessor would be straightforward. But while you're actively editing the code, your dev experience will still be bad: the editor will flag emoji identifiers as syntax errors so mass renaming & autocompletion won't work properly. Last time I looked into this in VSCode I got TypeScript to stop complaining about syntax errors by patching the identifier validation with something like `if (code>127) return true` (if non-ascii, consider valid) in isUnicodeIdentifierStart/isUnicodeIdentifierPart [1]. But then you'd also need to patch the transpiler to JS, formatters like Prettier, and any other tool in your workflow that embeds their own version of TypeScript...

[1] https://github.com/microsoft/TypeScript/blob/81c951894e93bdc...

Re: The emoji problem (2022)

#48

Earlier quoted context omitted.

While current year is 2025, the year the language was made in probably isnt

The early pages of the Swift docs show you can use emojis as variable names, and iirc that was the very first page in the Swift 1.0 handbook. I have a theory that the language design was originally motivated by emojis, because there were also interesting choices around strings, like originally having no ".length" method.

Here: https://docs.swift.org/swift-book/documentation/the-swift-pr...

Easter egg: The example is named dogcow, after a 90s Mac icon, designed by Susan Kare, which later became a small mascot: https://512pixels.net/dogcow/

Regarding .length: Effectly that is just the result of Unicode, there is no one-to-one equivalent between characters code points, the code units in an encoding and the resulting grapheme clusters. That is in effect a result of the complexity of the world's alphabets, including Emoji.

Re: The emoji problem (2022)

#50

Using other constants in place of the ‘4’ can lead to some _really_ gigantic smallest solutions: https://observablehq.com/@robinhouston/a-remarkable-diophant...

Ah, I really really love the dumb but magnificent on-demand loading of the 120-million-digit-long numbers in a nice little textarea!
Post reply on HN