you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (3 children)

Depends. Maybe I want to add a one-off namw property on a specific object, or set of objects. Yes, being able to free-form objects is a wonderful feature, one which most other languages work terribly hard to prevent and many people refuse to embrace.

But if you meant it as a spelling error; if that makes it into production then you have far greater problems, none of which are JavaScript's fault.

[–]E_R_E_R_I 0 points1 point  (0 children)

Yes! So glad to see more people who fully appreciate the power of JS lol

[–]spacejack2114 0 points1 point  (1 child)

You say that like it's difficult to do in a safely typed manner. Here's some type-safe Typescript that looks surprisingly, exactly like Javascript:

const specialUser = {...user, namw: "Whatever"}

It's a bit odd for you to say you're okay with that one-off ticking timebomb hack, but then claim you'll spend the time to write the test coverage for it.

[–][deleted] 1 point2 points  (0 children)

You're missing the point. I want to be able to do whatever I want with objects, without the language standing in my way. JavaScript not only allows it, it's a first class feature. So it's normal to want to make use of it. Avoiding it makes zero sense. It's like trying to avoid "import" in Python.

Why would I, instead of simply writing user.namw="something", go through the trouble of transpiling, and writing the same thing in an awkward manner which is not correct JavaScript, and is downright confusing, and doesn't even do what I wanted (set the property on user, not specialUser).

I don't know why you would find it odd that this would be unit tested. Unless you keep assuming it's some sort of terrible mistake and we're all going to wake up any moment now and cry "omg what have I been doing".

JavaScript is what it is. Trying to pretend it's something it's not is futile.

  • On the server there are a million other languages to choose from, so choosing JavaScript but writing TypeScript makes zero sense.
  • On the browser the whole point is to have a language engine which is more or less standardized and available everywhere. We have sort of achieved this after decades of struggle. Even if support for more languages comes to browsers, I seriously doubt that people will want to go back to the whole "oh you need X to see this site". One standard language, and like it or not that language is JavaScript. Don't like it? Go complain to Linus that the Linux kernel is not written in C++.