For modern development, Javascript is just something you need to learn
sidekicksrc.com
sidekicksrc.com
The single redeeming feature of JS is that it's implemented in all current browsers. If it wasn't for that fact I doubt anyone would have cared much.
It's just nowhere near as good as current alternatives for application development. Everything it can do another language can do better, except run in a browser - which is entirely out of control of the other languages so somewhat of a moot point.
The single redeeming feature of Oxygen is that it's pretty much everywhere, and yeah sure we can all breathe it and don't have any other choices for gases to breathe. If it wasn't for that fact I doubt anyone would care much for it.
Ok, I'm paraphrasing and extending what you said to make my point... Javascript being in every browser, to the exclusion of all other languages, is a huge factor in its popularity and utility, and it's the main driving force towards improving the language. If Javascript didn't become the in-browser language, it probably wouldn't have existed at all. Instead we'd have some other small language with similar design flaws, or maybe Perl would have been adopted as the in-browser language. At the time it was the main language for server-side web development, it was already embeddable and used for in-app scripting (like Lua is today), and I recall a browser extension for Netscape that let you use it instead of Javascript. IE, of course, would only have had VBScript.
Pick your poison.
The parent comment said "Javascript is a bad language but it's incredibly useful because it's in every browser." and you just agreed with him after writing a bunch of sarcastic drek.
>The single redeeming feature of JS is that it's implemented in all current browsers. If it wasn't for that fact I doubt anyone would have cared much.
>Everything it can do another language can do better, except run in a browser
That's the exact opposite of dismissing a key aspect of Javascript's value, that's explicitly acknowledging it.
>I can't think of any other language that has that level of flexibility. Can you?
(Subjective opinion here)- I think Lua got it better; you can create a better object oriented program with it, as you can do it with functional style; Ending with a more elegant final source code down the road
Well that's both subjective and ambiguous (subjective in the evaluation of quality in each area, and ambiguous because the meaning of "better at a and b" can be interpreted in a number of ways, such as max by min(a,b), max by average(a,b), etc.
But, given that, I'd say that several of the listed languages are better at "being both a functional and object oriented language" than JavaScript, including Scala and Ruby.
All over. Various functional approaches are basic core Ruby programming techniques.
Its not a great FP language because it lacks functional purity (like most Lisps, and, more to the immediate point, like JS) and the main Ruby implementations lack TCO (as, again, do many Lisps and, again, JS.)
But there's certainly a lot Ruby code using functional style.
Worse is better, sorry.
Bad examples. Ruby and Java are small languages too, just like JS. This immediately calls into question the credentials of the author. Not a good start.
"Null everywhere Attempting to access a property of a JS object that’s not defined gives you… undefined. If it’s important to your program that you know about this: write some code."
Or just, you know, use a better language?
"‘Callback hell’ isn’t a problem for people who’ve written a lot of JS."
So that makes it okay then?
It's just another article written by someone so immersed in their own little world that they can't see the wood for the trees. The author probably thinks he has put together a nice a little counter-attack to that "other" article; but really he has just reinforced it.
Nice to take 2 quotes out of context of their explanations.
And finally, I've written a heap of Ruby, Python & AS3 and enough Clojure, Haskell and Go to be able to say: Javascript is a great little language. We use it because of history, sure, but learn how to use it before bashing it.
Javascript is definitely microscopic compared to Ruby or Java. Lua, Smalltalk, Scheme have it handily beat on size, though. Furthermore, Haskell is absolutely lightyears ahead of Javascript in semantic niceness, but it succeeds there by being a much larger language, so YMMV.
From my perspective, Java has, effectively, structs (well defined groups of data) and a few primitive types, and a class system which is dead simple. It's tiny, comparable to Lua imo.
It's more restrictive, sure, but the dynamic-ness of Javascript is a hindrance when it comes to language spec because the base language functions need to be able to interpret all the different primitive types. There's stacks and stacks of corner cases to remember while Java just says "Nope, wrong type".
Another example, in Java Classes are not objects that can be manipulated, they require a special form (generics) for that. In JavaScript a "class" is just a function that has some default properties attached.
You're leaving out prototypes which I find much more complicated than Java Classes.
This description doesn't tell the whole story, leading people to a false conclusion of simplicity.
When it comes to JavaScript arrays, a lot of magic is happening under the covers that doesn't happen with non-array objects. Good JavaScript developers need to know those details, and that counts as complexity.
You're doing people here a disservice by leaving out relevant information.
Ah ok, well I can see why we have differing opinions because that's exactly what I mean :)
I mean base language including corner-cases, not any of the libraries (even if they're included in the SDK). I think they'd both be huge if we included libraries, since I'd lump in DOM manipulation and something like JQuery into Javascript if Java gets the SDK libraries.
Comparable to Lua? :)
Yes, comparable to Lua. I'd probably not say it's smaller than Lua but I would say it's not greatly larger than it.
The whole article just seems to be missing the point entirely.
It pretty much answers everything with "oh but you can write a hack to work around that" or "oh there is some library you can use that plugs that gap". Whilst yes, these may be viable "solutions" for hacking something out. It doesn't refute the claim by the original article that JS is a bad language. It actually just reinforces it with yet more examples.
The only positives to take away from the article are where it highlights features coming in ES6 to actually solve some of the problems. But these admissions seem to contradict the premise of the article.
No I'm not missing the point: I show how, within a few lines, these 'missing features' disappear. e.g: constants, type annotations, objects as keys.
Adding a whole language feature to save a few lines of code - not to my taste. You don't need a new language feature to express an idea if it can be trivially expressed in the language as it stands.
I guess I just don't agree with your fundamental position on this. That writing yet more code to workaround a bad language is in anyway a long-term solution. At some point you'll want to bring more devs onto your team and then you'll need to explain all this technical debt and hacks to them. Not good.
I still believe you're missing the point of the original article you were refuting. It's not about being able to workaround something. It's about not needing to workaround flaws in the language in the first place. That's what defines a good language.
Further reading for you (unordered):
1. http://www.codinghorror.com/blog/2007/05/the-best-code-is-no...
2. "The line of code you don’t write is the line of code you never have to debug." -- Steve Jobs
3. Mythical Man Month (a book)
Yes: we disagree. I write 3 lines where others see a need for new language features.
This completely discounts expressivity, of course, so perhaps a related measure would be, given a suitably complex and representative programming task "What is the size of the shortest written description of the entire spec of a language plus the shortest program in that language that solves said problem."
None of these things exist nor can be computed. They also still ignore readability (something very important and for which Brainfuck would likely fail), but I would wager a reasonable consensus could be built around the concepts.
So that makes it okay then?
I don't know of any language that makes it impossible to write bad code, do you?
JavaScript is a great language, but it's one that's been full of problems as well. It's great because people who traditionally aren't developers can get some JS snippet running to add something dynamic to a site, but at the same time if you are a developer who has spent time learning the language then you can do a lot more with it.
There are also alternatives to callback hell. I do take the method of naming functions instead of using a large number of anonymous functions. It helps significantly. If you prefer, you can easily use promises instead. That's been another effective approach.
I've never written any Ruby and can't speak to the comparison at all, but if it's a language that makes it impossible to produce bad code when you don't know the language and its idioms well then it's something I need to be learning.
This is a problem since many programmers do not like languages which make it hard for them to write code. I'm not sure whether it's the effect of "making it hard to write bad code" that makes it hard to write code or whether its "making it hard to write code" that makes you less likely to run into the effects of bad programmers.
The problem is that once you start accepting malformed inputs you can never be rid of them and thus you have a permanent tower of babble[1] problem.
[1] intentional
JS is not OO... IMHO OOP has not proven itself out to reduce confustion, or simplify code bases. It tends to make distributed systems which are increasingly necessary for large projects more complicated. In JS I tend to have two types of objects. The first being data, that which can be easily serialized, transported, stored and deserialized. The second being libraries meant to act against requests or use of said data. The second can be extended to those which tie a user interface to said data as well.
When you break things down in such a way it's easier to develop systems that can scale out, and are easier to maintain as such. You can do similar things in most OO environments. I also tend to think that my Duck data class should probably NOT have a quack method. My DuckHandler class should.
OO has brought us a lot of extremely bloated, over-engineered, "enterprise" monstrosities over the years, and imho should not be encouraged.
JS is very much my favorite language, and in some scenarios (testing, and build scripts) I have started to use CoffeeScript. My second is actually C#, which I pick over Java because JNI is such a pain by comparison. It really depends on what you need.
Sometimes you just need to get something done. You will not be able to use Ruby or C++ in client-side browser code any time soon. On the flip side node.js as a binding layer against a very nice set of C libraries is pretty awesome, and can be used to get closer to a "one language to rule them" ... it's often said, "don't let perfection get in the way of good enough."
JS is definitely OO; its not class-based OO -- but its still OO. And its purer OO than, e.g., Java (class-based OO in which classes are not first-class objects but require jumping through hoops to get an object that represents the class are not as much OO as either protypical OO languages that lack classes as language features like JS, or class-based OO in which classes are objects like Ruby.)
> IMHO OOP has not proven itself out to reduce confustion, or simplify code bases. It tends to make distributed systems which are increasingly necessary for large projects more complicated. In JS I tend to have two types of objects.
IMHO, OO languages, per se, do not have that effect, though Java has that effect, due to the same limitations which make Java the poster child for repeated-code-template style design patterns.
CoffeeScript isn't JS, its a different language that compiles to JS. So what CS can do doesn't say anything about JS as a development language.
> You will not be able to use Ruby or C++ in client-side browser code any time soon.
You can use C++ in client-side browser code now -- sure, you compile it to JS, just as you compile it to native binaries to run on the server side, but the development language can be C++. [1]
When done correctly, object oriented programming is a lot like the Unix philosophy.
The Unix philosophy (in part): Write programs that do one thing and do it well. Write programs to work together.
Correctly done object oriented programming: Write objects that do one thing and do it well. Write objects to work together.
There's a lot of very poorly written non-OO code out there. Don't blame OO because there's also a lot of poorly written OO code out there. OO is, in part, a tool to manage code complexity. Blaming OO for complexity is like blaming Unix for complexity because there are too many programs in the /bin directory.
I don't understand the vitriol. Is JavaScript perfect? No but I don't think anyone has ever made that argument. Can you build web applications with it? Absolutely.
The fact of the matter is JS can run on more "things" than anything else. Period. This includes legacy systems. Don't like the language? That's totally fine and, to an extent, understandable. But, holy shit, it's a highly accessible tool: learn it and stop complaining.
"But there are better tools!" Ok, that's great, but those tools aren't presently available in your toolbox. So write your own library to implement missing feature x. Syntax not terse enough for you? Write a preprocessor. Since you won't be the first, a lot of the hard work has already been done for you. Consider publishing it. Do what every other developer doing anything on the web has had to do for years: improve your sandbox.
"But these features should be standard!" They're not. Write the 3-5 lines to fix it and move on. Want to go the extra mile? Talk to the folks who run the show (the ecma folks).
Not happy with the tools? Fix them. Chromium and Firefox are OSS; write other runtimes into them. Push for their adoption. Does that seem like an insurmountable task? Then perhaps leverage what is available to you.
All of this religious debate is nonsense.
Your post complaining about complaining doesn't make the best case against complaining in general.
You're just bitching in the opposite direction and telling people that unless they agree with you on the topic, they can't express their opinion in same rhetorical style you do.
C and even C++ run in far more places than Javascript does or ever will. People using other languages won't be interested in or able to use your library written in Javascript.
Anyway, I don't particularly care about writing code that runs on every device ever. I want to write code to solve problems, and for a large set of problems Javascript inside a web browser is fairly useless. Javascript is great if your economic model is getting as many users as possible and then getting aquhired before you run out of capital. This is the case for a lot of people on HN, even if they don't realise it. However I'm a small time developer, not in SV, who programs because I enjoy solving problems and helping people, not to get rich. I'm only really interested in whether $(number of people who can run the code) * $(how much they can pay) > $(my cost of living) so that I can afford to eat. It means I don't care so long as the platform/language I choose has enough users to pay my bills, it doesn't have to be 100% of people. I realise that the industry giants at Google or Mozilla don't really care about people like me ('life style business' is usually a term of derision on HN). In a world of web based operating systems that only run web apps I would end up stacking shelves in the supermarket or on the dole because I dislike that technology stack enough that I can't be productive in it. That is why sometimes I bitch about Javascript.
>if you wanted to do that through the web then hey, you would probably use Javascript to accomplish that.
Well personally I wouldn't since as I said I'd rather not develop software at all then use Javascript/CSS/HTML.
Of course the rest of the industry has no obligation to continue supporting the open native platforms that allow me to use the technologies I prefer. However I don't think it is unreasonable to moan when I see those platforms being killed.
I want to use technologies that I enjoy, and I can do that so long as enough people use computers that I can deploy those technologies to.
What I don't want is to be forced to use technologies I dislike just because it's where the money is in the industry and the people with power have decided it benefits them to sell devices that only allow software that runs in the javascript sandbox.
Personally, I enjoy writing in Javascript a lot. I like how it's more functional than other mainstream languages. And if we're going to debate style, that's great, but distribution just isn't a problem of Javascript, instead, one if its greater strengths.
This video changed my mind: http://youtu.be/hQVTIJBZook (google tech talk, "JavaScript: the good parts")
Two facts mentioned in the video that I didn't previously know and make me feel better about JavaScript: 1- JavaScript is lisp in disguise 2- The name JavaScript is an inside joke referencing the language's differences from Java, not its similarities.
That was enough to make me change my mind, and I'm currently enjoying learning JavaScript unashamedly. Browser differences and lack of standards are a PITA, but OTOH, they all have awesome debuggers - HTML+JavaScript may be the only UI toolkit + dev environment that comes packaged with ALL computers, and for that reason has the widest reach.
There's no question that the JS world is a bit wild west compared to other languages, but there's also no question that the situation is getting better over time, and that depending on what you're coding, there are huge advantages to using it.
That is unfortunate because it isn't really true: http://journal.stuffwithstuff.com/2013/07/18/javascript-isnt...
This is an opinion post, not a statement of fact. There's also no byline on that very hyperbolic and negative opinion post. I don't need to defend JavaScript's Schemeness or Douglas Crockford. (I'm sure Douglas is perfectly capable of doing that by himself.)
The obvious authority argument: Given random dude on the internet (heretofore to be known as "Stuff" in reference to his web site), and the guy who wrote jslint and is currently fixing JavaScript, on the topic of what other languages JavaScript is most like, I will defer to Douglas for now.
First and foremost in the actual reasons "Stuff" is wrong is this claim:
[saying javascript is scheme is] "...a thought-terminating cliché. It carries negative informational content and makes people actually know less about languages than they did before."
I am walking talking evidence that "Stuff" is dead wrong on this point. The idea that JavaScript has the functional language parts that I like in Python and Scheme made me curious about the language, allowed me to drop by preconceptions, and I investigated further and learned more about the language. That may well be the exact intention of Douglas saying JavaScript is Scheme-y, which it turns out, "Stuff" admits to before he gets started. This completely undermines the point that "Stuff" was trying to make here, before he makes it.
Second, "Stuff" capitulates to 1/3 similarity on the number of core Scheme features. Except, as he notes, another several are reasonably there but not up to his snuff. That puts us at more like 1/2 to 2/3. The other third is crap nobody wants in a modern language. "Stuff" is being (admittedly) biased about where he draws the line.
The most telling is that he points right at the things that we all want in a language: minimalism, first class functions, and closures. He comes right out and names all the languages we like and hold up as being "better" than JavaScript. :O There's no better reason to call JavaScript Scheme-y.
Since I'm talking about him I'll say I think his Game Programming Patterns book is great: http://gameprogrammingpatterns.com
http://www.crockford.com/javascript/javascript.html
As the JS engines in browsers have got better and more "real developers" have come on board the wild west is no longer so wild. The problem I found before was that front-end developers would code JS but they had no formal education in programming, so they couldn't grasp those OO concepts. If you look at some of the libraries and JS code out there now you'd be amazed at the standard of code. Most of it far beyond me now, I haven't coded in JS in some time.
I think you mean more "things that one can superficially observe in a coffeeshop." :)
I'd hope that distribution comes to matter less and less in the future as we increase our ability to distribute something new.
It's basic human nature for us to behave this way. It's tribalism: "it's not how I roll, I don't understand it, therefore I hate it" is pretty natural for us.
I'd still love to have the safety of a language like Rust for modern web development. At some point, someone will fix Emscripten support up for it, so then it'll be comparatively alright. (I like the theory of the one-language-from-end-to-end approach, but I want it to be a safer language than JavaScript.)
I probably should have titled it "Javascript isn't a shit language, you just need to learn it" to avoid this ambiguity: I'm not claiming it's a "must learn" for modern dev ;)
On the other hand, you're well on your way to becoming a successful marketer with your deceptive titles.
Javascripts flexibility is why you see emulators, 3D games and simulations, everything written in Javascript. Every language compiles to Javascript, and you can edit code live in Javascript, having it render directly into the browser, without running a server, REPL, etc...
The main advantage of Javascript though is the freedom it gives to developers - you can be productive in it quickly, individual developers can get alot done with it in a short time, and it enables web apps to be created quickly.
Look at something like Firefox OS, how easy it is to script and develop for, and then you'll understand why JS is great.
Languages do not "offer" browsers. Browsers offer languages.
Javascripts flexibility is why you see emulators, 3D games and simulations, everything written in Javascript.
It's because people want to deploy to browsers and there are no alternatives.
Every language compiles to Javascript
Any language can be compiled to any other language if someone spends enough time on it. The reason people compile things to JavaScript is, again, because there are no alternatives.
The main advantage of Javascript though is the freedom it gives to developers
This sounds like something from Ministry of Truth in 1984. We're stuck with a single language, with no proper way to bypass it. The "alternatives" are ugly hacks that still revolve around the same language, have most of the same problems, then add some on top and make development tool-chains orders of magnitude more complex. How on earth this is freedom?
You misread? I said it offers a low barrier to entry. I'm well aware of Javascript's relation to the browser, or Dart's in Dartium as a counter example.
> It's because people want to deploy to browsers and there are no alternatives.
Flash? Java? C# (Silverlight)? Dart on Dartium? Native Client on Chrome? Some have came and went, some aren't catching on.
> This sounds like something from Ministry of Truth in 1984. We're stuck with a single language, with no proper way to bypass it. The "alternatives" are ugly hacks that still revolve around the same language, have most of the same problems, then add some on top and make development tool-chains orders of magnitude more complex. How on earth this is freedom?
So propose an alternative... Native Client in every browser perhaps? I wouldn't be opposed. Or is there another language you'd prefer? Dartium is here, you can test it today. https://www.dartlang.org/tools/dartium/
> This sounds like something from Ministry of Truth in 1984.
Freedom, as in low barrier to entry and shipping an app. And certainly more freedom than MS, Oracle or Apple offer with their solutions.
What platform makes distributing to users easier, and still free from corporate control?
It is currently the platform which is able to spread over the biggest range of devices because it evolved from an ongoing cooperation game.
This game isn't sane, it's not efficient and the result is a mess, but it's our mess for the time being.
A lot of the same arguments against Javascript are heaped on C as well. I think anyone has used these languages long enough and understand them deeply enough are more than aware of their short-comings. It hasn't stopped C programmers from writing the software that runs pretty much the entire world. Neither has it stopped Javascript programmers from making awesome things.
I think the argument that, X is a crappy language because it lets you do stupid things like Y, should be removed from the lexicon. I assume you've all seen the video of the wat talk and any Javascript programmer worth their salt has committed it to memory. If they haven't then they're either still new to the language or ignorant and could use some help. Maybe point them in Doug Crockford's direction.
There's no perfect defence against human error. It's why we write tests, static analyzers, linters and come up with practices like code review and prayer (hah!).
I get the feeling that people who say this write a lot of JS, but don't read a lot of JS written by others.
Nitpick, because I happen to be teaching myself the Javascript class system right now: instanceof examines an object's prototype inheritance, not its constructor. x instanceof Y if x inherits from Y.prototype, so it's possible to "sever" an object from its constructor by replacing the constructor's prototype property. Coming from a strongly typed language, this takes some getting used to!
You can find things to gripe about in every language you'll ever work with. Javascript is available. Use it and contribute to it's community, or don't. Griping is not contributing. It doesn't solve any problems.
If you think Javascript could use improvement, write a library to help solve a specific problem or contact emca and report your problem/issue/idea-for-improvement.
Basically just stop complaining and start working. If you are of the opinion that Javascript is a horrible language that is bound to make your project un-maintainable and disgusting regardless of your expertise then choose a different language.
Off to write come C :)
99% of the Comments are not about the Topic just about beliefs of other Commenters....
That's poorly written JavaScript.
On top of that, what I see missing on all this flamew.., err, discussion, is the difference between a more loose, small and open language and a more consistent, closed and regular one. Both feel a lot different. Comparing it in a given scenario may be valid, comparing they without any context at all feels like apples and oranges.
Hopefully someone can solve the problem of distributing and updating native apps as smoothly as web apps (or websites, to be more accurate) with a minimal security impact and we can all go do some real 'modern' programming.
https://www.quora.com/Computer-Science/What-is-the-most-valu...
I've heard it was supposed to be finalized in 2012,then 2013,then what ?
They should go with a minimal spec ( let,proxies,modules,promises,deferred ) and deliver.