News for hackers. Stuff that matters.
Re:JavaScript is not suitable for large web apps by neilk on Thursday June 14, 2012 @10:21PM (#4114631)
There are reasonable objections to JavaScript, but this is inane.

He uses an example of someone committing a classic mistake in software design. This error would be the same in JavaScript or Java. I'd like to see how his ActionScript translation magically fixed it.

However, the remedies for the mistake differ in each language.

It is somewhat difficult to fix it in Java's statically typed straightjacket (which I assume is similar in ActionScript). The easiest answer might involve a Feedable interface. I looked this up and it's not clear if ActionScript classes can implement multiple interfaces. So if you want your Toaster to be both Feedable and Heatable, get ready for interfaces extending each other.

In my experience most Java developers don't even do that. They don't think about revising their approach to the problem. They going to write a method that does what they want in the class that they want, come hell or high water. They'll create the BunnyOrToaster class which has methods which all contain if/else clauses testing if this in 'bunny mode' or 'toaster mode'.

In a language like JavaScript, you have other, simpler options, and often more powerful ones. I don't know for sure, but the mere fact that there are fewer tricks to learn might mean that it's better for naive to intermediate programmers. The typical JS way would be to rely on duck typing. If that disturbs you, you could implement a 'getFeeder' method on both kinds of objects that returns a closure, which can be executed later. That's what Java might call a 'Strategy pattern', but it's baked right into the language in JS.

Re:JavaScript is not suitable for large web apps by prophetjohn on Thursday June 14, 2012 @11:51PM (#4114835)
>In my experience most Java developers don't even do that. They...

It's awesome how, on Hacker News, people whose job require them primarily write code in Java are some sort of stupid luddites ready to be easily generalized as the worst kind of programmer. Way to stay objective, guys.

Re:JavaScript is not suitable for large web apps by neilk on Friday June 15, 2012 @03:33AM (#4115470)
Fair point -- it's unfair to stereotype Java developers. In my mind, I meant "most developers" and I happened to be talking about Java. But that distinction wasn't clear.

It's obvious that (in the OP's case) using JavaScript didn't help the problem either -- but that was my point. Bad design is bad design. I am not making a strong claim that JS is better.

Re:JavaScript is not suitable for large web apps by alexscheelmeyer on Friday June 15, 2012 @06:07AM (#4115779)
I like how you apologize for stereotyping Java developers by clarifying that you really wanted to stereotype ALL kinds of developers.
Re:JavaScript is not suitable for large web apps by gridspy on Friday June 15, 2012 @07:05AM (#4115909)
When you think only in A restrictive language, your thinking becomes equally restricted. Any of us would become rigid if we never used or understood dynamic languages and only use java or c++ bog standard OOP.

So the comment is less about the developer than it is about the mindset and the 'easiest path' that emerges from the language design.

Re:JavaScript is not suitable for large web apps by silentOpen on Thursday June 14, 2012 @10:42PM (#4114692)
Re:JavaScript is not suitable for large web apps by neilk on Thursday June 14, 2012 @10:48PM (#4114707)
Which is t3h awesome, but not an option in either language under consideration, as far as I know. Unless you used a Haskell-to-JS compiler. I apologize if I implied that static typing = Java's kind of typing.
Re:JavaScript is not suitable for large web apps by noblethrasher on Thursday June 14, 2012 @11:34PM (#4114795)
Java doesn't have pattern matching or nice tuple syntax but it does have Algebraic Data Types. Abstract classes are sum types (the dervived classes are the variants) while interfaces are (awkward) product types.
Re:JavaScript is not suitable for large web apps by klodolph on Friday June 15, 2012 @04:36AM (#4115590)
It's not the interfaces that are product types, but the concrete classes which correspond to product types.

Interfaces are a different concept. In functional programming, an implementation of an interface would extend the domain of polymorphic functions that use that interface. The same can be said about Java, if you tilt your head funny and don't need to communicate with other Java programmers, and if you only care about single argument dispatch.

Re:JavaScript is not suitable for large web apps by silentOpen on Thursday June 14, 2012 @11:19PM (#4114763)
Re:JavaScript is not suitable for large web apps by hatsix on Friday June 15, 2012 @02:12PM (#4117824)
His example was an exaggeration... It seemed obvious to me, but maybe not to everyone else.

A more real-life example is that it's very easy to accidentally return a number when you meant to return a string.

But yes, AS does support multiple interfaces.