51 points
*

Now this is UX. Wonderful stuff.

permalink
report
reply
31 points

And the site’s dark mode is fantastic…

permalink
report
parent
reply
11 points

Best dark mode ever!

permalink
report
parent
reply
3 points

Lol, who turned the lights out?

permalink
report
parent
reply
9 points
*
Deleted by creator
permalink
report
parent
reply
8 points

permalink
report
parent
reply
4 points

This one really got a laugh out of me

permalink
report
parent
reply
19 points

Thank god for reader view because this makes me feel physically sick to look at.

permalink
report
parent
reply
2 points

Same.

permalink
report
parent
reply
2 points

Right?? I normally love it when websites have a fun twist, but this one really needs an off button. The other cursors keep covering the text and it becomes genuinely uncomfortable to read. Fortunately, you can easily block the WS endpoint with any ad blocker.

permalink
report
parent
reply
6 points

The horror

permalink
report
parent
reply
4 points

I love it. People should be having more fun with their own personal sites.

permalink
report
parent
reply
2 points
Deleted by creator
permalink
report
parent
reply
1 point

Is that other readers’ mouse pointers?

permalink
report
parent
reply
24 points
*

I love the comparison of string length of the same UTF-8 string in four programming languages (only the last one is correct, by the way):

Python 3:

len(“🤦🏼‍♂️”)

5

JavaScript / Java / C#:

“🤦🏼‍♂️”.length

7

Rust:

println!(“{}”, “🤦🏼‍♂️”.len());

17

Swift:

print(“🤦🏼‍♂️”.count)

1

permalink
report
reply
43 points
*

That depends on your definition of correct lmao. Rust explicitly counts utf-8 scalar values, because that’s the length of the raw bytes contained in the string. There are many times where that value is more useful than the grapheme count.

permalink
report
parent
reply
15 points

And rust also has the “🤦”.chars().count() which returns 1.

I would rather argue that rust should not have a simple len function for strings, but since str is only a byte slice it works that way.

Also also the len function clearly states:

This length is in bytes, not chars or graphemes. In other words, it might not be what a human considers the length of the string.

permalink
report
parent
reply
11 points

None of these languages should have generic len() or size() for strings, come to think of it. It should always be something explicit like bytes() or chars() or graphemes(). But they’re there for legacy reasons.

permalink
report
parent
reply
10 points

That Rust function returns the number of codepoints, not the number of graphemes, which is rarely useful. You need to use a facepalm emoji with skin color modifiers to see the difference.

The way to get a proper grapheme count in Rust is e.g. via this library: https://crates.io/crates/unicode-segmentation

permalink
report
parent
reply
7 points

Yeah, and as much as I understand the article saying there should be an easily accessible method for grapheme count, it’s also kind of mad to put something like this into a stdlib.

Its behaviour will break with each new Unicode standard. And you’d have to upgrade the whole stdlib to keep up-to-date with the newest Unicode standards.

permalink
report
parent
reply
4 points

It might make more sense to expose a standard library API for unicode data provided by (and updated with) the operating system. Something like the time zone database.

permalink
report
parent
reply
4 points
*

The way UTF-8 works is fixed though, isn’t it? A new Unicode standard should not change that, so as long as the string is UTF-8 encoded, you can determine the character count without needing to have the latest Unicode standard.

Plus in Rust, you can instead use .chars().count() as Rust’s char type is UTF-8 Unicode encoded, thus strings are as well.

turns out one should read the article before commenting

permalink
report
parent
reply
18 points

Unicode is thoroughly underrated.

UTF-8, doubly so. One of the amazing/clever things they did was to build off of ASCII as a subset by taking advantage of the extra bit to stay backwards compatible, which is a lesson we should all learn when evolving systems with users (your chances of success are much better if you extend than to rewrite).

On the other hand, having dealt with UTF-7 (a very “special” email encoding), it takes a certain kind of nerd to really appreciate the nuances of encodings.

permalink
report
reply
6 points

I’ve recently come to appreciate the “refactor the code while you write it” and “keep possible future changes in mind” ideas more and more. I think it really increases the probability that the system can live on instead of becoming obsolete.

permalink
report
parent
reply
1 point

Yes, but once code becomes too spaghetti such that a “refactor while you write it” becomes too time intensive and error prone, it’s already too late.

permalink
report
parent
reply
3 points
*

Unrelated, but what do you think (if anything) might end up being used by the last remaining reserved bit in IP packet header flags?

https://en.wikipedia.org/wiki/Evil_bit

https://en.wikipedia.org/wiki/Internet_Protocol_version_4#Header

permalink
report
parent
reply
17 points

Man, Unicode is one of those things that is both brilliant and absolutely absurd. There is so much complexity to language and making one system to rule them all ends up involving so many compromises. Unicode has metadata for each character and algorithms dealing with normalization and capitalization and sorting. With human language being as varied as it is, these algorithms can have really wacky results. Another good article on it is https://eev.ee/blog/2015/09/12/dark-corners-of-unicode/

And if you want to RENDER text, oh boy. Look at this: https://faultlore.com/blah/text-hates-you/

permalink
report
reply
5 points

Oh no, we’ve been hacked! Theres chinese character in the event log! Or was it just unicode?

The entire video is worth watching, the history of “Plain text” from the beginning of computing.

permalink
report
parent
reply
15 points

They believed 65,536 characters would be enough for all human languages.

Gotta love these kind of misjudgements. Obviously, they were pushing against pretty hard size restrictions back then, but at the same time, they did have the explicit goal of fitting in all languages and if you just look at the Asian languages, it should be pretty clear that it’s not a lot at all…

permalink
report
reply

Programming

!programming@programming.dev

Create post

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



Community stats

  • 3.5K

    Monthly active users

  • 1.6K

    Posts

  • 26K

    Comments