News for hackers. Stuff that matters.
Re:The Rust I wanted had no future by rob74 on Monday June 05, 2023 @04:27AM (#36193832)
I think this quote also applies more generally:

> It's easier to work with than C++, but that's fairly faint praise.

So, while Rust positions itself as a C++ alternative with all the complexities that C++ developers love, it may become less attractive for other use cases. For instance, I find it highly questionable to develop a web app in Rust...

Re:The Rust I wanted had no future by smabie on Monday June 05, 2023 @04:43AM (#36193909)
There's tons of existing languages that are mostly okay that you can develop a webapp in.

Rust as a C++ replacement serves a real unmet need in the marketplace.

Re:The Rust I wanted had no future by devjab on Monday June 05, 2023 @04:46AM (#36193926)
We build a proof-of-concept backend replacement for what is essentially “SharePoint being used as a DB with a frontend by people who don’t know how to use SharePoint” and was a nice experience. We also build it in a few other languages, C#, Go, Python and TypeScript and Rust was probably the best experience of them all. We ended up going with C# because we needed Odata, and at the time we hadn’t yet run into the many “joys” of working with Odata, ASP and Entity Framework and how their model builders, really, really, really, won’t play together nicely.

Knowing what we know now, we should’ve gone with TypeScript and just written our own Odata filter on top of it, but live and learn.

If I was in a position where I could pick and chose languages, and not worry about how not having TypeScript in most things will mean our best front-end developer can never go on vacation because he’s sort of our only front-end developer, I wouldn’t mind using Rust for web-backends.

Rust GUI is obviously not a great experience. At least not yet. But it’s not that bad either. I think it’s mostly the case of how JavaScript is just so good at it and seeing such a fast pace of improvements because the entire world uses it for most GUIs these days, that it’s just hard for anything else to compete. I mean, look at stuff like Flutter or Blazor, they are backed by Microsoft and Google and they’re vastly inferior choices for most use cases compared to simply building things in React, ReactNative or even electron, and that’s not because I have some wild love for JavaScript, it’s because it’s seeing rapid improvements they dwarf it’s competition simply by being used by a lot of people.

I wish Rust would have someone like Facebook pick it up and build a frontend framework for it, but I think that is just too unlikely for you to bet on, and you certainly wouldn’t want to do it yourself, even as open source because then that would probably be your entire job.

On the flip-side, the packages that handle basic back-end web stuff for Enterprise use are rock solid in Rust. Which is impressive, at least to me, considering it’s young age. I have no idea why, but maybe some serious players are contributing to it because they use it themselves. There isn’t a “Django” or Ruby+Rails for Rust, but if what you’re building is a lot of smaller APIs with various transport methods and data access in an federated authentication scenario then Rust is surprisingly mature for the web. It’s primary disadvantage being that your TypeScript and Rust developers won’t be able to cover for each other (which is why we didn’t poc with Java).

Re:The Rust I wanted had no future by internetter on Monday June 05, 2023 @07:42AM (#36194967)
> I wish Rust would have someone like Facebook pick it up and build a frontend framework for it

We have yew, and my personal favourite: leptos (https://leptos.dev/)

Re:The Rust I wanted had no future by lumb63 on Monday June 05, 2023 @08:44AM (#36195424)
As someone who recently started their first web app in Rust and is using Yew for the front-end, I wish they included benchmarks against other Rust frameworks. I also wish I had more experience and had looked harder; Yew is very verbose in my experience and Leptos looks a little more sane.
Re:The Rust I wanted had no future by tick_tock_tick on Monday June 05, 2023 @04:49AM (#36193952)
> it may become less attractive for other use cases. For instance, I find it highly questionable to develop a web app in Rust...

I mean who'd want to and why bother trying to support that use case? Basically none of Rust's value proposition exists for a web app while nearly every single one of the downsides do.

Re:The Rust I wanted had no future by inferiorhuman on Monday June 05, 2023 @05:57AM (#36194314)
Hard disagree. Rust brings a lot to the table for a web app. Compiled vs interpreted makes it easier to catch (syntax) errors beforehand. You can even go as far as compiled templates. Mapping JSON (or whatever) to strongly typed objects is great. Dependency management is best in class. I rather like diesel.rs (although it is very much an acquired taste) especially if you treat it like a safe query builder rather than an ORM.

The single biggest problem I've run into is that there's no real good story for a web app framework (especially since everyone's gone crazy over async). Rocket is perhaps a bit too magical for rust folks and it's been abandoned, but I rather liked it. I've warmed up to axum, but all this async stuff still rubs me the wrong way.

And, yes, compile times still suck.

Re:The Rust I wanted had no future by vsnf on Monday June 05, 2023 @06:20AM (#36194476)
Although all of those things are true, I think the main point being made is why choose Rust for that, instead of Go, .NET, etc, any of which offer everything you've outlined as being worth having, while having fewer of the downsides of Rust.
Re:The Rust I wanted had no future by inferiorhuman on Monday June 05, 2023 @06:39AM (#36194583)

  any of which offer everything you've outlined 
They don't, that's the "problem". Off the top of my head dependency management in Go is not best in class to put it charitably. .NET will tie you more closely to Windows. Sure, mono is a thing but you'll have more packages to choose from and fewer compatibility issues running .NET on Windows.
Re:The Rust I wanted had no future by foobarbaz33 on Monday June 05, 2023 @08:34AM (#36195341)
Mono? 2000 and late called and want their .NET implementation back. Now it's all about the .NET formerly known as "Core".
Re:The Rust I wanted had no future by Merad on Monday June 05, 2023 @10:17AM (#36196496)
Your knowledge of the .Net ecosystem is a bit out of date. It's had first class support for mac and linux for 7-8 years now.
Re:The Rust I wanted had no future by scns on Monday June 05, 2023 @10:52AM (#36196998)
First class support on Linux and Mac with caveats. Zero snark intended.
Re:The Rust I wanted had no future by Paradigma11 on Monday June 05, 2023 @01:41PM (#36199986)
Web development for .NET is multiplatform for quite some years now. https://en.wikipedia.org/wiki/.NET

Mono is mostly only relevant if you need platform specific capabilities that wont be covered in .NET.

Re:The Rust I wanted had no future by LinXitoW on Monday June 05, 2023 @07:51AM (#36195024)
To me, one thing missing from most popular web languages is the single best part of Rust: A well-defined handling of the non-happy path.

I'm talking about things like exhaustive "switches", built-in, ENFORCED handling of "missing" values (null, undefined), and finally useful error handling.

I actually don't need any of the baremetal features of Rust. It's just that most of it's "zero-cost" abstractions are still far superior to those of other languages.

Re:The Rust I wanted had no future by kaba0 on Monday June 05, 2023 @10:10AM (#36196396)
Haskell, Scala, F#, OCaml.

(Some dislike it, but Java’s checked exceptions are exact homologous of result types)

Re:The Rust I wanted had no future by marcosdumay on Monday June 05, 2023 @12:25PM (#36198680)
The problem with Java exceptions is that they have very poor generic support.

Outside of that, yeah they just differ in very low-level aspects that most developers don't even know about.

Re:The Rust I wanted had no future by Gigachad on Monday June 05, 2023 @06:01AM (#36194339)
Arguably TypeScript is pretty close to as safe while being less work.
Re:The Rust I wanted had no future by inferiorhuman on Monday June 05, 2023 @06:12AM (#36194410)
Perhaps. But TS is still Javascript under the hood which means implementation details leak and they smell awful. If they didn't it'd come down to a preference for compiled vs interpreted.

The number one syntactical beef I've is operators. e.g. == vs ===, ""+number.

Re:The Rust I wanted had no future by EdwardDiego on Monday June 05, 2023 @07:20AM (#36194843)
> Dependency management is best in class

Do crates have namespaces that ownership is verified for?

Re:The Rust I wanted had no future by geodel on Monday June 05, 2023 @12:43PM (#36199027)
Crate namespaces is best-in-class++ feature and currently not available.
Re:The Rust I wanted had no future by EdwardDiego on Monday June 05, 2023 @06:27PM (#36204969)
Yeah, I ask because the JVM world has had that since... whenever Maven's central repository came about [0][1][2], I guess, and it ensures that there's no debate about namesquatting [3], nor typosquatting attack vectors [4].

I am constantly baffled that NPM, PyPi, crates.io etc. didn't copy this idea for those last two reasons. In my mind, it's not quite best in class without it.

[0]: https://central.sonatype.org/publish/requirements/coordinate...

[1]: https://central.sonatype.org/faq/how-to-set-txt-record/

[2]: https://central.sonatype.org/publish/requirements/coordinate...

[3]: https://internals.rust-lang.org/t/pre-rfc-formal-squatting-p...

[4]: https://blog.sonatype.com/this-week-in-malware-may-13th-edit...

Re:The Rust I wanted had no future by pjc50 on Monday June 05, 2023 @08:25AM (#36195264)
> Compiled vs interpreted makes it easier to catch (syntax) errors beforehand. ... Mapping JSON (or whatever) to strongly typed objects is great

cough C#. You also get LINQ. And a fairly heavy amount of web frameworks in ASP.NET / Razor.

Re:The Rust I wanted had no future by kaba0 on Monday June 05, 2023 @10:08AM (#36196381)
Or Java, F#, Scala, Kotlin, Haskell. If we were to randomly pick a language, chances are it could be a good fit for these — Rust became as well-known as is because it was made for a different niche, where there were no competition.
Re:The Rust I wanted had no future by moi2388 on Monday June 05, 2023 @11:19AM (#36197464)
Haskell is a beautiful language, but I find their web frameworks rather cumbersome to work with personally.
Re:The Rust I wanted had no future by EdwardDiego on Monday June 05, 2023 @06:30PM (#36205013)
Hell, even Python can map JSON to a strongly typed object. I am a firm fan of Pydantic and its competitors when dealing with JSON blobs. No-one deserves a KeyError in prod code.
Re:The Rust I wanted had no future by Vespasian on Monday June 05, 2023 @06:06AM (#36194364)
I am doing that for a just for fun side project and it was an interesting experience.

The pieces and features i wanted exist but tying them together was not always straight forward.

From the top of my head I used:

- actix-web

- tracing (logging)

- sea-orm

- config from yaml files and a custom implementation to allow profiles.

- utoipa (for openapi and swagger ui)

- thiserror

In a professional context I would not have used Rust for this project, but it was quite fun to explore it's possibilities and rich crate ecosystem.

Re:The Rust I wanted had no future by FpUser on Monday June 05, 2023 @10:24AM (#36196574)
>"I mean who'd want to and why bother trying to support that use case"

I write my web apps in C++. They tend to be little bit more than just query database / update database. They're exposed as JSON based RPC and can be accessed by JS front end from browser or third party systems we interact with. The performance is stellar and the code size is not much different comparatively to using PHP / Ruby / Python / your_pet_goes_here.

Re:The Rust I wanted had no future by throwaway2037 on Monday June 05, 2023 @11:16AM (#36197428)
Nice. Do you have some open source samples? I would like to see your style!
Re:The Rust I wanted had no future by FpUser on Monday June 05, 2023 @01:28PM (#36199748)
No. I do not work on opensource projects unfortunately.
Re:The Rust I wanted had no future by moonchrome on Monday June 05, 2023 @04:58AM (#36194006)
>So, while Rust positions itself as a C++ alternative with all the complexities that C++ developers love, it may become less attractive for other use cases. For instance, I find it highly questionable to develop a web app in Rust...

But we already have plenty of options for this use case (.NET, JVM, Go, Python, Ruby, node.js, PHP, Erlang, etc. etc.). Very mature ecosystems that solve a lot of different edge cases.

There are very few C++ alternatives worth mentioning, none as mature as Rust in terms of adoption/tooling.

If you need to write a webapp that would require C/C++ kind of memory handling/performance then Rust would be the ideal candidate I think.

I don't know what kind of tradeoff matrix makes you use the Rust graydon describes over the existing options.

For example my main issue with D (but TBH that's something I've given up on actively tracking 10 years ago probably) is that by including GC in the runtime/stdlib - it basically painted itself as a poorly supported competitor to C# rather than a C++ replacement.