- cross-posted to:
- programmerhumor@lemmy.ml
- cross-posted to:
- programmerhumor@lemmy.ml
Alright, enough making fun of languages that suck…let’s talk about JavaScript.
It only took one question for me to start wanting to flip tables.
Except for some reason “2” is interpreted as a month, and the year is set to 2001.
Aight I’m out
Ha this is even worse than I could have imagined!
I scored 10/28 on https://jsdate.wtf/ and all I got was this lousy text to share on social media.
If you’re not very familiar with JS, watch the Wat talk before taking the quiz to know what to expect from this wonderful language.
And then promptly get yourself familiar with how the language actually works. https://github.com/getify/You-Dont-Know-JS
People who complain about JS often assume it has features of other languages and fail to realize it has its own architecture and winding history.
Can we start a new web with a better language/platform already?
Google tried to do that with Dart, and failed. In fairness Dart 1 was much worse than Dart 2… So maybe that was a good thing because there’s no way they’d have been able to improve Dart as much as they have if it was part of the web.
For dates there finally is something better anyway: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal
There’s wasm if you need to target browsers.
Yes and no. Wasm has no “standard library” so if you wanted to use Dates, your wasm would need to have its own implemation bundled for when the user visits the page. Ditto for everything else including string support! As you can imagine having to ship all this basic functionality can bloat the wasm and slow page loads.
You also can’t fully escape JS, as the only way wasm can interact with the page & browser are through the JS functions you write and make available to your wasm. I suppose you could take advantage of this to not have to ship your own standard library & use the JS Date implementation, but at that point why not just use JS?
Wasm has strengths but it’s not suitable for replacing JS for everyday websites.
Why? Why not improve JS (e.g. with Temporal), especially given how excellent Typescript is?
I wouldn’t call typescript excellent, if I did it would be on a very low standard.
It unquestionably is excellent. Can you name another language in common use with a type system that’s close to the expressiveness of Typescript?
JS is a lost cause.
How? It’s easy not to run into the common issues by using TS. What’s so bad about it that we should throw away the existing ecosystem?
Please give arguments instead of platitudes.
You don’t need to use TS to avoid common issues. If you add an empty object to an empty array and expect a meaningful result, the problem sits in front of the keyboard.
Sure, discipline can prevent some errors. But it’s always possible to run into wrong type assumptions, and I’d say type coercion and null/undefined access make up a fairly large percentage of non-logic errors. You can entirely prevent those using Typescript, which is why it’s so useful.
Static type analysis is always a good idea if you’re writing more than a couple lines. IMO Python is the worst offender with its
kwargs
etc. - discoverability and testability is just so bad if you’re following common Python idioms.
I scored 13/28 on https://jsdate.wtf/ and all I got was this lousy text to share on social media.
Oof. I’ve been a JS dev since 1998.
Nobody understands JavaScript. It’s the quantum mechanics of the software world.
The quirks in this quiz aren’t even universal, and vary based on which browser you’re using. See the table at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse#non-standard_date_strings
Also I got 13/28 😑
I got 10/28, but I was crying after the 7th question
I am a frontend dev. JavaScript (well, TypeScript) is my bread and butter. Even knowing its quirks I never would have thought how inconsistent
Date
actually is. I encourage everyone to try this quiz.This is what JavaScript haters should bring forth, not
0.1 + 0.2 !== 0.3
!Or the ones where people point out how inconsistent JS is with adding strings to numbers.
Yeah, maybe don’t do arithmetic on numbers as strings?
Floating point rounding issues are basic comp science issues. Hopefully nobody thinks that those are JavaScript quirks.
Unfortunately, people do.
There is a reason almost everyone use some Date lib, like Luxon and not the built in. And well, having a horrible built in lib that they can’t change due to legacy code breaking is nothing really new or unique to JS.
The built-in lib is fine for basic stuff unless you do some crazy shit like expecting
"2"
to parse as a valid date.
9/28. WTF’ing through 90% of the questions.
I got a 4/28 and got told I would have scored higher if I guessed at random. Ouch. (I am not a dev)
I mean, for what it’s worth, I’m a seasoned dev and just did a run where I tried to answer everything as it makes sense to me (which is “throws an error” or “invalid date” for all of them) and I also got a score of 4/28.
…and two of those points were given to me, because the quiz interpreted my answer differently than I meant it.
In other words, this quiz exists to highlight that JavaScript’s Date functions make no sense.
I scored 17/28 on https://jsdate.wtf/ and all I got was this lousy text to share on social media.
Idk anything about Date but got pretty far with intuition of JS whackiness