5 ms·
Is Rust a good fit for business apps?
- Developerx 2y ago[dead]
- deleted 2y ago[deleted]
- jmclnx 2y agoIMO, it is just as good as Java and c, but rust people will say rust is better than both. But the standard is COBOL, for business applications you need predictable fixed point math. By that, if you divide 1/3 you get .33 instead of .33333333333333333, depending on how the numeric item is formatted. Or maybe a better example, 1/6 you would get .17 instead of .166666666 Does rust have that ability ? I do not know. Some bolt on libraries exist for c, but it is a bit harder to use IIRC.
- PaulHoule 2y agoJava has BigDecimal. This looks pretty nice https://docs.rs/rust_decimal/latest/rust_decimal/ https://docs.rs/rust_decimal/latest/rust_decimal/
- osigurdson 2y ago>> 1/3 you get .33 I have never seen any COBOL code but I'm surprised this works in a general sense even for currency related calculations due to the loss of accuracy. In any case, it seems that it would be relatively easy to implement COBOL compatible numeric processing in any language in a library (and maybe one case where operator overloading is a feature instead of a bug).
- triknomeister 2y agoIt's trivial (in the mathematical sense) to have this ability in Rust.
- lumost 2y agoThis is a good rundown of the pain of rust development. I had imagined that I'd reach a nirvana of rust dev where I could just write the code and feel like I knew what I was doing. This ultimately never happened after N learning attempts and M side projects. A nascent startup idea died due to the time spent on rustisms. I don't doubt that some people experience this zen, and I'd take rust over c/cpp every day for a new app if that was my choice… but that's not really my only choice. The article also nails the performance topic, while rust gives you all of the insight and control over what your code is doing - its exceptionally rare that all of the libraries and modules in your program agree enough on these interfaces to not end up with memory copies everywhere.
- PaulHoule 2y agoSome people say they like C++. It's little appreciated how revolutionary the garbage collector is, in that it probably contributes more to software reuse than every other innovation put together. If you were trying to please everybody in C, for instance, a library should be able to accept a buffer from the application, or allocate a buffer using a malloc/free passed in from the application, as well as many other scenarios. For very simple libraries it is not complicated but as libraries and applications get more complex the library can never be sure if the application is done with a buffer and the application can never be sure if the library is done with it. For a framework, which calls the application, it gets worse. However, the garbage collector always knows. Memory allocation is a global problem but Rust tries to treat it as a local problem which can be solved for any particular program but gets harder and harder as programs get larger and if you want to compose a program out of independent parts it is intractable: sure you can RC all the things (no cycles!) and copy a lot but you lose many of the reasons why you gave up on the garbage collector.
- triknomeister 2y agoIt is a local problem when you're doing HPC. Not for most business apps though I agree.
- PaulHoule 2y ago
- empath75 2y agoThere's a common theme in posts like this where the writer knows _too much_ about programming, and tries to do things that are awkward in Rust, but a lot of these problems don't actually come up in practice. Sometimes I feel like they take it as a personal challenge to never ever use .clone() and like -- it's okay -- use clone(), nobody else is going to know. I'm maintaining 4 kubernetes operators written in Rust with a team of devs who are _not_ brilliant developers, and it's all async, and once I setup the patterns, they were able to jump in and start contributing business logic immediately. Is it the most performant possible implementation? Definitely not! But once I told them how to stop using unwrap() everywhere, they have literally _never_ crashed or panic'd in over a year. When we were working in go, nil pointer exceptions were the bane of our existence.
- osigurdson 2y agoI always thought that using Rust for Kubernetes controllers / operators would be going against the grain a little (since almost everything in that ecosystem is golang). I'm interested in why your team ended up switching to Rust and how it is working out for you.
- bnpxft 2y agoAt the risk of making this another Go vs Rust comment, I hesitate to mention this, but Go developers copy structs all the time. We do it mostly as a way to make values immutable (and to avoid nil checking all the time). It is mostly not a problem. If something is a hot path, we'll use a pointer. Whenever we pass by value as opposed to by address, Go makes a copy. Use .clone() in Rust, it is fine most of the time. Optimize it out if you find it is a performance bottleneck. https://go.dev/play/p/Cm7mzRbva-5 https://go.dev/play/p/Cm7mzRbva-5
- arwhatever 2y agoI am hard-pressed to think of a context in which .clone() is better-suited than in business apps.
- osigurdson 2y agoPerhaps an interesting question is, can a programming language be created that works well from low level operating system use cases to business apps? Or, is it fundamentally necessary to have multiple languages to cover different domains?
- _mlbt 2y agoI think Swift gets very close to this ideal, but there is still an Apple-only stigma associated with it despite it having support for Linux, Windows, and embedded systems.
- pjmlp 2y agoOutside Apple, Swift is now around the state .NET Core 2.1 used to be, kind of. It is a great language, and should be used as much as possible, but mainly on Apple's kingdom.
- blashyrk 2y agoI think Nim might be a good candidate. https://nim-lang.org https://nim-lang.org
- apatheticonion 2y agoI feel quite happy writing high level application code in Rust and write most of my projects in it now
- skwee357 2y agoRust is hard to get started with, but once you reach optimal development speed, I can't see how you can go back to any other language. I have a production application that runs on Rust. It never crashed (yet), it's rock solid and does not require frequent restarts of the container due to memory leaks or whatever, and every time I need to fix something, I can jump into code after weeks of not touching it, and being confident that my changes won't break anything, as long as the code complies (and is free of logical bugs). I can't say the same about any other language, and I use a few of them in production: NodeJS, Ruby, Python, Java. Each of them has their own quirks, and I'm never 100% confident that changes in one place of the code won't cause harm in another place, or that the code is free of stupid bugs like null-pointer exceptions.
- apatheticonion 2y ago100% agreed. After writing Rust as my day job and using it in production for the last 2 years, my only criticism is the lack of a good high level standard library (like Go) and the insanity and fragmentation of Future type signatures. Though at this point, I wish I could write everything in Rust - it's fantastic Also, I can't wait to (practically) use it as a replacement for JavaScript on the web
- hcfman 2y agoSo you can't write everything in rust? You mean like business apps? Just asking.
- apatheticonion 2y agoIt's great for web servers and build tools but has work to do on the client side. It's difficult or impossible to write GUI applications in Rust (despite that being a great use case via macros and fearless concurrency)
- vlod 2y agoSystem76 trying to do that with their Cosmic DE (for PopOS)[0]. Hopefully that will change soon. (Well for linux) [0]: https://system76.com/cosmic/ https://system76.com/cosmic/
- hcfman 2y agoDoes rust have good deserializers for json and xml? Can you work well with a rust application that interacts with react? Just asking.
- sli 2y agoSerde is lovely, in my opinion. Not sure about React interop, though.
- indeyets 2y ago> Does rust have good deserializers for json and xml? yes. https://github.com/serde-rs/json https://github.com/serde-rs/json > Can you work well with a rust application that interacts with react? can you write an API-server in Rust? sure. or what do you mean?
- estebank 2y agoTo add to this, this should give you an idea of what this looks like to use: https://serde.rs/derive.html https://serde.rs/derive.html
- steveklabnik 2y agoYes to both, this is what I do for my day job.
- hcfman 2y agoNice, it would be great to hear about some of the stack you are using then. What interests me is: dezerializers rest API exposing. Annotations or sorts ? openapi support I guess these are some of the most criticial
- steveklabnik 2y agoWe have written our own http server framework focused on openapi support: https://docs.rs/dropshot/latest/dropshot/ https://docs.rs/dropshot/latest/dropshot/ https://serde.rs/ https://serde.rs/ is the serialization/deserialization framework in Rust, and is well supported in the ecosystem. We also wrote https://github.com/oxidecomputer/oxide.ts https://github.com/oxidecomputer/oxide.ts to generate TypeScript clients from the OpenAPI. We mostly use react-router (or remix for older things that haven't been upgraded yet). So the way that it works is, you define your api in dropshot. You ask it to generate an openapi document. You run this on that document to get a typescript client. And then you use that client in your react-router application. I'm personally using it in the "framework" mode, so I have a "backend for frontend" going on, but the main appliccation is using it purely on the client, served from the same server as that API. Both have pros and cons.
- hcfman 2y agoAre there people here that programmed in Java for more than 12 years then switched to rust for business app development?
- rcarmo 2y agoI've been waiting for the Rust ecosystem to stabilize, but reading through this I thought "OK, they still haven't had their Django moment". Go is weird and arcane (and oddly cathartic if you were exposed to Plan9), but it has so much less cognitive overhead that the most likely direction (for me, at least) if I need something else is back to C++ and not Rust.
- pjmlp 2y agoI like Rust, however for me when not doing C#, Java, Typescript, it is also C++. Mainly because when working with those ecosystems, runtimes and native libraries, when playing around with LLVM, or GPU coding, it is all about C++, unless I would like to build ecosystem instead of actually implementing what I wanted to do in first place. Also because for better or worse, I have the scars already.
- wolvesechoes 2y agoTo me Rust is a suboptimal choice for lot of other use cases. Automatic memory management should be embraced 90% of the time, but it is not due to cargo-cult (no pun intended, Rust's cargo is awesome) and superstition. I mean, people successfully did "systems programming" in GCed languages decades ago. They were lucky nobody told them that is not achievable. Besides Python that I have to use professionally for its numpys and matplotlibs, personally I settled on Go for my personal purposes, with all its warts and caveman-like design, even though I prefer a lot of Rust stuff (error handling, type system, FP-like constructs). D or C# came pretty close, as languages alone they are much better than Go, but tooling and ecosystem, in case of D, or still somewhat limited AOT capabilities, in case of C#, made Go a winner for me.
- pjmlp 2y agoWhile I am not a big fan of Go's design decisions, I am a cheerleader for TinyGo and TamaGo achievements, or having bootstraped the whole compiler toolchain and runtime. Likewise, even though I dislike the outcome from Android Java, I celebrate that Android has proven what Longhorn could have been if DevDiv and Windows division actually collaborated. Also share the same opinion regarding Rust, its sweetspot are places where any kind of automatic resource management isn't wanted, or even if possible, it would be quixotic battle trying to change the minds of the target audience.
- bitbasher 2y agoI'm currently using Rust for my saas product (very much a b2b web platform + api). It has been great so far. The only pain point is the change > rebuild > refresh flow is a bit slow (5-8 seconds to rebuild). It isn't ideal, but it comes with a number of positives. I am able to change code across the whole codebase with a high degree of confidence when it compiles, it's working. Even in my html templates. Previously, my product was written entirely in Go. The change > rebuild > refresh flow was better in Go, but I had less confidence with code changes (especially around go's templates and runtime errors).