Live data from Hacker News

Moving from TypeScript to Rust / WebAssembly

nicolodavis.com

251–260 of 428 posts

Re: Moving from TypeScript to Rust / WebAssembly

#251
post #185

Earlier quoted context omitted.

> Also, what stops something like [defining add as subtraction] cmon... "it doesn't guard you against every logic error under the sun" isn't a great argument

There's no strong evidence that static typing helps reduce application logic bugs https://danluu.com/empirical-pl/ Under the same pressures it's pretty likely that the same teams that deploy dynamic language code to production and get an unexpected nil deploy statically typed code to production which unwraps an unexpected None and throws exceptions or panics.

>There's no strong evidence that static typing helps reduce application logic bugs https://danluu.com/empirical-pl/

There's no evidence proving the opposite either. We can't say anything beyond that the existing studies don't really show anything. I think it's pretty obvious that the limit of static typing reduces logic bugs (since it can actually be used to prove statements about the logic), but beyond that everything is kind of up in the air.

>Under the same pressures it's pretty likely that the same teams that deploy dynamic language code to production and get an unexpected nil deploy statically typed code to production which unwraps an unexpected None and throws exceptions or panics.

There's nothing to support that that this is 'pretty likely'. As far as we know, it could very well be that statically typed languages push you in the direction of handling it the right way. Or hell, it could be that a team using a dynamic language is more cautious and conscious of edge cases.

Re: Moving from TypeScript to Rust / WebAssembly

#252

Earlier quoted context omitted.

For a lot of "usual" webdev, any reasonably modern language will do. Even modern JavaScript will be fine. Something like C# would have been way better, though, but we cannot change that now. However... software development has become a mess of slow technologies and abstractions one on top of the other. Some people are working routinely in a text editor that is behind three operating systems: the VM/hypervisor, the us…

Why can't you use C#? .Net Core (upcoming .Net 5) are pretty decent to work with. I'd still rather use node for the most part though. I have been playing with Rust, but not sure about how good an idea it is for the front end yet though.

Well, you can compile the .NET runtime into Wasm, send it to the client and run C# on top of it, but then you are adding yet another layer.

Re: Moving from TypeScript to Rust / WebAssembly

#253

Whenever I write Rust, I have a lot of fun, but I'm still not sold on it for most web dev. The analogy that comes to mind is that Rust is a really nice sports car with a great engine. It handles like a dream and you can feel the powerful engine humming while driving it. With the right open road, it's a great time. You can really optimize code, make great abstractions and work with data easily. Unfortunately, web dev…

Nice analogy. Here's somethine new. Rust is not just a sports car, but an eco-friendly electric one at that. One topic OP hasn't touched upon is the disadvantage of "pushing client side to the server" . JS is terrible at handling concurrent processes. The browsers have been able to make do because they typically care about just one user. In the server though, it's terribly important to handle thousands of users concu…

I wish speed mattered more, but JavaScript on Nodejs is performant enough for 95% of websites out there. Most websites are in the long tail, and never need to handle more than about 10 requests per second. For most websites, team velocity matters more than the AWS bill.

A clean static rendering system with caching, built on top of react / svelte / whatever performs well enough for almost everyone. And every year cpu costs drop, V8 gets faster and JS libraries get a little bit more mature.

I love rust, but I don’t see it displacing nodejs any time soon. Maybe when websites can be 100% wasm and the rust web framework ecosystem matures some more. Fingers crossed, but I’m not holding my breath.

Re: Moving from TypeScript to Rust / WebAssembly

#254

Earlier quoted context omitted.

Exactly. The frameworks aren't there yet but I think Typescript is pretty much ideal for web dev. We're still using dynamic languages for web dev for mostly legacy reasons now.

It's still a single threaded run time. There's one platform that's ideal for web, BEAM, but unfortunately it doesn't have a strongly typed language. Elixir and Erlang are both great languages though.

I can't speak to whether or not the BEAM is ideal for the web, but I will say I've been watching the Gleam project very closely because having static typing with the BEAM is a dream of mine.

Re: Moving from TypeScript to Rust / WebAssembly

#255
post #244

Earlier quoted context omitted.

