Hacker News new | ask | show | jobs
by pjc50 782 days ago
I feel like in the longer term we'll eventually get, via WASM or otherwise, another language that we're allowed to use in the browser, which can be properly type-safe from the beginning.
3 comments

That time is now. I've been shipping Rust code to browsers for years...
Rust is still the only language with decent tooling and an ecosystem to compile to WASM.

Many other languages haven't passed the PoC stage. Several are ready, and doable (C#, Go?) but hardly as easy and common as with rust.

At least that was the state when I looked six months ago. It's a fast moving area.

So, yes, that time is now. But the only practical option is rust. Which may be enough, idk.

> Many other languages haven't passed the PoC stage.

Wouldn't it be more accurate to say that WASM hasn't passed the PoC stage? There are quite a few languages that have great WASM support, to the extent WASM allows, but have to bring all kids of workarounds to deal with the shortcomings of WASM as it sits. An especially challenging problem as it relates to browser use with those workarounds is that they bloat the artifact size. Few are willing to subject users to multi-megabyte downloads.

Work is being done on WASM to address those shortcomings, but hands are pretty much tied until that arrives. Until then, the "lower level" and heavily constrained languages will be left to stand alone.

C# Blazor certainly exists and works, although it feels really clunky. Only suitable for a true application, not for integrating with web pages. It's almost the inheritor of the Java "applet" and the HotJava browser.
Yeah, but Rust is not great for UI code full of global values.
That was google's original plan with Dart.
I believe Dart was originally gradually typed, and then abandoned the gradual typing for strict-typing-by-default? That doesn't quite sound properly type-safe to me although still safer than how Javascript is by default.

My only reference is a memory of this talk by Richard Feldman but I might be wrong or misremembering. https://www.youtube.com/watch?v=Tml94je2edk

Released 22 February 2018

Dart 2.0 implemented a new sound type system

Dart's type system, like the type systems in Java and C#, is sound.

https://dart.dev/language/type-system

Thanks for the link. I'm aware Dart currently has static typing similar to Java and C#, and has had it for some time,

My question was different though and I was asking (quoting comments further up the chain) whether "google's original plan with Dart" really was to allow for a programming language "which can be properly type-safe from the beginning".

It seems that claim about the original intent is false. I checked Wikipedia [0] which states "Dart 2.0 was released in August 2018 with language changes including a type system" and the reference they link seems to corroborate that, before 2.0, Dart didn't have a sound type system.

Thanks for prompting me to dig deeper (I probably wouldn't have done it without seeing your comment).

[0] Quote found under the history section. https://en.m.wikipedia.org/wiki/Dart_(programming_language)

Thanks, I was probably responding to “That doesn't quite sound properly type-safe to me” in isolation.
Is Dart sound these days? When I tried it, it was pretty easy to trigger type errors at runtime.
These days Dart — considers all variables non-nullable — enforces sound null safety."

https://dart.dev/null-safety

Well, null safety is a good start.

But I seem to remember that the type-checker got confused rather easily with nested closures, for instance, or co/contra-variance.

Consider using Reason and/or Rescript. Ocaml with a nice syntax and clean JS interop.