Live data from Hacker News

Learn C, Then Learn Computer Science

qrohlf.com

81–90 of 134 posts

Re: Learn C, Then Learn Computer Science

#81

I think we need to break all of this down into at least three entirely separate areas: 1) Computer Science, which is, in my opinion, entirely a subset of mathematics, and should be taught as such. 2) Coding, which is the ability to break a problem down and describe it in a series of simple steps. 3) Craft and application, which is everything about how to use tools, best practices for code architecture, and everything…

The problem here appears when you want to teach #1. You shouldn't do it without also teaching #2 and #3 (isn't that obvious enough?), but #3 is often out, and it seems that there are some people trying to not "lose time" with #2 either.

Re: Learn C, Then Learn Computer Science

#82
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 t…

I'm not sure why, but this comment stuck with me and I kept thinking about it.

Here's an example of where I think learning CS, then programming, helped.

I had written my own JavaScript application framework, called Blossom[0], and I wanted "real physics". I took a look at the various 2D physics ports that had been made to JavaScript, and they all had pretty bad performance. Also, I knew from my work as a filmmaker that "real physics" is actually a pain in the ass, because what you actually want is directable physics that feel real. (Stick with me, I'm getting there...)

So, I took a step back and determined that what I wanted was to be able to use tween curves like normal, but have the actual path that was taken depend on the velocity and/or acceleration of the movement when the user released their finger, yet be "directed" according to the tween curve.

That required doing math, specifically, getting first and second derivatives from your tween curves. Yuck. Except, CS to the rescue, there are these things called Dual numbers[1], and when you use them, you get automatic differentiation[2] for free, without having to rewrite your code.

So I wrote a Dual number implementation for JavaScript, grabbed a JS parser and rewrote the tween functions at load time (i.e. with code, automatically) to use the Dual numbers so that I could extract the velocity and acceleration. I then took the original curve based on the user's movement, blended it with the tween derivatives, and the resulting animations were actually really great. The whole thing was efficient enough to get real time performance on an iPad 3 in mobile Safari, entirely in JavaScript.

And the total time from start of work to the physics-based Dual-number tween animations in Blossom? Two days, and about 2K LOC.

If I hadn't know about Dual numbers, there's no way I'd have gotten there just by sitting down and programming, and who knows how long it took the FB team to do the dynamics for FB Home, or the Apple team to add UI Dynamics to iOS 7. My guess is that it took longer than two days...

[0] https://github.com/erichocean/blossom

[1] http://en.wikipedia.org/wiki/Dual_number

[2] http://en.wikipedia.org/wiki/Automatic_differentiation

Re: Learn C, Then Learn Computer Science

#83
I'm biased, since I taught myself C when I was a teenager. My first language was BASIC (first on the Apple II, then the Amiga.) When I got to high school, they were teaching Pascal on old 8086's. It felt like such a step backwards.

This was back in the early 90's. When I go to college, I was able to opt out of the first couple of intro CS classes (and get credit for them) by taking a test or two.

Re: Learn C, Then Learn Computer Science

#84
post #66

Earlier quoted context omitted.

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

Whoops, I didn't mean to give the impression that C++ guys weren't real programmers. Of course they are. I literally meant "real programmers" as in, anybody who had more experience than I did. I was completely self-taught.

I will probably never touch C++ again. I solve all my problems with Ruby and if I ever need to go lower-level, I'll break out C and maybe Lua.

Re: Learn C, Then Learn Computer Science

#85

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.

Functions don't see arrays, functions see pointers, even if you passed an array. The sizeof a passed array is the sizeof a pointer. So they're not first class.

Re: Learn C, Then Learn Computer Science

#86
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…

While I definitely think everyone should learn C in college, I don't think it should be a first language. I'm currently teaching it in high school, and the amount of pain that goes into something as simple as managing arrays makes it extremely intimidating for students.

I would recommend a language like Python, where simple data structures like lists and dictionaries can be created on a whim, freeing up students to tackle more fun problems.

Re: Learn C, Then Learn Computer Science

#87
Terence Eden was saying the same thing that this post said, which is why I was confused at the contradictory tone in this article. It's vital to a good computer science education to understand pointers at a hardware level, differences between stack and heap variables, etc. It's a tragedy that the students at Lewis and Clark looked at pointers to functions and thought voodoo, but it would also be wrong to only teach them the low level stuff, since there most certainly is enough to fill a college experience with. That being said, the only thing that seems missing at Lewis and Clark was a good introductory course. A good background on what languages are doing behind the scenes, as provided by something like C, is a part of computer science and is necessary for a thorough understanding of the subject.

It just seems like all the issues talked about were computer science issues.

Re: Learn C, Then Learn Computer Science

#88
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…

In my experience those who start bottom-up tend to have a lot more practical sense of how computers work, and thus write simpler, more efficient code than those who went in the other direction; the latter tend to overuse abstraction and create elaborate architectures that result in writing far more code and generating more complexity than is really needed.

Re: Learn C, Then Learn Computer Science

#89
post #70
post #65

Earlier quoted context omitted.

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.

[deleted]

Re: Learn C, Then Learn Computer Science

#90
post #32
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…

I have a similar experience, and agree with your sentiment. I taught myself TI-Basic in the 7th grade. Then when I was really fluent in it and started hitting its limits around the 9th grade (I was mostly interesting in writing real time games), I picked up z80 assembly. Later (10th grade) I wanted to write programs on my computer, I installed Linux and learned C (not that they're related, but the hacker world really…

I agree. I think the ideal is something like 6 months Python/Ruby, 1 year C, then one OOP and one functional language.
Post reply on HN