3 ms·
If you know C, it doesn't mean you are any good at Haskell, Prolog, Forth, Smalltalk, Lisp, or any other major paradigms. All of those introduce fundamental con
by hajile 4y ago
If you know C, it doesn't mean you are any good at Haskell, Prolog, Forth, Smalltalk, Lisp, or any other major paradigms. All of those introduce fundamental concepts that the C programmer simply does not know (I recommend learning all of these to expand your horizons as a programmer, but you meet very few devs that know or understand anything outside their narrow proceedural/OOP window).
JS is a completely different paradigm from C++ mixing in functional programming with dynamic objects in a way that C++ simply cannot do things.
If a C++ dev wanted to learn Python, they'd pick up and read some books on the subject. Same if they wanted to learn PHP, Java, Perl, C#, or whatever. But when it comes to JS, they just try to wing it.
Their stuff kinda works, but they don't even realize that they are fighting the language every step of the way. As a result, they complain that JS is slow and the design sucks when the reality is that they don't understand, but have too much hubris to actually go back to school for a little while.
I spent much of the early part of my JS career fixing the code written by these kinds of C++ devs. While they wrote amazing C++ code, the JS they wrote was a mess. I could rewrite their code in a fraction of the LOC while making it more readable and faster too.
- CyberDildonics 4y agoJS is a completely different paradigm from C++ mixing in functional programming with dynamic objects in a way that C++ simply cannot do things. Where do these ideas come from? Every modern language has elements that were originally considered "functional". Good programmers will do well with any language. What are 'dynamic objects' and what is the way that 'C++ simple cannot do thing'? You make these claims without backing anything up. If a C++ dev wanted to learn Python, they'd pick up and read some books on the subject. Same if they wanted to learn PHP, Java, Perl, C#, or whatever. But when it comes to JS, they just try to wing it. Where are getting this from? Most programmers learn javascript before C++ because it's so easy to try things out in a web browser. Their stuff kinda works, but they don't even realize that they are fighting the language every step of the way. As a result, they complain that JS is slow and the design sucks when the reality is that they don't understand, but have too much hubris to actually go back to school for a little while. Who are you talking about? Is this describing a single person you met? these kinds of C++ devs. While they wrote amazing C++ code, the JS they wrote was a mess I have news for you, their C++ was probably terrible too. Even labeling someone as a "C++ dev" or "javascript dev" is a giant red flag of inexperience.
- hajile 4y ago> What are 'dynamic objects' and what is the way that 'C++ simple cannot do thing'? This is the foremost proof that knowing C++ doesn't mean you know anything about JS. JS objects are dynamic with the ability to add/remove class properties and methods or to dynamically change what class/object it inherits from all as the program executes. C++ classes are static and determined at compile time. > Most programmers learn javascript before C++ because it's so easy to try things out in a web browser. Most C++ programmers started programming C++ long before JS became popular. Most people who "know JS" don't actually know the language to any meaningful degree. I'm not talking about subtle things like the difference between `-0 === 0` and `Object.is(-0, 0)` or why you might use `x === x`. I mean that most can't tell me what a closure is, why you'd want to use one, or even how to use it in something like a factory. For the record, this question isn't even JS-specific, but applies to Ruby, Python, Lua, PHP, the ML family, Rust (actually just a ML with C-like syntax), Erlang, most lisps, etc. > Where do these ideas come from? Every modern language has elements that were originally considered "functional". JS is multi-paradigm offering imperative, OOP, and functional approaches, but because its functions inherited heavily from Scheme (I really wish Eich could have implemented scheme), it gets a lot of really nice properties. Consider the following code (leaning heavily into the point-free side for sake of illustration) let prop = key => obj => obj[key] let map = fn => arr => arr.map(fn) let filter = fn => arr => arr.filter(fn) let reduce = fn => arr => arr.reduce(fn) let sum = (acc, x) => acc + x let pipe = (...fns) => val => fns.reduce((acc, fn) => fn(acc), val) let data = [ { fname: "John", lname: "Doe", age: 41, sex: 'M', children: [ {fname: "Fred", lname: "Doe", age: 11}, {fname: "Jill", lname: "Doe", age: 8}, {fname: "Elliot", lname: "Doe", age: 3}, ] } ] let printSumOfChildenAgeOfMiddleAgedFathers = pipe( filter(x => x.sex === 'M' && x.age > 40), //get all males over 40 map( //for each male pipe( prop('children'), //get their children and age map(prop('age')), reduce(sum), //add ages together for father ) ), reduce(sum), //add ages for all fathers ) Sure, it is pointless code off the top of my head to illustrate my point (though with some changes it could be actual code I've seen). If you'd like to counter, write this functional-style code in C++ without changing to imperative code. It'll be 10x as long and an unreadable mess. > Even labeling someone as a "C++ dev" or "javascript dev" is a giant red flag of inexperience. I consider language design as a bit of a hobby and I've spent time with a LOT of very different languages. Even so, I only consider myself proficient in a handful of them. Even setting aside the impossible task of learning all those standard libraries completely (even most experienced Java or C# devs don't actually know the entire standard library of those behemoths), just learning the warts and weird edge cases of almost any language you can name takes at least a couple years and with large and/or convoluted languages (eg, C++ or JS) it can take many years.