3 ms·
The difference between JS and C++ is that C++ is addressing a complex problem domain whereas JS is addressing a simple one. So JS can put its complexity budget
by mantap 7y ago
The difference between JS and C++ is that C++ is addressing a complex problem domain whereas JS is addressing a simple one. So JS can put its complexity budget towards features that improve productivity whereas such features in C++ require huge amounts of complexity. Take for instance anonymous functions in JS compared with lambdas since C++11, the C++ version needs a complicated capture syntax, capability for capture by value and reference, type inference, templating, and more. All that complexity is useful and needs to be there (I have used most of it in my own code) - in JS anonymous functions are immensely simpler. That's why JS will never become even 1/2 as complex as C++.
- minimuffins 7y agoWeird that this is downvoted. It's a perfectly plausible point, clearly stated.
- lightgreen 7y ago> C++ version needs a complicated capture syntax C++ doesn't actually need it. Rust proved that capture everything by reference or capture everything by move is enough for all practical use cases. C++ lambdas is another example where C++ committee chose complex uber-universal solution instead of much simpler which solves 99% use cases.
- adev_ 7y agoThat's wrong. C++ object lifetime management is much more tricky and error prone than the Rust one. Passing an object by reference to lambda by default can be a beautiful source of out of scope and default. The committee did an excellent job by allowing explicit filtering.
- masklinn 7y ago> C++ doesn't actually need it. Rust proved that capture everything by reference or capture everything by move is enough for all practical use cases. That's kinda true but kinda not: precise "capture clauses" is a common design pattern in rust[0] showing that the flexibility is extremely useful, and I think I've seen rumblings about adding them to the language. I mean technically you only ever need `move` closure, "ref" closures are already a convenience. [0] http://smallcultfollowing.com/babysteps/blog/2018/04/24/rust-pattern-precise-closure-capture-clauses/ http://smallcultfollowing.com/babysteps/blog/2018/04/24/rust...