tags:

views:

624

answers:

17

Hi, since I was at the first year of my University I always envied my fellows (mainly coming from a tech-oriented professional school) for knowing C. I came from a natural-sciences-oriented lyceum and never had programming experience or courses but some summer work with PHP learned from a teach-yourself-PHP-in-7-hours (and my programming interest was very recent). I want to know ... was it a legitimate envy? Does any programmer have to know C? Does C provide deep understanding on how a system works or how programming has to be carried out? I know that when programming C you have to have a strong understanding about buffers, memory, and so on. So I want your opinion on it.

+12  A: 

No, you don't have to know C. But knowledge of C (or any other "close to the machine but not assembler" language) greatly enhances your potential as a programmer. Because you will understand a lot more of the inner workings.

And of course knowledge of assembler is also valuable. But in the above paragraph, I wanted to target the low end of computer language. Just because in modern languages, we take so much for granted (OO, extensive libraries, garbage collection to name a few). And yes it helps us programmers to work more efficiently. But it hides some of the machine aspects that we sometimes need to see and that's why it is so important that we need to know the inner workings.

Gamecat
Why, "But not assembler"?
Simucal
Because there is a lot more code out there (particularly for large projects) written in C instead of assembler.
Nik Reiman
@sqook, what does that have to do with anything? His statement was that any low level language greatly increases your knowledge of inner workings. I wanted to know why assembler was excluded from that.
Simucal
@Simucal, hope this clears a bit.
Gamecat
+3  A: 

You don't necessarily have to know C, but imo every programmer should know about basic machine architecture and how applications interact with the OS and the hardware.

Obviously if you're going to study this, C is a good choice for a language, but not the only option.

Another good reason to know C is that a lot of code is written in C so if you want to learn from others code, it will be very helpful.

Brian Rasmussen
+5  A: 

This is a quite discussable topic. I personally think that knowing C enhances your ability to work with other languages too when you understand what's going on under the hood. But you don't have to know C to be able to produce high quality code.

Eric Sink has also once thought of that question.

Kosi2801
+3  A: 

In addition to Gamecats answer, in my experience working with people in other languages, there is a difference in skill between the guys that know C and the guys that don't. I work primarily in Java and certainly appreciate having spent a few years working with C before I did. On top of that I also did quite a bit of Perl work as well. I would say knowing as many languages as possible helps to give you different views on your work and applying different paradigms

MrWiggles
+10  A: 

While I think it is important to understand memory allocation, pointers, registers, ... I would say that too much experience in C can also be a barrier to grasp higher level languages, or OO languages. C tends to make you think procedurally and that can be a bad thing in some cases ...

I would definitely not recommend C as a first language, but it can be of great help to do some C at some point...

As a side note, I think that assembly can be much more useful to help you understand basic principle. At the same time assembly is far enough from any language that you would use (unless you work in a very specialized field). That will help you keep a different mindset when doing assembly than when using a higher level language.

Guillaume
+2  A: 

C is not my language of choice, but even to this day, C is everywhere.

When I do some small code in Lua using LuaCurl, I use a C library. Lua itself is written in C.

When I do some Seaside Web application in Squeak Smalltalk, I use a VM generated in C (the Squeak VM is written in Smalltalk, and then it generates C code as a portable assembler).

So I would not start learning programming with C (see this thread for other choices), but as a programmer, knowing C is very handy even if it is not your language of choice.

Sébastien RoccaSerra
+1  A: 

Memory allocation and pointers.

After getting to handle C and C++, even if only in school, you have a better understanding of what needs to happen in memory in order for you to throw objects and references around and you get a better appreciation of what, for instance, garbage collection implies.

Also, in school, starting with Pascal and then C allowed us to learn "programming" first, the old way, and then move to more advanced languages (OOP, etc) on top of that.

Tiberiu Ana
"object orientedness" learnt from C?
hhafez
I've seen object-oriented C. It's a mess. However, I think he meant that they went on to other languages after that.
David Thornley
Indeed, OOP in C: http://www.google.com/search?q=object+oriented+c.It does seem a beauty but I can't say I ever had anything to do with it. David got it right, I was thinking about switching to C++ and dynamic languages after learning some C.
Tiberiu Ana
A: 

