Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Have you tried F#?


Nope, I must say I have only used a small subset of languages from the FP-language-zoo, so my opinion on OCaml might be biased

But as an example when writing Typescript, I feel so frustrated of not having a clean way of doing pattern-matching


You will have to wait for JavaScript to add it first.

The whole point of Typescript and why it is so successful, is because they only add type system on top of JavaScript.

Pattern matching would introduce new language constructs beyond what is required for defining types.


I think as long as they maintained it as a proper superset of javascript (i.e. all js code was valid ts code), adding a new language construct wouldn't hurt them much. see kotlin vs Java for a similar case


Except that isn't the design approach from TypeScript, all TS code without type annotations should be valid JS code.

As for your Kotlin example, Dart's failure shown why it isn't a good approach.

Kotlin also shows what happens when the underlying platform decides to go in another direction (value types, loom, default methods on interfaces), and the amount of boilerplate that needs to be generated to pretend to be like the host language.

A language that only matters, thanks to the way Google is pushing it on Android to replace Java for anything besides system libraries.


Typescript gets compiled to Javascript anyway. What's stopping any pattern matching construct from being compiled to vanilla JS?

We already get stuff like type narrowing and generics.


The philosophy of not adding language constructs beyond what is required for the type system.

Typescript code without type annotations should be JavaScript compatible, minus features still in flight for standardisation.

There are other languages for that like ReasonML.


Why wait? Just use ReScript. It's OCaml but adapted to fit natively in the JavaScript world.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: