Live data from Hacker News

I stopped everything and started writing C again

kmx.io

141–150 of 475 posts

Re: I stopped everything and started writing C again

#141
post #19
post #4

[flagged]

Rust has three major issues: - compile times - compile times - compile times Not a problem for small utilities, but once you start pulling dependencies... pain is felt.

Long compile times with Rust don't really bother me that much. If it's someone else's program that I just want to build and run for myself, the one-time hit of building it isn't a big deal. I can be patient.

If it's something I'm actively developing, the compile is incremental, so it doesn't take that long.

What does often take longer than I'd like is linking. I need to look into those tricks where you build all the infrequently-changing bits (like third-party dependent crates) into a shared library, and then linking is very quick. For debug builds, this could speed up my development cycle quite a bit.

Re: I stopped everything and started writing C again

#142
post #18
post #4

[flagged]

That really depends what you want to do. All that security in Rust is only needed if there is a danger of hacks compromising the system. The moment you start building something that's not exposed to the internet and hacking it has no implications, C beats it due to simplicity and speed of development .

> All that security in Rust is only needed if there is a danger of hacks compromising the system.

It's not just about security, it's about reliability too. If my program crashes because of a use-after-free or null pointer dereference, I'm going to be pissed off even if there aren't security implications.

I prefer Rust to C for all sorts of projects, even those that will never sit in front of a network.

Re: I stopped everything and started writing C again

#143
post #88
post #46

Try zig, it is C with a bit of polish.

Why zig and not Rust? Just to throw the question out there :-)

Zig is a much simpler language than Rust. I'm a big Rust fan, but Rust is not even close to a drop-in replacement for C. It has a steep learning curve, and often requires thinking about and architecting your program much differently from how you might if you were using C.

For a C programmer, learning and becoming productive in Zig should be a much easier proposition than doing the same for Rust. You're not going to get the same safety guarantees you'd get with Rust, but the world is full of trade offs, and this is just one of them.

Re: I stopped everything and started writing C again

#144
post #127

I'm kinda in the opposite camp. After doing a bunch of VB in my tweens and teens, I learned Java, C, and C++ in college, settling on mostly C for personal and professional projects. I became a core developer of Xfce and worked on that for 5 years. Then I moved into backend development, where I was doing all Java, Scala, and Python. It was... dare I say... easy! Sure, these kinds of languages bring with them other pro…

I think Rust is harder to learn, but once you grok it, I don't think it's harder to use, or at least to use correctly. It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall`. Rust's normal error messages are delightfully helpful. For example, I just wrote some bad code and got:

    --> src/main.rs:45:34
     |
  45 |         actions.append(&mut func(opt.selected));
     |                             ---- ^^^^^^^^^^^^ expected `&str`, found `String`
     |                             |
     |                             arguments to this function are incorrect
     |
  help: consider borrowing here
     |
  45 |         actions.append(&mut func(&opt.selected));
     |
I even had to cheat a little to get that far, because my editor used rust-analyzer to flag the error before I had the chance to build the code.

Also, I highly recommend getting into the habit of running `cargo clippy` regularly. It's a wonderful tool for catching non-idiomatic code. I learned a lot from its suggestions on how I could improve my work.

Re: I stopped everything and started writing C again

#145
post #72

Despite what some people religiously think about programming languages, imo C was so successful because it is practical. Yes it is unsafe and you can do absurd things. But it also doesn't get in the way of just doing what you want to do.

No, it's because of Unix and AT&T monopoly.

Monopoly of the long distance telephone call market??

Re: I stopped everything and started writing C again

#146
post #127

I'm kinda in the opposite camp. After doing a bunch of VB in my tweens and teens, I learned Java, C, and C++ in college, settling on mostly C for personal and professional projects. I became a core developer of Xfce and worked on that for 5 years. Then I moved into backend development, where I was doing all Java, Scala, and Python. It was... dare I say... easy! Sure, these kinds of languages bring with them other pro…

I think Rust is harder to learn , but once you grok it, I don't think it's harder to use , or at least to use correctly. It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall`. Rust's normal error messages are delightfully helpful. For example, I just wrote some bad code and got: --> src/main.rs:45:34 | 45 | actions.append(&mut func(opt.selected)); | ---- ^^^^^^^^^^^^ expe…

