11 ms·
Why JavaScript
same here: loving python and forced into JS.
- blablabla123 14y agoGreat post, it's just annoying to hear people ranting about JS over and over again. The most annoying fact is, most of these people don't know how to write anything useful in JS besides copy&pasting a few lines a jQuery code. (I have doubts whether it's possible with this knowledge to understand how modern webapps are working.) In the recent time I've often read posts about people suggesting: learn language X to a reasonable proficiency before you criticize.
- friendly_chap 14y agoI have written multiple large JS apps as part of my day job (and I still have to) and I think while JS has some cool features, and I even enjoy using it sometimes, it is mostly a dirty hack.
- dasil003 14y agoWhen you consider the circumstances under which Javascript was created and grew up, it's nothing short of a miracle that we have a language with the functional power of JS. Sure it's warty as all hell, but prototypal inheritance plus closures give you architectural flexibility that would be the envy of many "better" languages.
- acjohnson55 14y agoI don't know if I've ever seen prototype-based OO used to produce something that dynamically-typed, class-based OO couldn't accomplish in a much more comprehensible manner.
- PommeDeTerre 14y agoIn practice, we've seen its prototype-based OO functionality be a burden, rather than a benefit. In any sizable JavaScript code base, there is usually a lot of code and effort put into faking a far more sensible and practical class-based approach to OO. This often obfuscates the code significantly. This is part of the reason why languages like CoffeeScript and TypeScript have become popular. They offer the tools that developers actually need, rather than just telling them, "you should be using prototype-based OO because it's good".
- dasil003 14y agoArguably that's just because people aren't used to prototype-based OO, but in any case, it supports these custom pseudo-class-based OO constructs just fine doesn't it?
- cygx 14y agoNo, it's because JS doesn't expose (or at least didn't used to before ES5) it's prototype system, but instead provides a pseudo class-based overlay. The proper way to do inheritance in JS is // Foo extends Bar Foo.prototype = Object.create(Bar.prototype); function Foo() { Bar.call(this); } Before the introduction of Object.create, you either had to roll your own version, assigned a dummy instance of Bar to Foo.prototype (which is horribly wrong) or transferred methods manually from Bar.prototype to Foo.prototype, which is arguably more 'in the spirit' of JS1.0. That's not how it's done in 'real' prototypal languages like Self or Io.
- PommeDeTerre 14y agoNo, it does an absolutely horrible job supporting anything that resembles class-based OO. That's why so much JavaScript code is utterly unmaintainable. It doesn't offer the functionality that developers want and need, so they have to fake it, and this can only be done very poorly.
- camus 14y agoWell devs are ranting about JS because devs dont have the choice to use javascript or not period. Programmers dont like to be forced into something yet they cant avoid javascript as it is the only language that will work in most of the browsers. It doesnt make javascript a good language , in fact it is not. It is a poorly designed language that should not have survived the 90's, and if it would have been invented today it would have been different beast. Is there some good stuff in it ? sure, but the irony is it is used to code against the DOM which is strictly typed and made of classes and interfaces( that's the why of DHTML , because it made no sense to use that language against that API ). Now People can rant about it all they want it wont make a difference , browser scripting = doing some javascript , wether one likes it or not.
- PommeDeTerre 14y agoIn my experience, those who criticize JavaScript the most have often used it for many years, and know it extremely well. These people also usually have many years of experience with other, far more sensible programming languages, too. I'm not talking about PHP or Ruby, either. Rather, these people know one or more of languages like C, C++, Objective-C, Java, C#, Haskell, Erlang, OCaml, Standard ML or Python inside and out. With such knowledge, it becomes very obvious just how bad JavaScript is. The utter stupidity of many of its flaws becomes so apparent. These people also can see how it lacks the language features necessary for large-scale, multi-developer, distributed development, and then the subsequent maintenance of such projects. They've felt the pain of its numerous other problems time and time again. I'd say the reality is much the opposite to what you describe. The ones who advocate JavaScript most often have never used anything else. They don't realize how many of JavaScript's inherent problems, or "quirks" as they like to call them, just don't exist in most other programming languages. If they have used another language, it's usually PHP, which is arguably worse than JavaScript in many ways. While living in this bubble of ignorance, they don't see JavaScript's flaws for what they truly are.
- chris_wot 14y agoI notice you said all that without explicitly naming a single flaw.
- PommeDeTerre 14y agoAre JavaScript's many flaws truly not glaringly obvious to you?
- chris_wot 14y agoNo.
- PommeDeTerre 14y agoI'm truly sorry to hear that. Have you ever used any other programming language?
- w0utert 14y ago>> In the recent time I've often read posts about people suggesting: learn language X to a reasonable proficiency before you criticize. Hard to disagree with this. That said, I think even JavaScript guru's generally agree that the language itself is actually pretty awful unless you know all of the legacy quirks and WTFs it is dragging along. When discussing the merits of programming languages, the observation that "JavaScript is the best we have for browser-based development" or "it's possible to write really awesome things with JavaScript" just doesn't cut it for me. Either you acknowledge and accept JavaScript's deficiences and don't try to sugar-coat them, or you refrain from trying to objectively rank it against other languages at all. My personal opinion is that you simply cannot reasonably maintain that JavaScript is a 'good programming language', for the simple fact that before can say you are proficient with it, you likely have had to deal with multiple WTF's you'll never run into with (most) other languages. Other dynamic VM-based language exist that are much better than JavaScript, but just like the QWERTY keyboard layout, we're stuck with it.
- user24 14y ago> I think even JavaScript guru's generally agree that the language itself is actually pretty awful unless you know all of the legacy quirks and WTFs it is dragging along. Are you confusing pure JS with DOM APIs and xbrowser quirks? Pure ES5 (or 6) is actually a very lovely language to work in, and now thanks to Node, we can. Maybe I'm just so used to the quirks that I don't see them as a problem any more.
- cygx 14y ago> Maybe I'm just so used to the quirks that I don't see them as a problem any more. To jog your memory, here's a list of questionable design decisions I can think of off the top of my head: Automatic semicolon insertion and a broken == operator A language shouldn't try to guess the programmer's intention, but rather fail cleanly on ambiguous cases. Function scope and global by default Frankly, I'm appalled by how many dynamic languages get it wrong. Lexical block scoping with mandatory declarations are by far the most sane approach I've come accross, and the only P-language (Perl, Python, PHP with Ruby and Javascript as honorary members) that gets it right is (strict-mode) Perl. Weird object system While actually protypal, the constructor-with-prototype-property semantics add a pseudo-class based overlay without an obvious mechanism for object extension and code reuse.
- WayneDB 14y agoIn my experience, people who don't have any complaints about Javascript don't know many other languages very well.
- lampe 14y agoI think the biggest problem is that there are many many bad tutorials/book about javascript and only a few good once. Often people wane code javascript like language X but javascript isen't language X! You must learn it like every other language! But if often see people doing javascript "when they need it". Nobody writes C just cause they need it... Normally people just sit down and read a book about C.
- PommeDeTerre 14y agoThe "best" JavaScript-related book, as chosen by the community at large, is generally considered to be "JavaScript: The Good Parts", by Crockford. While the most widely respected books for other programming languages teach one how to use such languages' features effectively, "JavaScript: The Good Parts" basically says not to use large parts of JavaScript. That alone should show just how poor of a language it is. You don't have to ignore, or actively not use, so much core functionality when using a good programming language.
- dirkk0 14y agoAlso there is this resource, and the first sentence says it all: http://bonsaiden.github.com/JavaScript-Garden/ http://bonsaiden.github.com/JavaScript-Garden/
- DanWaterworth 14y agoThere are only two kinds of programming languages: those people always bitch about and those nobody uses. - Bjarne Stroustrup On the other hand, this was said by the creator of C++ and correlation doesn't imply causality; maybe some of the factors that contribute to a language becoming mainstream also cause irritation.
- dysoco 14y agoIt's funny because C++ is used a lot and everyone bitches about it.
- lucian1900 14y agoThat doesn't change the fact that it has more flaws and idiosyncrasies than most other languages. We use it because we must, not because we choose to.
- user24 14y agoWhere I work, we chose it. Could have carried on using PHP, could have moved to $otherLanguage. We chose NodeJS.
- camus 14y agoi'm sure he is talking about browser programming , what you do server side is 100% your business, nobody cares. And PHP is definetly not a good exemple as it is even worse than JS.
- lucian1900 14y agoWhen the alternative is something as stupid as PHP, sure. But there are much better languages out there that would entirely eclipse JavaScript, if it wasn't the only thing that can reasonably be used in browser.
- skrebbel 14y agoThis. JavaScript is in many ways a step forward if you're coming from C++, PHP 5.0 or Java (and a step backward in some other ways, but ok). People sometimes use that reasoning to call it a great language, or at least to call JavaScript's Good Parts a great language. Problem is, compared with other modern commonplace languages such as C#, Python or Scala, JavaScript simply loses on nearly all fronts. These languages all have all the points that the OP lists about Javascript, plus a whole bunch more. Only when compared to the hot languages of the nineties is JavaScript a serious improvement. That said, the fact that it's not awesome surely is no reason to diss it. JavaScript does have those Good Parts, and it isn't bad at all. Just not great either. Still, i can't wait until we can avoid it altogether and consider it some sort of bytecode that those old hackers with mustaches wrote by hand, back in the day. In text editors!
- shawndrost 14y agoDevs: you should make JS your primary language. It's a complete wild west right now -- still lacking so much as a package manager for the browser -- but meanwhile, the entire internet is moving into a rich client architecture. Tools like Backbone, while useful, are very clearly not the platform we'll be using in a few years. It's a phenomenal opportunity to do meaningful work and be in very high demand. Self promotion: I believe the above so firmly I went out and started a school for JS devs, Hack Reactor (formerly Catalyst). http://hackreactor.com http://hackreactor.com
- dirkk0 14y agoI totally agree with you except that I still stay with the combination Python and JS (actually like the author). But there's no way to avoid JS so why not better embrace it. @hackreactor: nice! @packagemanager Yeoman (http://yeoman.io/ http://yeoman.io/) does something like this and a couple of other solutions, too.
- madoublet 14y agoI personally believe that in a couple years, most programmers on the web stack will use traditional languages (PHP, Ruby, Java, etc) to serve up REST services. And, that is it. The client will handle the rest via JavaScript and client-side bindings (Backbone, etc).
- drdaeman 14y ago> you should make JS your primary language Could you tell at least one compelling objective reason to do so? Especially for non-web-frontend developers out there?
- tomaszkubacki 14y agoI hope some other sane lang compiled to js will gain traction e.g. Dart http://www.dartlang.org/ http://www.dartlang.org/
- acjohnson55 14y agoThe biggest problem with JS for me is not its quirks, but the way that until you know--and I mean, really know--the language, you WILL make absolutely horrific errors, on every single level of development. It does not matter how good you are at writing C, Java, or Python. Oh, what, you thought == was for comparison? Wrong. Oh, you didn't wrap your all your code in an anonymous, self-calling function? You lose. Oh, what you thought it was okay to leave off semicolons and var statements because they aren't required? Sorry. Hmm, you didn't know how to manage dependencies between scripts? Should have studied harder. You tried to iterate over an array? Ridiculous. Your brain exploded when trying to write a series of asynchronous functions in continuation style? A pity, really. People who are good at JS like JS because it makes them special. They can lord their knowledge of the quirks over "lesser" developers who come to JS expecting it to act like a sane language. It took an entire industry about a decade just to learn how to tame it. Sure, JS turned out to be really extensible to new paradigms, but hey, so is the lambda calculus. A good language makes good programming look natural. Like Python. JS is the opposite.
- chris_wot 14y agoDefine "natural". Firstly, == is indeed for comparison, just with an implicit cast beforehand. You don't need to wrap all your code in an anonymous self calling function, but to get the most out of it you need to - given the way it was designed, this makes sense. You speak like C syntax is "natural" - I remember grappling with pointers and references, it took some time for me to get it fully. It's not like Python doesn't have it's quirks. I find it ironic that those who use Python/Ruby/Clojure/etc want to often ridicule those who use JavaScript. They've got their own form of elitism. Get over it, seriously.
- deleted 14y ago[deleted]
- artmageddon 14y agoWhat the parent was saying regarding the == vs === is that unlike other languages it's very easy to get burned if you don't know the difference and when to properly use it. I'm hardly proficient at JS and not knowing that would've screwed me over.
- dschiptsov 14y agoNothing is deeply wrong with it as long as it stays inside a browser.)
- madoublet 14y agoToo late.
- jiggy2011 14y agoThe biggest problem I have with JS is the multitude of libraries you need in order to make it usable. These libraries all seem to use and encourage different patterns and trying to use 2 together often leads to confusion. Switching to a project that uses something different, say prototype instead of jQuery feels like learning from scratch again.
- davedx 14y agoTo be fair, I've found many, many projects use underscore for their go-to 'utility' library and it's pretty decent and readable. What other libraries have you seen as dependencies that cause clashes?
- jiggy2011 14y agoNot so much clashes, just documentation and examples tend to use often radically different coding styles.
- sramsay 14y ago"The first time, to hate it. The second time, to start appreciating it. The third time, to understand it and get shit actually done." Not unlike the process of becoming addicted to heroin.
- mhd 14y agoThis sounds awfully familiar, if you replace JavaScript with Fortran and Web with number crunching. And I didn't buy it back then.
- mnarayan01 14y agoThe reason people use JavaScript for scripting in the browser is because there is no other option. The biggest reason I see to use it outside the browser is because you're already using it inside the browser. There are plenty of things to dislike about JS, but the ability to use it both in and out of the browser is a pretty big upside.