Live data from Hacker News

Why Learn to Program in C?

philipbuuck.com

111–120 of 123 posts

Re: Why Learn to Program in C?

#111

C is great. I wouldn't recommend starting programming in C, though. At least not with the standard exercises you see. Get user input, read a file, do this do that with it. Why? the C standard library is full of gotchas and tricks and goofy shit that makes it unsuitable for new programmers. The comp.lang.c FAQ should be standard reading material for anyone taking a C class. Look at all the posts on StackOverflow about…

This is a strawman. The author is not advocating this as a first language: "Learning C is not necessary for everyone, but there are many posts on Reddit and programming forums with authors who feel like they’re missing something, and I wonder if this is part of what they’re looking for."

Yeah, seems to be some confusion of the title. Probably a better title is "Why learn C programming?" The article itself isn't about "Learning to Program with C as a beginning language".

And I don't know how I feel about C as a first language. I don't believe it would be worse than Java, which was the intro course at my Uni, but my first language was BASIC of all things, which is good in some respects as it really is a "Beginners" language, but both C and BASIC could encourage sloppy practices without good instruction and C especially has some gotchas.

Re: Why Learn to Program in C?

#112

Earlier quoted context omitted.

You realize that computers don't literally run C code, don't you? By that argument you should go further and build your own hardware, then write your own OS...you get the point.

I think C is a good choice to stop. I know it's an abstraction itself, but beyond that you get into hardware specifics and often-closed OS code.

> often-closed OS code.

If you use GNU/Linux, OpenBSD, FreeBSD, NetBSD, SmartOS, OpenIndiana, OpenSolaris, etc this isn't a problem.

Re: Why Learn to Program in C?

#113
post #20

Earlier quoted context omitted.

Yeah, but why start with an exceedingly painful one except to needlessly inflict pain and suffering on students. Better to lay the groundwork with a friendlier language, learn the basics, and then move on to the more complicated gottchas (at least in my amateur opinion).

JavaScript has been touted as an intro language, and in some ways it's even quirkier than C.

Recommending JS as intro language is just plainly wrong.

Re: Why Learn to Program in C?

#114

C is great. I wouldn't recommend starting programming in C, though. At least not with the standard exercises you see. Get user input, read a file, do this do that with it. Why? the C standard library is full of gotchas and tricks and goofy shit that makes it unsuitable for new programmers. The comp.lang.c FAQ should be standard reading material for anyone taking a C class. Look at all the posts on StackOverflow about…

I think that if you are going to teach someone the craft of programming (which is different from computer science) -- really teach them, you should follow what I call the Old School Curriculum. The Old School is based on the way many kids learned to program in the 80s, and the 80s version went: first BASIC, then assembly, then Pascal.

The first language you should learn should be a doddle to learn, even if it isn't very powerful. This was BASIC (or sometimes Logo) back in the 80s, but you could probably substitute Python or even Scheme today. This language teaches you concepts like these:

* Computers follow instructions supplied by the programmer

* The instructions have to be carefully worded in order for a computer to follow them (i.e., intro to errors and debugging)

* Arithmetic and mathematical operations a computer can perform

* Computers can remember things (i.e., variables)

* Computers can interact with the world (input and output)

* Computers can make decisions (conditionals and program flow control)

These are the very fundamentals of programming and it's amazing how many people haven't internalized these concepts at a deep level.

You can actually get very far with BASIC -- entire companies have been run with BASIC code. (Software written in and for Business BASIC variants was a major industry back in the 1970s and 1980s.) You can get even farther with Python. But once the learner is ready to go deeper, it's time to begin Phase 2.

The second language you learn should be assembly, which familiarizes the programmer with how a computer actually works at a fundamental level, as well as important concepts like CPU word length, memory addresses (essential for understanding pointers), program call and return (and stacks), etc. You don't have to even complete a large project written in assembly to get the benefits of this low-level, bit-twiddling learning.

Finally, the last language you learn should be Pascal. C or C++ would be today's equivalent. In this phase you synthesize the knowledge of high-level programming, structure, and control flow that you learned during your "BASIC" phase with your low-level understanding of machine details that you learned during your assembly phase. Then, the details of how and why the language works the way it does make much more sense.

So yes, to me it makes total sense to teach C -- as (at least) a third programming language, perhaps after several years of proficiency are acquired in the other two (depending on the student).

Re: Why Learn to Program in C?

#115
post #77

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…

I think there is a bit of a "survivor's bias" in this argument (which I actually hear very often). Many people give up after they first dabble with programming because its too hard or frustrating and C is a particularly unforgiving and restrictive language (and toolchain). The reason I think this is important to point out is that I believe programming knowledge could be more widespread than it is today but unforgivin…

