TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Learn C, Then Learn Computer Science

145 pointsby qrohlfover 11 years ago

30 comments

betterunixover 11 years ago
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 concepts with, professors who choose it are needlessly stressing out their students, and at the end of the day you can learn a lot more about algorithms and data structures when you are not busy worrying about pointers or trying to avoid the things that &quot;everyone knows to avoid&quot; (except people keep failing to do so).<p>I say this as someone who watched the catastrophic results of trying to use C++ as a language to teach data structures. It is far more important to be able to think abstractly than to know how to deal with pointers.
评论 #7206983 未加载
评论 #7207813 未加载
评论 #7206820 未加载
评论 #7206817 未加载
ChuckMcMover 11 years ago
Don&#x27;t confuse the strategies :-) Small liberal arts school has a strategy of broad based understanding of theory and the &#x27;art&#x27;, 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 may be assuming you&#x27;re going to have at least another 2 years of work on your master&#x27;s degree to get those bits in order.<p>In my experience, learning how the computer worked made it easier for me to learn to program it. My wife, was much more an algorithmic thinker and could care less if this variable was in a register or not, and focused on how things flowed through the program. I think they are both valid approaches.
评论 #7207729 未加载
评论 #7207559 未加载
评论 #7220228 未加载
anaphorover 11 years ago
&quot;The psychological profiling [of a programmer] is mostly the ability to shift levels of abstraction, from low level to high level. To see something in the small and to see something in the large.&quot; -- Don Knuth
pjmlpover 11 years ago
Please don&#x27;t!<p>Learn Delphi&#x2F;Object Pascal, Ada, Modula-2, Rust and discover control over memory managerment doesn&#x27;t require throwing safety out of the window. Performance can be fine-tuned to the 1% hotspots that really require playing dirty tricks.<p>That there are modular systems programming languages with compile times times that leave C to shame.<p>Then cry as you are forced to adopt C to be understood by the rest of the world.
评论 #7206969 未加载
UNIXgodover 11 years ago
Lean C when you need to grok how memory works in computing. Learn Scheme to grok the science of computing. Learn BSD when you want to understand operating systems and the network stack. Grok engineering when you write a scheme-&gt;c translator running on BSD.
评论 #7207734 未加载
评论 #7206856 未加载
habosaover 11 years ago
I think C is a great language to teach someone <i>why</i> all of the CS theory matters. When you write Java, almost everything you do will &quot;work&quot; and it will probably run pretty fast on your Core i7. When you write C you have to be much more deliberate. There&#x27;s no massive standard library to do arr.sort() for you and you have to really think about how to implement some basic processes that you took for granted. I think C made me a much better Java programnmer because I now understand what the most minimal way to complete a task can be. No more HashMap&lt;String, ArrayList&lt;Object&gt;&gt; once you&#x27;ve played with structs and C arrays.
评论 #7207071 未加载
Kapuraover 11 years ago
This article resonated deeply with my own experience. Like Rohlf, I learned to program TI-Basic in middle school, and like him, I&#x27;ve had the ability to see several different teaching paradigms when it comes to computer science.<p>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, and very little of the class focused on the &quot;how&quot; aspect of the language.<p>My first CS courses at university were in Ada. I don&#x27;t know how many of y&#x27;all have programmed in Ada, but I think about it like a wordier C that doesn&#x27;t let you just get away with shit because it&#x27;s strongly typed. This was the language we were taught basic control structures in and, to be fair, the way we were taught focused on good styling so that our code would be unreadable mush.<p>The UNIX class was in C, and it is, in my opinion, the most rigorous course that most of the students will take on their way to the bachelor&#x27;s degree. The students build, across a series of projects, a shell that can execute commands and run simple scripts. The sorts of problems encountered introduce the students to the nature of C at a very low level, as well as the sorts of structures that can be used to solve practical problems.<p>Many of the high level more theoretical classes are language-agnostic, and many of the students use either Python or C#. I think that it&#x27;s good that these higher-level theoretical classes allow us to choose our own language, because I think that the ways in which different programmers attack the same problem might bias them towards one or another language.<p>Recently, the lower-level classes had their programming language changed. Heeding the argument that Ada wasn&#x27;t super relevant in the higher-level classes, the faculty changed the language to Python. This was, I think, a mistake. My opinion is that the lower level classes should be taught in C for many of the same reasons Rohlf mentioned. I think it&#x27;s important that the students have an idea of how their data is being represented on the disk so that they could better understand the costs associated with certain tasks.<p>The best argument that I heard for Python was that not everybody taking these into classes go on to write the sort of code that requires something fast or efficient. Python makes data processing easy, which is really the most important thing that students should learn in intro-to-programming classes. I&#x27;d say this is a fair point.
评论 #7207091 未加载
评论 #7209634 未加载
评论 #7207806 未加载
YZFover 11 years ago
I would argue C is a difficult first language. It&#x27;s even a difficult 2nd or 3rd language.<p>I would start people off programming at a higher level of abstraction and once they can do that dive into how things work. You could start the other way but it may be too theoretical and discouraging.<p>Pascal used to be the language of choice and IMO can still work well. Things got more complicated when we got all those competing paradigms and now you have a matrix of language&#x2F;paradigm. Should you teach OO? Functional? Procedural?<p>I also think it&#x27;s important to lay our some theoretical foundations as you&#x27;re teaching the first language. You don&#x27;t want to overdo it but you need to start building some basic ideas, notations, concepts. As long as it doesn&#x27;t get in people&#x27;s way in their ability to actually build something...<p>If you want to understand how computers work there&#x27;s no substitute for programming in assembler, preferably, under different hardware architectures.<p>This debate about how to teach programming&#x2F;CS&#x2F;software engineering is endless. Different people and different schools have different goals and different capabilities. A well rounded software engineer definitely needs to have a good mix of theory and practice. A CS researcher needs a different perhaps mix.
评论 #7209204 未加载
评论 #7207914 未加载
mathattackover 11 years ago
From personal experience, I learned theory and structure first. It took a long time to &quot;get&quot; variables as locations in memory, and I had to relearn it many times.<p>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&#x27;t get &quot;the machine&quot; early it is hard to get it later.
NAFV_Pover 11 years ago
&gt; <i>This semester I used function pointers in an assignment and later heard them described as “Quinn’s magic C voodoo”.</i><p>I still think I have to polish up on &#x27;em:<p><pre><code> #include &lt;stdio.h&gt; #include &lt;ctype.h&gt; &#x2F;&#x2F; int chk_arg(char *s, int (*f)(int)) { while(*s) if(!(f(*s))) return 1; else ++s; return 0; } &#x2F;&#x2F; char *s[]= { &quot;1048leet576&quot;, &quot;numbers only pls\n&quot; }; if(chk_arg(*s, isdigit)) printf(*(s+1)); </code></pre> &gt; <i>This was confusing - my classmates were juniors and seniors who were 3+ years into a computer science degree, yet many of them didn’t seem to have an understanding of how computers worked. They could write high-level code and analyze algorithms, but had never used malloc.</i><p>What the hell, CS students who haven&#x27;t used malloc? I&#x27;ve got no formal background in CS, yesterday I wrote a binary search tree in C that passed valgrind.
评论 #7207175 未加载
gwu78over 11 years ago
To truly appreciate C I think having to program in assembly first helps.<p>I say learn assembly first, then learn C.<p>Then do whatever you want.
评论 #7207199 未加载
gpczover 11 years ago
Joel Spolsky wrote a good article about this called &quot;Back to Basics&quot; (src: <a href="http://www.joelonsoftware.com/articles/fog0000000319.html" rel="nofollow">http:&#x2F;&#x2F;www.joelonsoftware.com&#x2F;articles&#x2F;fog0000000319.html</a> ). My favorite quote from it (capitalization modified) is, &quot;If you want to teach somebody something well, you have to start at the very lowest level. It&#x27;s like Karate Kid. Wax on, wax off. Wax on, wax off. Do that for three weeks. Then knocking the other kid&#x27;s head off is easy.&quot;
was_hellbannedover 11 years ago
I think we need to break all of this down into at least three entirely separate areas:<p>1) Computer Science, which is, in my opinion, entirely a subset of mathematics, and should be taught as such.<p>2) Coding, which is the ability to break a problem down and describe it in a series of simple steps.<p>3) Craft and application, which is everything about how to use tools, best practices for code architecture, and everything else that every new graduate is usually terrible at.<p>I think we could satisfy most of the world&#x27;s need for &quot;programmers&quot; by teaching #2 and #3 in a trade school model.
评论 #7208396 未加载
knappadorover 11 years ago
My recipe for the best possible syllabus for CS 103:<p>* Turing machine -- just the tape and making it do the equivalent of procedures so that we can compose things. Brainfuck is a valid homework medium.<p>* A relevant ISA such as ARM -- We can let Thumb&#x2F;2 be bonus points, but the real goal is just to convey that ISA&#x27;s are usually written to take the most generally abstractable things you would do with a Turing machine and do it more succinctly and faster in hardware.<p>* Build a function stack with the goal of understanding how procedures become generalized by calling conventions or optimized by inlining. The lesson is that we stay pure for flexibility and get dirty for raw speed.<p>* Introduce Scheme and tail recursion optimization. Now the whole of functional programming and the abstractions -- and their optimizations -- are opened up with a firm footing in the machine.<p>Turing and Church probably did write most of CS, so it&#x27;s obvious that you want to relate the two to create the most generally useful bridge concepts for the rest of the long life of a programmer, that if they never let up, will inevitably touch both high-level and low-level languages.<p>OS&#x27;s are the final frontier here, but cannot possibly be squeezed down due to things like MMU functionality totally clouding up what is what. Making a machine look like it belongs to the program is what OS&#x27;s are good at, and this is a different kind of abstraction to grok than the relationship between the machine and the programmer.
austinzover 11 years ago
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&#x27;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?
评论 #7208230 未加载
评论 #7208624 未加载
dylandropover 11 years ago
In my time as a CS student, I&#x27;ve never needed to use C nor understand its syntax to get through my classes. I think you&#x27;re confusing the necessity of learning C with understanding how a computer works, and the two are not the same.<p>I think the most useful class I took that explained this (in my sophomore year) was a class on digital logic and micro-architecture. Just about every school I know teaches some class like this early on in your education (at least teaching the basics -- gates, latches, flip-flops, adders, etc.) In mine, it even carried up through some basic assembly code. This class gave me enough to know how computers are working at a fundamental level to be able to use that to my advantage when implementing projects.<p>Lastly -- you&#x27;re getting a CS degree, not a programming degree from a vocational school. Does everyone who researches... quantum computing, or natural language processing, or graph theory have to know and communicate in C? I think there are other pursuits beyond programming that you get from a CS degree, and to say it&#x27;s necessary to learn C pivots your school closer to a vocational school. Not that that&#x27;s bad -- it&#x27;s just different than what you signed up for.
rismayover 11 years ago
Good stuff. However, I don&#x27;t think that &quot;learning to code,&quot; ins being used in the same sense that Terence Eden meant. I think what Quinn Rohlf is trying to say is, &quot;Learn how computers work.&quot; And what Eden is trying to say is, &quot;Learn how to be logical.&quot; And for a hat trick of HNs submissions, what Andrew Wulf is trying to say over at thecodist.com is that in general you should just, &quot;Learn how to keep learning.&quot;<p>Taken as a sum of collective knowledge, I think everyone is right in this case. I think the general idea people are trying to get at is this: 1. To work in technology, you must love learning. (Don&#x27;t get steamrolled). 2. To work in technology, you should know how computers really work. (Learn about C.) 3. Working in technology is not about learning where to but the curly brackets. It&#x27;s about learning how to think logically. (Learn Computer Science.)<p>In this sense, I think a great way to get started is by working on a project that you love and in a medium you love. Then as you start hitting limits, descend to C and learn algorithms.
frou_dhover 11 years ago
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&#x27;s fundamental neither on bare metal nor in the presence of an OS.
评论 #7211398 未加载
madmax96over 11 years ago
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&#x27;s vital to a <i>good</i> computer science education to understand pointers at a hardware level, differences between stack and heap variables, etc. It&#x27;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.<p>It just seems like all the issues talked about were computer science issues.
dljsjrover 11 years ago
I&#x27;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 &quot;lecture&quot; and &quot;lab&quot; 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 Programming; you implement a lot of these algorithms and data structures in C.<p>Abstract vs. Concrete Data Types are introduced very early as representations for the theoretical structures discussed in class and then we are given projects that can be solved using concepts and theorems introduced with the expectation that we will implement the appropriate structures and algorithms in C. The code itself is read over carefully and just as important as whether the output is good. Now, this is partially a luxury afforded by my university&#x27;s small size; freshman and sophomore CS classes aren&#x27;t taught in 200 person lecture halls, they&#x27;re 30-40 students at the max. My first exposure to a linked list was writing one in C, not using one in Lisp. You model them, write proofs, recurrence relations, graphs, etc. on exams, and implement them in projects so that you show an aptitude for both the theory and the mechanics.<p>By the time you hit your fourth year, you take Programming Languages and Theory of Computation. Automata&#x2F;Machines, Grammars, BNF, Compilers, etc. in lecture; seeing these concepts applied by studying and writing code in OO languages, LISPs, and Prologs in lab. And you&#x27;d sure as hell better understand how the garbage collector in your favorite high level language works or you&#x27;ll get hosed on the exam. There&#x27;s other staples mixed in of course; a whole semester devoted to Java&#x2F;OO (I think a whole semester devoted to functional programming and Lisp would be better, but that&#x27;s another story). A semester of OS, a semester of Networking. But just focusing on the whole programming&#x2F;vs science side of it, there&#x27;s no reason they can&#x27;t both be taught effectively.
评论 #7207934 未加载
xarienover 11 years ago
You&#x27;re essentially advocating for a bottoms up approach as opposed to a top down approach (albeit in a pretty confusing manner). Both work for different people and circumstances. Personally, I think C is a bit high level for a true bottoms up approach which is more inline with a computer engineering education as opposed to a CS program from a liberal arts college. A good approach is one I experienced while attending a tier 1 eng school over a decade ago: using ASM of a simple simulated cpu with a small instruction set(risc or cisc doesn&#x27;t really matter although imo risc is by far easier to pick up for less experienced individuals).
yohaover 11 years ago
It really depends on what you&#x27;re aiming for.<p>- pure mathematical stuff, graphs and such, you can skip programming<p>- making algorithms&#x2F;protocols&#x2F;etc by simple models require to understand what a computer can do, etc so learn at least Python<p>- making new architectures, efficient functions (like for crypto), go to C.<p>I am suggesting Python, because it is probably the simplest programming language to learn.<p>I&#x27;m not saying that learning Python when you do purely theoretical stuff is useless, just that you can skip it and still work. Event if you do no CS-related things, programming is useful.<p>tl;dr: go for Python, unless you need to now the specific workings of a computer
评论 #7206787 未加载
bmoresbest55over 11 years ago
I am a recent graduate of CS and completed a year of C after my first year in Java. Then finished the final two years in something of interest and software development courses. I had the ability to do this at a single school and feel I got a full education in terms of covering a large area of study and understanding coding as well as the science behind it. I do however still feel overwhelmed at times and am constantly learning. Lynda for language basics because languages are cool and Two Scoops because Python and Django are awesome.
garrettdreyfusover 11 years ago
I learned to program in python, and later in front end web development languages such as js, css, and html. I have recently started to learn about operating systems, with the eventual goal to contribute to the Linux kernel. Before now I had never touched C. I ran into very similar problems. My first C program forked a child, its child initiated a shared memory object, wrote a collatz sequence to it and exited. Then the parent read and printed from the memory object. It took over 2 hours because C was so alien to me.
icedchaiover 11 years ago
I&#x27;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&#x27;s. It felt like such a step backwards.<p>This was back in the early 90&#x27;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.
mgmeyersover 11 years ago
Does any one know of any good self study resources (or online courses) on this subject?
评论 #7206915 未加载
评论 #7207079 未加载
评论 #7207098 未加载
maaarghkover 11 years ago
Hey, it sounds like if you write a book, I&#x27;ll buy it ;P
niioover 11 years ago
ignore this, using it to &quot;save&quot; article.
blahbl4hblahtooover 11 years ago
Lots of people confuse learning to code in C with learning how hardware works. Its close in some ways but not all.<p>EDIT: WOW. I&#x27;m amazed at how many people think that C is &quot;how memory works&quot;. Just wow. This is one of those things where you&#x27;re confusing the map for the territory and ascribing value to something because its &quot;hard&quot;. C is a fairly high level abstraction for interacting with a computer...i know that everyone has heard that c is close to being assembler...but what you are forgetting is that assembler is also an abstraction over operands. The reason i think its important to point this out is that malloc and free arent magical. Othér techniques are just as valid and the notion of &quot;low level&quot; is misleading. C makes tradeoffs that actually give rise to all of the vulnerabilities and stability problems in all the software that you have ever used. Those tradeoffs are REAL and just because lots of you get this macho nonsense about not using safe collection types everyone on the planet has to deal with malware. So many of you buy your own bullshit at an astonishing level...its really breathtaking to see how many of you cant see the built in assumptions in what you are saying.
评论 #7207273 未加载
评论 #7208363 未加载
评论 #7207103 未加载
michaelochurchover 11 years ago
Learn C <i>and</i> learn computer science.<p>Let&#x27;s get away from subjective &quot;shoulds&quot; and talk about practical stuff. You want to learn things, as much as possible, that (a) are likely to remain useful in 15 years and (b) are going to qualify you for the highest quality of jobs.<p>C, as a language, passes this test. So do the fundamentals of computer science; they may not bring you quantity in job opportunities, but they&#x27;ll give you access to <i>quality</i>. Aside from that? Well, it&#x27;s hard to predict the future. I can&#x27;t make individual calls. Who would have thought JavaScript would be so popular in 2014? The whole language is a hack. But if you learned it in 2000, you still have a high-demand skill set.<p>Learning one thing or one small set of things won&#x27;t do, though. You need to future-proof yourself with a wider knowledge portfolio, and very few jobs will teach a person to do that.<p>On the other hand, if you learn a lot of useless and parochial crap that won&#x27;t generalize (i.e. the quirks of your own corporate codebase) you get to a semi-depressed state of &quot;learnout&quot; (you struggle to assimilate new things, because you&#x27;ve filled your brain with unrewarding crap) and that&#x27;s no good either.
评论 #7207135 未加载