News for hackers. Stuff that matters.
Re:Is JavaScript getting worse? by vim-guru on Monday January 12, 2015 @07:16AM (#8873476)
Classes adds complexity and reduces composability. With OO you end up with a soup of inheritence and patterns. Functions are way easier to compose and reason about.
Re:Is JavaScript getting worse? by lgunsch on Monday January 12, 2015 @06:13PM (#8877099)
>Classes adds complexity and reduces composability.

I could easily argue the opposite. Classes reduce complexity, and increase composability. Classes allow you to group methods in a cohesive manner into a single entity. For example, a class named Queue, List, or Vector would imply to the programmer what it does without them reading any code at all.

>With OO you end up with a soup of inheritence and patterns.

Just because programmers don't make clean code, doesn't mean the whole idea is somehow lesser then just using functions. Having a hodge-podge of 2000 line functions in one massive file is just as evil as "dirty" OOP code. At least classes encourage you to group your functions in some hopefully sane manner.

>Functions are way easier to compose and reason about.

Functions are easy to compose and reason about, however, that does not mean that classes and OOP are not as easy. Each have their own clear costs/benefits. OOP, and procedural programming, should both be in a programmers toolbox.f

Re:Is JavaScript getting worse? by buzzdecafe on Tuesday January 13, 2015 @08:49AM (#8879763)
(article author here) I very much agree with this point of view. The most important concern is a developer who thinks and writes clearly, irrespective of style or programming paradigm.

That said, I find FP easier to reason about and comprehend, but that is just one man's opinion. I also find it more fun.

The "bad bet" I was referring to was that you can make JS impersonate Java. That strikes me as a losing proposition. Sugaring up prototype inheritance to look like class-based inheritance just muddies the water.

Re:Is JavaScript getting worse? by collyw on Monday January 12, 2015 @08:15AM (#8873702)
They don't necessarily introduce complexity. Its a case of using thing s in the appropriate place. I use Python Django. Class based inheritance is useful, though it probably not overdone like it is in the Java world. I also use functions - I find these tend to be better for smaller units of computation and classes for overall organization.
Re:Is JavaScript getting worse? by jerf on Monday January 12, 2015 @08:43AM (#8873787)
You might be interested in trying Go's OO out, which privileges composition above inheritance. It's not often talked about on HN under the low-signal furor about generics, but it is a case of a small change that has a surprisingly profound effect on the language. I am becoming convinced that the current backlash against OO should really be against inheritance, not OO. Inheritance is a thing that is occasionally useful and often painful; composition is occasionally painful and often useful. The latter should be the syntactically-privileged default.
Re:Is JavaScript getting worse? by tel on Monday January 12, 2015 @12:27PM (#8875089)
By Go's OO you mean the interface-driven mechanics? I think those are quite nice.
Re:Is JavaScript getting worse? by jerf on Monday January 12, 2015 @02:04PM (#8875735)
No, the composition aspects. Go privileges composition over inheritance syntactically, which has a surprisingly large affect on the whole. Interfaces end up extending it in other interesting ways, but that's a different aspect.

The whole is still an imperative language in the end, but I've found that while it may not encourage composition and separation of concerns as much as I'd like, it fights me less than some other imperative languages.