Live data from Hacker News

Why Learn to Program in C?

philipbuuck.com

71–80 of 123 posts

Re: Why Learn to Program in C?

#71
post #2

I'm surprised that people have managed to get through a CS program without learning C (or, at least, C++)! It seems to me that programming should be taught simultaneously in Haskell (or Lisp?) and C. - C teaches you how computers work. - Haskell teaches you how programming logic works.

> - C teaches you how computers work.

Except it doesn't. If any language "teaches you how computers work", its assembly. While a lot of the quirks of C's design compared to more "pure" structured programming languages (e.g., Pascal) reflect a desire to provide more direct access to common low-level features of systems of the time when C was introduced, it doesn't really teach you how computers work except insofar as trying to understand its quirks might motivate some inquiry into how computers work.

Re: Why Learn to Program in C?

#72

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…

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…

>> C isn't just hard for beginners because of the language but the rest of the tool-chain.

I can agree with this, if not moreso the fact that you also have to learn the underlying system when you learn C.

For example, I 'learned' C from Greg Perry's "C Programming in 12 Easy Lessons". I was 11 or 12 years old at the time, had played around with a few other languages, but I knew C was the language video games were written in, so I wanted to learn C.

Part of the reason I wanted to buy that book was because it came with a compiler, Borland C++ 1.0. The book was also only $29.99 and was at a store in town. You'd be learning how to use functions like fscanf() but they never covered the details of 'when things go wrong'. You're missing some bytes, your file is incorrect, DOS does this while UNIX does that... You learn just enough to get you in trouble.

Sure, one book can't teach you everything, but it wasn't quite enough to give you a real good understanding of how C worked.

http://www.amazon.com/C-Programming-12-Easy-Lessons/dp/06723...

I eventually bought a game programming book and started to learn all the 'hard' stuff that I didn't even dream about when I first started. x86 interrupts, accessing joysticks and sound cards, writing to video memory...

All of this can be solved to a point by dumbing it down and using libraries. You still have to make sure you've got things like pointers down, though. You don't quite have to worry about that stuff with say, QuickBASIC or Turbo Pascal.

Re: Why Learn to Program in C?

#73
post #9

Until not too long ago, De Anza College still taught C as an introductory programming language (I think because some recently retired instructors wrote a textbook on it). Even now, from what I've seen of the syllabi online, their C++ course that replaced it is still mostly C with some sprinkling of classes added on. I thought it was a horrible idea, and I had a pretty miserable experience at De Anza. If you're just s…

I agree. When starting out with programming, the most important aspect to learn about is the program logic. Syntax and implementation details that are not strictly necessary just get in the way and are likely to confuse students. Once you're comfortable writing algorithms, then you can move onto languages with more complex syntax and features. That said, you could do a lot worse than C for an introductory programming…

My university used Scheme (a Lisp derivative) as the first programming course language, and these were some of the reasons why I found that an excellent choice.

Some other points being that most people start on the same level, and functional languages allowing the construction of many concepts that are not part of the language itself.

Re: Why Learn to Program in C?

#74

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…

>> A language like Python has very little quirks that will stump a person coding for the first time in their life

Python is great but some of the things I've come across:

  Why do some keywords use parenthesis and others don't?
  What's this Python 2/3 hubbub all about?
  What are __INIT__ and __MAIN__?
  Why do I see single, double, and triple quoted strings?
  What does the u prefix mean in u"Hello World"?

Re: Why Learn to Program in C?

#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 its own benefits.

BTW: How many of you started learning natural numbers not from counting fruits/blocks/candies, but from the ZF set theory axioms and the von Neumann construction?

Re: Why Learn to Program in C?

#76
post #36

Earlier quoted context omitted.

I started with C and it took me 3 good years fooling around with other languages too to get a "good" understanding of C. Better learn with higher level languages indeed...

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.

Re: Why Learn to Program in C?

#77

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…

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 unforgiving beginning languages tend to weed out people who aren't as familiar with computers as we are.

Re: Why Learn to Program in C?

#78
post #57
post #50

Earlier quoted context omitted.

> a healthy dose of Hennessy's book Most any CS book seems to have been written in C, Java, C++ and lately, Python. Are there books on computer architecture, algorithms, compilers, whatever written in Scheme?

I have no idea what you're talking about. Are you interested in finding such a book? Do you try to refute any of my points? If so, which one?

I am not refuting. I was actually asking if there are CS books written in Lisp. Almost any CS book I've seen relies on C, C++ or something along those lines.

> Are you interested in finding such a book?

Yes.

Re: Why Learn to Program in C?

#79
post #50
post #5

Earlier quoted context omitted.

C doesn't really tell you how computers work, a healthy dose of Hennessy's book and an accompanying lecture works much better than learning C. But C has immense cultural value. Lots and lots of extant source code, important source code: Linux. The BSDs. PostgreSQL, SQLite, whatever. C is the lingua franca. "Everybody" speaks at least a little C, so it can be used as pseudocode notation (without learning some specific…

> a healthy dose of Hennessy's book Most any CS book seems to have been written in C, Java, C++ and lately, Python. Are there books on computer architecture, algorithms, compilers, whatever written in Scheme?

> Most any CS book seems to have been written in C, Java, C++ and lately, Python.

There are plenty of CS books where the code targets Scheme, another Lisp, or another functional language (e.g., ML or Haskell.)

Re: Why Learn to Program in C?

#80
post #50
post #5

Earlier quoted context omitted.

C doesn't really tell you how computers work, a healthy dose of Hennessy's book and an accompanying lecture works much better than learning C. But C has immense cultural value. Lots and lots of extant source code, important source code: Linux. The BSDs. PostgreSQL, SQLite, whatever. C is the lingua franca. "Everybody" speaks at least a little C, so it can be used as pseudocode notation (without learning some specific…

> a healthy dose of Hennessy's book Most any CS book seems to have been written in C, Java, C++ and lately, Python. Are there books on computer architecture, algorithms, compilers, whatever written in Scheme?

University textbooks with Scheme/Racket as a primary language for examples/exercises:

- Structure and Intepretation of Computer Programs (SICP), used for decades in MIT’s introductory CS course: https://mitpress.mit.edu/sicp/

- Picturing Programs: http://picturingprograms.com/

- How To Design Programs: https://en.wikipedia.org/wiki/How_to_Design_Programs

- Programming Languages: Application and Interpretation: http://cs.brown.edu/~sk/Publications/Books/ProgLangs/2007-04...

Post reply on HN