9point6 ,

GIGO

bahbah23 ,

I've read different defenses for JavaScript for cases like this, which usually runs somewhere from you shouldn't be doing that anyway all the way up to if you just understood the language better you'd know why. While I agree with both of those points strongly as general principles, JavaScript also violates the principle of least surprise enough to make it concerning.

For what it's worth, I do like JavaScript. I really don't think that there is any perfect programming language.

5C5C5C ,

I really don't think that there is any perfect programming language.

You'd be wrong 🦀🦀🦀🦀🦀

9point6 ,

That's a weird emoji to use for elixir

palordrolap ,

JavaScript, like some other languages of the time, was designed with the Robustness Principle in mind. Arguably the wrong end of the Robustness Principle, but still.

That is, it was designed to accept anything that wasn't a syntax error (if not a few other things besides) and not generate run-time errors unless absolutely necessary. The thinking was that the last thing the user of something written in JavaScript wants is for their browser to crash or lock up because something divided by zero or couldn't find an object property.

Also it was originally written in about five minutes by one guy who hadn't had enough sleep. (I may have misremembered this part, but I get the feeling I'm not too far off.)

zarkanian ,
@zarkanian@sh.itjust.works avatar

It was 10 days, but, yeah, not a lot of time, especially for one guy. (That one guy was Brendan Eich, by the way.)

morgunkorn ,
@morgunkorn@discuss.tchncs.de avatar

On the other hand, I don't think you should add those ever

RecluseRamble ,

Onfuscators probably use it though, so no spec ever will be able to get rid of this crap.

Windex007 ,

Can I vote for obsfuscators not holding a language hostage?

msage ,

Best I can do is tie your pension to it.

intensely_human ,

Only if I can vote for sandwiches not falling apart when I eat them

firelizzard ,
@firelizzard@programming.dev avatar

Sure. But in a sane language doing something totally nonsensical like that is an error, and in a statically typed language it’s a compiler error. It doesn’t just silently do weird shit.

morgunkorn ,
@morgunkorn@discuss.tchncs.de avatar

Agreed! Unfortunately these maddening behaviors were kind of set in stone several decades ago, and it has been (correctly) decided "Don't break the web", these weird quirks are kept in modern interpreters/compilers.

It's actually quite interesting to read through the logic to follow when implementing an interpreter:

https://262.ecma-international.org/13.0/#sec-object.prototype.tostring

leftzero ,

a sane language

JavaScript

Pick one.

firelizzard ,
@firelizzard@programming.dev avatar

I thought it was clear I was saying JavaScript is not a sane language for this very reason

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • kbinchat
  • All magazines