4 ms·
I struggled to find anything I liked about javascript. Other than ease of deployment.
by throwawayaway 12y ago
I struggled to find anything I liked about javascript. Other than ease of deployment.
- mhd 12y agoFor enterprise companies the ability to move programmers around from frontend to backend (or demand that they're doing both at the same time) is probably a benefit. Not a good idea, but that's rarely a hindrance for both enterprisey and startup "human resources" management. Reminds me a bit of how we treated torchbearers and henchmen in D&D...
- kyllo 12y agoFirst-class functions and closures are nice if you're coming from Java.
- empthought 12y agoThose are in Java now. Always have been, really, with a lot of boilerplate.
- woah 12y agoBut really, anything in Java requires a lot of boilerplate.
- kyllo 12y agoNo, they aren't. The only thing "first-class" in Java is classes. They added lambda expressions in Java 8 but they still must be defined inside of a class method. It is still illegal to define a function outside of a class in Java. And Java methods are still not lexical closures; there are some tricks you can do to sort-of emulate this but closures are not a language feature.
- empthought 12y ago> The only thing "first-class" in Java is classes. And lo and behold, they have decided that an anonymous class with only one method is equivalent to an anonymous function object, and given us syntactic sugar to invoke it without the class declaration boilerplate. You're essentially doing the same as complaining that conditionals aren't a Smalltalk language feature.
- kyllo 12y agoAn anonymous inner class with only one method. The "inner" is important. It still has to exist inside of an explicitly declared class. Also, a variable holding a reference to a lambda function cannot be called as a function (no function pointers). Contrast with JavaScript, where functions are first-class, can be declared at top level, can be passed as arguments to and returned by other functions, can be called by dereferencing a variable, can be nested, can be partially applied, etc. The minimal syntactic sugar for anonymous inner classes added in Java 8 doesn't even begin to approach the power of the function support in languages like JavaScript. Language-level support for this stuff matters.
- empthought 12y agoThey have exactly the same "power," they're just spelled differently. "func()" doesn't let you do anything that you can't do with "callable.call()". It's trivial to do everything that isn't syntactic sugar (for example, partial application, passing as arguments for abstraction) that you mention in Java, if a bit tedious (and often pointless, since the standard APIs generally weren't designed with that in mind.) _A Little Java, A Few Patterns_ came out in 1998; give it a read.
- kyllo 12y agoThe fact you put the word "power" in scare quotes indicates to me that you don't understand what it means in this context. Here, have a pg essay: http://www.paulgraham.com/power.html http://www.paulgraham.com/power.html
- Dewie 12y ago> Always have been, really, with a lot of boilerplate. Many uses of first-class functions is for reducing boilerplate to begin with.