ReScript 10.0
rescript-lang.org
rescript-lang.org
I think this would have huge potential in the backend space if it had good interop with Node.js and TS, with perhaps a functional framework similar to Elixir's Phoenix. Elixir proved it can have fantastic integration with Erlang.
* More robust applications with the Result type
* An actual integer type (for 64-bit database keys, Prisma uses BigInt)
* Finite state machines for stateful logic, games, websockets (enums and a sound type system)
* Benefit from the JS-centric serverless ecosystem
We've already been "compiling" or "transpiling" JS for years, most of written JS code has little in common with what is actually run.
In its current state, I don't even want to imagine what it would be like to set this up alongside ESM, TS, Prettier, ESLint, Jest, Storybook, ESBuild, Vite, (insert cool tool here). I've already spent literal days trying to setup a "modern" Node.js project, only to give up and go back to CJS for simplicity and import older non-ESM versions of packages[1], wish I wasn't using Node.js, then remember how many things I miss from JS when trialing another language.
Deno also has an interesting approach (you have all the tooling officially shipped like Rust does), but sadly most of the official libraries will not work or does not work with it (maybe I'm wrong and there's a work about), but also I think that not having a manifest with your dependencies makes all harder (will import maps be a thing soon enough? is up to the task?).
Also there is rome.tools, but seems far from being usable yet, besides the formatter.
Am I missing something?
In other news: now, there's scala-cli for smaller projects — https://scala-cli.virtuslab.org/docs/guides/scala-js
age?: int
Why does it (and ts) put “?” only at a name? I’d expect the above to define an optional key, and (type|undefined) but always existing key, as well as an optional argument, to have a type of age: int?
As a result, an optional key with an optional value would be age?: int?
Am I missing something?Maybe the reason is that this distinction creates an unnecessary complexity at matching semi-optional types together, because programs do not usually care about exists/defined distinction.
Without exact optional properties enabled, the type `{ age?: number }` will accept both `{}` and `{ age: undefined }`. With `exactOptionalPropertyTypes` enabled `{ age: undefined }` is illegal.
So `{ age?: number }` does mean the key is optional. If you want optional and supporting undefined then type you're after is `{ age?: undefined | number }`.
ReScript aims to be a strictly typed JS, simpler and faster than TS - https://news.ycombinator.com/item?id=30181349 - Feb 2022 (23 comments)
From TypeScript to ReScript - https://news.ycombinator.com/item?id=29903631 - Jan 2022 (175 comments)
I Switched from TypeScript to ReScript - https://news.ycombinator.com/item?id=25845147 - Jan 2021 (45 comments)
Confused about ReScript? ReScript, Reason, ReasonML, and BuckleScript explained - https://news.ycombinator.com/item?id=25842141 - Jan 2021 (1 comment)
ReScript 8.4 - https://news.ycombinator.com/item?id=25424034 - Dec 2020 (63 comments)
ReScript (previously BuckleScript and Reason) - https://news.ycombinator.com/item?id=24160424 - Aug 2020 (13 comments)
BuckleScript Is Rebranding - https://news.ycombinator.com/item?id=24119838 - Aug 2020 (71 comments)
BuckleScript: An OCaml to JavaScript compiler - https://news.ycombinator.com/item?id=15111265 - Aug 2017 (84 comments)
BuckleScript: write JavaScript faster, safer and smaller - https://news.ycombinator.com/item?id=13448769 - Jan 2017 (90 comments)
Announcing BuckleScript 1.0 - https://news.ycombinator.com/item?id=12400397 - Aug 2016 (75 comments)
Bloomberg/bucklescript: A back end for the OCaml compiler which emits JavaScript - https://news.ycombinator.com/item?id=11477238 - April 2016 (12 comments)
BuckleScript – A JavaScript Back End for the OCaml Compiler - https://news.ycombinator.com/item?id=11370968 - March 2016 (1 comment)
Doesn't need type annotations. Annotate as much or as little as you'd like. The types are inferred by the language (and, again, are guaranteed correct)
How is this achieved? E.g. you npm install module ‘foo’ which has no types and takes no part in a rescript compilation process. Does it force you to type-narrow all the values returned from foo.funcname()?
E.g., if a type returned from a function is nullable then you will be forced to handle that explicitly via pattern matching I imagine, rather than being able to dereference it without checking.
Take Rust, calls to C code are inherently unsafe, and must be marked as so. You're leaving Rust's source code and type system and calling into external functions that you may not even have access to source code for and that the compiler just can't feasibly vouch for.
https://rescript-lang.org/docs/manual/latest/introduction#di...
Seems like a type system for Javascript, built with a differing set of opinions than Typescript.
Looks like they also offer some form of TS interop:
> TypeScript's (admittedly noble) goal is to cover the entire JavaScript feature set and more. ReScript covers only a curated subset of JavaScript.
Rescript has a different approach which has lots of benefits, it is much better in terms of type inference, it's much faster, and I think it's fair to say safer. The tradeoff is that it's not JS, making it harder to adopt.
I do think they are doing a great job in taking steps to present the ocaml origins in more JS friendly patterns and syntax, but it still requires learning some new concepts.
I think a somewhat good comparison is; If Typescript is like C# for JS, Rescript is like F#/ocaml for JS. Different technologies have different tradeoffs.
So very different semantics to JS/TS but you gain a sound type system and great compile speed.
I even don't understand why browser don't start to work on supporting it directly, maybe google/chrome have something in mind and slowing down its integration, or it's because of performance issues.