9 ms·
Stop trying to make JavaScript into something it's not... If you want a type system Typescript works great, and it's very easy to set up. You even get debuggin
by cphoover 5y ago
Stop trying to make JavaScript into something it's not...
If you want a type system Typescript works great, and it's very easy to set up. You even get debugging to the original uncompiled source with sourcemaps.
If you want a strongly-typed static language, compile to a wasm target... That's what it is for.
Stop trying to change JavaScript into a language it is not.
JMHO
- halfmatthalfcat 5y agoI mean, with all due respect, who are you to decide what Javascript is and is not? There's obviously a huge demand for type safety in Javascript, hence the existence and adoption of Typescript.
- Turing_Machine 5y agoCompare the lines of code (on Github, say) written in straight Javascript and the lines of code written in Typescript. I do not think the demand is quite as huge as you think it is.
- rattlesnakedave 5y agoI'm not sure that's a useful metric.
- Aldo_MX 5y agoThis is like saying compare the lines using generators or proxies vs the lines using type annotations. Just because a feature is not widely adopted it doesn't mean that is not useful to the people using it, especially when the feature is used to mitigate the entire "cannot find property of undefined" type of errors.
- latortuga 5y agoIn the linked article, the author spends 1 sentence dealing with objections: > I can understand if JavaScript developers are afraid of TypeScript taking over their language. However, this proposal will be as far as things will go w.r.t. adding TypeScript features to JavaScript And in the next few sections it includes someone who wants to build on the proposal including using type hints to optimize code. I just think there's literally no way to guarantee that "this will be as far as things will go". Yes languages evolve and add new things all the time. But GP's point is that the language seems to be going toward what people want it to be coming from other languages. I agree, stop trying to make JS something it's not.
- neurotrace 5y ago> And in the next few sections it includes someone who wants to build on the proposal including using type hints to optimize code. This changes literally nothing about the JS language. JS engines already attempt to determine the types of things to optimize the code they generate. Type annotations would just allow them to make more aggressive optimizations.
- Turing_Machine 5y ago> This changes literally nothing about the JS language. Besides adding a bunch of new syntax, of which JS already has far too much.
- Turing_Machine 5y ago> Just because a feature is not widely adopted it doesn't mean that is not useful to the people using it But it does mean there likely isn't a "huge demand", which was the original claim. You're attempting to move the goalposts here.
- moron4hire 5y agoEvery TypeScript project is going to have at least an equivalent amount of JavaScript code sitting in the repo from the output of the TypeScript compiler.
- cphoover 5y agomost people don't version control the output of their compiled build though.
- cphoover 5y agoI don't know but I've been using JavaScript for a while now. It seems like a lot of the people that want JavaScript to look similar to other languages are coming from different programming fields, and want JavaScript to look more like their language of choice. Most of the changes to JS in the last 20 years, have been serious improvements, but they did not change the fundamental characteristics of the language. Believe it or not there are a lot of people that like JavaScript!
- Aldo_MX 5y ago> but I've been using JavaScript for close to 20 years now How dare you use JavaScript for anything else than validating forms!!! What is that jQuery thing??? Stop trying to make JavaScript into something it's not!!!
- halfmatthalfcat 5y agoAnd most of the developments in Java, since 1.8, have been taking ideas from other languages (primarily Scala) to make the language better. Why is it ok for other languages to evolve but not Javascript?
- 5y ago
- kyberias 5y agoBut didn't he merely express his opinion about this?
- halfmatthalfcat 5y agoI'm questioning their opinion, as we do on this site.
- kyberias 5y agoYou asked: "who are you to decide?". That's not questioning their opinion but rather their right to voice their opinion.
- riskable 5y agoThe only constant is change! The "don't make JavaScript into something it's not" ship sailed decades ago when AJAX was thrust upon the world. Besides, adding even more complexity to the JS ecosystem at this point is like pouring a cup of water into the sea.
- Salgat 5y agoThis argument could be used for literally any improvement to JavaScript.
- CraigJPerry 5y agoIt does feel like we have a problem saying no to language features, and it’s not just in the JS world.
- franciscop 5y agoDefinitely, ES6 was great and it seems we've ramped up to add as many features as possible, which has produced a lot of churn and unused/hated features. A committee was formed to add new features when needed, and now they... just keep adding and adding even when not needed.
- balefrost 5y agoOut of curiosity, where do you stand on ES6 classes?
- cphoover 5y agoCertainly cleaner than using the old prototypal inheritance syntax. // Dog Class function Dog(_name){ // call the parent constructor Animal.apply(this,arguments); } // extends the Animal prototype chain Dog.prototype = new Animal(); Although the new class syntax may obfuscate from what's actually happening in an effort to look more like traditional class-based languages like Java. However I'm the type of person that will only use React function components in my codebase. I don't think the object-oriented style has added much too my programming, except the temptation to reach for an unnecessary abstraction.
- kall 5y agoI think this proposal is trying to keep in that spirit while making everyone happy, by only adding what is effectively another comment syntax to JS, instead of defining a type system for it.
- nobleach 5y agoI get that this is a humble opinion. And I respect that. But for a language that draws so much ire from the programming community, and yet demonstrates such an ability to change and morph over the years. Are you saying you do NOT WANT it to get better? (and I realize "better" is subjective). The same is true of PHP. People hate it. People complain. PHP takes the criticism and makes updates. People complain more.
- cphoover 5y agoOf course I want it to get better. I just don't necessarily agree that a type-system = better, particularly in the way in which it's been suggested. Especially when you aren't talking about changing the internals regarding how JS is executed or how data is represented, you are only talking about adding "comments". JavaScript has evolved as an untyped language, it has type-coercion and a single way to represent (most) objects in memory. So regardless of what kind of syntax you add on top... it will still be a untyped dynamic language internally. Are we talking about changing this truth? Or just adding additional syntax for developers?
- nine_k 5y agoDo you remember Javascript from 1996? (I do.) Do yo think that all the improvements of ES5 (reflection, strict mode, JSON) changed it into what it was not? Did ES6 (classes, imports) change JS into something it was not, or should not be? Did ES2016 (async) do that?
- dangerbird2 5y agoDid you read the article? All the proposal does is allow the javascript engine to accept typescript-style syntax, while erasing all the annotations at runtime. From the browser's point of view, it would essentially treat the type annotations and type declarations as comments. This combined with native Ecmascript modules means you could theoretically develop a typescript application with no bundler or other build tools. You'd be able able to use typescript autocomplete and linting in your editor, and just serve the files to your browser with a static http server. Some newer bundlers like Vite and esbuild greatly reduce the amount of configuration required to set up a typescript project, but being about to develop a project with nothing but an editor and a browser would be a huge win for small projects. Since the proposal doesn't care about the semantics of the type annotations, it doesn't even necessitate typescript. It would work just as well with Flow typing or even a completely new type checker.
- jiyinyiyong 5y ago> From the browser's point of view, it would essentially treat the type annotations and type declarations as comments. V8 still has to updater its parser. Other tools that handle JavaScript parsing need to do that as well. > You'd be able able to use typescript autocomplete and linting in your editor, and just serve the files to your browser with a static http server. Nope, it's not using TypeScript directly, but just another language very similar to TypeScript.
- datavirtue 5y agoThat ship already sailed. If we were just twiddling the DOM I wouldn't even be reading this thread right now but people are writing production back-end code for financial services companies in JS. Bring on the type system.
- deleted 5y ago[deleted]
- monocularvision 5y agoI am mildly confused by your objection. It appears the proposal is to allow type annotations to appear as essentially no-op instructions. It isn’t adding a type system to JS.
- jiyinyiyong 5y agopartially agreed, I would love to see tools and supports of WASM being put on a higher priority and people improves dev experiences there. JavaScript syntax is already coupled with too many factors being a scripting platform or a compilation target.