3 ms·
Apparently derw is going to be a new ML based programming language compiling to TypeScript. That is an awesome goal. I could use it right now! It would be grea
by auggierose 4y ago
Apparently derw is going to be a new ML based programming language compiling to TypeScript.
That is an awesome goal. I could use it right now! It would be great if features like the Or type A | B from TypeScript and value types could be preserved though. But that will be difficult to do.
There are projects like Reason and ReScript that do something similar with JavaScript as a target, but these projects don't seem to be mature / reliable enough to base a large project on.
- eeue56 4y agoString untagged unions (value types) are currently supported by Derw, e.g type Fish = "Salmon" | "Trout". I will most likely add some way of handling types composed of other types, too.
- auggierose 4y agoThat's cool. I am continuously tempted to do something similar like derw, but it would just be a distraction from my goal. On top of my daily todo list is the following sentence: FUCKING STAY WITH TYPESCRIPT, as a reminder to myself not to look for better solutions, or even create a better solution myself, because I just don't have the bandwidth. But if you are going for it, that is great. Here are some features I would love for a language like derw. This is just meant to be a source of ideas you may or may not have thought of already, and obviously, your goals probably differ from mine: 1. Optimised arithmetic for 32-bit integer types int and uint. 2. Tagged unions based on uint, compiling to "const enum". 3. Provide an out-of-the box ! operator that actually throws an exception if the value is null or undefined. 4. Support for both mutable and immutable data structures out of the box. 5. Support for building reliable APIs, that cannot be breached even at runtime through some meddling JavaScript code. Currently I use Object.freeze all over the place, just to make sure that people cannot change randomly a class definition from right under me, etc. For example I have a decorator @fixed that is defined as export function freeze<V>(x : V) : V { if (typeof x === "function") { Object.freeze(x.prototype); Object.freeze(x); } else { Object.freeze(x); } return x; } freeze(freeze); export function fixed<T extends { new (...args: any[]): object }>(target: T): T { return freeze(class Final extends target { constructor(...args: any[]) { if (new.target !== Final) { throw new Error('Cannot inherit from immutable class'); } super(...args); freeze(this); } }); } freeze(fixed);
- cercatrova 4y agoReScript is used by Bloomberg (the creator was hired there) so it's pretty stable, although for library support I'd still use TypeScript.
- auggierose 4y agoI think the original creator of Reason is not with the ReScript project, and I am just not sure what the technical chops of the maintainers are with respect to implementing functional programming languages. That's not saying that they are not stellar, it's just that I have no clue. Some choices with regard to ReScript syntax seem pretty superficial to me, though. But without a doubt, if you want ML for the web, ReScript is currently the best option.
- cercatrova 4y agoThe original Reason creator was also the original React creator. He left Facebook and is now doing something else, it's unknown what though. The ReScript creators have pretty good experience I believe, building their own compiler based on Reason and OCaml.
- tobinfekkes 4y agoHe left Facebook indeed, moved his family to Hawaii to take a break, and haven't heard what's next on his plate yet. I'm good friends with his sister :)