Live data from Hacker News

Why Learn to Program in C?

philipbuuck.com

91–100 of 123 posts

Re: Why Learn to Program in C?

#91
post #85
post #75

C is an abstraction. Assembly is an abstraction. Even physical transistors are abstractions. You can go down the ladder as deep as you wish, there is no bottom. (Sure, you can delude yourself you that X is the fundamental level of Y... as long as you define Y properly.) In this grand scheme of things, C is not better than Python. I don't mean the we should avoid going deeper. I mean that each level of abstraction has…

>How many of you started learning natural numbers not from counting fruits/blocks/candies, but from the ZF set theory axioms Ha ha, good one. I don't even know what the ZF set theory is. Not putting down theory either in general or in this case, of course.

Zermelo-Fraenkel set theory, an axiomatic set theory that basically forms a logical "foundation" for math. I think this comparison of counting blocks to zf set theory is super hyperbolic and not accurate though.

Re: Why Learn to Program in C?

#92

Earlier quoted context omitted.

My first language was C and I loved it. Maybe it takes a certain type of mindset and tenaciousness (madness?) that will put up with the gotchas. It was exactly those gotchas that got me hooked though. It was similar gotchas that made me love Linux the terminal, vi etc ... The argument that one "should study other languages before they're fit to learn C" is terrible IMO and somewhat condescending. It's like saying one…

It sounds to me like you haven't spent much time trying to teach a class to program. Most introductory courses these days focus on trying to teach students to understand how to solve problems (usually to some degree agnostic of language) and then how to turn their solution into code. The largest mental leap seems to be with the former, and using C as a starting language makes the latter unnecessarily difficult compar…

>Most introductory courses these days focus on trying to teach students to understand how to solve problems (usually to some degree agnostic of language) and then how to turn their solution into code.

The "to some degree agnostic of language" part has been available for a long time in computers, initially as flowcharts and later as pseudocode.

>and b) has the right mindset to properly frame their ideas at the low level c operates at, C could be a good starting language

That requires prior knowledge and practice more than a mindset, IMO.

Re: Why Learn to Program in C?

#93

Earlier quoted context omitted.

My first language was C and I loved it. Maybe it takes a certain type of mindset and tenaciousness (madness?) that will put up with the gotchas. It was exactly those gotchas that got me hooked though. It was similar gotchas that made me love Linux the terminal, vi etc ... The argument that one "should study other languages before they're fit to learn C" is terrible IMO and somewhat condescending. It's like saying one…

Learning to program is about solving problems using a computer. Any programming language allows this, however some languages make it harder than others, and C is in that category. A language like Python has very little quirks that will stump a person coding for the first time in their life; in C they'll wonder "what does int main(int argc, char argv) mean?", "why is there a & before my variable in a scanf but not in…

>in C they'll wonder "what does int main(int argc, char argv) mean?

They'll only wonder that if the book / course / instructor teaching them C, does NOT explain it to them. Which would be more of a reflection on said book / course / instructor than on the C language or the students.

Re: Why Learn to Program in C?

#94
post #76

Earlier quoted context omitted.

Which languages ? How common is it for people to get better understanding by travelling in other programming cultures ? My personal experience goes this way but I rarely hear it.

I'm not the parent poster but in my opinion, any language that doesn't frustrate the beginner is fine. The most important thing for learning is practice and if that is not fun people will end up quiting to do something else.

I hesitated to say that, but to me the most important part is paradigm and structures/patterns. lisp will teach you untyped tree recursion and metalevel perspective. ml/haskell will teach you typed composition. prolog goal based space exploration. forth stacks. APL arrays. C/Pascal etc are supposed to teach you 'imperative' but I believe imperative is mostly a conflation of lots of things, mutable state.. at best you'll learn state machines.

Re: Why Learn to Program in C?

#95
post #85

Earlier quoted context omitted.

>How many of you started learning natural numbers not from counting fruits/blocks/candies, but from the ZF set theory axioms Ha ha, good one. I don't even know what the ZF set theory is. Not putting down theory either in general or in this case, of course.

