Live data from Hacker News

Learn C, Then Learn Computer Science

qrohlf.com

21–30 of 134 posts

Re: Learn C, Then Learn Computer Science

#21
This article resonated deeply with my own experience. Like Rohlf, I learned to program TI-Basic in middle school, and like him, I've had the ability to see several different teaching paradigms when it comes to computer science.

In the high school computer science courses I was able to take, the programs were relatively simple with an, in my opinion, too-overt emphasis on object oriented programming. It was in java, and very little of the class focused on the "how" aspect of the language.

My first CS courses at university were in Ada. I don't know how many of y'all have programmed in Ada, but I think about it like a wordier C that doesn't let you just get away with shit because it's strongly typed. This was the language we were taught basic control structures in and, to be fair, the way we were taught focused on good styling so that our code would be unreadable mush.

The UNIX class was in C, and it is, in my opinion, the most rigorous course that most of the students will take on their way to the bachelor's degree. The students build, across a series of projects, a shell that can execute commands and run simple scripts. The sorts of problems encountered introduce the students to the nature of C at a very low level, as well as the sorts of structures that can be used to solve practical problems.

Many of the high level more theoretical classes are language-agnostic, and many of the students use either Python or C#. I think that it's good that these higher-level theoretical classes allow us to choose our own language, because I think that the ways in which different programmers attack the same problem might bias them towards one or another language.

Recently, the lower-level classes had their programming language changed. Heeding the argument that Ada wasn't super relevant in the higher-level classes, the faculty changed the language to Python. This was, I think, a mistake. My opinion is that the lower level classes should be taught in C for many of the same reasons Rohlf mentioned. I think it's important that the students have an idea of how their data is being represented on the disk so that they could better understand the costs associated with certain tasks.

The best argument that I heard for Python was that not everybody taking these into classes go on to write the sort of code that requires something fast or efficient. Python makes data processing easy, which is really the most important thing that students should learn in intro-to-programming classes. I'd say this is a fair point.

Re: Learn C, Then Learn Computer Science

#22
post #9

Please don't! Learn Delphi/Object Pascal, Ada, Modula-2, Rust and discover control over memory managerment doesn't require throwing safety out of the window. Performance can be fine-tuned to the 1% hotspots that really require playing dirty tricks. That there are modular systems programming languages with compile times times that leave C to shame. Then cry as you are forced to adopt C to be understood by the rest of…

The problem being, if you show up and all you know is Delphi / Pascal / Ada, you're going to be unemployable.

