News for hackers. Stuff that matters.
Re:Speed of Rust vs. C by Lvl999Noob on Saturday March 13, 2021 @04:18AM (#26445231)
The author did say that there is nothing that Rust does that C cannot. The difference is that in Rust, those things are easier, or many times, the default way, while in C, you would have to take care of way too many things to make sure things work.
Re:Speed of Rust vs. C by rbanffy on Saturday March 13, 2021 @05:17AM (#26445523)
I used to say that wrt to memory leaks with Java and C++ and it remains true when comparing C and Rust:

It's not that it's easier to write programs in [Java|Rust]. It's that it makes it much harder to write the bugs.

Re:Speed of Rust vs. C by rocqua on Saturday March 13, 2021 @06:14AM (#26445829)
Yesterday I upgraded an entire code-base from C to C++ just because it was faster than writing my own dynamically resizing array in C.

Writing programs in C is harder just because there are essentially no containers in the stdlib.

Re:Speed of Rust vs. C by JohnStrangeII on Saturday March 13, 2021 @06:26AM (#26445872)
Aren't there good container libraries for C?
Re:Speed of Rust vs. C by ben0x539 on Saturday March 13, 2021 @08:03AM (#26446274)
There are a lot of great libraries for sure, but they aren't in the stdlib and C doesn't make it as easy to use external libraries as languages with modern tooling. Everybody gets grumpy about dependencies and a lot of people probably figure it's easier to maintain their own container code in their application than to deal with that.
Re:Speed of Rust vs. C by rocqua on Saturday March 13, 2021 @08:36AM (#26446453)
They are either based on void * with performance issues, or macro based with weird ergonomics that look like function calls, but aren't.

It's doable, but not very easy.

Re:Speed of Rust vs. C by cb321 on Saturday March 13, 2021 @09:06AM (#26446647)
You are right in a library-demographical sense, but not in a fundamental sense. There is a 3rd way. Have a look at the CTL I linked to (downvoted..maybe I should have explained more?).

Once you give up the closed source/prebuilt binary library idea and embrace the C++-like header library idea and write implemenations in terms of "assumed macro/inline function" definitions, the problem becomes straightforward with no performance issue and different ergonomics issues than you probably think.

It's a more "manual instantiation" than C++ templates or generics in other languages where just refering to them works, but most of C is quite manual. So, it fits the headspace & the hard parts of data structures/meddlesome hands remain factored out. Since you parameterize your files/code with #define/#include, you have to name your parameters which can make the instantiating client code more obvious than C++ templates with many arguments. OTOH, there is no/poor type checking of these parameters.

Re:Speed of Rust vs. C by rocqua on Saturday March 13, 2021 @02:19PM (#26449120)
I had a look, and it feels like template programming but with even worse guarantees.

Having a type declaration dependent on #define P whether it is plain old data or not, and needing to know what that means, is not the kind of ergonomics I'd want. That requires learning a whole new paradigm to ensure I am not doing wrong things.

In my mind it is so big an extension of the C language, that it leaves the C headspace and becomes its own headspace.

Re:Speed of Rust vs. C by cb321 on Sunday March 14, 2021 @07:34AM (#26454486)
Yeah. It's not for everyone. I think "different ergonomic issues" may cover that and I did mention the type checking already. :-)

It is a smaller learning curve from pure C than "all of Rust" or even "all of C++/STL". You got the basic idea in short order (that may be for ill as well as good..I was never trying to make a normative claim).

Re:Speed of Rust vs. C by cb321 on Saturday March 13, 2021 @06:38AM (#26445928)
Re:Speed of Rust vs. C by scorpion95 on Saturday March 13, 2021 @04:48AM (#26445395)
Yes.

But it’s not just taking care of those things that must be done; it seems to bloat the code.

I think it’s a great alternative to C for large apps like Firefox, and perhaps it’s a good alternative to Go for services.

For general purpose, I personally want something fast that’s easy, clear, and concise like Ruby.

Do I just accept that Rust is the most evolved version of C, or is my gut correct that it’s bloated? Is it a good choice for general purpose as-is?

Re:Speed of Rust vs. C by hderms on Saturday March 13, 2021 @09:04AM (#26446639)
As someone who's worked predominantly in high level languages (Scala, Ruby, etc...) I've found Rust to be relatively straightforward to use for simple CLI tools or gRPC servers (tonic library is pretty nice). I haven't tried building a CRUD app yet, but I don't see any real reason why it would be impossible to have an ergonomic web framework in Rust.

The things I find most difficult: 1. Wrangling with the borrow checker can be painful before you know what you're doing (and even afterwards) but if you understand the standard library/patterns well, it seems to minimize the cost. Example being trying to write your own `get_or_else_insert` style method for a HashMap. Writing your own version is easy in other languages but hard in Rust. If you didn't know that methods like that already exist on HashMap you will experience a lot of pain until you understand the "right" way to do something.

2. Shared memory concurrency is definitely at the nexus of all the more difficult parts of Rust. Especially with async/await. There's no question in my mind that if you want to write a webserver that has async functions accessing shared memory, that you will for sure need to fill in any gaps in your knowledge as it will be difficult to get to a working program without understanding significantly more concepts than what it might take for a simple single-threaded CLI app

I'm pretty sure that it will be possible (if it isn't already) to get the Rust ecosystem to a state where writing a CRUD app is about as simple as in Go (and considerably easier/more ergonomic w.r.t certain things like JSON serialization).

Re:Speed of Rust vs. C by anfilt on Saturday March 13, 2021 @05:35AM (#26445617)
Firefox's is compiled code is mostly written in C++ not C. You conflate C with C++, Java, and C#. C++ while has source compatibility with C tends to end up much different than C. C will not give you the OOP hell-scape you can dig yourself into with those three languages. C code tends be simpler and much more close to the assembly that will be generated than you would get in those language. Moreover, Java and C# are not even compiled. Anyways C != C++. C++ has changed quite a bit since it's earlier days and has diverged from plain C in a lot of ways. Some people even feel C++ keeps adding too many new features too fast.
Re:Speed of Rust vs. C by eru on Saturday March 13, 2021 @08:18AM (#26446349)
> Some people even feel C++ keeps adding too many new features too fast.

It's not so much that they keep adding features, but that they (almost?) never remove any.

Re:Speed of Rust vs. C by pjmlp on Saturday March 13, 2021 @12:49PM (#26448293)
Python 3 has shown the world what happens when that is done without bringing the ecosystem along.
Re:Speed of Rust vs. C by eru on Sunday March 14, 2021 @01:15AM (#26453209)
Haskell has also removed some features over time.
Re:Speed of Rust vs. C by pjmlp on Sunday March 14, 2021 @04:18AM (#26453608)
Haskell or GHC?

If you mean GHC, the language version is whatever the pile of configuration flags at each source file ends up meaning, some of them even contradict themselves.

Great for language research, which is Haskell main purpose in life, hardly a good idea for getting industry love.

Re:Speed of Rust vs. C by eru on Sunday March 14, 2021 @07:36AM (#26454500)
I am talking about Haskell, specifically the removal of 'n+k patterns' and 'monad comprehensions'.

About GHC: I think their approach with pragmas is great and something for other languages to emulate. It's also great in production, with the caveat that you might want to restrict that mechanism to surface level changes only, and nothing that changes the intermediate format.

Re:Speed of Rust vs. C by anaerobicover on Saturday March 13, 2021 @01:47PM (#26448850)
Are there many other programming languages that remove features?
Re:Speed of Rust vs. C by eru on Sunday March 14, 2021 @01:16AM (#26453212)
Python 3 made some backwards incompatible changes. Haskell removed some features over time, as well.
Re:Speed of Rust vs. C by ttt0 on Saturday March 13, 2021 @06:50AM (#26445971)
> C++ while has source compatibility with C

It doesn't really, some things from C won't compile in C++, but that's a minor nitpick

Re:Speed of Rust vs. C by ben0x539 on Saturday March 13, 2021 @08:05AM (#26446290)
I guess people mostly take source compatibility to mean that you can write the headers for your C library so that it can be used from C++. That's not the same thing as C being a proper subset of C++ or whatever, but it's still a vast enough advantage of C++ over most competitors that it might as well be.
Re:Speed of Rust vs. C by DJBunnies on Saturday March 13, 2021 @05:38AM (#26445636)
Ruby is not fast.
Re:Speed of Rust vs. C by Can_Not on Saturday March 13, 2021 @10:04PM (#26452429)
But if you want something between rust and ruby, checkout crystal (garbage collected, strongly typed with inference, llvm binary, ruby-like syntax, fast like golang).