Zermelo-Fraenkel set theory, an axiomatic set theory that basically forms a logical "foundation" for math. I think this comparison of counting blocks to zf set theory is super hyperbolic and not accurate though.

Thanks. Will look it up.

Re: Why Learn to Program in C?

#96
post #84

Ugh, while I 100% agree that learning C (or similar lower level language) should be a prereq for any programming job, the use of the K&R C book is idiomatic of what is wrong with C. To many people pick up that book and try to emulate what they read. I firmly believe that book will teach you every bad habit you should never use in actual practice. 30 years ago, many of those "tricks" made sense given the compilers and…

> hardware support for base+displacement addressing Not sure exactly what you mean by the "hardware support" part, unless it is machine instruction support of some kind for C syntax. (But I thought that a basic level of support for that was present in most processors - things like base + offset addressing mode, indirect addressing via the value in a register, etc.) But: a[i] is equivalent to star(a + i) in C. (The K&…

> Not sure exactly what you mean by the "hardware support" part,

Yes I should have been clearer, and said no penalty or minimal penalty, support for base+offset address calculation. A fair number of machines a couple decades ago, had additional latency or throughput penalties for addressing modes that required address calculation. This is still true in some cases for more complex calculations. So the use of pointer arithmetic was in many cases noticeably faster than using array syntax even though they are functionally the same. This was also partially due to the compilers not being smart enough (or not having enough registers) to dedicate one explicitly for the resulting address (and using register indirect) if the programmer was using a base[offset] calculation.

For example, the ARM I'm using at the moment has a 1 cycle latency penalty for certain scaled displacements. This means that if your looping over an array of 16 bit ints it will be faster to use a pointer to the integers if the compiler fails to increment the index by 2 and instead uses a (base+offset * 2) load/store. This means the compiler has to be fairly smart about code that uses the index's absolute value as well as its "offset" value in an array.

(BTW the particular ARM in question does base+offset*4 or 8 at full speed).

Re: Why Learn to Program in C?

#98
post #29

Earlier quoted context omitted.

I don't think the author is arguing everyone should use c for everything. He is arguing that everyone should write something in c so that they understand the abstractions they use better. Abstraction is great because it let's you build your conceptual structure atop a virtual foundation, but your structure will be more grounded and therefore more sound if you learn to connect your understanding of the virtual foundat…

Yep, exactly. Abstractions help make us more productive, but if we don't understand what it is they're actually abstracting, I believe they're limiting us, not enabling us.

I'll toast to that. No, I was talking about the "Handmade Manifesto" that you linked to, which seemed to say that high-level abstractions are EVIL.

Re: Why Learn to Program in C?

#99

Earlier quoted context omitted.

In no particular order any of the following as an introductory language. Ruby -- puts "Hello World" Python -- print "Hello World" Lua -- print("Hello World") Personally I wish every programmer would eventually learn C. Getting down to that low level and really understanding how things work is important, but if it is the first language I think we would end up with a whole lot less programmers as many would give up ear…

Ruby is written in C Python is written in C Lua is written in C

I don't write Python in C /s

You meant Ruby, Python and Lua have their reference implementations written in C. They all also have other implementations written in other languages.

Re: Why Learn to Program in C?

#100
post #76

Earlier quoted context omitted.

I'm not the parent poster but in my opinion, any language that doesn't frustrate the beginner is fine. The most important thing for learning is practice and if that is not fun people will end up quiting to do something else.

I hesitated to say that, but to me the most important part is paradigm and structures/patterns. lisp will teach you untyped tree recursion and metalevel perspective. ml/haskell will teach you typed composition. prolog goal based space exploration. forth stacks. APL arrays. C/Pascal etc are supposed to teach you 'imperative' but I believe imperative is mostly a conflation of lots of things, mutable state.. at best you…

I agree with you but I think paradigms are more of a "second" language problem than a "first language" problem.
Post reply on HN