Live data from Hacker News

Switching to C over 'Modern' Programming Languages

devtails.xyz

11–20 of 170 posts

Re: Switching to C over 'Modern' Programming Languages

#11
post #7

Earlier quoted context omitted.

Yep. You think C is "low level", but it was once considered "high level", and the compiler does many things you don't want, and the standard's ambiguously-worded, and implementers have their own interpretations about the ambiguity, and also bugs in their compilers, and you eventually arrive at: "If you really want those instructions to happen in this function, without fear of magic, write them in assembly."

Then you realize that your CPU has hardware bugs, and you go design and manufacture your own CPU :).

“I don’t get much programming done these days, what with all the goat herding…”

Re: Switching to C over 'Modern' Programming Languages

#12
post #9

Don’t expect to see immediate benefit from Rust by writing a small Pong application. Rust gives you confidence at scale: the ability to depend on many 3rd party blocks without compromising stability or performance, the ability to grow and maintain the code, collaborate on it, etc. Nothing of this is easily seen on a small self-contained program you can write in C.

I still cannot figure out how to easily write small applications with Rust on low resource computers, like the one I'm typing this from. (Limited storage, CPU, memory.) It seems even the smallest programs require a massive toolchain. The default reliance on network connection for compilation is offputing. It's vastly easier for me to write small programs, offline, with C.

The rationale for using Rust over C that I see published the most is "memory safety". But I can write small C programs for text-processing using flex that do not manually manipulate memory. What benefit would there be to write them in Rust.

Re: Switching to C over 'Modern' Programming Languages

#13
> There’s just so much “magic” happening in each that it’s difficult to figure out what’s going on. When I’m writing code in these languages, I realize my brain is effectively writing psuedo-C code and then transpiling to whatever language I’m working with.

I feel the same way about these other languages, but for kind of the opposite reason! I write some code in the new language and then transpile it to C in my head just to see what I expect the CPU to be doing. I'm going through SICP right now and I find myself fighting the urge to imagine `cdr` as dereferencing the `next` pointer of a linked list. I spend a lot of time worrying about this stuff when writing other languages, probably to the detriment of my productivity.

Re: Switching to C over 'Modern' Programming Languages

#14

Other than assembly language, all languages embody abstractions. I find understanding certain abstractions hard going because they don't mesh well with my view of the problem domain and my design for solution's implementation.

This is silly. Assembly is an abstraction too. Do you think the CPU actually runs the code you give it? Of course not. There's microcode, register aliasing, speculative execution, etc. Even assembly itself has symbols and labels, which are themselves abstractions.

[deleted]

Re: Switching to C over 'Modern' Programming Languages

#15

Other than assembly language, all languages embody abstractions. I find understanding certain abstractions hard going because they don't mesh well with my view of the problem domain and my design for solution's implementation.

This is silly. Assembly is an abstraction too. Do you think the CPU actually runs the code you give it? Of course not. There's microcode, register aliasing, speculative execution, etc. Even assembly itself has symbols and labels, which are themselves abstractions.

Did you really not understand the point the GP was trying to make or is this an attempt to be clever?

Of course assembly is an abstraction, but it is the lowest level programming language that ordinary mortals can still write code in, which was the point the GP was making.

Exactly nobody writes applications in microcode. Register aliasing and speculative execution have under normal circumstances no effect other than some performance which if the CPU just did as it was told by the assembly code (or actually, the machine code, the binary representation of the possibly optimized assembly) would still work exactly as advertised. You can also switch those off if they're features of the assembler, and if the CPU does them then you're going to have to live with it.

If you really wanted to make the point that Assembly is an abstraction then macros would have probably been a better thing to mention.

Re: Switching to C over 'Modern' Programming Languages

#16
Is this becoming a thing now (or maybe it was always a thing), where a language, like Rust, has become popular enough that instead of everyone talking about learning it, they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist?

Rust exists for a reason, and it solves specific problems. That’s the “magic”, just like any abstraction in any language. So what’s the argument, that abstractions are bad? Clearly not:

> I also haven’t really experienced the problems Rust claims to be solving

This is like hearing someone say 20 years ago that “I’ve heard a lot of good things about PHP but I don’t see the point of it, because I’ve never had to write a web application that interfaces with a database” — well, no shit?

Re: Switching to C over 'Modern' Programming Languages

#17
post #9

Don’t expect to see immediate benefit from Rust by writing a small Pong application. Rust gives you confidence at scale: the ability to depend on many 3rd party blocks without compromising stability or performance, the ability to grow and maintain the code, collaborate on it, etc. Nothing of this is easily seen on a small self-contained program you can write in C.

I still cannot figure out how to easily write small applications with Rust on low resource computers, like the one I'm typing this from. (Limited storage, CPU, memory.) It seems even the smallest programs require a massive toolchain. The default reliance on network connection for compilation is offputing. It's vastly easier for me to write small programs, offline, with C. The rationale for using Rust over C that I se…

That's a point I was trying to make multiple times - that C (apart from O/S code and drivers) is used for small command line utilities and language runtimes of higher-level languages. Nobody (except maybe game devs) wants to develop fat application server binaries or other long running server apps in C++ or other non-GC'd environments (due to memory fragmentation issues alone if not other things). And for a language runtime, you can't use Rust's memory safety guarantees either. This leaves Rust for what it was originally invented - browser engines and fat desktop apps.

Re: Switching to C over 'Modern' Programming Languages

#18

Other than assembly language, all languages embody abstractions. I find understanding certain abstractions hard going because they don't mesh well with my view of the problem domain and my design for solution's implementation.

This is silly. Assembly is an abstraction too. Do you think the CPU actually runs the code you give it? Of course not. There's microcode, register aliasing, speculative execution, etc. Even assembly itself has symbols and labels, which are themselves abstractions.

The difference is that a CPU does way less magic under the hood than an optimizing compiler for a high level language, and there's no such thing as UB in assembly (outside some exotic cases like 'illegal' instructions on the 6502 which behave unpredictably)

Re: Switching to C over 'Modern' Programming Languages

#20
post #9

Don’t expect to see immediate benefit from Rust by writing a small Pong application. Rust gives you confidence at scale: the ability to depend on many 3rd party blocks without compromising stability or performance, the ability to grow and maintain the code, collaborate on it, etc. Nothing of this is easily seen on a small self-contained program you can write in C.

I still cannot figure out how to easily write small applications with Rust on low resource computers, like the one I'm typing this from. (Limited storage, CPU, memory.) It seems even the smallest programs require a massive toolchain. The default reliance on network connection for compilation is offputing. It's vastly easier for me to write small programs, offline, with C. The rationale for using Rust over C that I se…

Why would you write small apps in rust? Just use go. It's perfect for I've written more in C than in any other language (and I've written in dozens of languages professionally over the past 25 years). But the one thing that gets hammered home with every line of C I write is this: You're playing with a loaded gun.

The more code there is, the more likely it is that you have subtle heisenbugs that break in mysterious ways. My current job requires C (for a number of good reasons), and I really notice the jump in crazy, hard-to-track bugs despite my DECADES of experience as a careful, expert C programmer.

C is "simple" because all of the complexity gets pushed to the compiler behaviour and runtime environment. You don't even discover how many assumptions you've been making until you have years of experience under your belt.

Post reply on HN