Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am a front-end developer who barely even see a file with .h or .c extension. I know basic C syntax, I've learned it in Unreality but never was interested in such low level programming because it was simply too much setup for simple things.

I am very interested in learning all aspects of Computer Science but I want to believe I do not really have to know a specific language in order to understand most of concepts in Computer Science. Yet when I start reading books and articles about fundamental Computer Science concepts like Data Structures and Algorithm Design it seems that I have to learn C, because all examples and even lessons are in C (and sometimes Java).

My question is, is C as a programming language essential for Computer Science or we just happened to have all of our resources in CS written in C? Can one learn Computer Science without learning C?

share|improve this question

closed as primarily opinion-based by gnat, GlenH7, Corbin March, Jimmy Hoffa, Joris Timmermans Sep 10 '13 at 15:16

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

4  
Here is Joel Spolsky's opinion about that: joelonsoftware.com/articles/CollegeAdvice.html It is discussable, but I think he has his points. –  Doc Brown Sep 7 '13 at 7:56
2  
Purists would argue that computer science isn't about computers, which renders programming languages unnecessary. –  Blrfl Sep 7 '13 at 12:33
1  
What do you mean by "Computer Science"? What you describe is mostly the Software Engineering part of computer science I think. Also, I fail to see how all resources are written in C. I've read quite a few books on algorithms/data structures and none used C. Almost all of them used some kind of pseudocode language, easily understandable to everyone (well, except TAOCP which uses assembly... but that's another story) –  Bakuriu Sep 7 '13 at 12:38
    
