Live data from Hacker News

Learn C, Then Learn Computer Science

qrohlf.com

61–70 of 134 posts

Re: Learn C, Then Learn Computer Science

#61
I would argue C is a difficult first language. It's even a difficult 2nd or 3rd language.

I would start people off programming at a higher level of abstraction and once they can do that dive into how things work. You could start the other way but it may be too theoretical and discouraging.

Pascal used to be the language of choice and IMO can still work well. Things got more complicated when we got all those competing paradigms and now you have a matrix of language/paradigm. Should you teach OO? Functional? Procedural?

I also think it's important to lay our some theoretical foundations as you're teaching the first language. You don't want to overdo it but you need to start building some basic ideas, notations, concepts. As long as it doesn't get in people's way in their ability to actually build something...

If you want to understand how computers work there's no substitute for programming in assembler, preferably, under different hardware architectures.

This debate about how to teach programming/CS/software engineering is endless. Different people and different schools have different goals and different capabilities. A well rounded software engineer definitely needs to have a good mix of theory and practice. A CS researcher needs a different perhaps mix.

Re: Learn C, Then Learn Computer Science

#62
post #29
post #23

Earlier quoted context omitted.

C++ and C are completely different beasts. C is an elegant clean small language with few distracting elements, making it very suitable for a teaching language. C++ is a grotesquerie more suitable for a carnival horror show than something you want to introduce to new programmers. Unfortunately at some point, teaching OOP became all the rage in schools, and so C++ is chosen instead. That's a mistake, Java or C# should…

> C++ is a grotesquerie more suitable for a carnival horror show than something you want to introduce to new programmers. I bought into this previously after hearing it constantly repeated, but don't anymore. Your point about OOP is fair, but I think there is a sane subset of C++ that is incredibly useful for teaching new programmers. One thing to be avoided is needless OOP hierarchies. User-defined types are an incr…

I think the same way. Nowadays I jump between JVM and .NET ecosystems.

For me C was just one year transition between Turbo Pascal and C++, back in the mid-90's. Only used it for university assigments and on my first job. Otherwise when the option is reduced to C vs C++, I always pick C++.

For me, C was too litle when comparing with what Turbo Pascal offered me. Luckly I discovered C++ shortly after learning C.

Re: Learn C, Then Learn Computer Science

#63

Earlier quoted context omitted.

"C is about as close to teaching the mechanics of the computer as you can get while staying portable" Why is it important to teach the underlying mechanics of a computer in a data structures course, or an algorithms course, or really anything beyond OS or computer architecture courses (and perhaps a compilers course)? The reality is that the way computers work "under the hood" is counterintuitive in an extreme sense.…

I agree with you except for your use of cryptography as an example. In anything dealing with security, unfortunately the nitty-gritty implementation details wind up mattering as much (if not more) than the theoretical portion. Most cases of crypto failing are not examples where the algorithm is flawed (or outdated), but rather where the implementation is weak. Any course on crypto needs to address both algorithms in…

> In anything dealing with security, unfortunately the nitty-gritty implementation details wind up mattering as much (if not more) than the theoretical portion.

Specially if buffer exploits and pointer misuses are to be taken into account.

Re: Learn C, Then Learn Computer Science

#64
post #61

I would argue C is a difficult first language. It's even a difficult 2nd or 3rd language. I would start people off programming at a higher level of abstraction and once they can do that dive into how things work. You could start the other way but it may be too theoretical and discouraging. Pascal used to be the language of choice and IMO can still work well. Things got more complicated when we got all those competing…

C is an excellent 2nd language. The language itself is obtuse, but the underlying model is fairly simple. C++ is a horrible one. These days, probably nobody should learn C++ and should probably pick up Go instead.

As a teenager, I picked up a book on C++ having already learned BASIC, Pascal, and MS-DOS but never got proficient in it. I should have picked C. The "++" lead me to believe that it was a better language than C and I didn't have any real programmers around to tell me otherwise.

Oh the missed opportunities...

Re: Learn C, Then Learn Computer Science

#65
post #56

I'm not convinced that these things need to be mutually exclusive. In the CS department at my university, the only language used for the first 3 years is C. But all of the courses are split in to a "lecture" and "lab" component. In lecture you learn about Computer Science; you learn data structures, algorithms, computational complexity, graph theory, proofs, summations, stats, combinatorics, etc. In lab you learn Pro…

And how did that work? I'm just trying to imagine those first year students staring at those segmentation faults or trying to decipher some other non-intuitive C behaviour (promotion rules, = vs. ==, pointer arithmetics, various implicit rules). Talk about being thrown into the deep end of the pool to swim...

When a language like Pascal is taught as a first language students can focus on the mechanics of their algorithms rather than struggling with language oddities and machine architecture. I think that's important for new programmers to be able to focus on the flow and mechanics without worrying about other details. Once you get that you can "advance" to things that leak more of the underlying architecture into your program. There are probably many other languages that fit that bill.

EDIT (replying to jkrems): E.g. in C if(a=1) assigns 1 to a. I think some modern compilers at least warn on this but they didn't use to and it's perfectly legal. You can't do this in Pascal. You can still make a mistake but you'll get a compiler error. This is a very common mistake for beginners...