Won ? Ruby fell off a cliff once it got to a point where people had to maintain that shit in production - I'm currently working on a large mature RoR codebase and I'm switching jobs ASAP because it's incredibly painful to work with and feels like a dead end career wise - and I like the gig otherwise - good product and a decent team - but the technology is draining so much of my life energy on nonsense it's ridiculous…

Which standard function in Ruby is a single letter?

p

Re: Moving from TypeScript to Rust / WebAssembly

#256

Earlier quoted context omitted.

For a lot of "usual" webdev, any reasonably modern language will do. Even modern JavaScript will be fine. Something like C# would have been way better, though, but we cannot change that now. However... software development has become a mess of slow technologies and abstractions one on top of the other. Some people are working routinely in a text editor that is behind three operating systems: the VM/hypervisor, the us…

Why can't you use C#? .Net Core (upcoming .Net 5) are pretty decent to work with. I'd still rather use node for the most part though. I have been playing with Rust, but not sure about how good an idea it is for the front end yet though.

Pretty sure the parent comment was talking about client side.

Re: Moving from TypeScript to Rust / WebAssembly

#257
post #161

Earlier quoted context omitted.

I think you get it backwards. Things are disjointed, loosely coupled because highly dynamic languages have won. The flexibility of dynamic languages, which can be great when working around dynamic corner cases, does not force developers into fixed, well-defined contracts keeping everything loose and disjoint. PHP is highly to blame. PHP, being a scripting language, is easy to deploy and keeps chugging along at all co…

I completely disagree with this. I work on a large C# platform that interops with a ton of vendor API's, the majority of which are also written in typed languages. The disjointed, loosely coupled nature of web systems is what causes problems. In particular, knowing what a "correct input" is to web systems is very difficult, where correct means: 1) Passes the API's immediate validation 2) Passes validation inside API'…

> knowing what a "correct input" is to web systems is very difficult

I cut my teeth programming an XML web service using soap and while I can't say that it was as drop-dead simple as a restful HTTP web api these days, between the wsdl and the uddi, it sure was convenient to be able to know as a client what methods were being exposed and what inputs they expected.

Sometimes I wish the w3c had not required XML for those web services ,so that we could do that with json plus whatever add-ons can make it have an enforceable schema like XML. WSDLs were underrated.

Re: Moving from TypeScript to Rust / WebAssembly

#258
post #220

Earlier quoted context omitted.

Have you used sorbet on these codebases? I'd be curious if there'd be a benefit here in terms of maintainability.

Sorbet is the only way I can function in anything larger than a 10 line script these days. I’ve started adding it to personal projects because it makes revisiting them later so much easier.

Without the LSP implementation out in the open, though, sorbet is just a type checker. It's not made much for sense for me to start integrating it into my personal projects just yet, since I only get the benefits when I run tc manually. Once Stripe opens up the LSP, however, I can see it gaining widespread adoption.

Re: Moving from TypeScript to Rust / WebAssembly

#259
post #244

Earlier quoted context omitted.

Which standard function in Ruby is a single letter?

b, to_s, to_i, to_a, to_c, to_h, to_r, etc. Should have said methods but you get what I mean. And I've encountered ambiguous and pointless abbreviations all over the place.

It's weird, when I was I younger I used to love shortform syntax like that as well as removing unnecessary punctuation

But now that I'm older, I appreciate things being more descriptive and orderly, including strict use of semicolons, functions that say what they are doing (e.g. to_string), or being explicit about converting (e.g. static_cast)

I think it's because I find trying to make everything as succinct as possible ends up trying to be too clever.

Re: Moving from TypeScript to Rust / WebAssembly

#260

Earlier quoted context omitted.

When you're writing synchronous, single-threaded code like, say, a binary file parser or even an HTML scraper with blocking APIs, Rust is 1:1 with high level languages, and usually better. Where Rust diverges is when you're doing async or multithreaded things with complicate lifetimes. Getting things right from the start instead of solving them JIT as runtime issues pop up in production over the course of the year is…

> But even after using Rust for three years, I sometimes feel like I'm one requirement-change away from a problem I can't solve myself in Rust where I could solve it in a couple hours in another language. Rust does have these sorts of issues wrt. managing highly generic graph-like data, possibly with cycles. That's where tracing GC actually shines, and where writing that whole portion separately in something like Go…

Reference-counted graphs are usually quite fine.
Post reply on HN