I too think this survivor bias is kind of a key point yes. Also from my experience if I survive a steep learning curve I tend to build an elitarian view of my skills And I have seen this in most developers out their defending whatever it is they do. If you put your blood, sweat and effort into something it will stay with us. (I have seen this attitude also in others during countless flamewars on usenet when discussing the right editors, linux flavors etc, LOL ... and nobody really spends years studying something that was really hard and then gives up on it without defending it. There is just too much (self-)conditioning in the process of acquiring the skill.

In the end people will always choose the tool they're most comfortable with, whether it's the right tool for the job or not. I have no problem with this because, if there are not enough C experts in the team to maintain the project, it would be a good enough reason why a high-level language becomes the "right tool for the job".

Re: Why Learn to Program in C?

#116
post #105

Earlier quoted context omitted.

Yeah exactly a simple language like Python, with simple rules, one way to do a thing, and not the opposite.

What I like the most in python is, until you peek too much below, the curated features that make it small yet expressive: - tiny set of builtins: list, dict, set - literal - slices - small syntax, and canonical indentation - simple mapping between some operators and class methods you have enough to abstract a bit but not too much without drowning in details.

Yeah and another good thing I like about Python, it doesn't force you to do object oriented. A beginner doesn't really need this. Its like if you begin with C, you'll have to deal with pointers early, and that means understanding things like memory, stack and heap allocations, safety, etc... Way too much for a new coder.

Re: Why Learn to Program in C?

#117
post #42

C is great. I wouldn't recommend starting programming in C, though. At least not with the standard exercises you see. Get user input, read a file, do this do that with it. Why? the C standard library is full of gotchas and tricks and goofy shit that makes it unsuitable for new programmers. The comp.lang.c FAQ should be standard reading material for anyone taking a C class. Look at all the posts on StackOverflow about…

"Unsuitable" is far too strong a word. It was ok for generations to follow the K&R examples, and now it somehow suddenly became "unsuitable"? I'd say it's just "somewhat more tricky" and "got a slightly steeper learning curve", that's it.

If you start with C as your first language you're not really starting out by learning how to program, you're starting out by learning how the computer operates.

I'm not saying this is necessarily a bad thing, mind you, but it's important to note the distinction.

Using an analogy; starting out with C is like learning to drive by being told how an internal combustion engine works, and then you're asked to wire up your pedals manually and install a fuel tank of sufficient size before you're allowed to learn how to put the car in gear.

Those are all useful things to know, but you can learn them after you know how to drive, and your knowledge of either topic (driving and automotive engineering) is not in any way impaired by learning it in a different order.

Re: Why Learn to Program in C?

#118
post #42

Earlier quoted context omitted.

"Unsuitable" is far too strong a word. It was ok for generations to follow the K&R examples, and now it somehow suddenly became "unsuitable"? I'd say it's just "somewhat more tricky" and "got a slightly steeper learning curve", that's it.

If you start with C as your first language you're not really starting out by learning how to program, you're starting out by learning how the computer operates. I'm not saying this is necessarily a bad thing, mind you, but it's important to note the distinction. Using an analogy; starting out with C is like learning to drive by being told how an internal combustion engine works, and then you're asked to wire up your…

Why? C is a very high level language. It is not that dramatically different from Pascal, which, in turn, is almost a pseudocode from your algorithm textbooks. You can learn fairly abstract concepts with C without caring at all about how it maps to the hardware.

Re: Why Learn to Program in C?

#119

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…

I agree with this sentiment. In my experience, it's hard enough for a novice to learn to reason through basic control flow (loops, functions, variable assignment).

Over a few years of working as a teaching assistant, I saw two types of students: those that had some prior knowledge and effortlessly picked up the concepts, and first-timers that had to put in serious effort to stay afloat. If you were in the former camp, it's hard to envision how the latter might feel, and why every bit of additional complexity is a menace to someone who's already struggling with frustration over internalizing the basics. If you add too much complexity, the novice becomes discouraged, gives up trying to understand, and simply tries to memorize - this is always catastrophic for them.

As an example, I'm taking about students that write code like:

  if(x == true){
      y = true 
  } 
  else if (x == false){
      y = false
  }

Re: Why Learn to Program in C?

#120

C is great. I wouldn't recommend starting programming in C, though. At least not with the standard exercises you see. Get user input, read a file, do this do that with it. Why? the C standard library is full of gotchas and tricks and goofy shit that makes it unsuitable for new programmers. The comp.lang.c FAQ should be standard reading material for anyone taking a C class. Look at all the posts on StackOverflow about…

Harvard's CS50 begins with C and it's quite successful. Well, technically they begin with Scratch, but the course quickly moves into C. They get around certain barriers (you mention user input) by providing helpers/abstractions, which are gradually torn down as the course progresses.
Post reply on HN