Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's pretty true. However, in C, you can actually write interesting data structures and algorithms that come up in computer science. I think that makes for good "theory meets practice"-based learning.

I'm not saying all algorithms classes should incorporate writing C code all the time. But probably every budding computer scientist or software engineer should take at least one such class.

I'm also not saying C is the only language for which this is true. But it's definitely not generally true for interpreted languages.

Also, C is pretty much the language everything higher-level is implemented in. So once again, at least some exposure to C can help someone conceptualize what's happening on the computer at every level.



Hmm, can you give an example of a typical "learning CS" level algorithm that you can't implement in, say, JavaScript?


Not an algorithm, but used in many. Pointers.


Emulating pointers in JS is pretty easy; you just wrap the values in objects or arrays.


B-Tree indexes in JavaScript


Googling around, I see a number of implementations. What's wrong with them, and why do you feel this is impossible?

(And hint: it's guaranteed not to be impossible since JS is Turing complete)


You could probably implement any of them in JavaScript, but it would be sort of silly, because the actual runtime complexity and memory usage aren't really going to be close to what they "should be" due to the interpreter.

I haven't given it a lot of thought, but I doubt it makes sense to implement "textbook" algorithms and data structures without pointers.


As I said in another thread, you can get the same functionality as pointers by using arrays or objects, which are always passed around by reference.

You're right that this is an inefficient way to implement those algorithms, but I disagree that that makes it silly. The purpose of writing those algorithms is to learn how they work, not to use them in practice. Generally, if you're using them in practice, you shouldn't be rolling your own in the first place.


I like this quote from Knuth: "People who are more than casually interested in computers should have at least some idea of what the underlying hardware is like. Otherwise the programs they write will be pretty weird."

C is only marginally closer to the hardware than other languages, and programmers really should be aware of even lower level concepts, but I think learning C is a hugely useful and relatively digestible step towards really understanding what's going on.


absolutely! C is so widespread that you should be conversant in it as a software practitioner, whether as a programmer shipping code or a scientist making tools and working with others tools.

however you can explore what computer science has to offer without subjecting yourself to C. I think that "computer science" has more to do with "optimizing algorithms for efficiency" and less to do with "staring at stack traces and wondering why gdb is so bad"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: