3 ms·
Crazy we're still talking about it. I thoroughly understand `this` now after over a decade working in javascript, as well as thoroughly understanding `this` in
by mattmanser 9y ago
Crazy we're still talking about it.
I thoroughly understand `this` now after over a decade working in javascript, as well as thoroughly understanding `this` in Typescript which I use more now.
And I still make a mistake at least once a week. I know what I've done as soon as the code fails, but it's still so ridiculously easy to get into a context you didn't think you were.
Of all the mistakes made in javascript, `this` stands head and shoulders above everything else, with its arm round the prototypal class structure.
- christophilus 9y agoI almost never use "this" in my JS code. I find that when you use a functional style of development, you largely avoid the "this" pitfall.
- mattmanser 9y agoThat debate is long over. If there's anything that a decade of functional style being "the next big thing" has taught us, functional style is not "the next big thing" and most programmers don't work well in it.
- disantlor 9y agoi strongly disagree with this. half of my posting history on here is evangelizing FRP in javascript (in my case via bacon.js). it has dramatically reduced the amount of time i spend on these and many other sorts of problems. honestly it makes programming way more fun. maybe haskell is a bit extreme for most situations but the concepts are not.
- mattmanser 9y agoWhile you may love functional, and I'm not saying you shouldn't, I think you're strongly disagreeing with the statement you think I'm saying, "functional is bad", rather than the actual statement I'm making which is "functional programming's had many chances to become a mainstream language and it never takes off (outside a few specialities)". What evidence do you have that functional is taking off? Since this board was around, every couple of years there's been a flurry of 3 months when a chunk of the community bangs on about functional programming. First it was Lisp, then Erlang, then Haskell, then F#, then Scheme. I might have got the order wrong. And it never, ever, ever takes off because while 10% of programmers find functional truly brilliant, the other 90% can't work with it. For context, in that time Ruby (via Rails), Python (via Django and use in Science), javascript server-side (Node.js), Go, Swift, Rust and now possibly Kotlin have all taken off. Plus various other techs like NoSQL.
- christophilus 9y agoHm. I guess it depends on your definition of mainstream. In the front end space, functional programming is taking off, I think. Could be wrong, but React + Redux + immutablejs is a popular and very functional approach to UI. Elixir appears to be on the same trajectory as Rails in it's early days. Anectodally, I know a lot of Rails devs and shops that are now primarily Elixir. Most mainstream languages have adopted functional styles and best practices. Higher order functions, a general acknowledgement of the benefits of immutability, etc. Fp may not be mainstream, whatever that means, but it's more popular than I can ever remember it being.
- zhte415 9y agoThis could depend on industry. In finance, functional is not the next big thing, but required. Needs context.
- spinningarrow 9y agoI may have misunderstood but do you mean that the prototypal class structure is also a mistake? If yes, in which way?
- mattmanser 9y agoThey ended up having to add classes (albeit as syntactic sugar). Argue its advantages all you want, but I'd say that's representative of what a failure it's been. One of the last languages supporting prototype-based inheritance has basically given up on it. Personally, I find it an awkward way to try and encapsulate code, generally, it has terrible performance to boot.
- Raphmedia 9y agoWas there ever any issues with prototype-based inheritance? I've always assumed that they added classes simply because of stubborn classical-based programmers who couldn't bother to learn JavaScript correctly.
- spinningarrow 9y agoThat was my impression as well, especially since the class-ish syntactic sugar doesn’t improve performance either.
- MoTTs_ 9y ago> One of the last languages supporting prototype-based inheritance... Actually, all this time, both Python and Ruby use what we would call prototype-based inheritance. https://www.reddit.com/r/node/comments/6oqiyn/is_es6_completely_useless/dkjjh7t/ https://www.reddit.com/r/node/comments/6oqiyn/is_es6_complet... https://www.reddit.com/r/learnjavascript/comments/6c6use/how_the_hell_did_you_guys_learn_js/dhuut92/ https://www.reddit.com/r/learnjavascript/comments/6c6use/how...