by romanovcode · 10y ago · 0 comments
Try Haskell or an ML. Heck, even C# isn't that bad these days.
JavaScript's just a minefield of pitfalls. To be fair, it was designed in 10 days, and progress on it has been slow to say the least. (Hence the silly crap like having a "left-pad" thing as a 3rd party "module" instead of part of a proper stdlib.)
Other stuff like using "function" as the lambda identifier just make me shake my head. Or not having integers. Just poor decisions all around.
Generally, unless you're doing systems or realtime programming, or you are writing a serious fast path for a lot of data, the only reason you'd need more than the very basic features present in every programming language is that you're trying to do something more complicated than you should be.
Many programmers seem willing to take on almost any amount of complexity in their toolchain if it will allow them to express an idea in a slightly more concise way. I would prefer to stay much closer to the basics and just take the time to make really beautiful and powerful functions, rather than rely on a rickety stack of concepts that, if not confusing to me, will be confusing to many of the people who end up interacting with my code.
== vs ===
No integers.
Assignment is declaration.
Prototypes.
Curly brackets & semicolons.
Semicolon insertion.
It may be flexible (in the sense that an Alfa Romeo driven into a telephone pole at 120 mph is flexible), but it sure as heck ain't effective. JavaScript is the great shame of the computing industry: that it exists, and that it is used, and that it is used in more than just the browser, is an indictment of our entire profession.
JavaScript: take off and nuke it from orbit. It's the only way to be sure.
JavaScript: you'll envy the dead.
JavaScript: a mistake, carried out past the point of absurdity.
And that is good.
With things like rust and go backing us up in places where more verbose and static code is beneficial (for performance?) we are finally entering new age which leaves closed corp-controlled "enterprise" things (java, net - looking at you) behind.
Fair enough.
> Assignment is declaration.
Not exactly. You can declare variables separately, if you want. In fact, a "var x = 42" statement will actually be split into "var x;" at the top of the scope and "x = 42" wherever you actually wrote it by the interpreter. The specified behaviour is a little weird and non-obvious, but once you know it, you know it.
> Prototypes.
That's a matter of taste (plus the problem of optimisation at the VM level, admittedly). Besides which, you can basically use prototypes to do classes, if that's your bag, and of course we have class syntax now anyway.
> Curly brackets & semicolons.
Semicolons are optional, which however you complain about below. So are some curly braces. The only alternative to having some kind of block delimiter would be significant whitespace, which is a perfectly legitimate preference but has its own warts.
> Semicolon insertion.
Around which the rules are fairly simple to understand. It's possible there's just a better way to do it (I know Go has ASI, for instance, but have never heard anyone complain).
---
I find this a most peculiar list of JS warts (what, not even a shout out for ==, bizarre implicit type coercions, etc?) There's no doubt it is a deeply flawed language, a big part of learning it is learning about the various spike-pits lying in wait for you, and the extra tooling required to mitigate its flaws comes with its own set of costs.
At the end of the day, though, you can write pleasant, readable and - yes - effective code in JS. There are worse languages to be stuck with, as long as you watch out for the spike-pits.
The issue is that 'fop = 1' is not an error (outside of strict mode), even when I mean 'foo = 1.' Automatically creating variables makes what could be compile-time errors run-time instead.
> Besides which, you can basically use prototypes to do classes, if that's your bag, and of course we have class syntax now anyway.
Which I also find to be a mistake. Generic functions are the right way to do OO.
> The only alternative to having some kind of block delimiter would be significant whitespace
The block delimiter I prefer is () grin
> It's possible there's just a better way to do it (I know Go has ASI, for instance, but have never heard anyone complain).
Yes, whereas good practice on JavaScript is to always use semicolons (because its semicolon insertion is wrong), good practice in Go is to never use them (because its semicolon insertion is correct).
> not even a shout out for ==
That was my very first point …
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Type...
Even using Class syntax you're still locked into prototypical inheritance model. There is no classical inheritance in JS. (Probably a backward step in UX to call it "Class")
The fact that using JS you can write a browser based app, a mobile app, backend software, configuration files and flat data files (JSON) without switching gears is the flexibility.
I would also argue that if you really don't like JS, you are using the wrong tool for whatever job you are trying to do.
Unfortunately, instead of going back and fixing core deficiencies in the language standard, it looks like ES6 & 7 are thick cakings of lipstick on the pig.
There are a few other smaller issues that are nuisances, like not being able to actually check if a value is a number, but I think coercions cause the most headaches for discoverability and debugging.
The Web would also probably stop working and be much more of a pain to code if JS acted that way: http://i.imgur.com/76Wtthy.jpg
I really think the problem with javascript really boils down to the fact that it's still in beta and will never have the breaking changes necessary to move it to a 1.0 language (i.e . the ECMA committees commitment to not breaking the web). But, it's easy enough to get around that in new projects by using linters that get rid of the bad parts.
I respect Brendan Eich a great deal and I truly appreciate what he did for NetScape in 1995 by introducing JavaScript. What I don't appreciate is that we decided to extrapolate that madly-rushed, designed-and-implemented-in-less-than-a-week-of-all-nighters language not only into the default client side language for the web for the last 2 decades, but we have also allowed very badly informed people to start using it for server-side applications.
There has to be a way to bring order to this chaos. Any ideas?
The amount of "Bad Things" does make stumbling hazards, which is why I'm completely convinced that if you can, you should use a saner language, but there's no <script type="python"> (yet?). In those cases, we need to fence off the trash, put up warning signs on the exposed wiring, tape a post it note to "v instanceof Array" and try to write the sanest javascript we can.
I later went to go port my code to PHP 4 (that was current at the time). To my surprise I was getting all these errors about how crappy of a programmer I was (both from globals and from misspellings and related problems).
I'm honestly not sure how people hate PHP so hard and yet don't mind JavaScript.
My problem with people who say such things is that they almost always have been saying the same thing for many years, while the language itself did several 180° turns and backflips.
"Classes are stupid, we don't need them!" "Look, we have fake classes in ES6!" "Asynchronous code is awesome!" "Asynchronous code is horrible!" "Prototype mutation is awesome and powerful!" "Everything should be functional and immutable!"
If someone considers the current direction of JavaScript good, then they should have considered several previous directions absolutely idiotic. If, however, they are simply oblivious to the incessant flip-flopping of the "mainstream" JavaScript, their opinion about quality of any language is worth very little.
https://www.jwz.org/blog/2010/10/every-day-i-learn-something...
My question: IF we all (mostly) don't like JS, why don't we simply take Webkit or something and build-in our own (presumably) better language? Call it the "Hacker News Language for the Web" or something; the goal being to replace JS inside the browser. Naturally, we'd need a JS-to-HNL converter; but done properly, both front-end and back-end could be the same, and could be built on the 'natural' structures of The Web, 2020-style (and beyond!) (Maybe HNL is [a descendent of] ARC? Just riffing here...)
One more idea: If browsers would permit batches of signed and authenticated code to be made part of the browser semi-permanently (e.g. node.js, other JS/HNL libraries), then that would save the download time, speeding up sites. In fact, if the code were truly trusted, it could even be in assembly language(!!!! tie in, above) for some totally kick-ass performance. Assumes security issues properly solved.
Flexibility is good for frameworks, not for languages.
I read once a list of good and bad adjectives applied to paintings by Chinese painter Shi Tao. In the same vein here is my list for our topic.
Good computer languages are:
- Expressive, readable, memorisable, deterministic, stiff, simple, obvious, clear, concise, precise, sharp, smooth, pedestrian, regular, parsable.
Bad computer languages are:
- Obscure, arduous, terse, stark, viscous, flexible, lumpy, bumpy, redundant, verbose, restrictive, poetic, foolish, extravagant, awkward.
(This is not to be take too seriously, but just this: all built-in "flexibility" in languages leads to nightmares)
Obviously none of us truly believes that `convenience === quality`.