Unreality? Was it supposed to be a quirk of auto-correction from University or is it some school of black magic? I know the Unseen University, though :[ –  Deer Hunter Sep 7 '13 at 18:36

9 Answers 9

up vote 30 down vote accepted

I'm going to go against the flow here and say yes, you do have to learn C. I actually agree with the points in many of the other answers, but you make the very strong statement that

I am very interested in learning all aspects of Computer Science but I want to believe I do not really have to know a specific language in order to understand most of concepts in Computer Science.

(emphasis mine)

Well, operating systems and network stacks are two huge aspects of Computer Science, and all the dominant operating systems and network stacks are written largely in C. If you want to understand those, you should learn C. Yes, some schools do manage to teach their OS classes in Java, but it's like reading Homer in English.

Besides, C is not that big of language. If you really want to learn all aspects of computer science you should shrug and say 'meh', 'what's one more language?'

share|improve this answer
    
I generally agree with this, though to me "learning" C means that I'm essentially fluent enough in the language to write non-trivial programs in it without assistance. I'm not sure if that level of understanding is a prerequisite for operating systems and network programming. –  Telastyn Sep 7 '13 at 12:44
3  
@Telastyn: it means that you are fluent enough to understand and modify operating systems code and networking code - the domains where C is used for, and that's it. It does not mean you need to know how to write games in C, make prettiful UI and charting applications in C, graphics or machine intelligence engines in C; because for every other domain of CS there are other language choices. –  rwong Sep 7 '13 at 22:22

For a very long time, during the height of computer science as a science rather than a vocation, there were a few limited choices for a language that ran on all the systems that all the different universities used.

By far, universities tended to use Unix systems. Conveniently, this was programed in C. One could start with learning C on any machine, and eventually get into the unix source code in C. At home, students could use a C compiler such as Borland Turbo C on Windows, or MPW on a Mac - it worked everywhere.

Pascal was another option, but that tended to have the problem that at a certain point in programming, it just wasn't enough of a language to do what you really needed to do (programming an OS in pascal would be painful).

Some of the older school learned Fortran, but again, it wasn't a powerful enough language in many cases to be able to teach higher level CS classes (AI theory in fortran? Doable but painful).

And so, for a long time C was the choice.

It isn't the only choice and there are many colleges now that teach in other languages to gloss over some of the internals and learn higher level concepts without having to deal with the ugliness of memory management and the like. Some think this is good, some think this is bad.


So no, learning C isn't essential to learning computer science. You can find many other books out there that teach computer science from Java or Python. Its just that for a long time, C was the choice and academic books move slowly.

share|improve this answer
    
For the record, AI training was traditionally done with C's egghead companion through the 70s and 80s, LISP, but the answer is on the head. –  jwrush Sep 7 '13 at 2:33
    
@jwrush my answer was more along the lines that you can do AI study in C too, compared to the other languages of the time (not LISP - and I took a lisp class in the '90s for AI). Granted, MIT (home of the eggheads) at the time taught many their classes in LISP - and it was certainly another option, but not quite as practical in other areas. In teaching, it was important to work from the same basis in each class so that one didn't have to spend the first week or two teaching the students another language specialized to that class. –  MichaelT Sep 7 '13 at 2:42

I admit that one can get a well-paying job and be productive without ever touching C, but I highly recommend learning C for anybody who is serious about having solid understanding of computer science.

Although computer science is about concepts, which could be learnt irrespective of any specific programming language, there are fields which may be much better understood by learning C or by learning that field using C.

  • Algorithms and Data Structures. Standard C has almost none of these - having these already implemented in the language or in its standard library tend to be demotivational for students: "Why should I bother implementing something readily available?" Looking at a piece of C code, you immediately see its algorithmic cost, since everything in C compiles to a few machine instructions only. High-level languages (e.g. Perl or Python) often use advanced data structures under the hood of lightweight syntax. Code feels light, but it is not. You already need a great deal of knowledge to correctly reason about the algorithmic complexity of those code pieces. Therefore those languages are not as suitable for learning algorithms and data structures, and many programmers who was always living on high-level languages, tend to be incapable of dealing with performace problems, when they run into them.

  • Operating systems. Most operating systems are written in C. How do you want to understand process creation without ever calling fork? The abstraction layer of the Java VM is no help here. And just talking about it without ever creating a process is even worse... How can you write a software like Eclipse which can redirect the standard output into one of its windows? You need to understand OS-level concepts for that, and you can touch those directly in C only.

  • Indirection. You cannot do C without dealing with pointers. Pointers force you to think on two-levels, and that stretches your abstraction skills.

There are also some technical advantages of C knowledge:

  • Cross-language interoperability. You want to integrate a great Ruby module into your Python project (substitute two arbitrary languages here). Chances are that the only way to do that, is through C, because both languages has a foreign interface to C.

  • Writing performance critical software. One cannot omit going low-level to do this.


I do not say, that every program should be written in C. But C can help you to knowledge, which is useful whatever language you program in.

share|improve this answer
    
Pointer arithmetic is critical to understanding operating systems since leads to the why. Eg why are heaps and stacks different, why does virtual memory perform well or badly, why do some loops work faster than others, etc. –  Michael Shopsin Sep 13 '13 at 14:42

I'm also going to go against the grain here and try to make a (slightly humorous) aesthetic case for C. While some people might call it "ugly" for different reasons, such as the lack of higher-level constructs like classes or its reliance on pointers, I find that it isn't the case for me.

TL;DR: In my opinion, C is simple, good C is readable and there's a certain joy to be found in banging bits.

C is simple

Standard C defines only a few basic types and mechanisms to create functions, pointers and arrays out of them. On top of that, there's a small number of composition constructs to make more complex types out of the primitives (like structs and unions). Notice how I described most of the language in two sentences. This means you don't have to keep too many syntactic rules and forms in your head while coding.

Simple is beautiful.

C isn't arcane

Unlike many higher-level languages, you would be hard-pressed to find a lot of weird, unintelligible symbols in C. In the C world, the main facility for both abstraction and "syntactic compression" is the function - semantically a very simple and self-explanatory construct. Good C style encourages almost poetic, readable beauty. To illustrate, let's try to read the following snippet from the Linux kernel. Even without having grasp of the underlying data structures and implementation details, we can make a lot of sense of the following:

bool kthread_freezable_should_stop(bool *was_frozen)
{
    bool frozen = false;

    might_sleep();

    if (unlikely(freezing(current)))
        frozen = __refrigerator(true);

    if (was_frozen)
        *was_frozen = frozen;

    return kthread_should_stop();
}

The middle of the function reads "in the unlikely event that current is freezing, ask the refrigerator if freezing actually happened". Dr. Seuss couldn't have written it better.

Readable is beautiful.

C is transparent

Unless a C statement includes a function call, you can generally get a very good idea of its run-time cost and side effects. C gives the programmer control and ultimately trusts him or her to do the right thing. We can get a picture of what happens when this (slightly reformatted for SE) snippet out of the implementation of strlen() in the GNU C library runs, because every operator has well-defined semantics. There is no overloading in C.

for (char_ptr = str; ((unsigned long int) char_ptr & (sizeof (longword) - 1)) != 0;
        ++char_ptr)

if (*char_ptr == '\0')
    return char_ptr - str;

For the purposes of "optimizability", this property is great. Arguably, some higher-level languages make the concise expression of higher-level algorithms easier (like C++ with classes and overloading), but for the purposes C was designed for - acting as a portable assembler - C is ideal. Sometimes, upon successful execution of low-level code, a programmer might feel one with the machine, in a sense (or zero - it's an implementation detail). This isn't to say other languages are bad, not "zen" enough or something silly like that, just that IMO C can be interesting in ways that many other languages have chosen not to be, for many valid reasons.

In my opinion, the three points presented above make manageable the creation of complex - yet efficient - systems, embodied in my mind by Linux. I find that this world appeals to my aesthetic sensibilities and I'd advise anyone considering C as his or her next target to consider these points. I feel that arguments about operating systems and whatnot are better supported by explicitly stating them because one certainly does not need to understand kernels in order to be a successful programmer, but one might find these fields compelling subjectively.

share|improve this answer

The programming language you use to discuss the science of computing is largely irrelevant to the task of learning the means and science of computing.

The (arguably) seminal work on Computer Science, The Art of Computer Programming, does not use any existing language to inform the subject. Instead, Donald Knuth chose to define a fictional computer and a fictional machine language (and an associated assembly language) in terms of which he discusses all topics.

Another highly regarded work on the subject, The Structure and Interpretation of Computer Programs, took a similar approach, devising a simplified dialect of the LISP programming language to act as its own context. This language is what we know now as Scheme.

Yet another very good work on Computer Science, The Elements of Computing Systems (which is actually equal parts Computer Engineering and Computer Science, and very brief), takes the more fundamental approach of teaching digital logic, from which it builds the machine, the tools, and the language, before teaching elementary Computer Science.

So, no, C is not necessary for an understanding of Computer Science. What matters is your understanding of the core concepts of algorithms and their application.

share|improve this answer

I started a career in programming by learning vb3 from the manuals that shipped with the floppy disks it came on. I learnt some java and was able to produce some respectable programs but it wasnt until I studied C at university that I felt that I really understood what was happening "under the hood". I now work only with .net and never really worry about pointers, invalid addresses or overflows - but I understand them, this informs the decisions I make on a daily basis and some of the old school stuff is still there in modern interpreted languages, flags, bit wise operations, Boolean logic, all powerful tools and very efficient.

Learn C. It will stand you in good stead. I kept a copy of the c programmers handbook for years and read Kernighan and Ritchie from cover to cover. Doesn't matter what language you end up working with Understanding C will definitely help.

share|improve this answer

Can one learn Computer Science without learning C?

The answer is Yes. I have my degree in CS and was not required to learn C, but rather Java. At least in my school, the emphasis was on learning Object Oriented Programming, with some teachings on Assembly Language, Data Structures and Database Design.

share|improve this answer
7  
Are you sure your degree covered "all aspects" of CS? –  SK-logic Sep 7 '13 at 8:37
    
I would say all necessary aspects. No degree covers all aspects of a degree program. Plus "all" is subjective. –  Phil Vallone Sep 7 '13 at 12:01
1  
How do you define "necessary"? All is all - meaning, covering all the possible CS application. It's not "subjective", it's quite quantifiable. –  SK-logic Sep 7 '13 at 12:46
    
I define 'necessary' in the context that CS covers the study of computation and computer technology, hardware, and software and not any specific language, which is answering the original question. –  Phil Vallone Sep 7 '13 at 15:58
    
Ok, and how you're going to cover the hardware without the low-level languages? How will you cover the history of programming languages (which is an exceptionally important part of "all" the CS) without such a key language? How will you cover programming language semantics without at least one language with pointer arithmetics? One way or another, but a language similar to C must be present in any comprehensive CS curriculum. –  SK-logic Sep 7 '13 at 20:47

It really depends on what you want to do with what you're learning. It's definitely true that a lot of algorithms are given in C, or descendent thereof. However, over the years I've seen more C++, C#, and Java examples. What CS is meant to teach is a general understanding of computing, and therefore how to pick up or create a language appropriate for the task at hand.

However, there are still a lot of people whose first and last language is some variation of C or Java, and not all of them are going to have the training to understand any-given language that a CS degree provides. Even some CS graduates have trouble with programming. So you may need to have a good enough understanding of those languages that you can communicate with them, depending on your career path. If you plan to stick to academia, then you'll have even more language barriers to content with, especially in interdisciplinary areas (where people use prolog, lisp, haskell, mathematica, etc.)

share|improve this answer

If you're really going to learn "all aspects of Computer Science" (ambitious plan!), you'd have to deal with several different assembly languages, and at least one HDL (and practice coding on a netlist level in it).

And as a higher level step to approach these truly fundamental things you'd have to pick up something like C or Pascal, its unavoidable. Skipping steps on a ladder of abstraction is counterproductive.

Anyway, I doubt this question even worth asking. After all, C is just a tiny language. You could have learned its basics in a shorter time than you wasted reflecting on whether you have to learn C or not.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.