5 ms·
So, is Rust a better C? I haven't dug into it too much but that's been my general impression of how it's been presented.
by gfodor 12y ago
So, is Rust a better C? I haven't dug into it too much but that's been my general impression of how it's been presented.
- dllthomas 12y agoI doubt it's a uniformly better C, just because the space has so many dimensions. I hope it's a better C, on balance, for the things I want to use C for. I've not yet dug in, though.
- femngi 12y agoRust is aiming more to be a better C++. However that doesn't preclude it from being used in the same space as C and can become impressively lightweight if you forgo things like the standard library. I would argue that it is better than C for its safety features alone. I hope in the future we look back at this decade with its never ending stream of buffer overflow vulnerabilities with disbelief that we could use something so insecure for something so vital.
- reikonomusha 12y agoShouldn't we already be suspended in disbelief given the languages we have had for 30+ years?
- pjmlp 12y agoI have been complaining about it since the MS-DOS days and many of us used Turbo Pascal, when Assembly wasn't required. Somehow along the way UNIX spread into the enterprise and brought C along.
- byuu 12y agoIt's somewhat higher level than C. I've always liked to think of myself as a programming polyglot, able to pick up and reason about nearly any standard language. I'm not sure how Rust is doing it, but the more I read and learn about it, the more confused I am. The syntax is just so bizarre and counter-intuitive to me. And yet I seem to be the only person in the world who doesn't "get" it. It's as if the language is being explicitly developed to be my kryptonite.
- lincolnq 12y agoRust seems to me much more like Haskell than C or C++. Try thinking about it that way and see if it makes more sense.
- byuu 12y agoInteresting, that could well be it. Languages I pick up very easily (in rough order): C, C++, PHP, C#, Java, Scala, Perl, Python, Ruby, Javascript, Lisp. Haskell is definitely one that gives me trouble as well. It's not the functional aspects: I've no trouble writing recursive descent parsers and the like in C++. I can't stand the parentheses, but I can understand and reason with Lisp. I think in Haskell's case, it's just doing too much with too little. Like how they can implement quicksort in three short lines of code, and to me it's just so much to unroll in my head at once; but it's hard to be sure for obvious reasons.
- Yxven 12y agoI've been using Haskell for a few months now, and quicksort has become trivial to read. Although, I agree that knowledge of other programming languages barely transfers to Haskell. I think being very different is the main factor that restrains Haskell's growth. It says a lot that Haskell's popularity grows anyway.
- panzi 12y agoAll the languages you list maybe except for Lisp are basically the same. They are all imperative, some of them are object orientated. If you understand e.g. C++, you should understand any of the others with not much effort. Really different languages would be Haskell, Prolog and maybe APL. Or recursive (hence Turing complete) SQL queries.
- codygman 12y agoThere's only one thing you need to learn Haskell: 1. Forget everything you know and follow the types. 2. https://github.com/bitemyapp/learnhaskell https://github.com/bitemyapp/learnhaskell
- 12y ago
- jeffreyrogers 12y agoMy impression of Rust is that it focuses too much on safety at the expense of making it hard to do what you want, especially when dealing with low level things.
- imron 12y agoYes, hard to accidentally introduce buffer overflows, memory leaks and other things you probably hadn't fully considered. If the Rust compiler is stopping you from doing something, there's good chance you really shouldn't be doing it.
- jeffreyrogers 12y agoPreventing buffer overflows requires runtime checks. That's a performance hit. Memory leaks require either GC or a restrictive type system. The first is another performance hit, the second is cumbersome to use. I think Rust does a lot of things nicely, but I don't expect it to replace C simply because it adds a lot of complexity that people don't really want to deal with.
- codygman 12y ago> Preventing buffer overflows requires runtime checks. Incorrect. "By using theorem proving and strict type checking, the compiler can detect and prove that its implemented functions are not susceptible to bugs such as division by zero, memory leaks, buffer overflow, and other forms of memory corruption by verifying pointer arithmetic and reference counting before the program compiles."[0] 0: http://en.wikipedia.org/wiki/ATS_%28programming_language%29 http://en.wikipedia.org/wiki/ATS_%28programming_language%29
- imron 12y agoBuffer overflows occur in C because the language doesn't force programmers to perform those runtime checks and so many don't (or don't do it correctly). Rust makes sure you are checking those things. Some of those checks are only at compile time and have no runtime cost. Others have a runtime cost but in the vast majority of situations the 'performance hit' will be negligible. Anywhere it is important you would rearrange your code to move the checking out of any critical path. Note that it's still the same thing you'd have to be doing in C anyway to be both correct and fast. Rust just makes sure you don't forget the correct bit. http://doc.rust-lang.org/nightly/intro.html#safety-<em>and</em>-speed http://doc.rust-lang.org/nightly/intro.html#safety-<em>and</... Regarding complexity and being cumbersome, Rust increases compile time dependency, but reduces debugging complexity. Personally I would rather spend a bit more time at compile time thinking about memory ownership than spending hours (or even days/weeks) tracking down memory problems.