As someone who felt that C was the path to knowledge for how modern computer systems "work", Forth and QEMU have become my "stretch challenge" for those with the motivation to tinker. For me, working thru the resources on the OSDev wiki by taking jonesforth and linking it with the bootstrap from the "Writing an OS in Rust" tutorial ( https://os.phil-opp.com/ ) really showed me how far C is from the hardware, and how…
Should you learn C to “learn how the computer works”?
361–370 of 381 posts
Re: Should you learn C to “learn how the computer works”?
#362Earlier quoted context omitted.
If a language lets you cause undefined behaviour via FFI into C, I think it's fair to say that that remains a problem created by C. I do take your point about Rust, but I'd see that as deriving from LLVM's undefined behaviour which in turn descends from C; I'm not aware of any pre-C languages having C-style exploding undefined behaviour or of any subsequent languages inventing it independently.
> If a language lets you cause undefined behaviour via FFI into C, FFI isn't into "C", it's into your operating system's binary format. And since no two systems behave the same, it's UB however you look at it.
Most people call that format "the C ABI," and "FFI into C" is short for "FFI via the C ABI."
> And since no two systems behave the same, it's UB however you look at it.
That's not what UB means. It would be implementation defined, not undefined.
Re: Should you learn C to “learn how the computer works”?
#363Earlier quoted context omitted.
So, this post isn't attempting to address the usefulness angle; that's going to be in the two follow-ups. But I'll give you a summary of where I'm going with this, because you were actually in the back of my mind when I was writing this, and I'm interested in your thoughts. First though, this post. The first reason that this is useful is that there are a lot of people out there who believe that C is somehow fundament…
I think if you'd led with the UB thing, the notion of C targeting an abstraction rather than being an abstraction would have been more compelling to me (the perf argument gets back to a place where basically everything in every language is artifacts and leaky abstractions; it's worth visiting but doesn't persuade me in either direction). I guess my issue, even with the whole outline laid out (thanks!), is that while…
Re: Should you learn C to “learn how the computer works”?
#364Earlier quoted context omitted.
You keep talking about Python's problems, and I'm trying to talk about the habits I've noticed C programmers form and are rewarded for, but are bad for Python development. There are literally no habits in your mind that could be good in C but bad in Python?
As I am a veteran C programmer with decades of experience with several years of straight python now, what I see is a people who think they understand how to write complex software but don't grasp the fundamentals. This isn't explicitly a C V Python programmer discussion so much as exposing that Python insulates you from the peculiarities of things like debugging complex problems, writing robust code, good software pr…
This is exactly the problem, and it's actually kind of rare to get an example of what you're talking about to show up in the very comments you're using to explain the problem! Very validating, that is.
For the other folks reading this, imagine trying to work with someone who thinks these things. Imagine how unwilling to change their bad habits they'll be, since they think that because they're good at C means they're good at writing software. Any trouble they run into is the language's fault, not theirs!
Re: Should you learn C to “learn how the computer works”?
#365Earlier quoted context omitted.
There is not really any such thing as "the" C ABI -- different platforms have totally different conventions, even on the same instruction set.
It's shorthand for "the ABI relevant to the current context", which is entirely reasonable.
Re: Should you learn C to “learn how the computer works”?
#366Earlier quoted context omitted.
>It was probably the hardest course of my entire degree, and I ended up taking it twice, Interesting. Did you study at a US univ.? I have not heard of being able to take the same course twice (except via, say, failing a year of the degree and having to repeat the whole year). I did hear that US universities are more flexible in some ways than, say, Indian ones, whose rules are probably based on British ones (maybe on…
I wasn't really ready to take it the first time (freshman spring...), and dropped it before the halfway point so I wouldn't take the hit on my GPA. US colleges are all over the map with regards to how flexible they are about course order, and even between different degree programs at the same school. My alma mater had a somewhat weird trimester schedule and was relatively flexible about offering sections of courses y…
Re: Should you learn C to “learn how the computer works”?
#367As someone who felt that C was the path to knowledge for how modern computer systems "work", Forth and QEMU have become my "stretch challenge" for those with the motivation to tinker. For me, working thru the resources on the OSDev wiki by taking jonesforth and linking it with the bootstrap from the "Writing an OS in Rust" tutorial ( https://os.phil-opp.com/ ) really showed me how far C is from the hardware, and how…
Re: Should you learn C to “learn how the computer works”?
#368One valuable property of C that the author didn't hit, C code is easily translatable into assembler in your head. He kind of misses this point with the virtual machine discussion. Yes C code becomes different types of assembly by platform, but you can look at C and have a clear idea of what the assembly will look like. This is at a really good level for driving intuitions about what the computer is actually doing. Yo…
You are correct though that it is a close as you are going to get compared to many other languages, mostly because they all will make use of GC, vtables and dynamics on almost every line of code which adds noise in generated output or they run behind an interpretter or JIT.
Re: Should you learn C to “learn how the computer works”?
#369C teaches you how a computer works because the C abstract machine is defined such that operations that must be manually performed in assembly language must also be manually performed in C. C doesn't let you write something like: string x = y; ...because to actually create a copy of a string the computer must allocate memory, copy memory, and eventually free the memory. In C each of these steps is manual. Higher-level…
> *operations that must be manually performed in assembly language must also be manually performed in C.*
That's not true and if it were it would defeat the whole purpose of C, being a higher level abstraction than assembly.To give one obvious example, in C i can just call a function, no thinking required. Calling a function in assembly requires manually pushing stuff to the stack and then restoring it again.
Re: Should you learn C to “learn how the computer works”?
#370Earlier quoted context omitted.
As I am a veteran C programmer with decades of experience with several years of straight python now, what I see is a people who think they understand how to write complex software but don't grasp the fundamentals. This isn't explicitly a C V Python programmer discussion so much as exposing that Python insulates you from the peculiarities of things like debugging complex problems, writing robust code, good software pr…
> which is fine given Python is a scripting language at heart This is exactly the problem, and it's actually kind of rare to get an example of what you're talking about to show up in the very comments you're using to explain the problem! Very validating, that is. For the other folks reading this, imagine trying to work with someone who thinks these things. Imagine how unwilling to change their bad habits they'll be,…
What I find generally from Python developers who have lived an breathed the language for many years is that they accept there are fundamental failings and acknowledge the better means to workaround those.
In reading back through your comments, it seems you are blinkered by those with the benefit of working in other languages. In particular, you seem to have hang ups about C which are not clear why.
Perhaps you'd care to explain those.