Hacker News new | ask | show | jobs
by chrisdhal 2055 days ago
> const MAX_POINTS: u32 = 100_000; // wtf is this ugly numeric shit

Java has had this since Java7 and Go has had it since at least 1.13, so I'm not sure why he hasn't seen it based on his other experiences.

3 comments

In 2001 I witnessed five Java devs (all with over a year of experience) huddled around a desk looking at a line of code like this:

  int x = foo?bar:baz;
"Question mark and colon aren't legal characters in variable names!"

"They must be. The code compiles!"

"But where is this symbol defined? How can it be in scope here?"

"The code compiles, but it doesn't work, right? It must be a compiler bug!"

That's the risk of learning a language "on the job" or from piecemeal tutorials, instead of reading a book or similar resource from start to end. Sometimes there's a corner of the language that by chance you just haven't seen yet, even after years.

A very junior dev once called me over for help with some JavaScript.

Going through his code, all his numbers were in the form of 1,234,567 with coma place separators. The code worked somewhat purely by accident. It took a surprising amount of convincing on my part to have them understand that wasn’t a thing they could do in JavaScript.

I must say, I find it ugly as well; I prefer e.g. 100 000 over 100_000. It's the "easy to parse" solution, I guess.