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

Why not write your code in F# and compile it to TypeScript using Fable [1]?

This way you can use native language features for discriminated unions, functional pipelines, and exhaustive pattern matching to model your domain instead of shoe-horning such functionality into a non-ML language!

Model your domain in F#, consume it in Python or C# backends and TypeScript frontends. The downside is needing to know all of these languages and run times but I think I'd rather know F# and the quirks with interacting with TypeScript than a library like Effect!

[1] https://fable.io




I've tried compile-to-JS languages before but their big weaknesses are:

1. Debugging can become quite a pain. Nobody likes debugging generated code.

2. You don't get to use libraries and tools from the enormous JavaScript ecosystem.

3. Eventually you'll find some web feature that they haven't wrapped in your language and then you're in for FFI pain.

In the end I found Typescript was good enough that it wasn't worth dealing with those issues.


Fable is still very much integrated with the runtime so there’s an expectation to handle those bullet points with inline annotations.

You can build an entire application in F# and compile to JS but another option is compiling to TS and calling that F# code from your TS app. I/O and views and whatnot are written in TS and the domain model is in F#. The entire model could be nothing but pure functions and resolve to a single expression!


This is so cool! I’ll have to try it out soon. Thanks!




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: