Live data from Hacker News

Rust vs C Pitfalls

garin.io

371–379 of 379 posts

Re: Rust vs C Pitfalls

#371

A more interesting question for me is: is there any reason why would I want to use Rust over Haskell on any task where Haskell is "fast enough"?

Probably not. There's been a lot of work put into Haskell design, and a lot of work put into Rust design.

A stand-out difference is that Rust put a lot of work into the borrow checker. But if a borrow checker is irrelevant (i.e. GC is fast/small enough), there isn't a huge reason.

(To be clear, there are a number of differences, e.g. strict vs. lazy evaluation, but whether one is better than another is debatable.)

Re: Rust vs C Pitfalls

#372
post #266
post #92

Earlier quoted context omitted.

Because Rust is IMHO the first viable replacement for C. Well-written C programs translate almost 1:1 to Rust. It can do (roughly) everything C can, i.e. it's natively compiled, gives control of memory layout, and doesn't depend on a GC runtime. Previous C killers were either dependent on a fat runtime (which isn't a big problem in general, but is a problem for some of niches dominated by C), or didn't offer meaningf…

Easy on the propaganda there. * "First viable replacement for C" - C++ was invented decades before Rust. * "Well-written C programs translate almost 1:1 to Rust" - C programs can be compiled with minimal changes as C++. * "or didn't offer meaningful improvement in safety/concurrency/expressiveness." - C++ offers major improvements in all of those areas. A lot of C programmers don't want to switch to C++ and they won'…

I'm a C programmer who switched to Rust.

Rust is complex because it's powerful.

C++ is complex because it's a mashup of overlapping features from different eras.

I don't write C++, because whatever I write will crash for subtle reasons and I'll be told it's my fault, because of course you don't do this when you use that feature.

I can write Rust with all its complexity, and as long as I get it to compile, I'm confident it works more reliably than any C++ that I could have written.

Re: Rust vs C Pitfalls

#373

Earlier quoted context omitted.

What are you talking about? I don't get people making these posts without any detail whatsoever as to what they're talking about. I have a fully static binary that includes futures, nix, tokio, uuid, and more. Even statically compiled with Muslims it's less than three megs. And if I didn't use the nix package for a setsockopt call, it would be perfectly capable of running on Windows (and I could easily make it cross…

There are more systems than POSIX and Windows. Also, even in popular Linux systems Rust is not even installable in a straightforward way (e.g. Ubuntu 15.10, my system), so go figure. Regarding Rust bloat, I don't know if has got any better recently, but it was crazy bloated in comparison to C.

Do you not consider adding a PPA to be straightforward? Or downloading the rustup binary and simply running it?

Re: Rust vs C Pitfalls

#374

Earlier quoted context omitted.

The Rust community is as great as it is because of very deliberate decisions and investment in engineering structures to maintain a positive community at scale, so I'm pretty optimistic that it will stay really good. Arguably this work is as innovative as the language itself. Emily Dunham of Mozilla has a talk about this Community Automation: https://www.youtube.com/watch?v=dIageYT0Vgg

The rust community is very small so it's easy to 'engineer it' at this phase. Once it gets so large that you have an eternal September it's effectively a complex system that will be very difficult to reason about with any changes resulting in lots of gnarly side effects. Name a large programming community that is pleasant to interact with for newcomers and insiders alike.

One of the distinctive things about Rust community management is how much is literally engineered, and done with software and processes so that it can scale. All of the touch points are designed: the rustup tool manages the installation experience, Cargo the build process and 3rd party dependencies, the RFC process structures online discussion, the This Week in Rust newsletter provides a heartbeat for the community, bots like Bors handle routine interactions, all of the entry points for interacting with other community members display the Code of Conduct, and so on.

It's a level of purposeful design that only the .NET and Go ecosystems approach, and because it's unusual and largely unobtrusive, it's not obvious that this really good, highly productive community is not at all accidental.

I would say that most large programming communities split into multiple communities, so different kinds of folks don't interact as much: the people on the core developer mailing lists are mostly not the same people as on IRC, or on user mailing lists, or working on issues for 3rd party frameworks in GitHub. I can't think of a sub-community that I've had experience with that I would characterize as unpleasant.

Re: Rust vs C Pitfalls

#375
post #322
post #308

You're so wrong that is laughably. That laughably hashing functions are highly specialized implementations for a proposed problem. There is NO MORAL there. I code C for living and if we can use "laughably hashing functions" to gain performance we WILL DO.

> You're so wrong that is laughably. This comment breaks the HN guidelines by being uncivil. Please express your point substantively. If someone else is wrong, show them (and the rest of us readers) how. Then we all learn something. Also, please don't use uppercase for emphasis—that's in the site guidelines too. https://news.ycombinator.com/newsguidelines.html We detached this comment from https://news.ycombinator.co…

please take your life somewhere else.

Re: Rust vs C Pitfalls

#376

Earlier quoted context omitted.

C does have a standard library. It's described in full in the ANSI/ISO/IEC standard for the C programming language, and it's on your system, likely called libc or something along those lines. Anyway, I don't think that's a problem with my concept at all. What I want for Rust, and what I think will eventually be feasible for Rust as the language matures, is a standard that can be shared by compiler writers and Rust pr…

> C does have a standard library. It's described in full in the ANSI/ISO/IEC standard for the C programming language, and it's on your system, likely called libc or something along those lines. What you're describing is the spec and not the implementation. An implementation would be glibc (GNU Libc with open source proprietary extensions) and musl (MIT implementation that strictly adheres to spec). These libraries ar…

I can only attest to my own experiences at various corporations, and those corporations want to thoroughly vet any software platform before targeting it and supporting it for customers.

As to my own concerns (rather than corporate concerns), here's where I'm coming from:

When I wind up choosing C for a particular project, I don't use it because I like it (I don't particularly like C). Typically, I use it because there are three factors I've considered: 1) This particular project needs the low-level access or performance characteristics provided by a systems language, and 2) C is such a language, 3) C is ubiquitous.[1]

The thing is, every platform for the last 25 years or so has had a reliable ANSI C compiler. If the goal of my project is to be cross-platform, then a carefully-written application in standard C is guaranteed to be able to reach the widest number of users, many of whom won't have to do or install anything to build my application, since many environments already include a C compiler without any additional installation necessary (think Unix, BSD, a shrinking number of Linux distros, ...). Using C puts my application on the path of least resistance for potential users.

Similarly, if I'm writing a library, every language with an FFI can trivially access a library written in C. Even without an FFI, most languages can interface with C code through some kind of bindings (like the Lua-C API, for example). Again, choosing C is a path to wide adoption.

Again, I don't particularly like C as a language. However, right now, it has an undeniable advantage as a platform. I do like Rust, however, and I would love to see Rust give C the boot. In order to do that, it needs to eventually (one day when the rate of additions/changes to the language has slowed and it has grown more stable/mature) offer a platform that can be relied on to "just work" on any given platform with minimal fuss and without any sudden changes. As such, both the "end-programmer" and the compiler-writer in me would like to see some version of Rust (again, eventually) that is "set in stone" and widely available, which really would solidify that notion of stability/maturity.

I'm not advocating for Rust to stop innovating. For all I care, the "standard" can be a simple snapshot of some state of the language, the way the Haskell Reports seem to be nowadays: GHC keeps on iterating and innovating the language, yet there's still a standard updated every x years that provides a static target. But for that designated snapshot, I want to see a compiler (or two, or several) and a bunch of libraries that are supported for the long haul.

It's simply a matter of "C has this, it's an important property thereof, and any replacement will need it, too".

[1]: Some other projects demand C because they constitute contributions or extensions of other projects that are already written in C; e.g., kernel code for an existing OS that is written in C.

Re: Rust vs C Pitfalls

#377
post #33

Earlier quoted context omitted.

yeah of course, doing simple programs and checking their time is a good benchmark... oh wait.. also real world performance in bigger programs is mostly different, especially when you deal with big heaps. Btw. this site is extremly bad for benchmarks since it also measure's the startup time of the runtime in java/go/rust.

Rust doesn't have any significant runtime startup cost, but it certainly is an issue for Java (and presumably Go as well).

It is an issue for Java programs that complete in a few tenths of a second. So these do more work than a few tenths of a second.

Re: Rust vs C Pitfalls

#378
post #356

Earlier quoted context omitted.

When someone fully re-implements khash in Rust and publishes the library, that will become a question which merits consideration. Meanwhile, from the task description: Please don't implement your own custom "hash table" - it will not be accepted.

So, the answer is "no, you are not allowed." But you're open to changing that. Got it.

Can't use a library that doesn't exist.

If you want an additional Rust hashmap implementation then you need to persuade the Rust community to provide one in std::collections.

No one is allowed to -- in your words -- "write an entirely custom [hashmap] just for the benchmark".

Re: Rust vs C Pitfalls

#379
post #378

Earlier quoted context omitted.

So, the answer is "no, you are not allowed." But you're open to changing that. Got it.

Can't use a library that doesn't exist. If you want an additional Rust hashmap implementation then you need to persuade the Rust community to provide one in std::collections. No one is allowed to -- in your words -- "write an entirely custom [hashmap] just for the benchmark".

> If you want an additional Rust hashmap implementation then you need to persuade the Rust community to provide one in std::collections.

Again, this means that for Rust, it _has_ to be in the standard library. But C doesn't have one in the standard library. So C gets to write their own, and Rust doesn't.

Post reply on HN