Live data from Hacker News

I stopped everything and started writing C again

kmx.io

351–360 of 475 posts

Re: I stopped everything and started writing C again

#351

What's the best way to learn C? Any good modern book recommendations, or sites?

I highly recommend Zed Shaw's "Learn C the Hard Way": https://learncodethehardway.org/c/

I worked through this and felt well-prepared to actually use C in anger when I had to.

Re: I stopped everything and started writing C again

#352
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…

Lately I've been paying interest in D being from PERL/TCL background. Rust, Python, Go just feel tainted to me.

https://dlang.org

Re: I stopped everything and started writing C again

#353

About a year ago, I had gotten fed up with what felt like overlyb strict context requirements basically giving me to abandon years of work and thought I'd try my hand at C++ again. I wanted to do this on Linux, because I my main laptop is a Linux machine after my children confiscated my Windows laptop to play Minecraft with the only decent GPU in the house. And I just couldn't get past the tooling. I could not get th…

The last time I was writing C professionally I used ceedling (https://www.throwtheswitch.org/ceedling) and I highly recommend it. I hate cmake too. :-)

Re: I stopped everything and started writing C again

#354
post #4

[flagged]

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 applications are sometimes (often?) slower than comparable C applications

Could you cite some examples? There are plenty of counter-examples

- ripgrep is 5-10x faster than grep (https://github.com/BurntSushi/ripgrep/blob/962d47e6a1208cf21...). There's a reason ripgrep is embedded within VS Code to power search.

- Memory-safe implementations of PNG (png, zune-png, wuffs) now dramatically outperform memory-unsafe ones (libpng, spng, stb_image) when decoding images. (https://www.reddit.com/r/rust/comments/1ha7uyi/memorysafe_pn...)

- The Rust implementation of GNU Coreutils compares favourably in performance. For example, uutils/sort outperforms coreutils/sort by 6x while working on every mainstream OS - Linux, FreeBSD, NetBSD, OpenBSD, Illumos, Redox, Android, macOS, and Windows.(https://lwn.net/Articles/1007907/)

- Android rewrote their IPC code (Binder) from C to Rust. The Rust version is within +- 1-2% of the C version (https://www.phoronix.com/news/Google-Linux-Binder-In-Rust).

- rustls outperforms OpenSSL and BoringSSL (https://www.memorysafety.org/blog/rustls-performance-outperf...)

- zlib-rs is the fastest implementation of zlib (https://www.phoronix.com/news/Zlib-rs-0.4.2)

- Advent of Code - The one C example I saw executed the first 10 days of 2024 in 36ms (https://www.reddit.com/r/adventofcode/comments/1hbcyhz/comme...), while my idiomatic Rust solutions (https://github.com/nindalf/advent) took 10.1ms. I'm not even that good, there are Rust solutions 10x faster than mine - https://github.com/maneatingape/advent-of-code-rust.

- I don't consider the benchmarks game a worthwhile comparison because they're only writing assembly, but Rust and C are comparable in speed (https://benchmarksgame-team.pages.debian.net/benchmarksgame/...)

So yes, I'm surprised by your claim of C programs "often" outperforming comparable Rust programs, but I'd be interested to know if even the "sometimes" is true. Please share if you've found any.

The other claims are questionable as well, but this one was the most easily disproven.

Re: I stopped everything and started writing C again

#355
I started writing C code again because i started using gstreamer and needed to write a modem plugin for ModemManager. This meant i had to get familiar with glib. Even thought the learning curve has been steep it been worth and I am really enjoying writing in C again, even going so far as to refactor some existing code of mine use glib and make it GObject based. The end goal here is to use gir to use my code from scriptable languages like python.

Re: I stopped everything and started writing C again

#356
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…

Lately I've been paying interest in D being from PERL/TCL background. Rust, Python, Go just feel tainted to me. https://dlang.org

Dlang is a clean langauge. Unfortunately it never got the attention it deserves.

Re: I stopped everything and started writing C again

#357
post #241
post #221

Earlier quoted context omitted.

This is objectively nonsense

Interesting use of the word 'objectively' there.

Not really.

I have written a lot of C and Rust. The notion that identical projects written in both languages would have identical numbers of (or even severity of) bugs is laughable on its face.

I mean, literally just not being able to deref a NULL pointer by itself is enormous.

Re: I stopped everything and started writing C again

#358
post #213

Earlier quoted context omitted.

I'm over here with TTS: Underlining in a terminal rarely translates to audio. It isn't the only consideration that needs to be made, when making things clear.

except nobody has to cater to every worst case scenario

I am sure the Rust community would welcome feedback from blind developers about their error messages. Accessibility is a good thing.

Re: I stopped everything and started writing C again

#359
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…

Writing user-facing applications in Swift and dropping to C and C++ when required seems to give the best of both worlds. For me the main benefit of C and C++ is the availability of excellent and often irreplaceable libraries. With a little bridging work, these tend to just work with Swift.

Swift seems like an excellent language, but I can't shake the feeling that it's just not worth learning unless you're writing code on and for Apple's ecosystem.

Re: I stopped everything and started writing C again

#360
Without reading the comments here, I read the blog entry first.

After I finished I was puzzled, "what is the author trying to communicate to the reader here?"

As near as I can determine, enough people weren't using the author's program/utility because it was written in a language that hasn't been blessed by the crowd? It is hinted at that there might be issues involving memory consumption.

The author does not write lessons learned or share statistics of user uptake after the re-write.

No new functionality was gained, presumably this exercise was done as practice reps because the author could do it and had time.

No argument was made that the author has seen the light and now only C from this point on.

Post reply on HN