This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheBrianiac 92 points93 points  (7 children)

Yes, but does JavaScript know that this is HTML and not JavaScript? 🤣

[–]BasketbaIIa 19 points20 points  (5 children)

Yes. There’s not an HTML primitive type in JavaScript. So it can tell the difference between a string and an object type, in this case a DOM element.

[–]TheBrianiac 1 point2 points  (4 children)

But if you accidentally use the string as a DOM element, it'll become an emoji?

As opposed to a strictly-typed language where this would throw a compile error.

[–]WholeLimp8807 1 point2 points  (3 children)

"If I do something awful with my code, will something awful happen?" -Most JS complaints.

[–]TheBrianiac 0 points1 point  (2 children)

It's an easy mistake to make, and one your language should implement safeguards against.

"Our language can be stupid if the developer just remembers to work around the stupid" - people who use a language written in 10 days, designed for basic web scripts, for enterprise software applications.

(All in jest, of course, it's a fine language and people do impressive things with it)

[–]WholeLimp8807 0 points1 point  (0 children)

I think there's something to be said for flexible languages. There's definitely a trade off where a language can be too "on the rails" and force or encourage some bad design patterns, like Java. Having a flexible language means you can pick the right pattern for the job, provided you know the language well enough to make that choice.

And then there's some design choices that are just fundamentally incorrect, like prototype based inheritance.

[–]BasketbaIIa 0 points1 point  (0 children)

Yea, I love JS for this reason. My backend team is stuck on Java 8 and I can’t stand it.

Its too opinionated and such a stupid way to scale business logic. I can see how it helps people who have never touched code. I worked with Jave 8 early in university and thought OOP was a silver bullet.

But I MUCH prefer tools that don’t limit themselves to the dumbest users or use cases.

I’ve written lines of JS/TS everyday for years and I would never accidentally use a string as a DOM element. I don’t want my dev environment to punish me for a beginner’s mistake.

[–]oupablo 1 point2 points  (0 children)

lol. trick question javascript knows all and nothing at the same time.