4 ms·
I just don't feel like rust can replace C/C++, because the syntax is not simple enough. Rust has a lot of cool things, but to me syntax simplicity is more impor
by jokoon 7y ago
I just don't feel like rust can replace C/C++, because the syntax is not simple enough. Rust has a lot of cool things, but to me syntax simplicity is more important.
Maybe I have a hard time adapting myself to rust? Maybe my brain is too much "wired" to a C style syntax. It still seems that to me, C-style syntax is just better.
I would rather prefer a C++-like language that breaks down from backward compatibility with C while keeping its simplicity, has STL containers, and is simpler to read and use.
Rust is cool, but I'm just curious if it can really be adopted for large project to justify rewriting existing code.
- timw4mail 7y agoC++ has simple syntax? Since when?
- jokoon 7y agoSince you're not really required to use templates or inheritance at every corner.
- floatboth 7y agoMaybe you're looking for D? :) Anyway, what is "not simple" about Rust's syntax?
- jokoon 7y agoUsing "let thing: type" seems bloated, I prefer the C style "type thing;" ; can also make a lot of difference, which is a little weird. I don't understand why there is both str and String, seems complicated for nothing. Option things are not really clear yet, and I don't understand what is their use, it seems like an alternative to unions, but few developers use unions anyway... Pattern matching seems powerful but I fail to understand its usage, and I'm a little skeptical about the machine code it generates. D is fine, but I think that even D is not simple enough. Rust seems like it's awesome, but it requires to entirely rethink how you write code, and I've never been a fan of high level abstraction.
- floatboth 7y agoMost of the time, just `let thing`. Let (ha) type inference do its thing. Explicit type annotations are for when it fails. `String` is roughly a Java `StringBuffer`, `&str` is roughly a C++ `string_view`. Yes, you need to rethink how you write code. Rust relies a lot on the basics of typed functional programming. Reading a Haskell tutorial up until the M word would help a lot. But surely there's a lot of good guides written for Rust specifically. tl;dr the core concept you're looking for is sum types, aka discriminated/tagged unions. If you're going "up" from C level abstraction, imagine a C union starting with an enum that indicates which value is there. That's essentially what it is at the memory level (modulo optimizations). But conceptually, you just have a "this OR that" type. Pattern matching is how you access values of that kind of type. https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html