6 ms·
I've only ever used GCed (and largely dynamic) languages up until now (Python, JS and Clojure primarily); C is alien and C++ is frankly terrifying. With all tha
by mattdw 12y ago
I've only ever used GCed (and largely dynamic) languages up until now (Python, JS and Clojure primarily); C is alien and C++ is frankly terrifying. With all that, I've been having a ball using Rust to solve Project Euler problems, with astonishing speed compared to what I'm used to.
It doesn't quite have all the libs you might want for general development yet, but for the things it's currently equipped for it's a lot of fun, and surprisingly easy. (Up until I find myself in a quagmire of lifetime problems of my own making. Looking forward to the coming lifetimes inference enhancement.) It's a surprisingly reasonable functional programming environment too.
- Pacabel 12y agoWhy do you see C++ as "terrifying"? Yes, it is a very powerful language and there can be a lot to it, but it shouldn't "terrify" you. These days, it's generally quite easy to avoid much of its C heritage (including potential security pitfalls) if using the so-called "modern C++" techniques, but the extra power and flexibility is still there if you do ever need it. There are numerous ways of easily avoiding manual memory (or other resource) management, too. The STL and Boost, among numerous other libraries that are out there, offer lots of convenient, high level functionality. The portability of C++ code is often quite excellent, the language and its standard libraries are quite stable, and there are multiple commercial-grade implementations from numerous vendors/projects. You probably won't find anything else that gives you a high degree of performance along with high level abstractions, while also giving you the peace of mind that your code will still compile just fine years or even decades from now. While it's certainly possible to to overboard and misuse C++ to a point where it causes serious problems, one of the best things about C++ is that it doesn't force you to do that. You generally don't pay for what you don't use, and it's certainly possible to use a very effective subset of the language much as one might use Java or C#, or even Python and JavaScript. I'd say that C++ is even easier to use than JavaScript is. C++ is much more sensible in so many ways, and nowhere near as quirky or just outright broken in fundamental ways like JavaScript, while also providing at least some type safety and other compile-time checks. If you want a stable, portable, safe, well-supported language that offers high level functionality without the performance tradeoffs of other languages, then I think that a modern subset of C++ could very well be exactly what you're looking for.
- pcwalton 12y agoC++ is not safe in the same sense that Rust is. Without the use of "unsafe", Rust is designed to never segfault or have undefined behavior, ever. Even a modern subset of C++ cannot make the same guarantees (consider iterator invalidation, etc.)
- Pacabel 12y agoI'll gladly use modern C++ techniques and a bit of care, even if that means only getting say 90% or 95% of the safety that Rust potentially offers offers, if it also means that I can get my code written today, and I can trust that it'll still compile unchanged tomorrow, next week, and probably a decade from now. I think it's great what Rust could potentially offer software developers. But it's still pretty theoretical at this point. The language and standard libraries aren't sufficiently stable enough for serious, long-term use, currently. I hear we may start to see the beginning of such stability at the end of the year, but until it actually happens, Rust isn't very useful, while C++ is.
- baq 12y agoif C++ doesn't terrify you, you're probably using it too much. C++ is the most complex programming language ever invented.
- Pacabel 12y agoYes, it's a big language, but the complexity is at least justifiable, and generally comprehensible. C++ gives you immense power and a huge range of functionality to choose from, and some of the complexity arises from this. It has a very long history, which also contributes to the complexity. And it's first and foremost a pragmatic language, which of course brings in some complexity in order to deal with the inherent complexity of reality. If something is seen as "complex" in C++, there's usually a good, or at least understandable, reason for this. You can usually find technical documents or discussion that justify why things are they way that they are, and the reasoning is usually quite sound. And in many cases, it's possible to safely ignore or just not use large portions of the complexity that C++ offers without facing any sort of a penalty or harm. It's very different from the complexity that languages like JavaScript or PHP bring. The complexity there is usually unjustifiable, and often due to very rushed work, a lack of understanding and poor design, or a lack of care and consistency. They suffer from serious flaws and complexity that were not justified when introduced, and were subsequently not cleaned up or fixed once recognized. They suffer from harmful complexity, while C++ offers beneficial complexity.
- steveklabnik 12y agoI would looooove any insight that you have on making the docs better for people who haven't done systems programming before. If you've ever got the time to type out a few thoughts, my email is in my profile.
- jsmthrowaway 12y agoAssuming you wrote this, you lost me in the book analogy. Once you wrote "let's ignore programming for a moment" I thought to myself, why am I here? And why are we talking about ownership? How do I set up a tool chain and write hello world? This doesn't strike me as a 30 minute intro to Rust. More like a quick guide to what sets Rust apart from C. Perhaps my expectations would be different with a different title ("How Rust can benefit you as a working C++ dev")
- steveklabnik 12y ago> Perhaps my expectations would be different with a different title Hmm yes, I will think about it. Ownership is Rust's most important and unique concept, so an intro to ownership _is_ an intro to Rust. I will think about how to make this more clear.
- Scramblejams 12y agoI had no problem with the book analogy. I've been hovering around the periphery of Rust for a while, waiting until I understood the ownership thing before I move into it more seriously. Thanks for writing this! I think it was a solid step in the direction of clearly explaining ownership. I know more than I did before and I'm looking forward to reading your next piece on it. Good work.
- steveklabnik 12y agoThank you! The URL to watch is http://doc.rust-lang.org/guide.html http://doc.rust-lang.org/guide.html . I'm working on it every day. Two more sections should land tonight, and I'm writing the next one as we speak... don't hesitate to ping me with ways the docs could be better, either on IRC, email, or just opening an issue on the repo and CC'ing me.