News for hackers. Stuff that matters.
Re:TypeScript Is Surprisingly OK for Compilers by moonchrome on Friday August 18, 2023 @03:28AM (#37172349)
That's some very high level view - in reality even tough those languages are in similar categories the experience would be vastly different :

TypeScript - powerful type system but shit underlying stdlib and language (no pattern matching/switch expressions)

Dart - worse than TS because the object model is closed - so no dynamic freedom, but the type system and expressions are weaker then the rest. Also 0 meta programming facilities - Java level of boilerplate and code generators

C# - closest to ML featureset out of the mentioned, but unlike TS doesn't have sum types which will make a lot of things more tedious.

Re:TypeScript Is Surprisingly OK for Compilers by pja on Friday August 18, 2023 @04:07AM (#37172631)
If you’re going to use C# for a compiler, why not go the whole hog & use F#?
Re:TypeScript Is Surprisingly OK for Compilers by moonchrome on Friday August 18, 2023 @07:43AM (#37174347)
No argument from me, just saying lumping in all those languages together sounds reasonable in theory, in practice they are very far apart.

You'll probably have similar overlap between C# and F# implementations as you would with say TypeScript - they are just that different in practice IMO.

Re:TypeScript Is Surprisingly OK for Compilers by delta_p_delta_x on Friday August 18, 2023 @11:24AM (#37176899)
I was going to mention F#. The parent and grandparent comments mention C# and ML, and the intersection of the two is... F#.
Re:TypeScript Is Surprisingly OK for Compilers by crooked-v on Friday August 18, 2023 @04:35AM (#37172826)
> no pattern matching/switch expressions

They're still waiting on the do expression proposal for that (https://github.com/tc39/proposal-do-expressions), which has been in the bikeshedding stage for the past five years.

Re:TypeScript Is Surprisingly OK for Compilers by yunohn on Friday August 18, 2023 @05:47AM (#37173354)
I’m not clear on the benefits of this proposal over just using anonymous functions. Some of the examples just seem contrived.

And the React example makes no sense, you can use a ternary and it is even shorter.

``` return ( <nav> <Home /> {loggedIn ? <LogoutButton /> : <LoginButton /> } </nav> ) ```

Re:TypeScript Is Surprisingly OK for Compilers by doctormanhatten on Friday August 18, 2023 @06:13AM (#37173595)
Having written quite a lot of Reason react (similar in syntax to the proposed React example) - while in this particular case because the example is so simple the ternary looks nicer, its also nice to just have a longer expression block in the middle of your JSX when you're doing more complex things.
Re:TypeScript Is Surprisingly OK for Compilers by baq on Friday August 18, 2023 @06:09AM (#37173566)
for me the point is to be able to return from inside multiple expressions from the correct scope i.e. the root function without throwing.
Re:TypeScript Is Surprisingly OK for Compilers by graftak on Friday August 18, 2023 @07:03AM (#37173992)
What if you want a `switch` instead?
Re:TypeScript Is Surprisingly OK for Compilers by graftak on Friday August 18, 2023 @07:02AM (#37173977)
The proposal for pattern matching syntax seems more akin to what they're looking for.

https://github.com/tc39/proposal-pattern-matching

Re:TypeScript Is Surprisingly OK for Compilers by jezzamon on Friday August 18, 2023 @09:59AM (#37175705)
Could you speak more to the dart, and specifically the "Java level of boilerplate and code generators"?

I've used it a bit but I haven't found it very boilerplatey in general, so I'm interested in learning what contexts you run into that.

I'm assuming you're using it with flutter?

Re:TypeScript Is Surprisingly OK for Compilers by munificent on Friday August 18, 2023 @01:08PM (#37178717)
Your understanding of Dart sounds a little outdated. We have a fully sound static type system and the language is pretty expressive, especially with the new pattern matching stuff in 3.0:

https://medium.com/dartlang/dart-3-1-a-retrospective-on-func...