by aikah · 11y ago · 0 comments
Says who? I don't think it's going anywhere.
I for one will be happily programming in ES2015+ in the future, for many years to come. And I know I'm not the only one (have you ever been at a JS conference?).
Anyways WebAssembly is very much welcome. I can't wait to use python or haskell "natively" in the broweser.
> No transpilation
You'll have to compile instead.
> people will be able to get rid of javascript wholesale
Modern JS (ES6+) isn't worse than Java or C# in terms of expressiveness. In fact, it might even be better in some cases.
No other language is going to come with built-in tools for editing within browser/client dev tools. Modern JS is going to be one of the easy languages to get started on.
And of course, you totally underestimate the billions of lines of JS already written for the Web.
ES6 isn't statically typed. It might be better for you , it is not for me.
> You'll have to compile instead.
Yes, and without caring about Javascript. That's the point. Javascript will become irrelevant when it comes to front-end development. One language cannot possibly satisfy everybody's needs.
If that was the case we would all be using nodejs on the server and that's hardly the case.
Perhaps you should just look into using TypeScript? It's basically ES6 with static typing.
So you are saying that because it isn't statically typed it's inherently worse in terms of expressiveness?
There's a valid argument that static typing has big advantages (navigation, refactoring) but it worries me when people write off dynamic code entirely.
That being said, yes, it has been shown that, for large projects, statically typed languages are strictly superior than dynamically typed ones.
Don't get me wrong here, I like a LOT about C# but expressiveness compared to JS doesn't even come close, when you include the pending ES7 stuff via Babel.
> Javascript will become irrelevant when it comes to front-end development.
I understand the enthusiasm but this becomes a bit of an argumentum ad populum.
Here are some examples from this week:
Checking whether a passed argument is an array or a dict:
var a = []
if (Object.prototype.toString.call(a) !== '[object Array]') ...
(perhaps not js itself, but how it is used) Leaking DOM nodes are a thing:
https://developer.chrome.com/devtools/docs/heap-profiling-do...Easy things like getting values of a dictionary:
var d = {
a: [1,2,3,],
b:[4,5]
}
var values = Object.keys(d).map(function(key){
return d[key];
});in Python, it's just .values()
Errors aren't thrown when there are obvious issues with the code.
String.replace replaces one instance instead of all instances in a string.
Functions arguments are a bit of a mess.
differences between
for each (var myVar in myObject)
for (var myVar in myObject)
random things like these:http://stackoverflow.com/questions/2568966/how-do-i-pass-the...
All the things here:
http://www.toptal.com/javascript/10-most-common-javascript-m...
If you import a library, they could have modified the global scope. This is common in JS libraries. Then some things you wrote don't work.
undefined/null thing
differences between var declared function and regular named function.
Many things in the language are not obvious and you have to discover them through trial and error or study JS internals and find out how things are implemented.
Things that take 5 lines in JS take 200 in C++ all to make the type system happy. Yes I understand the trade offs. Wrote games most of my career. I used to find it cool that I could write a 400 line templated intrusive list class that generates just 1 instruction on use. Yippee. Now though I just resent the fact that have to write giant implementations like that for code who's performance doesn't matter.
In JS forgot a little piece of data? It's generally almost zero lines to hack it in. C++? It's often refactoring hundreds of lines of code.
Wanna to wrap some function to monitor it, test, sanitize, .. trivial in JS. Next to impossible without massive refactoring in C++
When I have to do C++ again I will but it won't be without kicking and screaming.
Luckily solved in ES2015:
Array.isArray(thing)
The toString trick is pretty outdated, in ES5 you can also do:
thing instanceof Array
> (perhaps not js itself, but how it is used) Leaking DOM nodes are a thing
Definitely not JS itself, it's easy to create circular references between JS objects and DOM elements. It's just the way the DOM is (poorly) designed and the way it interacts with JS.
> for each (var myVar in myObject)
That's not even standard, just a Mozilla "dialect". I don't think that's supported by any engines other than SpiderMonkey and predecessors.
> thing instanceof Array
instanceof is ES3.
> That's not even standard, just a Mozilla "dialect". I don't think that's supported by any engines other than SpiderMonkey and predecessors.
To quote MDC:
> The for each...in statement is deprecated as the part of ECMA-357 (E4X) standard. E4X support has been removed, but for each...in will not be disabled and removed because of backward compatibility considerations. Consider using for...of instead. (Please refer to bug 791343.)
if (a instanceof Array) ...
// or polyfill
Array.isArray = Array.isArray || function(a) {
return a instanceof Array;
};
Object.keys can be cleanly shimmed without braking older browsers. You can always shim in the behavior you want, as long as you don't need IE7 support. Object.prototype.values = function() {
var instance = this;
return Object.keys(this).map(function(key){
return instance[key];
});
}
Replacing globally in a string console.log("I lose and lose again, not even close.".replace(/\blose\b/g, "win"));
If you're using ES6 or node-style modules, you shouldn't generally mess with global state, unless you are polyfilling new features. Promises (bluebird), fetch, etc...Understanding falsy values is a core part of learning JS, as is coercion... no it isn't perfect, but there are flaws in any language you can bring up.
As to a function assigned to a variable vs a function declaration, well again that's part of learning the language.... Being able to use functions as first class expressions is a very powerful feature, that frankly works pretty well.
Of the features missing from JS proper, an isolated invokable web-workers scenario with plain, side effect free functions/modules would be a great start (not the current way via secondary script).
That said, most of your complaints are things that are easier to work around, or simply things that you learn with the language. It's not that different from learning warts in Python (which is better than many), C#, Java or anything else.
var iframe = document.createElement('iframe');
document.body.appendChild(iframe);
xArray = window.frames[window.frames.length-1].Array;
var a = new xArray(1,2,3);
>> a instanceof Array;
<< false
>> a
<< Array [ 1, 2, 3 ]
>> Object.prototype.toString.call(a) === "[object Array]"
<< true
All I'm saying is there are way too many such things that you have to keep in mind. import { isArrayLike, values } from 'ramda';
const a = [];
const aIsArray = isArrayLike(a);
const d = {
a: [1,2,3,],
b:[4,5]
};
const dValues = values(d);
Not to mention that a lot of the problems you mention have native solutions in ES6.JavaScript is a very different language than the one people used to use 5 years back.
Why should people use JS with a non-standard library when dictionaries come built into better languages?
It's hard to compare. Java is horribly verbose, but C# (and F# even more) is pretty concise these days, definitely comparable to JS if you factor in the increased lines of code you need in a dynamic language to have any certainty when refactoring.
Good and 80% of JS bugs will disappear in a puff of smoke ;-)
I think you've confused the present with the future. No other language comes with that today. There's no reason other languages shouldn't in the future, however.
I think most coders would choose a language that has better tooling and robust standard library over Javascript which doesn't even have a standard library. This is certainly the death of JS.
If someone build a great tool, lest's say the equivalent of D3.js, in Java; I don't see a way I can use it in python without having to write a python API for that library.
It's not necessarily bad. The first advantage being, that hopefully people are going to stop recreating new javascript frameworks every 2 months.
https://github.com/WebAssembly/design/blob/master/FAQ.md#is-...
But It would be real nice to use C# as wasm.
https://github.com/WebAssembly/design/blob/master/TextFormat...