15 ms·
> I like to make silly things, and I also like to put in minimal effort for those silly things. I also like to make things in Rust… I think this part is perhap
by devjab 2y ago
> I like to make silly things, and I also like to put in minimal effort for those silly things. I also like to make things in Rust…
I think this part is perhaps the silliest part of a very silly article. If you really like to put in a minimal effort then why on earth would you use Rust? If you want efficiency, memory management and a compiled modern language just use Go. Then you won’t even need anything but the standard library for what you want to do. Or… use Django as you suggest?
Yes, yes we use Rust in production because we thought it would be easier (well safer) to teach to interpreted language OOP developers than c/c++ but why on earth would you ever use it for the web unless you are a member of the cult?
- deleted 2y ago[deleted]
- wongarsu 2y agoThis is definetly something the article should have drilled down on. Why Rust? I'm sure everyone's tired of hearing why rust is an excellent alternative to c/c++ for new projects, but as an alternative against Python it gets muddier. Rust has a clear advantage in performance and memory footprint and a much better multithreading story, but those are things that aren't high priorities for 95% of web development. That basically leaves you with Rust's type system. Rust's type system is pretty great, and if we pretend we can't hear the Haskell developers it's one of the best type systems out there. That might seem to get in the way of quick prototyping, but on the other hand it would mesh really well with a framework like Django. One of the great things of Django was that you define your data schema, and Django takes care of both the database and a passable admin area. I'm sure you could greatly expand on that principle, with data types driving a lot of behavior and conveniences that the framework just handles for you. Maybe a bit like .NET, but without the enterprisy coat of paint and without putting dependency injection everywhere.
- creatonez 2y agoThe answer for why folks are so inclined towards doing high-level tasks in Rust... is the type system. Its sensibilities are in a sweet spot that makes it very easy to pull off huge refactors. It was also a lot of people's first introduction to algebraic data types being used in nearly all error handling (its usage of `Result<T, E> where E implements Error` and lack of nulls or exceptions). It makes a lot of progress towards the goal of "make invalid states unrepresentable", which could be really useful for web apps.
- kortilla 2y ago>Result<T, E> where E implements Error` and lack of nulls or exceptions This all goes out the window when people throw “unwrap” all over the place because “this should always succeed”.
- creatonez 2y agoRust does not skirt around the fundamentals. You can still handle errors however you want, you can still blast side effects all over the place, and you still have to uphold an arbitrary set of invariants specific to the task at hand. But the ecosystem as a whole is filled with things being done the right way because the language and its linters have always been quite helpful.
- LAC-Tech 2y agoIn any program there are errors you can handle and errors you can't, errors whose vary existence suggests something has gone horribly wrong. What else should you do in that situation but panic?
- kortilla 2y agoI see unwrap used all of the time on things that could be recoverable if people bothered to write the control flow. “Meh, let the program crash” is easier because unwrap is much less verbose than the match unpacking or carrying results to callers. Rust has exceptions, they are just named Result and people just as frequently decide not to handle error results as not catch exceptions in my experience. Typed exceptions are just as good as what rust offers IMO.
- ActorNightly 2y agoTyping in modern days is effectively moving the task of debugging to compile/ide annotations process instead of testing for correctness. Albeit it makes the process easier compared to a really shittly written code without strict typing, but against good codebases, it takes the same amount of time.
- elcritch 2y ago> and if we pretend we can't hear the Haskell developers it's one of the best type systems out there Eh, Rust's type system isn't one of the best out there. It's lacking higher kinded types, etc. It's abilities in type level programming are frustratingly limited as well. So it's advanced aside from from Haskell, OCaml, Idris, Scala, etc. Compare to OCaml's effect system for an advanced type system feature.
- kelnos 2y agoI 100% agree with you (I really miss HKTs), but I don't think the GP was using "best" to mean "most fully-featured". And with that in mind, I do agree with the GP. Scala's type system, for example, is full of warts (well, Scala 2; I still haven't tried Scala 3). Rust's is cleaner and has fewer gotchas. I very rarely have to look up how to express something in Rust's type system, but I remember when I last did Scala, I often ran into weird type-system related errors that I just didn't understand and had to dig into to figure out. Some of that, sure, is likely due to Scala's type system having more features, but some of that is because it's just more complex. And I would usually rate something of lower complexity as better than something with higher complexity.
- Quekid5 2y agoOne of the major things about Scala 2 vs Scala 3 is the removal of many of the type system warts, in particular the type hierarchy now forms a lattice (if I'm getting my terminology right) rather than being rather adhoc in various places. Lots of other small annoyances like the whole tuple situation have also been fixed. EDIT: Plus: intersection types, sane macros/inlining, etc. Unfortunately (for me), some of our projects still have to cross-compile to 2.x, but that's irrelevant for greenfield. I'd give it a whirl -- it's a great improvement over Scala 2.x.
- satvikpendem 2y agoOCaml's effects are fairly new, and the Rust maintainers are also looking into effect systems. Who knows, we might also get HKTs and dependent types too in the future.
- deleted 2y ago
- slashink 2y agoFor what I hack on I often run into issues with the FFI performance between go/c# <-> c/c++. I’d rather not write C or C++ and Rust is one of the few languages that allows me to mess around with obscure libs at native performance and yet slap a web interface in front of it. cxx/bindgen is stellar in how fast they allow you to wrap libraries. These cases is where I would want like the simplest most opinionated web framework (like gin in Go). For everything else, there’s Go IMO.
- neonsunset 2y agoFFI can be a source of performance issues in Go but not in C# (at least not to the same extent), unless you go out of your way to fight the happy path approach. Sometimes you do have to rethink what you marshal vs what you just manage manually, but that’s what pointers are for (that can be turned into ref Ts for single values and into Span<T>s for slices/arrays/etc). The idea is that performance ceiling of FFI in .NET is as cheap as direct calls.
- WD-42 2y agoHave you had real success with cxx? I've been trying to FFI a C++ lib (that I have limited control over) and it's been a real PITA. At this point I'm thinking of just making a pure-c interface for what I want on the C++ side and using C bindgen or just straight "extern C" because C++ FFI seems so painful.
- pjmlp 2y agoBetween Rust and Python there are a huge distance full of options with managed compiled languages, with AOT, JIT, or even both AOT and JIT as standard toolchain feature.
- berkes 2y ago> but as an alternative against Python it gets muddier For me, a clear advantage of rust (and also Go) over Python (or Ruby, or PHP) is not having to deal with runtimes. With Python, the server needs all sorts of setup. Exactly the right version and configuration of the runtime. Pip. Or Pipenv. Or Pyenv. Or Conda. Or... and so on. Then it needs the libraries installed. Some of which must be built natively; so just packaging them in some CI is often not even possible. These native builds need lib-something-dev packages. Then with an update of the underlying server, suddenly nothing works anymore. Having a single binary that I can plop onto almost every linux box and which "just runs" regardless of the exact version of Ubuntu, cargo, rust-toolchain on the server/hosting machine is invaluable. I'm so done with maintaining the fragile card-house that my Ruby-on-rails apps require, or that my python/flask services need, that my nodejs insists upon: with rust this is no longer needed. And yes, docker/containerization is a solution to it. And yes, I know about the options to package up a python app with runtime included. But all that adds extra complexity. It merely makes it easier sometimes. Not simpler. And it inevitably makes troubleshooting, upgrading, etc even harder in some future.
- paulgb 2y agoThe author is clearly building things for the joy of it. If she gets the most joy from Rust, that's what she should use! > See, if I want to make something for the web, I could use Django but I don't want that. I mean, Django is for building serious businesses, not for building silly non-commercial things! Personally, I spent the first decade of my career switching between languages, believing that I should use the best tool for any given job. I spent the last ~five years doing mostly Rust, and I've learned that there's a level of mastery of a language you can never quite reach if you're always context-switching between them, especially a language as “deep” as Rust. This means I write things in Rust that Rust is not the best language for.
- brendamn 2y ago> If she gets the most joy from Rust, that's what she should use! In the past I’d try to justify why I’d done something a certain way when another way would’ve been faster / better / cheaper, but I now realise that (at least for personal pursuits) an acceptable answer to “why?” is simply “because I wanted to”.
- iterance 2y agoI feel like this is where I've personally landed with Rust. For many applications, it's at least good enough. It gets the job done. It looks and feels professional. Fit and finish are rarely a material concern. It rarely causes active problems (except where there isn't native coverage yet) and reduces or eliminated many more. And... well, I like it. If I were putting together a web development team, would I recommend Rust? ...probably not. But that's because I'm putting together a team, not a playground. I'm paying people. I want to use common, well-supported, time-tested methods, unless steering away from that is truly needed to make the project successful. For web dev, that assuredly ain't Rust ("yet," some may add). But for me? Just for me? I think it's a language I'll always enjoy. Within that line of thinking, I do feel there's room for better web dev tooling in Rust, though what's already there is probably enough to at least get started.
- oguz-ismail 2y ago[flagged]
- andrewxdiamond 2y ago> I also like to make things in Rust Seems like a good enough reason to use it to me, but perhaps I’m just another cult member. > we use Rust in production because we thought it would be easier (well safer) to teach to interpreted language OOP developers than c/c++ I think rust is just safer period, regardless of your level of expertise or background. Or are you saying that every memory safety bug was written in by someone inexperienced? Not to mention the concept of “sharing code.” See I may write garbage tier rust code that basically glues together a bunch of libraries, many of those libraries are written by programmers way better than me, and I can gain performance and safety from using their work. The performance difference between languages like Rust and JS is huge, even if I, tainted by my background in Java, write dogshit code.
- kelnos 2y ago> I think rust is just safer period, regardless of your level of expertise or background. Or are you saying that every memory safety bug was written in by someone inexperienced? I think you're reading too much into that and creating conflict where there isn't any. GP just meant that they had a bunch of interpreted language OOP developers (probably Java or C# or something like that), and they wanted them to start writing code in an AOT-compiled language (yes, I know about Graal native image; not the point). And that teaching them Rust is probably going to result in safer code than if they were to teach them C or C++. That shouldn't be a controversial statement.
- bigiain 2y agoAlso, without claiming that experienced c/c++ developers never write memory safety bugs, I don't think it's at all controversial to say inexperienced c/c++ developers write a lot of them (and hopefully experienced ones write way fewer).
- Fulgen 2y ago(Also not the point, C# can be AOT-compiled as well these days)
- a57721 2y ago
- phoronixrly 2y agoWhat kind of logic is this... The Rust language is quite rigorous, so web frameworks on it should also be equally laborious to work with? You have to roll your own authentication, you have to do your own routing, you have to do ad-hoc string manipulation instead of templates?... The person likes writing in Rust, and would like to have a batteries-included web framework so they can tie together a web app quickly on the language they like to use... And I know they did not include https://rocket.rs/ https://rocket.rs/ in their 'existing ecosystem' section.
- lovethevoid 2y agoIf you find the language rigorous, a web framework can't magically do away with that. It's genuinely illogical to believe so. There are plenty of web frameworks on Rust that are quite nice to use, but they are still Rust, with all its shortcomings in the same way Django is still Python with all its shortcomings. What you're asking for is a DSL built on top of Rust for the purpose of creating web apps.
- phoronixrly 2y agoShow me where I asked for a framework that magically turns Rust into Ruby. The person has created a list of (high-level!) features that they need. None of them are 'no borrow checker'.
- bigiain 2y agoI reckon "Rust on Rails" would be a great idea. It'd be cool to have an out of the box "90% of what a website needs" toolkit that means writing your 10% custom code/secret-sauce in a modern code security obsessed language. Even if it is opinionated and "batteries included" in ways that make some things annoying. I have built many projects that start with a WordPress install, to piggyback it's CMS, user management, and admin backend. I then inevitably end up making a choice between writing the project in php, or jumping through hoops to use the WP features (like auth and user accounts) in some other language that's more appropriate to the task at hand.
- lnxg33k1 2y agoAs a Linux user I’ve had to deal with these kind of people who wouldn’t use something new unless it was made the same of what they’re currently using, all my life, they just are not able to get it
- beeflet 2y agoIt could beat using C/C++ for using an embedded web server. I remember I tried that once and a lot of the work was using aho-corasick for working with paths, handling cookies and dealing with a bunch of nasty error handling all of which in theory would be easier in rust. My problem wasn't so much dealing with memory management, but trying to put an upper bound on memory usage and failing nicely when that upper bound is met. I generally don't like working with garbage-collected languages, or having to use some niche application-specific language when I can just use a general-purpose language instead.
- dwattttt 2y agohttps://github.com/BurntSushi/aho-corasick https://github.com/BurntSushi/aho-corasick I've had a lot of fun playing with it, it was very nice & simple to use. It's also foundational in the Rust ecosystem, so it's well maintained.
- jvanderbot 2y agoYes the intersection of compiled performant and web is mostly filled by Go.
- kelnos 2y agoIt would be great to introduce some competition there, then! (Not only because I think competition is good, but because I really do not enjoy writing Go.)
- demi56 2y agoNobody enjoys writing Go but there’s a reason do code in Go and we can’t ignore it
- jvanderbot 2y agoI write rust full time. I don't see how people can "love" writing rust either. I love a lot of things about Rust and its ecosystem, but the syntax day-to-day isn't one of those things.
- mike_hearn 2y agoThis thread is amusing. Go look at job boards. The competition for Go, Rust, Django or whatever is Java+Spring. That's pretty much the industry standard unless you're in a Microsoft-only shop.
- neonsunset 2y agoIt’s disingenuous to leave out C# and F# out of this, given how much closer they are to Rust in language features and how much more “close to the metal” capabilities they offer while also having opinionated web frameworks, better CLI tooling and package management and being generally very productive languages.
- mike_hearn 2y agoI specifically mentioned Microsoft and pointed out that it's mostly gonna be Spring unless in an MS shop. C# wasn't mentioned explicitly because I thought it was clear what was meant.
- dwattttt 2y agoI don't as a rule web dev, so when I do I fall into the same category as the author: lowest effort to get something mostly right. An explanation for "why bother try to have a low effort web server in Rust?" that I haven't seen mentioned: Once you're past the introductory phase of being familiar with Rust, if you don't need to pedantically handle every error case, it can be _very_ simple. A low effort "doesn't have to be very flexible" web server would be terrific & easy to use in Rust. Having said that, I'm not aware of the actual offerings available. Maybe there is one, other posts have suggestions.
- gcau 2y agoRust has benefits besides just memory safety and being efficient, it has great language design and a great toolchain. I chose (learning) rust over golang for quite simple projects with no performance requirements, out of sheer frustration with the toolchain/design of go, golang came off to me as "let's try to be special and make bizarre design decisions" which made it confusing to learn, not only that but I very quickly ran into pain points, whereas rust felt like everything just took the most logical straightforward path, and everything "just worked". It, to me, genuinely feels simpler, because things were what I expected. Kind of like apple simplifying their mouse to have no buttons and thinking it's very simple and easy, but then its just more complicated because it's so unusual, whereas everyone knows exactly how a normal mouse works. Just my view. I use typescript and needed a language to make a couple simple programs that could compile to a single executable, I'd love another option but don't want to use one that's not matured enough.
- angra_mainyu 2y agoZig is an excellent middle ground though it doesn't hit the maturity spot - I keep on having to update build.zig with most releases. That said, what exactly was the issue you had with Go?
- demi56 2y agoBasically the type system, most rust projects usually don’t come near “The advanced Reason there’s rust” and if they do need that there’re hardcore libraries for that, an ecosystem like that usually suffers from exhaustion cause no dev will want to maintain just a library and this is also the good apart of rust cause it lessens the barrier into the language as the ecosystem gets bigger
- lenkite 2y agoStrange - my experience was the opposite for Rust. The extreme plethora of String types, the way life time annotations made refactorings very difficult with very high cognitive overhead, no batteries included standard library, even error handling needing external support, string slicing panicking in Rust, async is a mess to debug - Go in contrast is a far more comfortable and consistent developer experience.
- troad 2y agoI am a fan of Rust for systems programming, but so many people are using Rust for things that are nothing even remotely close to systems programming. So many projects you see being written (or rewritten) in Rust are projects where I just think 'wait, why can't this just have a GC'? And then you look at the code base, and it's all Arc<Mutex<RefCell>>s, and you can't help at marvel at this, since that's just GC, so what's the benefit of Rust here, exactly? (Don't @ me, ARC is GC.) I think a lot of what people actually like about Rust, to be honest, is that it's essentially an ML language masquerading as a C-like, with a stellar packaging and tooling story. What people fall in love with is the rigorous static typing, the Option monad, the exhaustive enums (which are just sum types in disguise), the traits (type classes in disguise), the borrow checker (a half-way house to immutability) etc. People will brag about Rust's memory safety, and then you find out that they don't really know how lifetimes work, they just .clone() or Arc<Mutex<RefCell>> everything. Which is totally valid, but Rust is hardly necessary for that. Rust is great, but - heretic idea - not literally everything needs to be in Rust. Go try Ruby on Rails for a while! Or - if Rust has whetted your appetite for more functional styles - Phoenix on Elixir! Yes, it's not quite so blazing fast, but - let's be honest here - you're not going to be getting billions of requests per second on your hobby website where you write about taking apart Amigas. It's OK! She'll be right.
- CharlieDigital 2y ago> I think a lot of what people actually like about Rust, to be honest, is that it's essentially an ML language masquerading as a C-like, with a stellar packaging and tooling story. F# seems like a good option.
- cmrdporcupine 2y agoOr just OCaml
- sunshowers 2y agoOCaml is an excellent language, but doesn't it have a GIL?
- ergonaught 2y agoBecause performance is a thing? Because you like the Rust ecosystem? Because you enjoy developing in Rust?
- EnigmaCurry 2y agoI feel like my Rust code takes 3x as long to write as my Python code, but the gpt results for rust are about 10x better, because the tooling is a backstop against hallucinations. I really like the Rust tooling and I like exhaustive pattern matching. Python post-dev debugging time is probably 10x vs Rust. That's why I choose Rust.
- dap 2y agoFor what it’s worth, for me, the time-to-first-attempt-to-run-it is faster in Python or Node than Rust (sometimes), but the time-to-first-working program is generally not, and by the time I have the Rust one working, it handles most of the corner cases with clear error messages. There are rarely unexpected cases not handled. In other words, I find it faster to produce working stuff in Rust and much faster to produce quality stuff. Obviously I’m just one data point.
- satvikpendem 2y agoI use Rust primarily due to the type system. I could use OCaml of course but its a tooling nightmare compared to cargo. The fact that Rust is fast by default is just a plus.
- whirlwin 2y agoFrom a technical point, you are absolutely correct. From a developer heavy business, it's a little more complicated. If Rust had a good full-fledged web framework, it would enable more developers to justify why the business should use Rust. The culprit is that it would require a heavy education budget, but it would in turn enable the business to allow using Rust for other parts of the business which could benefit from Rust, e.g. middleware, small components, CLIs and systems programming in general. Having a little bit of Python here, a little bit of Go there and a bit of Java elsewhere can become chaotic. There is a huge benefit for a small company to only have 1 programming language everyone agrees on using.
- devjab 2y agoIf your goal is to use just one language then why wouldn’t you pick JavaScript (likely Typescript), C# with Blazor, Go with templates or basically anything on the JVM? Rust is a bad general purpose language in my opinion, and its performance isn’t actually good enough compared to C# to really justify the added headaches. I say this as someone who really, really, doesn’t like C# by the way. If your goal is easy web development, Django, Ruby on Rails and Laravel are frankly going be extremely hard to beat. I prefer Go with templates, but that’s still much worse than those options.
- qalmakka 2y ago> I like to make silly things, and I also like to put in minimal effort for those silly things Saying that and then use Rust is like saying, "I want hassle-free driving, that's why I drive a car with a 7-speed manual shift". If you want a full-auto, then use it. "Minimal effort" is the reason why people wrote garbage collectors in the first place.
- selfmodruntime 2y ago> If you really like to put in a minimal effort then why on earth would you use Rust Because it's a fun language and you really do get to avoid the borrow checker nowadays if you just use `Arc` and `Clone` all over the place. I'm the same as OP. Also, I love the package ecosystem. I know it (rightfully) gets some of the flack that the JS ecosystem gets, but most of the time, I truly don't care. I enjoy C programming as well, but C not having a common packaging system / cargo equivalent has really hurt it a bit in my opinion.
- 0x1ceb00da 2y agoFor writing web services that do a lot of data processing?
- pyrale 2y ago> and a compiled modern language Let's just say different people have different opinions on this one. Personally, I find Go to be a big regression in language design given modern PLT research, and wouldn't use it unless forced (e.g. terraform providers). Other people have other opinions: a friend I respect a lot has great success in the Go community. I'm telling you that because if, as a Go enjoyer, you're baffled by the writings of a Rust enjoyer, it's very likely the result of different perspectives rather than silliness. And if your conclusion is "just use go", you're probably the one being silly.
- kaba0 2y agoGo is only modern in release date.
- scotty79 2y ago> Yes, yes we use Rust in production because we thought it would be easier (well safer) to teach to interpreted language OOP developers than c/c++ but why on earth would you ever use it for the web unless you are a member of the cult? Rust is great, high level language that's super convenient for implementing arbitrary algorithms on arbitrary huge, complex data structures safely and quickly. Value semantics is absolutely unique and useful. The system of traits and standard library using traits like Ord or Hash means that it's enough for your type to implement one of those and suddenly it can be a key in a HashMap or BTreeMap and can be a part of even larger and more complex data structure. Adding a web to that easily could be super useful.
- deleted 2y ago[deleted]
- keybored 2y ago> I think this part is perhaps the silliest part of a very silly article. If you really like to put in a minimal effort then why on earth would you use Rust? “I like to play basketball but tbh I like to put in the minimal effort” “Then why do you even play basketball? It’s a physical activity…” The first thing takes precedence over the other. > If you want efficiency, memory management and a compiled modern language just use Go. Then you won’t even need anything but the standard library for what you want to do. Or… use Django as you suggest? Just do what someone else dictactes. The surefire way to self-expression and Fun Town. > Yes, yes we use Rust in production because we thought it would be easier (well safer) to teach to interpreted language OOP developers than c/c++ but why on earth would you ever use it for the web unless you are a member of the cult? You forgot to capitalize. The Cult. Since you apparently want to look silly. There’s a difference between what you do in production (at a job presumably) compared to what someone does to be “silly”.