News for hackers. Stuff that matters.
Re:For modern development, Javascript is just something you ... by nbevans on Tuesday October 29, 2013 @09:44AM (#6633960)
"The intrinsic smallness of the language can be alarming when you come from a bigger language (Ruby, Java)"

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.

Re:For modern development, Javascript is just something you ... by timruffles on Tuesday October 29, 2013 @09:50AM (#6634010)
Actually Ruby and Java are both large languages compared to JS. Ruby especially - compare its object system with Javascript's, or consider it has 3 flavours of lambda ;)

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.

p.s http://www.paulgraham.com/disagree.html

Re:For modern development, Javascript is just something you ... by nbevans on Tuesday October 29, 2013 @10:44AM (#6634461)
Are you the author?

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.

Re:For modern development, Javascript is just something you ... by timruffles on Tuesday October 29, 2013 @10:59AM (#6634590)
Yes.

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.

Re:For modern development, Javascript is just something you ... by nbevans on Tuesday October 29, 2013 @11:14AM (#6634704)
I didn't like the constants solution for nulls. Why not use a Maybe monad? I'm surprised that you didn't considering your claimed language experience.

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)

Re:For modern development, Javascript is just something you ... by timruffles on Tuesday October 29, 2013 @11:26AM (#6634795)
Maybe monad - like this one I wrote? http://truffles.me.uk/playing-with-es6-generators-to-make-a-.... FYI - I'm sure you're not trying to be, but you're coming off as terribly condescending...

Yes: we disagree. I write 3 lines where others see a need for new language features.

Re:For modern development, Javascript is just something you ... by blueblob on Tuesday October 29, 2013 @10:09AM (#6634177)
I cannot comment on Ruby. I, personally, think Java is a much bigger language than (base without other scripts included) Javascript. Of the two, I prefer Java for it's strong types. My biggest problem with Javascript is that if I make a typo on a variable name, it can be very difficult to debug. This could perhaps be mitigated by using an IDE, I don't know since I don't use JS that often. I feel like this is not a major issue and work on LLVM+emscripten will let me work in almost whatever language I want and have it end up in Javascript in the near future.
Re:For modern development, Javascript is just something you ... by candydance on Tuesday October 29, 2013 @10:34AM (#6634378)
Why do you think Java is bigger?

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".

Re:For modern development, Javascript is just something you ... by timruffles on Tuesday October 29, 2013 @10:47AM (#6634489)
Generics, interfaces, abstract classes, method visibility, statics, different flavours of numbers (and primitives), inner-classes, huge array of data-structures, iterators, checked exceptions, annotations, threads...

Comparable to Lua? :)

Re:For modern development, Javascript is just something you ... by candydance on Tuesday October 29, 2013 @11:03AM (#6634624)
I'll give you generics. Statics, method visibility vs global/local/self. Interfaces, abstract classes, inner classes vs metatables. Data-structures apart from array are implemented on top of the language, array vs tables. Iterators are implemented on top of the language vs lua where they are part of the language. Checked exceptions can just be cast to Exception and ignored. Annotations are optional. Threads vs coroutines.

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.

Re:For modern development, Javascript is just something you ... by blueblob on Tuesday October 29, 2013 @10:45AM (#6634469)
I think Java is bigger in terms of the amount of classes/methods that there are to remember. Perhaps I compare them unfairly because I consider everything in the SDK to be a part of Java, whereas the things people might usually bundle in JS (JQuery, etc) I don't consider part of JS because you have to go out and get them separately. I didn't mean bigger in the sense that you need to know more to be able to use it, I meant it in the sense that it is a larger API.
Re:For modern development, Javascript is just something you ... by candydance on Tuesday October 29, 2013 @11:08AM (#6634659)
>I didn't mean bigger in the sense that you need to know more to be able to use it

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.

Re:For modern development, Javascript is just something you ... by Touche on Tuesday October 29, 2013 @10:41AM (#6634441)
But all of those things you listed are very different things. In JavaScript they are the same thing.
Re:For modern development, Javascript is just something you ... by candydance on Tuesday October 29, 2013 @10:45AM (#6634477)
Please expand your response, I don't understand what you mean when you say they are "the same thing".
Re:For modern development, Javascript is just something you ... by Touche on Tuesday October 29, 2013 @10:51AM (#6634512)
Just a couple of examples. Arrays and Objects are the same type of structure in JavaScript. Arrays just happen to be indexed by integers and Objects by strings. In Java this is not the case.

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.

Re:For modern development, Javascript is just something you ... by Teckla on Tuesday October 29, 2013 @10:47PM (#6639126)
Just a couple of examples. Arrays and Objects are the same type of structure in JavaScript. Arrays just happen to be indexed by integers and Objects by strings.

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.

Re:For modern development, Javascript is just something you ... by candydance on Tuesday October 29, 2013 @11:19AM (#6634738)
The associative arrays in JS are simpler than objects in Java but the expressiveness means you need to be aware of all the different types of type coercion and how it all interacts at runtime. I don't think this is that difficult but it's no more difficult to lay out your data before runtime. I think this is a wash that goes to the dynamic vs static debate which we all know can be argued about for days.

You're leaving out prototypes which I find much more complicated than Java Classes.

Re:For modern development, Javascript is just something you ... by Touche on Tuesday October 29, 2013 @12:08PM (#6635198)
But the discussion isn't about complexity, the discussion is about "smallness" and prototypes are definitely small. They are just "bags of properties" like all JavaScript objects. They just have the special function of being automatically applied to a new object's "__proto__" property when using new. Compare that to Java, where Classes are not objects themselves, they are blueprints for creating objects. But the distinction there means if you want to reason about Classes you need a special form in generics.
Re:For modern development, Javascript is just something you ... by tel on Tuesday October 29, 2013 @10:01AM (#6634104)
Javascript suffers the curse of popularity in spades. Most of its users today do not use it as a language at all, but instead as very light mechanism for getting a web browser to do weird things. Using Javascript as a language isn't bad and I think that's worth talking about. Especially since putting more effort there may let Javascript take advantage of some of its popularity.

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.

Re:For modern development, Javascript is just something you ... by Swizec on Tuesday October 29, 2013 @09:55AM (#6634048)
What exactly is the distinction between a big and a small language? If you ask me everything looks big compared to Brainfuck or a queue machine.
Re:For modern development, Javascript is just something you ... by tel on Tuesday October 29, 2013 @10:08AM (#6634169)
I'd think there is a reasonably good metric in there around approximating Kolgomorov Complexity: "What is the size of the shortest written description of the entire spec of a language?"

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.

Re:For modern development, Javascript is just something you ... by Touche on Tuesday October 29, 2013 @10:33AM (#6634370)
For example in JavaScript you can easily write your own version of new. JavaScript is a just a "bag of properties" and everything else follows from that. Very very rarely do you run into something in the language that breaks that expectation.
Re:For modern development, Javascript is just something you ... by scrabble on Tuesday October 29, 2013 @09:57AM (#6634071)
"‘Callback hell’ isn’t a problem for people who’ve written a lot of JS."

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.

Re:For modern development, Javascript is just something you ... by nbevans on Tuesday October 29, 2013 @10:33AM (#6634375)
Often when discussing JS as a language the conversation drifts off on tangents talking about all the amazing and wonderful libraries available for it. Unfortunately this is sorely missing the point. The conversation is about the language, not its ecosystem.
Re:For modern development, Javascript is just something you ... by ulisesrmzroche on Tuesday October 29, 2013 @10:37AM (#6634399)
What do you think libraries are written with? Glue? A language has a direct impact on a library, so no, you can't get out of that one this easily. Either defend your point well or don't try anymore.
Re:For modern development, Javascript is just something you ... by nbevans on Tuesday October 29, 2013 @10:54AM (#6634539)
Just because a book whose subject matter is of how to write better English and it itself is written in English doesn't make English itself a better language.
Re:For modern development, Javascript is just something you ... by ulisesrmzroche on Tuesday October 29, 2013 @11:20AM (#6634742)
Don't make yourself dizzy now.
Re:For modern development, Javascript is just something you ... by chewxy on Tuesday October 29, 2013 @10:05AM (#6634137)
No, but there are languages that make it hard to write bad code. Go, Erlang, heck, even Python comes to mind.
Re:For modern development, Javascript is just something you ... by tel on Tuesday October 29, 2013 @10:11AM (#6634192)
I feel like making it hard to write code tend to correlate with making it hard to write bad code.

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.

Re:For modern development, Javascript is just something you ... by cuttle on Tuesday October 29, 2013 @10:39AM (#6634419)
Some people might consider Erlang a puzzle language, but Python and Go most definitely do not make it hard to write code.
Re:For modern development, Javascript is just something you ... by tel on Tuesday October 29, 2013 @11:02AM (#6634606)
I think one of the arguments for Ruby over Python is the whole Theres More Than One Right Way To Do It philosophy which does make things significantly easier to write down in Ruby, especially coming from scratch. This is much like Postel's principle---a computer should be receptive to many slightly malformed inputs because they will happen. That makes the computer more successful.

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

Re:For modern development, Javascript is just something you ... by dragonwriter on Tuesday October 29, 2013 @12:28PM (#6635393)
Its hard to write bad looking code in Python, but its quite easy to write bad code in Python.
Re:For modern development, Javascript is just something you ... by collyw on Tuesday October 29, 2013 @11:22AM (#6634754)
I have had to re-wite some really shitty python. Two variable in the same function Index and index.
Re:For modern development, Javascript is just something you ... by asdasf on Tuesday October 29, 2013 @11:02AM (#6634605)
The bigger problem is that there are languages that make it hard to write good code. Javascript is one of them.
Re:For modern development, Javascript is just something you ... by Mikeb85 on Tuesday October 29, 2013 @10:22AM (#6634280)
No, you can write bad code in Ruby. Ruby's advantages are that it's insanely flexible, very OO, very easy to write and get started with, but has lots of very powerful features. But in some ways Ruby is like C++; it gives you alot of rope to hang yourself with...
Re:For modern development, Javascript is just something you ... by tracker1 on Tuesday October 29, 2013 @12:33PM (#6635448)
And JS has some incredible flexibility, with CoffeeScript (CS after) you can even get a more terse syntax similar to ruby/python.

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."

Re:For modern development, Javascript is just something you ... by dragonwriter on Tuesday October 29, 2013 @12:44PM (#6635551)
> JS is not OO

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.

Re:For modern development, Javascript is just something you ... by Teckla on Tuesday October 29, 2013 @10:33PM (#6639075)
OO has brought us a lot of extremely bloated, over-engineered, "enterprise" monstrosities over the years, and imho should not be encouraged.

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.

Re:For modern development, Javascript is just something you ... by dragonwriter on Tuesday October 29, 2013 @01:36PM (#6635997)
> And JS has some incredible flexibility, with CoffeeScript (CS after) you can even get a more terse syntax similar to ruby/python.

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]

[1] https://github.com/kripken/emscripten/wiki