The only transpiler I've seen that gets close in terms of quality of output is BuckleScript, that thing is damn near magic but TS has the momentum and adoption.
TypeScript has been so good and caused me so few problems that I actually look at ways of moving more bits to the frontend, it makes it pleasant to work and I think (personally) the highest praise you can give a language is that it's pleasant.
Without it you frequently run into objects passed to you after going through 10k lines of code and it becomes a wicked game to figure out which properties the object actually has at that point.
JavaScript, even ES6, is IMO crap for large codebases.
Does this object have the property I'm looking for? Did somebody overwrite it with the wrong type 5000 lines ago? Why is the prototype chain broken? Where's my damn inline documentation.
My company has abandoned JavaScript wholesale with great relief. If it was a physical object we would have tossed it off the balcony.
> My company has abandoned JavaScript wholesale with great relief. If it was a physical object we would have tossed it off the balcony.
I would like to do the same with our gigantic SPA-ghetti.
(Though I'm still fan of the "rip off the Band-Aid" approach I used in a few projects back in the day: rename every .js to .ts and then fix compiler errors until things compile. allowJS is a great option now.)
I also believe dynamic language tooling has regressed.
I'd truthfully love to hear more about that. Care to elaborate?
Writing [1,2,3].map(function(x) { return x+10 }) really doesn't bother me. I don't see what the benefit is of an arrow function. Are there other things that you like?
As the OP mentions, the inheritance stuff is just likely to cause architecture headaches. I like JavaScript's concurrency model (single threaded with callbacks) so I don't see any benefit to the async stuff.
It just seems like people added a ton of complexity to give up a few keystrokes. Transpiling and shimming and adding more control structures make your application more complicated, so there is a real cost. And keystrokes are not generally a big problem when I'm programming. I'm not in a race.
Same goes for 'arguments', though that comes up less. Basically, they're much more representative of a simple lambda than a classical function.
From my experience at least, binding to the outer/creating scope is something I do very often, and as far as I know my use of JS is pretty idiomatic.
Concerning 1, being able to use terser, clearer syntax for something I do so often is a huge win, and in regards to 2, it's nice to see an arrow function and to immediately know what this means, and hella better than having to search for a .bind(), var self = this, var that = this, Car.method(), etc, all equally valid as an approach, and depending entirely on the whims of the programmer behind this code.
And honestly, the sugar often speaks to readability as well. Compare myArray.every(function (x) { return x; }); with myArray.every(x => x).
I don't understand your scope preference. These seem the same to me:
family.findEldestFirst(person => this.isRoyal() && person.name == "Kate")
vs family.findEldestFirst(isPrincess.bind(family))
function isPrincess(person) {
return this.isRoyal() && person.name == "Kate"
}
11 tokens vs 16, same order of magnitude. Second one has an explicit return, which is good for readability. Shorter lines, to which is better for readability. Also relies on fewer control structures, which is good for readability. No need to understand the =>/-> distinction, which is very subtle and beginners won't know about it. To me I'd rather just learn functions and closures and be done with it.... And frankly I think using "this" that way in either case is not a win. I'd rather make family its own argument to isPrincess:
family.findEldestFirst(isPrincess.bind(null, family))
function isPrincess(family, person) {
return family.isRoyal() && person.name == "Kate"
}
Mm. Dat explicitness. Anyway... I think I'm not understanding you. How is this forcing your hand in terms of where you bind the scope?Franky, my sense is that the people who like ES6 and promises are people who are just allergic to writing named functions. Named functions make callback hell go away, and they solve all the problems these arrow functions do. Somehow people think it's bad form to define lots of functions. But defining functions is my job. :) It doesn't bother me.
My sense is it's just Rubyists who miss Ruby and think "more Rubyish" is better. I sympathize because my path was BASIC -> PHP -> C# -> Ruby -> JavaScript. But I think it is a mistake to try to bring your old idioms to a new language.
... and if I wanted to reduce character count above all else, I'd just go use PERL.
It's either "only syntactic sugar" or it "added a ton of complexity". To be honest, you sound like someone who's bitter because all the hard stuff you had to learn to deal with is now super simple and intuitive.
> I like JavaScript's concurrency model (single threaded with callbacks) so I don't see any benefit to the async stuff.
This sentence also demonstrates you either don't understand the concurrency model or async/await (async/await doesn't change the concurrency model).
The syntactic sugar isn't only there to save keystrokes, it also makes code easier to read and is less prone to errors.
I won't disagree about the added complexity.
The "use a more functional approach" and "take advantage of ES6" are by far the biggest for me. ES6 added so much good stuff, I wouldn't consider it optional. It's better than incremental upgrades, feels almost like a different language to me.
Every language has its quirks, and while I'll keep on hating Javascript's, I'll never lose sight of the fact that if you're holding out for the perfect language, you're not going to be doing much coding.