8 ms·
JavaScript is a tool. Once it becomes trendy idiots will always abuse a tool. It's not JavaScript's fault people are bad at web design and development. If it wa
by ebbv 13y ago
JavaScript is a tool. Once it becomes trendy idiots will always abuse a tool. It's not JavaScript's fault people are bad at web design and development. If it wasn't fucked up JavaScript these people were contacting you about it'd be something else, be glad you have a job.
- chewxy 13y agoIt does not however, preclude the possibility that the tool is in fact a bad tool, and that the tool is bizarrely the only tool we have. They say poorly skilled people blame their tools, and that highly skilled people who know their tools well, will know how to use it well. That being said, see that circular saw over there that will occasionally bounce and cut off its user's fingers? I'm not gonna use it, no matter how skilled I am. I for one am hoping for a replacement for JS (that isn't Dart, which feels like JS Patched). I have more than just a hairy experience with JS lately.
- marknutter 13y agoPeople don't use javascript because it's a beautiful, well thought out language. They use it because it runs everywhere.
- chewxy 13y agoHere's the painful part: Douglas Crockford wrote a book called Javascript, the Good Parts. If Javascript were limited to The Good Parts alone, it has the potential to be a beautiful well thought out language. It would be quite close to a beautiful well thought out language
- city41 13y agoWhat's stopping you from only using the "good parts" in your own code? How is JS a bad tool? It runs reasonably fast, works everywhere, is a small, simple language that's surprisingly powerful. What if Eich had been influenced by C instead of Lisp when creating JS? All things considered, it could have been way worse than it is, and the truth is JavaScript lets you get in there and do good stuff. Not sure why we are still hating on this environment.
- jgeerts 13y agoI think a lot of experienced developers are only using the good parts, it's difficult to learn but it can indeed be a very beautiful language when you use it with modules/jsLint/jsHint.
- Joeri 13y agoOn our svn repo (team of 20 js devs) i've added jshint checking in a precommit hook. Devs who don't follow the rules literally cannot commit code. It was much less of a big deal than you would think.
- tracker1 13y agoAgreed... I only had to do a couple tweaks to my jshint rules (I prefer comma first, and a few other things)... but it wasn't hard to get used to at all. Testing is another point... having JS tests can help a lot, though my opinions of TDD aren't as strong as many.
- pekk 13y agoWhat kind of modules do you mean - there are so many kinds in Javascript?
- jgeerts 13y agohttp://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html http://www.adequatelygood.com/JavaScript-Module-Pattern-In-D...
- eagsalazar2 13y agoDid you read the Good Parts? If so, read it again.
- tomjen3 13y agoYeah, he did. As a javascript developer I wouldn't limit myself that much though - he considers using ++ a sign of bad code.
- rallison 13y agoTo be fair, Crockford gives his reasons [1] and the replacement is literally += 1 instead of ++. Given the very low cost of the change, and that it is an optional rule in jslint, I have no problem with it. [1] See here for more discussion and links to Crockford explaining the reasons: http://stackoverflow.com/questions/971312/why-avoid-increment-and-decrement-operators-in-javascript http://stackoverflow.com/questions/971312/why-avoid-incremen...
- tomjen3 13y agoTrue, but for me the issue is that with += I have to double check that it is only adding one (and not skipping any) to understand the loop, where as ++ is something I have seen so many times that my brain reads it in a different way.
- deleted 13y ago[deleted]
- GnwbZHiU 13y agoI used JS because it was the only option. I'm using it now because it's beautiful and fun.
- ebbv 13y agoYeah JavaScript has problems, so do all programming languages. JS has some particularly egregious ones, but the abuses and problems the slide complains about are not a symptom of a defect with JavaScript. They would be the same problems with any other language being used by incompetents.
- chewxy 13y agoI like to think of it this way: Some languages allow you to shoot yourself in the foot easier than other languages, given the context and environment. Abuses and problems precisely show Javascript's defects. The more easily abusable a language is, the more defective it is. A lot can be said about familiarity with the language. Many examples in wtfjs.com boils down to (mis)understanding the language itself. Let's call this the cognitive overhead of a language - the amount of corner cases you have to store in your head about a language. Surely a language with high cognitive overheads is more abusable than languages that have low cognitive overheads. Incompetent python, C, or even scheme programmers wouldn't be able to shoot themselves in the foot (by shooting themselves in the foot, I mean having unexpected results - even with Undefined behaviours) as much as incompetent javascript programmers. That's my beef. I currently have no way of empirically proving that, but my gut is leaning that way.
- ebbv 13y agoYou are 100% wrong. C allows you to shoot yourself in the foot much more easily and much worse than JavaScript. JS is a far more "safe" language to code in. No pointers, no memory allocation. Yeah JS isn't typed but the problems that you get into with that are nothing by comparison. And again, I'm not saying JS doesn't have problems, it does. But the problems this presentation is complaining about are not results of flaws in JS they are results of incompetent developers. So he's complaining about the wrong thing by complaining about JS. It should be titled "I wish incompetent people wouldn't try to do things." And we'd all agree but then consultants like him would be out of a job.
- joshuacc 13y agoFYI, Nicholas Zakas, the person who gave this presentation (which I attended) is a well-known JavaScript expert. He's definitely not complaining about JavaScript as such, just horrible misuses of it.
- akdetrick 13y agoI agree that it's a bad tool in many ways, but even if the language (and environments) were beautiful, the problem at hand is often the way that people use it. In this case, a poor craftsman uses his tools to do the things that the browser already does for you. I've seen some JS that reinvents lots of what the browser rendering engine should handle (recalculating & reflowing heights of elements every time something was added or subtracted from the DOM, for example). Expand this kind of thinking to an entire project, and you start to find yourself in the kind of mess described in the slides. If/when Dart replaces JS, some of the enforced structure may help prevent badly organized or buggy code, but it won't fix poor assumptions of what concerns scripting should and should not handle.
- nine_k 13y agoFortunately, JS is not the only tool we have. JS is a relatively fine compile target, and with asm.js, a pretty fast one. So pick your favorite among CoffeeScript, TypeScript, Dart, GorillaScript, Elm, ClojureScript, etc, or try compiling your favorite language using LLVM. Let a compiler take care of all the numerous rough edges raw JS has.
- dgesang 13y agoalso Haxe.
- sker 13y agoAlso, FunScript (F# to JS). http://funscript.info/ http://funscript.info/
- deleted 13y ago[deleted]
- pbsdp 13y ago> JS is a relatively fine compile target ... No, it's not. > ... and with asm.js, a pretty fast one. And asm.js demonstrates why it's not, because asm.js isn't JavaScript. It's a strictly defined ASCII-encoded bytecode that happens to be representable using a subset of valid JavaScript. At which point, one must ask, what bizzaro-world engineering justification do we have for using a JavaScript subset as a first-order bytecode format? Why couldn't the silly JS bytecode format be a second-tier target for legacy browsers that don't support a proper format? On top of which, why are we willing to throw away 2x+ performance (in the best case)? Is the iOS/Mac App Store not successful enough for us, such that we absolutely refuse to try something other than adding more JavaScript to every problem we face with web app deployment?
- pcwalton 13y agoasm.js is JavaScript. It executes according to the semantics specified in ECMA-262. The 2x performance numbers for OdinMonkey are not "best case": they include compilation time and will certainly improve (they are better now already). Regarding having a "real IR", throwing away backwards compatibility for surface syntax doesn't work on the Web. It was tried, with XHTML 2.0 for example. It failed.
- eagsalazar2 13y agoSeriously your analogy is absurd. JS has a few rough edges that any decent editor will warn you about and that you automatically know to avoid after doing a lot of it for even a couple months. This complaining that JS is unusable is just BS and whining by people who are simply shying away from something they don't know. There are bigger things that can bite even experienced developers like memory leaks and bloat but that has little to do with JS since you can fall into those pitfalls in any language. I'm not attached to JS and have pretty much switched to CoffeeScript. I like CS better but that doesn't mean JS is anywhere near as bad as you make it out to be.
- WayneDB 13y agoHe didn't say it's unusable, he said it's a bad tool...and it is. That's why a whole industry was born to work around it by transpiling to it. It's a bit ridiculous to say that anyone who complains about JS doesn't know it.
- peterashford 13y agoCoding JS is 95% of my day job and I'm 100% sure that it is the worst language I have ever used. All languages have flaws but JS's are serious, inexcusable and onerous.
- munger 13y agoI know you are just making a point with the circular saw metaphor, but for those wondering here is some good info on how to use a circular saw as safely as possible: http://www.docstoc.com/docs/87338746/CIRCULAR-SAW-SAFETY-AND-PROCEDURE http://www.docstoc.com/docs/87338746/CIRCULAR-SAW-SAFETY-AND... http://carpenterbooks.com/userFiles/556/frame_table_mw_pdf_256kb.pdf http://carpenterbooks.com/userFiles/556/frame_table_mw_pdf_2... Even still, as the safety guide states, "Be careful, making one small mistake with a circular saw could be the last thing you ever do in your life"
- roc 13y agoBut JS isn't just a tool. No programming language is. JS is more a workshop that happens to contain, amongst its stations, a less-than-safe circular saw. And you can absolutely, productively use the shop without using the saw, or by using the saw, if necessary, with additional safety precautions. And because some people use the saw willy-nilly, you're saying we should throw out the whole shop?
- deleted 13y ago[deleted]
- stiff 13y agoWe are all abusing the technologies originally developed for hypertext documents (HTTP, HTML, CSS, JavaScript) for building applications. If you today started working on a set of standards for handling what people currently build on the web proposing those technologies would be completely ridiculous, so ill suited are they for this job. And JavaScript is probably the worst of all, it is designed badly enough that there isn't even a standard way of defining modules or classes so you end up connecting shit structured in a 100 different ways.
- xradionut 13y agoAmen! The fact that it's still insanely easier to write desktop apps, using one or two languages and a layout manager vs. dealing with two decades of WTF! web programming makes me sad.
- tracker1 13y agoSee CommonJS and/or AMD combined with a build tool Grunt... You have component options around, mostly pretty new for building modular JS and building them for use in the browser as a single download. RequireJS in particular goes a long way towards helping with browser development. AMD lends itself more towards the browser, but there are build tools for CommonJS style modules as well. If I were starting today, I'd probably have a reduced subset of what HTML is, with extension points for form inputs. The issue is that extensible/modular, skinnable and a centralized authority are points of contention for application building. I really liked Silverlight as a concept, I thought the package system was well thought out. What I really didn't care as much for is how verbose XAML is. I can say most of the same about Flex+ActionScript. The problem is neither of these formats were open enough for browser vendors to simply have built-in support for them as a specification.
- dsego 13y agoI think the problem is that the original technologies were bad to begin with. And the development was ad hoc and without foresight. Just look at the history of the img tag (http://diveintohtml5.info/past.html http://diveintohtml5.info/past.html). DOM was tacked on later, JS was developed in a couple of weeks, with Java-like syntax just bolted on for marketing purposes. And CSS is the worst. Why anyone considers cascading to be a feature is beyond me. I mean, what were they thinking, what was going through the person's head when they decided "yep, cascading, that's what we need, forget name spacing, variables or expressions, we need cascading". Oh boy.
- tommorris 13y agoJava is a tool too. But the years and years of people inflicting bad Java desktop UIs on the world might have been avoided if we had been more critical of it rather than going with what's cool and hip and new. I think in a few years time, we'll look back on the current trend of client-side-all-the-things just as we now look back at Flash intro pages, pop-up ads and all that shit.
- jgeerts 13y agoNobody has ever liked the swing GUI's, everyone with a little bit of taste disliked it, were constantly looking to change their theme and it was really aweful for a developer to create a decent user interface with.
- shubhamjain 13y agoNot only idiots, it seems everyone is so obsessed with creating ajax navigation, rich controls, and one page apps. The one apt reason why I never open Google Plus is because every things takes years to load with their fucking javascript in everything. Why can't sites be like StackOverflow, it only uses JS where necessary.
- Domenic_S 13y ago> $LANGUAGE is a tool. Once it becomes trendy idiots will always abuse a tool. It's not $LANGUAGE's fault people are bad at web design and development. If it wasn't fucked up $LANGUAGE these people were contacting you about it'd be something else, be glad you have a job.
- bradshaw1965 13y agoThe same comparisons were made when Flash was being misused. It doesn't take much to muddy an ecosystem. There were certainly other problems with Flash, but thinking that best practices for JS will filter through to most developers is unlikely.