Have to know/learn C? Probably not, although it might make learning some concepts easier. Understanding something about memory allocation, structures and pointers of all kinds is worthwhile and C is a good language to use to gain that understanding. Plus, to be honest, "straight" C is really not complex. Tricky to get right, sure, but not in itself complex. I'd advise getting hold of a compiler that wasn't a C++ one too, that way can lie madness. (Fond memories of Quick C For Windows)

Have to know/learn C++? Definitely not.

Mike Woodhouse
+1  A: 

I share the same sentiments as the others in this thread, however, to answer the question that was asked:

The only programmers that have to know C are C programmers.

Dane
+1  A: 

All knowledge is useful, so yes, you should envy their knowledge. You should also envy people who are AI nerds and know LISP, etc. The best mix would be a dynamic language, a functional language, SQL, a low level language and an object oriented language.

If you want some stranger to make some recommendations, I would go Python, OCaml, SQL, C and Java/C#. But, find your own path :-)

Travis
+1  A: 

I think you have.

Languages have their own evolution. They developed within a very intriguing and fast evolution of computer systems. CPU power grew, features grew, Assembler got more complex... everything got more powerful.

Thing is: if you never saw the low level and "easy" beginnings, and you start with some high-level languages like C#, C++, or Java, you won't understand the elegance or backend perspective of these very powerful languages.

I think you don't need to learn LISP, because if differs a lot from common C-like languages. But some C is a must-know. It's for developers from developers, very near to machine code. Know what the machine does when you program it.

wishi
You should learn Lisp, or something like it, *because* it differs a lot from common C-like languages. If you never learn anything really new, you're fencing yourself in.
David Thornley
A: 

I would use a metaphor: Knowing C for programmers is like knowing latin for (western languages) writers. It is not something you need, especially if you just write sports columns or cooking recipe books, but if you want to refine your craft it is something that I would consider nearly mandatory. But it will not be useful for daily work on ordinary software. Or knowing mechanics for a car pilot, or how to build sails for a sailor. At some level of expertise, you need to know how the things you use are working internally.

If you learn C, try to master the pointer concept, and the way they map to the hardware. That's really the point of learning C. Do not spend time on the rest of the language.

Colas Nahaboo
But latin is a dead language, C is not.
tunnuz
Not to mention that, on any machine you need to program, there will be a C compiler available. C gives you the ability to write a program on virtually any platform.
David Thornley
+2  A: 

In the same way that not every mechanic needs to know the inner workings of an engine to fix a car, not every programmer needs to learn C to produce code. however, the ones who do, acquire a better understanding of the craft and ultimately achieve a higher level of success.

Zabbala
A: 

Maybe it was just my particular educational experience, but I hated C/C++ in college and haven't touched it since. I'm thankful for learning about the concepts involved, like pointers and memory allocation, but trying to accomplish anything with the tools that were available to me was too cumbersome for me to want to bother. I hope your experience is better.

Greg
A: 

("slightly" tongue-in-check) You should learn it if, for no other reason, than it will make you love whatever language you're working in at that moment.

+3  A: 

Something I find missing from most of these answers is that C is a very easy language to learn. Everything you'll ever need to know about the syntax is contained in one thin, concise book (K&R), and that includes all the standard libraries. So I'd encourage you to at least skim a book and see what it's all about, even if you don't intend to use it.

That simple C syntax only gets expanded for most modern C-based languages (C++, C#, Java). You can't say you really know those languages until you've mastered at least a subset of the hundreds of libraries that come with them, and that can take months or years of experience.

What's tough about C is that it can expose you to the true nature of the machine underneath. If you really want to grok how a computer works, you need to understand things like pointers, memory allocation, and stack vs. heap vs. executable code. You can learn basic C syntax in a few hours, and that puts you on the road to understanding much more. Saying "I'm a C expert" is just a proxy for saying, "I really understand how a computer works."

Casey Barker
A: 

I don't call myself a C programmer, but I can write code in C. It has helped me a number of times in my career. I've spent a lot of time working with Visual Basic, and there are some things you just can't do with VB. It's been very handy to drop down to C to do things like windows hooks. It's made me the "hero" a time or two.

Jim Blizard