[I'm a veteran of a ton of Object Pascal, btw. Done some Delphi, too -- it was nice. But.]

In general, pushing a niche language as The One does not do a beginner a service. Delphi has never been more than a niche.

We had a guy at Apple decide to do his project in Oberon. Super smart guy who pretty good work. He wound up getting fired because it wasn't a smart choice for the people around him who had to take over the code.

I don't know why some people over-index on programming language. You use what's appropriate. If you're working alone, do whatever floats your boat. If you're on a team, using the Latest Shiny Thing or The Most Correct Safest Thing may not be the best choice. If you're a student, using your professor's favorite language (we used to call these little pet horrors PL/Prof or PROF-TRAN) outside of the course is probably a bad choice -- you want to learn what the market is, and you need to know what the weak points of your chosen language are.

It's particularly poignant to see "Java only" kids come out of school who are utterly ignorant of memory models, barely know what XOR is, and who can only express themselves in terms of classes and interfaces. There's more to life than that.

Re: Learn C, Then Learn Computer Science

#23

Personally I take a different view: learn a high-level language, use it to study computer science, and if you feel like writing some low-level code go ahead and learn C (though even then, you could probably do better by bootstrapping a compiler for your favorite high-level language and adding some extensions for low-level operations). C is not the best or even a particularly good language to try to learn abstract CS…

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 be used for teaching OOP, C should be used to teach data structures and at least some algorithms. Without hands on memory allocation, you're not really getting a full understanding of how data structures work.

Re: Learn C, Then Learn Computer Science

#24
I think C is a great language to teach someone why all of the CS theory matters. When you write Java, almost everything you do will "work" and it will probably run pretty fast on your Core i7. When you write C you have to be much more deliberate. There's no massive standard library to do arr.sort() for you and you have to really think about how to implement some basic processes that you took for granted. I think C made me a much better Java programnmer because I now understand what the most minimal way to complete a task can be. No more HashMap> once you've played with structs and C arrays.

Re: Learn C, Then Learn Computer Science

#25
post #3

Does any one know of any good self study resources (or online courses) on this subject?

The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie (Kernighan has 2 other good programming books too) and/or look around youtube for tutorials on C. MIT has this online, lecture notes were good enough for me plus K&R book http://ocw.mit.edu/courses/electrical-engineering-and-comput... This is a good course about architecture http://www.nand2tetris.org/course.php

> look around youtube for tutorials on C

This is likely to be horrible advice. I don't doubt that there are good C tutorials on youtube, but there are probably also hundreds of extremely poor tutorials that are seductive and even highly rated because the people rating don't know better.

K&R C is excellent. I don't like overbearing advice, but "Every serious programmer should read K&R C" isn't bad as far as such advice goes.

I don't particularly like the "Learn X The Hard Way" series (maybe it is the right way, but I find it too painful), but there is Learn C The Hard Way [0].

[0] http://c.learncodethehardway.org/book/

Re: Learn C, Then Learn Computer Science

#26
Lots of people confuse learning to code in C with learning how hardware works. Its close in some ways but not all.

EDIT: WOW. I'm amazed at how many people think that C is "how memory works". Just wow. This is one of those things where you're confusing the map for the territory and ascribing value to something because its "hard". C is a fairly high level abstraction for interacting with a computer...i know that everyone has heard that c is close to being assembler...but what you are forgetting is that assembler is also an abstraction over operands. The reason i think its important to point this out is that malloc and free arent magical. Othér techniques are just as valid and the notion of "low level" is misleading. C makes tradeoffs that actually give rise to all of the vulnerabilities and stability problems in all the software that you have ever used. Those tradeoffs are REAL and just because lots of you get this macho nonsense about not using safe collection types everyone on the planet has to deal with malware. So many of you buy your own bullshit at an astonishing level...its really breathtaking to see how many of you cant see the built in assumptions in what you are saying.

Re: Learn C, Then Learn Computer Science

#28
post #24

I think C is a great language to teach someone why all of the CS theory matters. When you write Java, almost everything you do will "work" and it will probably run pretty fast on your Core i7. When you write C you have to be much more deliberate. There's no massive standard library to do arr.sort() for you and you have to really think about how to implement some basic processes that you took for granted. I think C ma…

"There's no massive standard library to do arr.sort() for you and you have to really think about how to implement some basic processes that you took for granted"

Not massive by any means, but the C standard library does include qsort() (quicksort) in stdlib.h

Re: Learn C, Then Learn Computer Science

#29
post #23

Personally I take a different view: learn a high-level language, use it to study computer science, and if you feel like writing some low-level code go ahead and learn C (though even then, you could probably do better by bootstrapping a compiler for your favorite high-level language and adding some extensions for low-level operations). C is not the best or even a particularly good language to try to learn abstract CS…

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 incredibly powerful abstraction, and makes certain programming tasks look and feel extremely natural. If you listen to Stroustrup talk about C++, this is what he tends to highlights about C++, not the advanced features. Those can come later.

C++ has plenty of warts, and I dislike certain parts of it as much as its detractors, but C++ is still an awesome language.

Re: Learn C, Then Learn Computer Science

#30
post #3

Does any one know of any good self study resources (or online courses) on this subject?

I currently follow this course: http://c.learncodethehardway.org/book/

I'm at exercise 19 and enjoy it so far. I think I already learned a lot. It may not suite everybody and I don't even know if it's good, though.

Post reply on HN