4 ms·
So Rust combines the expressiveness of C++ with the ease of development of Java?
by ahoka 3y ago
So Rust combines the expressiveness of C++ with the ease of development of Java?
- kaba0 3y agoI wouldn’t call Rust easy to develop in.
- mcronce 3y agoI would
- cmrdporcupine 3y agoIt's like skiing (or maybe riding a bike for the first time.) Steep learning curve then becomes somewhat instinctual and fairly routine and trivial and fun. Until you get into the tricky terrain, and then it will put up resistance. But usually for your own good.
- neoCrimeLabs 3y agoRolling with the analogy, I think learning rust a lot more like snowboarding, and C/C++ is more like learning to ski. I fell a lot more learning on snowboard than on skis. Skis had a much quicker early learning curve, and made me feel over-confident. Several times I found myself on trails too steep for my skills, and the skis made me have to work hard to recover. Most of the techniques I learned as a beginner didn't work beyond green trails, and blues, blacks all required new, harder, techniques. With snowboarding, because I fell a lot more early, my confidence slowly grew. Meanwhile the techniques I was learning on the greens, and the tool in general, that were HARD to learn on the greens were actually EASIER on the blues, and continued to work on the black-diamonds. Granted I also had to learn new techniques on the harder trails, but the beginner techniques and the slower development made me MUCH more confortable across the whole mountain much faster than skis. Double-blacks are more like unsafe rust. :-D
- cmrdporcupine 3y agoYeah, fair, I often make the same point about snowboarding vs skiing. Skiing is "easy" to pick up but difficult to master. Most people on the hill are just backseating it down in bad form, like they learned in their first week. Getting good form is ... a lifelong effort. Snowboarding is brutally hard to pick up at first, unless you hate your tailbone. I have never really tried, I'm too old for that kind of pain. But I'm a telemark skier, so the worst of both worlds :-) Maybe telemark is like advanced C++. But probably more like Haskell.
- arethuza 3y agoIsn't that the same for most languages once you move beyond vanilla Java/C#/Go etc.?
- cmrdporcupine 3y agoRust has "opposite" call semantics from what most people are used to, trained since they were new programmers. Sort of. It takes a while to think like the borrow checker and get used to the way arguments get passed around. It's like using C++ and doing std::move for every non-reference argument.
- alternatex 3y agoSounds like the transition from OOP to functional. It feels opposite before you become comfortable.
- shpongled 3y agoI would as well. I've also placed in the top 100 of advent of code before... using Rust :) I think once you get familiar with it, it is just slightly slower to write than python.
- duped 3y agoI use it professionally and can't disagree more with this statement.
- shpongled 3y agoI also use it professionally, for both web apps and HPC algorithms. Are there some things faster to write in python? Sure. But I find the mental overhead is significantly less (for me) in Rust, and overall dev time is about equal, since I typically hit far fewer bugs and spend less time reading docs in Rust. I can't remember the last time I hit a footgun in Rust. Seems I hit one every week in python. We recently migrated a ~10k SLOC Django JSON API server to axum/sqlx (Rust). I couldn't be happier - faster to ship new features, faster to refactor, fewer bugs, and response times got about 10x quicker.
- duped 3y agoI work a lot on async code with data structures that need interior mutability and it's kind of a pathological case for borrow checking. Everything is effectively wrapped in Arc<RwLock<_>> which adds a bunch of noise to method implementations.
- fleventynine 3y agoI agree with this statement if my data structures map cleanly to Rust's preferred single-ownership, which most problems in my domain do. Sometimes I do run across problems that are difficult to express in Rust without resorting to interior mutability, and it can slow me down to figure out the best way to model my data.
- shpongled 3y ago
- amunra__ 3y agoI'd say expressiveness of C++ with productivity of Java. Rust is indeed not easy to learn. A little example. Yesterday I was making changes to our C++ client library and I wanted to improve the example in our documentation. We use a dedicated protocol called ILP for streaming data ingestion and each of the inserted rows has a designated timestamp. In the Rust example, I using added support for chrono::DateTime and it was trivially easy for me to add a timestamp for a specific example date and time: Utc.with_ymd_and_hms(1997, 7, 4, 4, 56, 55). Our C++ library instead takes an std::chrono::time_point. I wanted to use the same datetime. As far as I can tell it requires first going through the old C "struct tm" type (which is local and not UTC), then converting to "time_t" then converting to utc via gmtime and then constructing a time_point from that. After 10 minutes the code got too long and complicated so I just substituted it a timestamp specified as an int64_t in nanoseconds. Don't get me wrong, the C++ time_point is a work of art in how flexible it is, but unnecessarily complicated in most cases. I should add that I also spent 45 minutes yesterday debugging a CMake issue. Rust is not easy to learn, but it's just more modern and productive. C++ is still great if you've got a massive team, but at our scale I don't think it makes any sense.
- jandrewrogers 3y agoRust development is Java-esque in some ways, I think that is a fair characterization, but the Rust language is noticeably less expressive than C++. The relative lack of expressiveness has been a stumbling block for use in some domains, because modern C++ implementations require a fraction of the code to do the same thing. This disparity doesn't show up for all types of code, so it is not uncommon to see both Rust and C++ used in the same org depending on what the code is trying to do. They have different strengths.
- jgilias 3y agoWhat makes you say that development in Rust is Java-esque? Genuinely curious!
- jandrewrogers 3y agoJava and Rust have similar goals, you can see it in the design of the language and the ecosystem. I lived in the early Java ecosystem and the Rust ecosystem has a similar vibe. They were both attacking the same problem but were are products of their respective times. The key difference is that Rust was able to learn from Java's mistakes and make ambitious technical bets that would not have been feasible at the time Java was designed. Java was invented when most serious applications were written in C and sometimes early versions of C++. It eliminated much of the conceptual complexity that made it difficult for all but the best developers to be productive in C or C++. In this Java was a massive success, it was easy to scale development even if you didn't have the world's best engineers. Java's mistake is that they went much too far when they nerfed the language. For highly skilled developers that could write robust C or C++, the poor expressiveness of Java made many easy things difficult or impossible. It was clearly a language designed with business logic in mind, any systems-y software was an afterthought. The release of C++11 ushered in the era of "modern" C++, killing Java's momentum in the systems-y software space. Rust, in my view, attempts to solve the same abstract problem as Java -- we will never produce enough developers that are competent at writing C or C++. Rust talks about "safety by design" in the same way Java did when it was first released. However, it does so without being so limited that highly skilled software engineers will find the language unusable or giving up so much runtime performance that the operational economics are poor. In my mental taxonomy, Rust is pretty close to what Java intended to be but then never quite delivered on.