Live data from Hacker News

Learn C, Then Learn Computer Science

qrohlf.com

121–130 of 134 posts

Re: Learn C, Then Learn Computer Science

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

that was exactly my experience as a first-year CS student. i had no prior programming experience and CS 101 started with implementing several programs in C. for help i was told "use valgrind" and that was about it. the CS tutors were constantly busy and the class was so big that i couldn't get one on one help, so i had to just spend hours on my own trying to decipher how to dynamically allocate memory without fucking myself. we ended up having a final involving implementing a trivial program in C in front of a TA. my program wouldn't work, yet after trying and trying i couldn't figure out what was wrong with it, so i resigned myself to failing the class and said "i'm done" with a program that didn't run. i had a single syntax error but the implementation was otherwise correct..the professor took pity on me and passed me. had i failed that class i would've said "fuck this" and left CS forever.

Re: Learn C, Then Learn Computer Science

#122
post #92
post #79

Earlier quoted context omitted.

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…

malloc() and free() (not to mention realloc() and calloc()) are part of the Standard C Library, and must be provided for a C compiler to be certified as ANSI compliant. Granted, you don't have to use any Standard C Library functions, but a C compiler must have them (or else, it can't claim ANSI compliance).

I knew they were part of the standard library and the specification -- I mean, even the stdio stuff is, right? -- I had no idea the compiler had any involvement in that, though.

I know gcc provides them for you if you don't specify the right includes, but that's gcc, like.

I think I'm going to go on considering them not technically part of C itself, until I have more information.

Thanks.

Re: Learn C, Then Learn Computer Science

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

The way that C memory management works is a design decision. that design decision had criteria that informed it...it's no more or less valid than other design decisions that are made in the face of other criteria. It's no more "low level" that lot's of other methods that have been/are being used.

ufo got my point. the modern microprocessor is vastly different than the view of the world that is exposed through C. The fact that C still works is more of a testament to hardware designers than it is something "intrinsically true" about C and its design decisions.

Re: Learn C, Then Learn Computer Science

#124
post #40

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…

At this point, the only thing that still keeps C close to the hardware is that they need to keep the hardware close to C model because of all the legacy code in the world. Most recent hardware innovations, like pipelining, speculative code execution, SIMD, etc are not easily expressed in C. Additionally, C was written in a time where accessing the memory was cheap and had a uniform cost - nowadays memory access times…

right on my knowledgeable homie...

Re: Learn C, Then Learn Computer Science

#125

I find the notion of syscalls as the interface to an OS more intriguing than the world according to C. C as it stands may be ubiquitous, but other languages can conceivably be implemented as peers to it (rather than on top of it - it took me far too long to realise that). It's fundamental neither on bare metal nor in the presence of an OS.

Yep, when C was mainly a UNIX only language, there were another ones to choose from.

With UNIXs spread into the enterprise, C started to gain weight.

If UNIX hadn't been successful, it would just be yet another language.

Re: Learn C, Then Learn Computer Science

#126
post #54

Earlier quoted context omitted.

"I think they are both valid approaches." For limited ranges of valid. If you are implementing a low performance requirement CRUD app, certainly you can become an effective programmer without knowing the low level details. But if you want to be an engineer? Good luck. I've worked with people that didn't know the stuff behind C, and they are pretty useless as soon as performance matters, or you need to talk to hardwar…

There are advantages to the other side. Many fascinating developments were made possible by those who prefer to think functionally, as opposed to imperatively. Modern relational database engines are fairly easy to implement once you understand set theory. Lambda calculus has taught me how to create a linked list using nothing but partially applied higher order functions. Software transactional memory was invented in…

If you aren't able to think about both sides, you've got a massive hole in your education.

I'd be willing to bet that the people that came up with software transactional memory were comfortable in C and assembly as well as Haskell, and hadn't bottlenecked themselves with the false dichotomy of thinking functionally vs thinking imperatively.

The world needs people who think mechanically AND at a high level of abstraction at at the same time.

Re: Learn C, Then Learn Computer Science

#127
post #90
post #32

Earlier quoted context omitted.

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.

I also started programming with my TI Calculator and also had a few lessons from my Dad in Pascal. Then in my college, I started with Lisp, then C, then Java. C was definitely the primary language for my college education: Operating Systems, Architecture, Software Development, Compilers. Although C allows you to understand the computer at a low level, I had no intention to get a career in it.

I appreciate C, but wish I learned more high level languages to be more prepared come graduation. C is important to know, but it can also be overemphasized in some colleges.

Re: Learn C, Then Learn Computer Science

#128
post #108

Earlier quoted context omitted.

Ah may I ask which university? Mine also did Ada, then Unix in C, also Scheme thrown in there. Awesome progression, having learned Ada is really nice, it made me aware that there is a better way to do things, even if I never get to use that better way in real life!

That's the thing, many that learn only C think it is the only way to do system level programming.

This is the #1 habit I have to break new developers of! If my team wasn't already so busy I'd hold classes on learning other languages.

The last team I was on held regular classes on F#, I'm sad the team got disbanded before I picked up a significant chunk of the language.

Re: Learn C, Then Learn Computer Science

#129

Earlier quoted context omitted.

C is about as close to teaching the mechanics of the computer as you can get while staying portable. I've found that my ISA knowledge "just works" on any architecture though, so I would feel okay teaching something like C-- or LLVM IR along with an arbitrary ISA to allow the mind to have a lowest-common denominator. CS is to CE as Chemistry is to Physics. Chemistry lets you do a lot with less, but Physics is where yo…

"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.…

> 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)?

I'd say this is an extremely important part of a data structures course.

Say we have an array of integers and a linked list of integers. Which will take less time to iterate through? We all know it's the array, but you have to be aware of how caching works to know that that's the case. Which takes less space in memory? Again, we know it's the array, but you have to understand pointers to know why that's the case. If you only know what a linked list is in the abstract, then you'll have a hard time reasoning about space usage when compared to an array.

These are just a few examples, but there are countless more. It's hard to reason about how the different data structures work in the real world if you don't know how the computer works.

> The reality is that the way computers work "under the hood" is counterintuitive in an extreme sense.

Since when was CS about teaching only what's intuitive?

Re: Learn C, Then Learn Computer Science

#130
post #109
post #57

Earlier quoted context omitted.

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!

> It's a shame it's so damn verbose. When a big part of your job is to read the code from others of various skill levels, one learns to have a soft spot for verbosity.

After reading probably millions of lines of code, I find myself wishing people would learn the difference between verbosity and clarity.

More words do not necessarily lead to clearer, more understandable code.

Post reply on HN