7 ms·
JavaScript is actually an incredibly flexible and effective language.
by forgottenacc56 11y ago
JavaScript is actually an incredibly flexible and effective language.
- geniium 11y agoYes sir!
- lr4444lr 11y agoREALLY flexible... https://www.jwz.org/blog/2010/10/every-day-i-learn-something-new-and-stupid/ https://www.jwz.org/blog/2010/10/every-day-i-learn-something...
- wtbob 11y ago> JavaScript is actually an incredibly flexible and effective language. == 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.
- abysmal_cynic 11y agoYour assertion that the language is not effective appears false. ALL the major players and financial forces in our industry have put time and effort into quite solid solutions built with JavaScript, rather than solving those problems other ways (and in some cases AFTER trying to solve those same problems other ways). Two of those companies build browsers and sit on the W3C and WHATWG. They could have presented both suggestions for alternatives and lobbied as hard as anyone can for their adoption. Neither did that.
- gear54rus 11y agoNo amount of cute phrases will change the fact that it is being spread by people who actually understand its flexibility instead of focusing on something that rubs them the wrong way (which, most of the time is the result of working with other, often shiver enterprisey language(s) and thinking that that's how it's done) quite effectively and there's no sign of stopping for its growth. 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.
- StavrosK 11y agoMy litmus test for whether an argument for JS is valid is replacing "JS" with "PHP" in my head and seeing if it reads the same. PHP did all the same things, but that doesn't make it a good language, it just makes it a language that's easy enough to learn for it to get popular.
- elmin 11y agoIn my experience Go is a better choice than Node for reliability and stability reasons, rather than performance most of the time.
- bottled_poe 11y agoJS is popular for one reason - browser support.
- gear54rus 11y agoThere is another - unique async nature from the start. That's why it made its way into node. It is not popular the same way PHP is popular in any capacity. It really is a unique useful efficient language.
- ribs 11y agoIndeed. It's the best (shittiest) way to deploy code on as many people's desktops as possible.
- almostarockstar 11y agoThe flexibility of JS is not how the language is designed, it is the hole that the language is filling. 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.
- douche 11y agoThat'd be fine, if there was any other tool that worked in a browser. Sure, you can transpile from some other real language, but it's still javascript when you finish up, with all the foibles and warts that haven't been fixed in twenty years. 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.
- ZenoArrow 11y ago> "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." The fix isn't ES6/7, it's WebAssembly: https://en.wikipedia.org/wiki/WebAssembly https://en.wikipedia.org/wiki/WebAssembly
- kabes 11y agoprototypes are actually a really good way to deal with inheritance.
- cpburns2009 11y agoSingle inheritance is awfully limiting which is what Javascript's prototypes provide. And structurally copying multiple prototypes into a single object to achieve multiple inheritance is an awful hack.
- Retra 11y agoNot having inheritance is also a pretty good way to deal with inheritance.
- tragic 11y ago> No integers. 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.
- wtbob 11y ago> You can declare variables separately, if you want. 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 …
- hawleyal 11y agoSuch hate. By far not as bad as you portray. Have you attempted the 8th level of hell that is PHP?
- frenchy 11y agoBack in the day when I was just learning to program, I wrote a BBcode library in JavaScript. Not knowing any better, I made very liberal use of globals throughout my code. 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.
- quicklyfrozen 11y agoFor me it was things like "function_returning_array()[0]" working in JS but not PHP and other unexpected parsing weirdness like that. (Though I don't really mind PHP, just much of the code written in it :-) )
- Joeri 11y agoPHP7 is ok. They rewrote the parser to use a real AST which fixed a lot of the weirdness and inconsistency, threw out a ton of deprecated stuff, and made error situations saner by replacing errors by throwables. I like also that php is gradually getting strict typing as an option. Function signatures are strictly typed now, with class properties getting it soon. Plus, PSR guidelines have made the popular libraries object-oriented, namespaced and consistent. My main complaint with php these days is that it's starting to look too much like java with dollar signs.
- naasking 11y agoThe only truly terrible part of JavaScript is all the implicit coercions around equality checking. It would actually be a decent language if it reported type errors instead. 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.
- dccoolgai 11y ago| It would actually be a decent language if it reported type errors instead. 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 http://i.imgur.com/76Wtthy.jpg
- naasking 11y agoIt would stop working if you did it NOW. That's irrelevant to the point that that's how JS should have worked from the beginning. Also, they can add these semantics to JS now too with a new type of strict mode without breaking anything. As for how painful it would be, your claim is a total fabrication. Other dynamically typed languages are a pleasure to program in without implicit coercions everywhere. JS is widely considered a pain. Coincidence it is not.
- dccoolgai 11y ago|JS is widely considered a pain. I find that is widely enjoyed by the "silent majority" and decried as a pain by a very vocal subset of developers. It's a little surprising that 1 + '1' is '11', until you spend a little time and learn the rules instead of fighting them - then you start doing your work in a way that uses that to save time. It's not great for everyone, but I like it - and I know a lot of other good devs who prefer the answer '11' (when you understand the fairly simple rules) to 'OMFGNOIQUIT'. I find "Number beats bool, string beats number" for implicit coercions covers 95% of cases where it would actually matter. For the other 5%, just type it in the console. Because I like it that way, doesn't mean you have to as well - but it also doesn't mean that because you don't like (or even most of the commenters on HN) it it is "widely considered a pain".
- cookiecaper 11y agoThank you for this post. We have a really bad habit of chasing "cutting edge" fads as an industry. It must come from the tendency of programmers to burn out and bow out, which exacerbates the tendency of young bucks to lack any respect for their elders. Software dev is still a very immature industry. 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?
- 50CNT 11y agoI can't say that Javascript is the most fun language to use, but I think that's because given the way it's positioned, it has a bit of a hoarding problem. It's picked up the millenial issue that the stupid things you said in your teens are never ever going away, because they are permanently spread through the internet. Fun. 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.
- imtringued 11y agoI get that convenience beats quality everytime but why do we pretend that `convenience == quality` is true?
- _puk 11y agoI believe that's cognitive coercion in action. Obviously none of us truly believes that `convenience === quality`.
- TeMPOraL 11y agoJavaScript was supposed to be a sane language (Scheme), but it is what it is because Netscape's management decided (twice) they need to be competitive with (first) Java and (later) Microsoft right fucking now.
- tobltobs 11y agoAssembler is actually an incredibly flexible and effective language.
- GeorgeTirebiter 11y agoWhen I worked at DEC as an MIT intern many years ago, we wrote the PDP-10 OS in Assembly Language (MACRO-10); I wrote the spooler. Look at some things from http://pdp-10.trailing-edge.com/ http://pdp-10.trailing-edge.com/ - you can see how we did it: a lot of appropriate abstration, and great in-program documentation, built around a sound system architecture. 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.
- colllectorof 11y ago> JavaScript is actually an incredibly flexible and effective language. 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.
- johnsonjo 11y agoI feel the contradictions in JavaScript and it's community is actually a reflection of the background of any one who uses JavaScript coming from other languages. Those people bring their paradigms to JavaScript. I like that about it. Though I know many other languages JavaScript is my favorite language and I use it at work. It's the first language that I took a deep dive into programming with.
- 3minus1 11y agoOr maybe they are focusing on other things altogether?
- gbog 11y ago> flexible 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)