Live data from Hacker News

Learn C, Then Learn Computer Science

qrohlf.com

71–80 of 134 posts

Re: Learn C, Then Learn Computer Science

#71
post #69

Earlier quoted context omitted.

"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++?

It was a course on data structures, not on the C++ standard library. Referencing counting would have been the wrong thing for the lesson on doubly linked lists -- which was basically the first lesson of the course. "Modern" C++ would not have helped at all for the student who had a function with a missing return statement and a confusing error log.

Frankly, almost none of the C++11 features are actually useful for teaching data structures, and those that are relevant would only confuse students. Basically, only auto and the three kinds of smart pointers are relevant to an introductory data structures course. At the end of the day those would only create as many problems as they solve. For example, unique_ptr means that there is only one "owner," right? Wrong, get() returns a raw pointer to the object, and you can make a new unique_ptr from that. Sure it is easy to avoid -- if you are an expert with lots of C++ experience, who follows coding guidelines and all that. The data structures students had little to no C++ experience and would almost certainly have done what I just described -- and that is just one of many ways they can and will screw up C++11 features.

At the end of the day, C++ is too complicated, too poorly defined, and has all the wrong abstractions for basic CS courses.

Re: Learn C, Then Learn Computer Science

#72
From personal experience, I learned theory and structure first. It took a long time to "get" variables as locations in memory, and I had to relearn it many times.

Harvard (who sends a lot of people on to PhDs) forces everyone to learn C in introductory cs50. I like how they do it. If you don't get "the machine" early it is hard to get it later.

Re: Learn C, Then Learn Computer Science

#73
I come from an EE background, so I learned C and studied various aspects of computer hardware and computer architecture to some relative level of detail before doing any sort of algorithms or software design. Sometimes I wonder what sort of software engineer I'd be if I had gone the other way - studied CS to start off and then descended down the stack later on. Would I be better? Worse? How would I think about problems, and what mental models would I go for first?

Re: Learn C, Then Learn Computer Science

#74
post #73

I come from an EE background, so I learned C and studied various aspects of computer hardware and computer architecture to some relative level of detail before doing any sort of algorithms or software design. Sometimes I wonder what sort of software engineer I'd be if I had gone the other way - studied CS to start off and then descended down the stack later on. Would I be better? Worse? How would I think about proble…

I've wondered the same, but in the reverse direction: by the time I started programming, I had read—not kidding—thousands of papers on computer science, and read hundreds of books.

I just had no interest in coding. (Or math for that matter, though ironically, I also read math books.)

Anyway, I've always wondered if I'm a better or worse CTO for having taken that route. I do know I code much less than my peers, even though (it seems to me) I get much better results with far less coding effort.

Re: Learn C, Then Learn Computer Science

#75
post #2

Don't confuse the strategies :-) Small liberal arts school has a strategy of broad based understanding of theory and the 'art', with graduate school providing the nuts and bolts specialization, large engineering school (USC) has the strategy of maximally skilled in execution of the art with enough theory to be effective. USC will assume that you will go to work right after you get your 4 year degree, Lewis and Clark…

yes, and a significant portion of our famous scientists studied philosophy and then laid the foundations across multiple disciplines some of which many graduate students still don't understand even though they studied them. i know a whole bunch of people are going to argue pro specialization, but i think we need to rethink the way we teach. we've built efficient workhorse factories which we call universities, and som…

   > yes, but the question is, do you need university to tell you that?
Of course not, anyone can tell you that. But knowing who told you what you know, sometimes helps a third party evaluate your statements of knowledge :-)

Re: Learn C, Then Learn Computer Science

#76

Earlier quoted context omitted.

The thing that makes C a good candidate is that it's a very very small language. Yes there are plenty of strange quirks that the experts need to deal with but you can come up with an elegant and compact implementation of every standard data structure. High level languages tend to favor one data structure over another. Starting with those languages can give students the "hammer syndrome" w.r.t. that structure.

Scheme is a small language as well, and it is worlds better for teach abstract concepts. You can write far more elegant and compact implementations of data structures in Scheme than you can write with C. As for preferring one data structure over another, C does that as well: arrays are the only data structure with first-class support.

Scheme is a small language as well, and it is worlds better for teach abstract concepts.

I've heard this claim many, many times, but for me, I find Scheme (and Haskell, for that matter) impossible to work with. I love what Scheme and Haskell do in theory, but in practice, I find them unusable for those things.

With Scheme and Haskell, I find I'm always trying to figure out how I should make the compiler happy, vs. taking an abstract concept that I understand well and just implementing it, which is something I find easy to do with C.

But I also suck at math, and my assumption is that for people who don't suck at math, Haskell and Scheme and all the others are probably easier, and that makes sense to me.

Re: Learn C, Then Learn Computer Science

#77
post #69

Earlier quoted context omitted.

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

It was a course on data structures, not on the C++ standard library. Referencing counting would have been the wrong thing for the lesson on doubly linked lists -- which was basically the first lesson of the course. "Modern" C++ would not have helped at all for the student who had a function with a missing return statement and a confusing error log. Frankly, almost none of the C++11 features are actually useful for te…

So you were basically teaching C? How does C++ come into this discussion at all?

How do you teach a basic data structure course in Python?

Pascal seems like a much better choice for data structures than C or C++. Or you can use Scala and teach functional data structures if you're adventurous ...

Re: Learn C, Then Learn Computer Science

#78
post #57
post #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, a…

Ada's powerful. The typing system is the best of the mainstream imperative languages. You can write good cross-platform code without thinking about endian issues. Almost as fast as C, strong gcc support. It's a shame it's so damn verbose. A fortnight ago I was trying to brainstorm how I could put a tighter syntax on it, possibly with some kind of pre-processor. Ideas welcome!

I can't understand what you're saying about endianness here. If some file format or network protocol has a specific endianness in it, it has a specific endianness in it.

Re: Learn C, Then Learn Computer Science

#79

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 every…

To elaborate on this...

malloc and free aren't even a part of C itself. Other than static (globals and "static" the keyword) and automatic (stack) allocation there isn't any memory management in C itself. malloc and free are library functions wrapping system calls. That's something to do with the operating system - the machine itself has NOTHING like malloc and free.

I and many people know C but know fuck all about assembly programming. (for now)

Re: Learn C, Then Learn Computer Science

#80
post #79

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 every…

To elaborate on this... malloc and free aren't even a part of C itself. Other than static (globals and "static" the keyword) and automatic (stack) allocation there isn't any memory management in C itself. malloc and free are library functions wrapping system calls. That's something to do with the operating system - the machine itself has NOTHING like malloc and free. I and many people know C but know fuck all about a…

P.S: Read "Deep C Secrets - Expert C Programming", and once you've understood the chapter on memory, go back and read the malloc implementation in the back of K & R.
Post reply on HN