News for hackers. Stuff that matters.

tmewett

Re:Everything I wish I knew when learning C on Wednesday November 30, 2022 @06:49AM (#33799465)
Thank you :) Though I should say, most of the code is by the original author Brian
Re:Everything I wish I knew when learning C on Monday November 28, 2022 @12:39PM (#33776656)
Hah, "unnecessarily abstract" is my middle name :)

I don't really like stack/heap terminology. "Heap" especially is a nightmare because (a) it also means some specific, irrelevant kind of data structure and (b) there's so many ways of implementing allocation it feels wrong to call it "the" anything.

Function variables are deleted after return, allocated stuff isn't - no need to know about stack pointers, etc. It's good enough for me!

But it's really interesting to hear from other programmers who learned things in the historical order. I suppose I come from a new generation where abstractions are first, and I wrote this article for them, really.

Re:Everything I wish I knew when learning C on Monday November 28, 2022 @12:20PM (#33776374)
>C does a wonderful job of looking like a high level language but it was designed to do low level stuff. There is an implicit assumption, to my mind, that the user has a deeper understanding of what is behind the "curtain" that is created by the compiler.

Lots of people say this, indeed several comments here talk about learning assembly before C being beneficial.

I actually think this is not true, today. In its original incarnation C may have mapped closely to instructions, but the details of e.g. x86 are IMO neither necessary nor particularly useful knowledge. Knowing what memory is like and how stuff is laid out is enough.

C is not just a super-thin layer to the bare metal. By "integers are cursed," I mean exactly that: C integers are cursed. The arithmetic behaviours that standard C defines for integers are error-prone and in many cases undefined. C is a layer and it has its own behaviour, it doesn't just expose your CPU.

Re:Everything I wish I knew when learning C on Monday November 28, 2022 @10:58AM (#33775197)
I didn't learn computer science at college/university - only via the internet, and C is quite different to learn that way vs other languages. That was my main motivation for writing :)
Re:Everything I wish I knew when learning C on Monday November 28, 2022 @10:42AM (#33774950)
Thank you so much! I will definitely be amending a few things. WRT no section on undefined behaviour - you're so right, how could I forget?
Re:Everything I wish I knew when learning C on Monday November 28, 2022 @10:40AM (#33774919)
Completely agree - that's exactly why I wrote this. Some of things I wrote even seem super obvious but with no real authority you wonder whether or not this is "the way" to do things. If you ever want to get some practical experience, we'll help you out if you want to contribute to Brogue :)
Re:Everything I wish I knew when learning C on Monday November 28, 2022 @10:35AM (#33774856)
Interesting, I didn't fully realise that. That it's arbitrary is annoying, I clearly had tried to rationalise it to myself! Thanks for the comments, will get around to amending
Re:Everything I wish I knew when learning C on Monday November 28, 2022 @10:27AM (#33774762)
Ah, that was one of my less considered additions - thank you for the feedback!