Re: Learn C, Then Learn Computer Science

#66
post #61

I would argue C is a difficult first language. It's even a difficult 2nd or 3rd language. I would start people off programming at a higher level of abstraction and once they can do that dive into how things work. You could start the other way but it may be too theoretical and discouraging. Pascal used to be the language of choice and IMO can still work well. Things got more complicated when we got all those competing…

C is an excellent 2nd language. The language itself is obtuse, but the underlying model is fairly simple. C++ is a horrible one. These days, probably nobody should learn C++ and should probably pick up Go instead. As a teenager, I picked up a book on C++ having already learned BASIC, Pascal, and MS-DOS but never got proficient in it. I should have picked C. The "++" lead me to believe that it was a better language th…

C++ has many followers but it's a multi-headed beast and some of it can be much harder to grasp. I think it's easier to argue that it's better than C; all you need to do is to look at C code that tries to implement some patterns that are more naturally expressed in C++. Go isn't really a substitute for C++ but one might argue D is.

Sounds like C++ and you didn't quite work out. I'd still encourage trying to figure out how some pieces of C++ can improve your C code and use those. You're welcome to stick to C in the rest of your code. A lot of "real programmers" do use C++ successfully and a lot of software you use has C++ in it's DNA...

EDIT: (That said I would only expose new students to C++ after they've seen C and some higher level language so they can appreciate the niche that it fills)

Re: Learn C, Then Learn Computer Science

#67
Good stuff. However, I don't think that "learning to code," ins being used in the same sense that Terence Eden meant. I think what Quinn Rohlf is trying to say is, "Learn how computers work." And what Eden is trying to say is, "Learn how to be logical." And for a hat trick of HNs submissions, what Andrew Wulf is trying to say over at thecodist.com is that in general you should just, "Learn how to keep learning."

Taken as a sum of collective knowledge, I think everyone is right in this case. I think the general idea people are trying to get at is this: 1. To work in technology, you must love learning. (Don't get steamrolled). 2. To work in technology, you should know how computers really work. (Learn about C.) 3. Working in technology is not about learning where to but the curly brackets. It's about learning how to think logically. (Learn Computer Science.)

In this sense, I think a great way to get started is by working on a project that you love and in a medium you love. Then as you start hitting limits, descend to C and learn algorithms.

Re: Learn C, Then Learn Computer Science

#68
In my time as a CS student, I've never needed to use C nor understand its syntax to get through my classes. I think you're confusing the necessity of learning C with understanding how a computer works, and the two are not the same.

I think the most useful class I took that explained this (in my sophomore year) was a class on digital logic and micro-architecture. Just about every school I know teaches some class like this early on in your education (at least teaching the basics -- gates, latches, flip-flops, adders, etc.) In mine, it even carried up through some basic assembly code. This class gave me enough to know how computers are working at a fundamental level to be able to use that to my advantage when implementing projects.

Lastly -- you're getting a CS degree, not a programming degree from a vocational school. Does everyone who researches... quantum computing, or natural language processing, or graph theory have to know and communicate in C? I think there are other pursuits beyond programming that you get from a CS degree, and to say it's necessary to learn C pivots your school closer to a vocational school. Not that that's bad -- it's just different than what you signed up for.

Re: Learn C, Then Learn Computer Science

#69
post #23

Earlier quoted context omitted.

C++ and C are completely different beasts. C is an elegant clean small language with few distracting elements, making it very suitable for a teaching language. C++ is a grotesquerie more suitable for a carnival horror show than something you want to introduce to new programmers. Unfortunately at some point, teaching OOP became all the rage in schools, and so C++ is chosen instead. That's a mistake, Java or C# should…

"C++ is a grotesquerie more suitable for a carnival horror show than something you want to introduce to new programmers." In my experience TAing an undergrad course that used C++, almost all of the things that left students scratching their heads were things that are present in C. No garbage collector, no built-in way to determine array sizes at runtime, no way to determine if a pointer has already been deallocated,…

Did you teach standard library container classes? reference counted pointers? Doesn't sound like it. So did you really teach C++?

Re: Learn C, Then Learn Computer Science

#70
post #65
post #56

I'm not convinced that these things need to be mutually exclusive. In the CS department at my university, the only language used for the first 3 years is C. But all of the courses are split in to a "lecture" and "lab" component. In lecture you learn about Computer Science; you learn data structures, algorithms, computational complexity, graph theory, proofs, summations, stats, combinatorics, etc. In lab you learn Pro…

And how did that work? I'm just trying to imagine those first year students staring at those segmentation faults or trying to decipher some other non-intuitive C behaviour (promotion rules, = vs. ==, pointer arithmetics, various implicit rules). Talk about being thrown into the deep end of the pool to swim... When a language like Pascal is taught as a first language students can focus on the mechanics of their algori…

Can you elaborate what you mean by "= vs. =="? Since you mention Pascal I'm guessing that you'd say ":=" and "=" would be better, but since the general model of math is different from procedural code, I'm not sure that's an uncontested truth. I learned Pascal in high school and ":=" was confusing to more people than "==", even among first time programmers.
Post reply on HN