I’ve thought about this a lot, and writing a compiler is actually one of the projects on my GitHub but I’ve realized recently that my dream language is actually just JavaScript with 2 changes.
1) Module only operation, nothing in global scope except primitives (String, Number, Array, Symbol, Object), every other API must me called via import
2) and the addition of a ‘use native’; directive that could be used to make JS fully compliable within certain rules. Ie: forced jshint comments on all functions to define parameter types, no setting a variable to a type other than its initial, and no dynamic property setting unless in constructor
Scoping and Hoisting are two very different things. No I don't particularly hoisting but the way module mode keeps the global scope almost entirely empty as well as the import/export system is wonderful for both library developers and site developers alike.
... no setting a variable to a type other than its initial ...
At a previous company, they developed a language called TypeScript that transpiles into JavaScript (ES3 or ES5). (Sorry Bob van Hoove... yep, transpiles.)
One of its features was static type checking, which went a long way to eliminate a large category of bugs. The folks at Google liked it so much, that they used it for Angular 2.
I worked on a very large project that used TypeScript throughout, and it was pretty nice. (TypeScript also made available a lot of ES6 features, way before ES6 was ready for primetime. So that was very cool too, at that time.)
Now we have ES6 at our disposal, so at least one big feature that TypeScript still provides is the static type checking.
Maybe some future version of JavaScript (ECMA-262 and ISO/IEC 16262) will add that into the core language.
TypeScript is very cool and I especially like their idea of automatic constructor property assignment but unfortunately, TS isn't supported natively and must be transpiled :(
About me: software developer who is into JavaScript and NodeJS and constantly working on one or another side project and/or open source. I have a blog at https://alex-rudenko.com
About me: software developer who is into JavaScript and NodeJS and constantly working on one or another side project and/or open source. I have a blog at https://alex-rudenko.com
No, in a perfect world, as a part of the 'use native' directive I mentioned in my OP comment, you would be able to comment on variables to specify the number type
something along the lines of
/** @type i64 */// i64 could be replaced with any of i8,i16,i32,i64,f8,f16,f32,f64constnum=12;
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I’ve thought about this a lot, and writing a compiler is actually one of the projects on my GitHub but I’ve realized recently that my dream language is actually just JavaScript with 2 changes.
1) Module only operation, nothing in global scope except primitives (String, Number, Array, Symbol, Object), every other API must me called via import
2) and the addition of a ‘use native’; directive that could be used to make JS fully compliable within certain rules. Ie: forced jshint comments on all functions to define parameter types, no setting a variable to a type other than its initial, and no dynamic property setting unless in constructor
You like those scoping rules? You think hoisting is in any way sane?
Scoping and Hoisting are two very different things. No I don't particularly hoisting but the way module mode keeps the global scope almost entirely empty as well as the import/export system is wonderful for both library developers and site developers alike.
+1 for type safe javascript w/o transpiling, I'd like that a lot
At a previous company, they developed a language called TypeScript that transpiles into JavaScript (ES3 or ES5). (Sorry Bob van Hoove... yep, transpiles.)
One of its features was static type checking, which went a long way to eliminate a large category of bugs. The folks at Google liked it so much, that they used it for Angular 2.
I worked on a very large project that used TypeScript throughout, and it was pretty nice. (TypeScript also made available a lot of ES6 features, way before ES6 was ready for primetime. So that was very cool too, at that time.)
Now we have ES6 at our disposal, so at least one big feature that TypeScript still provides is the static type checking.
Maybe some future version of JavaScript (ECMA-262 and ISO/IEC 16262) will add that into the core language.
TypeScript is very cool and I especially like their idea of automatic constructor property assignment but unfortunately, TS isn't supported natively and must be transpiled :(
You forgot 64bit integers and, perhaps, proper integers in general :-D
All numbers in JavaScript are automatically 64 bit floating-point numbers.
Source: ECMAScript 262 § The Number Type
Do you say that a 64-bit float-point number is as good as a 64-bit integer? stackoverflow.com/questions/964362...
No, in a perfect world, as a part of the
'use native'
directive I mentioned in my OP comment, you would be able to comment on variables to specify the number typesomething along the lines of