tags:

views:

532

answers:

13

Often one of the main reasons given for learning C is that it brings you closer to programming at a low level which gives you insights into how things really work in higher level languages.

I've been programming in various Assembly flavors for awhile and you can't get any lower level than what I have been coding in and I have no illusions about what reference types or pointers really are. It should be pointed out that I also am fairly prolific in Java and C#. I don't only know assembly.

Is it still worth the effort cracking open K&R and spending some valuable time learning the intricacies of the C language or would my time best be served learning something else?

A: 

Maybe not...but it won't hurt to learn it :) I personally learned x86 assembly before C and my assembly knowledge made it easier for me to grasp C pointers.

cruizer
+1  A: 

I think the most important reason why you should learn any programming language is so that you can put it to some use.

If you've learnt Assembly to do something, and you feel you can do something else better in C, then go ahead by all means.

But if you find that you've got nothing to do in C, then professionally there's no point in learning it.

If however you want to do it as a hobby or a personal endeavor. Then it's your time, do anything you want.

Cyril Gupta
While it certainly makes sense to say that you should learn a programming language if you have some specific use, there is also something to be said for the intrinsic knowledge and insight learning certain languages can bring you.
Simucal
A: 

Amazing that in a world of new scripting languages every day there are still people that manage to only know assembler.

I myself, after writing perl or javascript for longer periods always find lower level languages like C or C++ kind of lacking, for instance, where in perl I write foreach(@array), in C/C++ I have to fiddle with for loops and indexes and/or iterators.

So, yes, I can only imagine how much you will get from the abstractions C will provide for you.

Additionally, widening your perspective is always a Good Thing.

heeen
He did say he uses more than just assembler (Java and C#), so I doubt the abstractions in C will be as much of a learning experience.
Wilka
he edited that in later actually....
Tony Lambert
A: 

It depends. If you want to work with C++, you surely should also learn C. If you want to code in Python or Perl you don't really need it, as you have an understanding for the internals from Assembler.

One thing: Do you worked in Assembler with pointers and the heap? Understanding pointers and memory-management is very important for every higher language. If you didn't get the idea of pointers and the heap right, you should give C a try.

Mnementh
It's kind of impossible to not think of pointers in assembly; every load and store is a naked pointer.
Crashworks
Yes, that's true. But reserving and releasing memory on the heap is something you don't always do in assembler.
Mnementh
+1  A: 

C is portable (if you write it carefully), that is a good reason for me.

Sébastien RoccaSerra
+9  A: 

Yes, absolutely. Writing a program of any significant size is very cumbersome in straight assembly, so most applications that are written down-to-the-metal (like hardware drivers) will mostly be in C, or at least C gluing together calls to assembly functions.

Also, because C has such a close relationship with the machine (that is to say, it is low level), learning C after assembly will be a good stepping stone for understanding what a compiler really does to turn high-level code into machine instructions.

Crashworks
+14  A: 

Often one of the main reasons given for learning C is that it brings you closer to programming at a low level

Well, scratch that one off, look at the others and decide for yourself. If you want to:

  • remain close to low level but gain portability
  • be able to work with the huge codebase that C has already
  • just learn something new

then you might want to learn C.

Rafał Dowgird
+3  A: 

You know assembly and you seem to know C#. It's never a bad thing to learn yet another language but I would only recommend learning C if you are going to need it in the near future. I think you would broaden your knowledge more by learning a dynamic language like Ruby or a functional like Common Lisp.

Jonas Elfström
+3  A: 

Absolutely! Learning C will improve your assembler programming as well. As you learn C you will start to transfer the structured method to your assembler programming. I noticed that the more I learn of high level languages the better the organization and understandability of my assemble language programming.

It is very useful to be able to mix C and assembler. Being able to use both in a single project allows you to use the appropriate solution in any given situation within that project. For most tasks C is quicker to code, occasionally the opposite is true, assembly language is quicker. Sometimes the assembly language is better able to express a particular aspect of a solution (assembler's close mapping to the hardware can make programming I/O or device management clearer). For more abstract concepts C can be clearer (C++ can be better again).

The same goes for learning C++. I find myself using an object oriented approach to both my C and assembler programming.

In the end it's horses for courses. Use the appropriate language for the problem at hand.

Tim Ring
A: 

I look at it pragmatically - I wouldn't bother unless you feel like you have jobs where performance is more important than programmer productivity. After 12 years of programming, I've never come across a job that should have been written in C, instead of a garbage collected language. But, your situation may vary.

If all you knew was Java, then I would say yeah, it would be great.

Travis
A: 

No one has mentioned....

that C is a route to writing assembler quicker. When I wrote computer games, we wrote everything in C first then re-wrote the parts that took all the time, the old 80-20 rule. 80% of the time is in 20% of the code.

To do this we compiled the code we wished to re-write and used the dump to assembler file flag. Then we took the C generated assembler file and used that as the basis to write more optimised assembler code. This was far quicker than starting from scratch.

Today this approach is far harder as the compilers are far better and it is so much harder for humans to improve the compilers code - since processors got so complicated and fast code has become about keeping the caches and pipelines full.

Tony

Tony Lambert
+1  A: 

Learning a new language is always a fun thing to do, especially if it's significantly different, paradigm-wise, from what you already know. So I'd say go for it.

I found it very interesting that C has still been one of the most sought-after languages on major search engines and book sites.

moffdub
A: 

I think it depends - do you (or might you in the future) have to deal with a codebase that includes C? There's an awful lot of it out there, so I'm actually surprised that you haven't already had a need to do something with C (at least reading it) given the assembly, C# and Java experience you cite.

Also, given that you know the above set of languages and the concepts that go along with them, I'd guess that learning C would be a cakewalk for you.

Michael Burr