LWN.net Logo

Why learn C? (O'Reilly Radar)

Why learn C? (O'Reilly Radar)

Posted Jun 28, 2012 18:53 UTC (Thu) by felixfix (subscriber, #242)
Parent article: Why learn C? (O'Reilly Radar)

I have often thought that for programmers, the best first language is assembler / machine language, not because that itself will ever be much used again, but because it teaches the most fundamental constraints on computers, like instructions have variable timing and space requirements, and there are tradeoffs between the two.

I know way too many higher level programmers, including just plain C, who think counting lines of code is a good indication of the speed and size of code. They utterly ignore sub calls and complex multi-level data structures.

Then you get to the object oriented crowd who additionally cannot see any disadvantage to anything object oriented. They cannot articulate any tradeoffs between speed of development vs speed of execution.

I realize good design has little to do with counting cycles and bytes, but there are simply too many programmers who have no comprehension of anything below lines of code. Good design has a practical side too. It's more than just throwing cycles and memory at a problem.


(Log in to post comments)

Why learn C? (O'Reilly Radar)

Posted Jun 28, 2012 20:36 UTC (Thu) by wahern (subscriber, #37304) [Link]

They cannot articulate any tradeoffs between speed of development vs speed of execution.

There's no tradeoff to articulate. The stricter the OOP model, the more both development and execution costs increase. Is this not common wisdom, yet? ;)

Why learn C? (O'Reilly Radar)

Posted Jun 29, 2012 17:27 UTC (Fri) by iabervon (subscriber, #722) [Link]

On the other hand, counting cycles only makes sense for some embedded architectures these days. On x86_64, your speed is going to be most affected by cache misses and pipeline stalls, neither of which you can determine by looking at the assembly. For that matter, you don't even really know how many cycles any particular instruction will take or which instructions may overlap; when you're writing the code, the processors that will end up running it may not have even been selected yet, so you can't know their microarchitecture.

In any case, I think that learning assembly is a terrible thing to do first, but it's a good thing to do before learning algorithms. Assembly would be a good first language for people who are somehow already programmers, but its better for making someone a programmer to pick something that lets you do something practical with only a small amount of effort.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds