4 ms·
Recently as an exercise I worked through the examples in Sandi Metz's "Practical Object-Oriented Design in Ruby" using Javascript. To approximate her examples I
by roneesh 12y ago
Recently as an exercise I worked through the examples in Sandi Metz's "Practical Object-Oriented Design in Ruby" using Javascript. To approximate her examples I did have to do a few pretty unintuitive things (for example use .call to invoke parent constructors, whereas in Ruby the native syntax allows it). But it wasn't anything that mind-bending to wrap your head around, and it was learned in just a few minutes (learn is a strong word, remember, realize or connect the dots might be more applicable).
That I suppose is the core of the "I hate JS" arguments, to get it to do what you want, it has a slightly unintuitive non-syntactical way of solving it's problems. That of course, is only the case if you intend to replicate the programming styles the syntax of other languages gives you. I don't think you should. And now with ES6, we have those other styles in our syntax, so it's even less of a problem. Hate on JS all you want, but it's probably not so amenable to you because you're using a metal file when you really need a belt sander, close but not quite right.
- tracker1 12y agoHonestly, I'm not a big fan of Class-based design... I really feel that JS lends itself much better to a system of functions with composition. You can create a number of stand-alone functions that take an object that is operated against as a parameter and return a value, or modified object. You can now test these independent functions as modules without a lot of distractions that come from side effects and state. With that in place you can bind those functions into a composed object (state), and use that in the rest of your application. You have composition, encapsulation and testable code that is just plain difficult to reason about when you are using Class-based inheritance and trying to test against it. I actually love JS... it has its' quirks, but I find the flexibility it offers to exceed what most other languages offer for most tasks. Using small function libraries and modules, I find that I can orchestrate much larger operations far more easily than can be done with other systems (usually). All of that said, I also love C#, and use it very differently. People should stop trying to walk in water, and just swim.