> I think Rust is harder to learn, but once you grok it, I don't think it's harder to use, or at least to use correctly. It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall`.

When I say Rust is harder to use (even after learning it decently well), what I mean is that it's still easier to write a pile of C code and get it to compile than it is to write a pile of Rust code and get it to compile.

The important difference is that the easier-written C code will have a bunch of bugs in it than the Rust code will. I think that's what I mean when I say Rust is harder to use, but I'm more productive in it: I have to do so much less debugging when writing Rust, and writing and debugging C code is more difficult and takes up more time than writing the Rust code (and doing whatever less debugging is necessary there).

> Also, I highly recommend getting into the habit of running `cargo clippy` regularly. It's a wonderful tool for catching non-idiomatic code.

That's a great tip, and I usually forget to do so. On a couple of my personal projects, I have a CI step that fails the build if there are any clippy messages, but I don't use it for most of my personal projects. I do have a `cargo fmt --check` in my pre-commit hooks, but I should add clippy to that as well.

Re: I stopped everything and started writing C again

#147

This reads like a cautionary tale about getting nerdsniped, without a happy ending.

" I was gaining a lot of money with Ruby on Rails

Then, I decided to move to Common Lisp and start gaining less and less money

Then, I decided to move to C and got Nerd Snipped "

Well, atleast he seems more happy xD

C is cool though

Re: I stopped everything and started writing C again

#148

Earlier quoted context omitted.

Rust is not free of trade offs and you're not helping the cause the way you think you are. Just a few off the top: - Rust is a much more complex language than C - Rust has a much, much slower compiler than pretty much any language out there - Rust takes most people far longer to "feel" productive - Rust applications are sometimes (often?) slower than comparable C applications - Rust applications are sometimes (often?…

Many of these are false? * Rust is vastly easier to get started with as a new programmer than C or C++. The quality and availability of documentation, tutorials, tooling, ease of installation, ease of dependency management, ease of writing tests, etc. Learning C basically requires learning make / cmake / meson on top of the language, and maybe Valgrind and the various sanitizers too. C's "simplicity" is not always he…

Sorry bud.

Neither of our opinions make someone else's opinion false.

- Rust may have felt easier for you or some, but certainly not everyone or even most. It might be worth it, but it's not an easy on ramp for many.

- Excuses for slow compile times don't make compile times faster.

- That's why I said "feel." There are warm fuzzy and cold prickly human things in here. Studies that pretend at measuring something we all know cannot be measured are summarily dismissed.

- More excuses do not make a statement false. Rust compile times are some of the slowest I have seen in >25 years of development.

Again, the trade-offs work for many people and orgs. That's great!

That doesn't make them disappear or become, "false."

It's precisely this tone and attitude (that is so prevalent in the community) that keeps so many of us away.

Re: I stopped everything and started writing C again

#149
post #32

Earlier quoted context omitted.

Rust is not free of trade offs and you're not helping the cause the way you think you are. Just a few off the top: - Rust is a much more complex language than C - Rust has a much, much slower compiler than pretty much any language out there - Rust takes most people far longer to "feel" productive - Rust applications are sometimes (often?) slower than comparable C applications - Rust applications are sometimes (often?…

> Rust is a much more complex language than C Feature wise, yes. C forces you to keep a lot of irreducible complexity in your head. > Rust has a much, much slower compiler than pretty much any language out there True. But it doesn't matter much in my opinion. A decent PC should be able to grind any Rust project in few seconds. > Rust applications are sometimes Sometimes is a weasel word. C is sometimes slower than Ja…

This is a fair response! Thank you. We can disagree on these things and I'd still gladly buy you a beer.

Re: I stopped everything and started writing C again

#150
post #8

I started programming with C a long time ago, and even now, every few months, I dream of going back to those roots. It was so simple. You wrote code, you knew roughly which instructions it translated to, and there you went! Then I try actually going through the motions of writing a production-grade application in C and I realise why I left it behind all those years ago. There's just so much stuff one has to do on one…

> Similar to C, but with much more help from the compiler with all sorts of things. Is that not the problem rust was created to solve?

Indeed. I'm still not entirely sure why Rust was created when we have Ada, but if I had to guess it's mainly because Rust has slightly more advanced tricks for safe memory management, and to some degree because Rust has curly braces.
Post reply on HN