views:

758

answers:

19

I'm currently working as a Actionscript 3 and Php developer. I started out learning Php then moved on to Actionscript 3 and now I'm learning Python. These 3 languages are high level languages which in none of them you have to worry about low level memory management and things like knowing which data type to use for different numbers.

It feels like I'm missing something even though I know 3 different programming languages. For example I don't even know what a stack overflow (Yes, I know I should be ashamed since I'm writing this question on stackoverflow) is in and why it occurs. I will never know these kinds of things since I'm never going to face these kinds of problems in my line of work.

So my question to you is pretty simple. Would I benefit from learning C even though I'm not going to work with it in my line of work?

Thank you

Richard

+11  A: 

Learning something is rarely a waste of time. And C is a pretty simple language to learn. I used to teach it commercially, and we did the lot in 4.5 days. So I'd say give it a try.

anon
Kevin Montrose
Actually, for on-site presentation for a specific customer, we routinely cut it down to 3.5 days :-) Thinking back, I realise there was one bit we didn't cover - use of vararg macros to write printf()-like functions.
anon
To learn how it works and to know how it works are two entirely different things in my opinion. You can learn a language in a week (4.5 days sounds really fast to me) but it will take years to know a language.
borisCallens
semiuseless
anon
Ferruccio
+6  A: 

I suggest you reading this article by Joel:

http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html

It more or less does a comparison between Java and C/C++, but I think it addresses quite a few of your concerns.

Cambium
+11  A: 

It's a good step, but it's like asking whether learning Italian is enough to understand Dante's The Divine Comedy. There is a lot different in OS and low-level programming that doesn't exist in high level programs. C, at the end of the day, is just a language.

I'd say definitely learn C, but use it to study some books on things like compiler construction, basic OS concepts and so on. That's where you'll really learn the low level concepts.

Mark Pim
+1  A: 

All that you need it's learn programming, no matter the language. Try to learn at least one of each paradigm. C is a good starting point.

BTW ... Stack Overflow

Jonathan
A: 

yep. i guess you answered your own question. short and simple :)

Umair Ahmed
+2  A: 

First up, you should never be ashamed if you don't know something. Besides, stack overflow is not terribly difficult to understand ( the answer is in the name itself).

I always have a terrible time learning something just in theory. Unless, I can get my hands dirty, I dont totally grasp the concept. That is indeed where C comes in extremely handy. You can read about Os internals & stack overflows but only with C would you be able to see them in action.

C is an easy language to learn but a very tough language to master (with all its idiosyncrasies).So, it would require a little bit of effort (specially if you want to master the advanced concepts) but I speak from experience its totally worth it.

Aditya Sehgal
Thank you for a great answer. I'm exactly like you when it comes to learning stuff. I have to do it practically to fully understand. I will definately start learning C.
best of luck then. The link to the Joel article put up by one the posters is a must read. What Joel says in that is exactly what I felt for a long time about Java and to a certain extent C++. Have loads of fun learning C.
Aditya Sehgal
+1  A: 

Hi Richard,

if you want to become a serious programmer you definatly should.

Id even suggest to have a look at assembler. you dont have to code real-world programs, but i think its essential to know how control structures and functions look in assembler. This gives you a better understanding of what really happens and you'll get a better feeling which stuff in high-level languages is expensive.

But C (beeing something like an assembler-macro) should be the first step. Try to get as much index errors (access array elements out of bound) and memory leaks (keep on allocating memory without freeing it after use) as you can. Keep your code complex enough so that you dont find them too soon. ;) Youll love your higher languages even more after that.

And: what i found very instructive in terms of understanding OOP was coding object-oriented in plain C. This demands some knowledge of C:

http://www.state-machine.com/devzone/cplus_3.0_manual.pdf

Dill
Serious programmer. I program in C# and consider myself a very serious programmer, but don't know C.
Colin
Thank you. Great advices! Now I feel even more stoked to start learning C.
Colin, sure that was a little categorical.Id rather say: knowing C makes it easier to become a good programmer.Knowing how OOP works by "reimplementing" it in C (which is easy) makes it easier to understand it and use it.
Dill
+2  A: 

Maybe. I write C pretty much exclusively for now, because I'm working from the bottom up. I have a bunch of time to kill before I go to college so I thought: I might as well be (at least somewhat) well versed in the architecture of software before I start. It makes (in some instances) the higher level concepts easier to learn, increases your ability to problem solve, etc. When I was a lot younger I learned PHP and VB6. When I moved down to C and assembly, the HARDEST thing for me to grasp that a "string" wasn't a single value, but an array of single values--and I couldn't just compare one to the other--I had to traverse each array of characters and find the difference--etc. Small things like that made me re-think and re-learn how computers actually worked. I mean, before I found that thing about strings out--I thought processor registers were utterly useless (how could you put anything useful in 32 bits!?).

That being said, I can babble about potential benefits of learning lower-level programming, despite the fact that you will never use it. But for me, no matter what reason I come up with--it's mostly for general interest. I think C is fun, and the more I accomplish with it, the better I feel about my skill. If you don't find a lot of interest in learning things like what a stack overflow is, computational math, low-level memory management (invalid or null pointers, heap corruption and fragmentation, etc), etc--then there's no guarantee you'll really benefit from it. But you might.

If you do learn C to learn about the architecture--and how stuff actually works under the hood--maybe try what I do. I frequently compile down to assembly code to see how the computer actually handles what I ask it to do. To see each individual step that is taken for each task. Actually, that's how I figured out the difference between char *a = "a string" and char a[] = "a string". However the best benefit for you will be realizing how painless higher level languages really are :P.

For the record--each process is given a call stack. It is a block of memory which is of a pre-determined size. It is used for local variables, mainly. Every time you make a local variable, the contents of it is added to the end of the stack--and when a function returns (and those variables go out of scope), that data is taken back off. A stack overflow is when too much stuff is added to the end of the stack, and you overrun that pre-allotted memory space. It is usually as a result of putting HUGE objects on the stack, or too much recursion (a function calling itself). Also I guess if you just get too tangled up in functions calls inside of function calls, which is basically the same (in this case) as the recursion issue.

Carson Myers
A: 

The answer is simple, too: yes, you would.

There are some languages that should be useful to any developer as they are like milestones. I would say that C, Java, PHP belong to such languages. Right now I am reading a book on JavaScript just for education, though my site doesn't use it at all and probably won't.

If you like it, go for it!

Malcolm
A: 

You should also look at Compiler Construction. It will give you a lot insight about the "mechanics" under the hoods, independent of any language or programming paradigm.

ftl
A: 

The way I see it, your problem is "should I learn a language I'll never use", my answer like many answers given here would be - "yes".

You would significantly improve your programming skills and benefit in a way you will never understand untill you try writing code in other languages and find that you not only think faster, but also write simpler, cleaner and better code.

The three languages you know are all script languages and dont do much for variable and memory assignment. C would lead you into a different world and approach to programming from that you already know.

Check this link.

P.S. For better understanding of stack overflow check Jonathan's answer and refer to the nice sackoverflow.com's image on top of the site.

Secko
This is great. I was afraid that I would get answers saying it's not going to be worth it etc. So far I'm really positive to start learning C. Thank you for your answer.
+1  A: 

This is a perennial question and many bits have been spilled on the subject. The answer is: yes.

  • Even if you don't use it on a day to day basis, a working low level knowledge of what makes the computer tick will always be beneficial.

  • You will use the knowledge (and in some circumstances C itself) more often than you might think.

  • There are many experiences that will make you a better programmer overall, even if you aren't programming directly in the languages. C is one example. Other examples are functional programming, Lisp, assembly language and learning to write a parser.

C is also fairly simple, so it's easier to learn than is generally made out. K&R's C book is compact for a reason. Many languages such as Python, Lua or Tcl lend themselves to including modules written in C - this is often a good way to develop a system.

So, as this debate always seems to resolve: Yes. Learn C. You will see many benefits from it.

ConcernedOfTunbridgeWells
+1  A: 

Being an embedded developer, C is my bread and butter language but to me it tastes like roast beef with roast potatoes and a good gravy. If I were starting out today there are two languages that I would set out to master; C and C# and maybe throw in a smattering of C++, just for those unmanaged native applications that C# won't bastardise itself to cope with.

These days there is practically no need to muck about with assembler. C compilers and chip design are so intertwined that you will almost never be able to write more efficient assembler than what a C compiler generates. In addition you can get all of the understanding of the underlying system using C.

Now, before that sounds all romantic. let me re-phrase. You will NEED to understand the underlying system if you are to write something worthwhile in C. This means that before you get something remotely more useful than outputting "Hello World" you are going to be doing a lot of reading, a lot of mis-understanding and more re-reading, because the guys writing the docs understand what they are talking about but the chaps reading the docs don't otherwise they wouldn't be reading them.

C syntax is very, very easy, and "writing" a program is very easy. Getting the interaction between your program and the underlying OS and hardware to work is where the difficulty comes in. Nothing is for free in C, but Aye! a beautiful language it is.

MY advice on learning any language is: Find a project that you have to do and force yourself to use the language that want to learn.

EndsOfInvention
Well, you do need to muck about with assembler if you're writing a compiler. :)
Bob Somers
A: 

Like others have pointed out, learning something new is always worth it.

However, speaking as someone who learned C in the past couple of years; I think the answer to your question depends on if you have any practical applications to learning C.

In my instance; I enjoy C in server programs, embedded programming and basically anywhere you want to control as much as possible (without risking further insanity in assembly).

So my suggestion is that you find some mini-project that interests you that would make sense to develop in C. Then learn by doing.

Andrioid
+1  A: 

I think you should learn C.

Well, rather than (just) learning C, you should be reading K&R2.

Here's a laundry list of what K&R2 teaches you about:

  • C
  • Sorting
  • Binary search trees
  • Hash tables
  • Memory allocation algorithms
  • The Von-Neumann flat-memory machine architecture
  • Systems programming (wc is---or can be made---surprisingly complex)
  • Interfacing with the kernel

When you truly "get" C, you also have easy access to the bare metal; it becomes much easier to get at the machine-native call stack. Once you see the similarity between function pointers, if-then-else blocks, "goto" and "return", it becomes much easier to understand how buffer overflow exploits work.

Learning C is a good thing. Not because it automatically teaches you everything about how programs work, but because it makes you gravitate towards that knowledge.

Jonas Kölker
toto
Section 6.5, "Self-referential Structures" talk about binary trees. Section 6.6, "Table lookup" talks about hash tables.Not thoroughly, mind you; it's a book about C, not algorithms and data structures. But the eager, attentive student can learn trees and hash tables just the same.
Jonas Kölker
A: 

For example I don't even know what a stack overflow [... is ...] and why it occurs.

Whenever one function calls another, the computer needs to remember where in the execution of the caller it was. This information is stored in a stack: calling a function pushes a new record saying "return to $HERE when done", whereas returning from a function pops the return address and goes back to there (or rather, the next thing after the function call that has just been returned from).

Typically (determined by the OS or language runtime) you only have a limited amount of space for this stack. Running out of that space is called a stack overflow.

See also http://en.wikipedia.org/wiki/Stack_overflow

Jonas Kölker
A: 

I'm also an Actionscript 3 developer (with some Python thrown in). Learning C is a current project. I have dove into Objective-C a bit and submitted my first app to the AppStore, but I want a lower level understanding of what I am doing. I don't have much interest in writing a compiler or hacking at the Linux kernel, but essentially everything I touch is C/C++ at the core, so I figure it is worth my time to at least get a cursory understanding of the language.

In terms of leveraging it with your existing experience, the Alchemy project is pretty sweet, and allows you to leverage C/C++ libraries in AS3. There are some exciting ramifications of this.

Personally I have a loose goal of learning a language every year. This year it is Objective-C, but getting into that has made me want to take a step back and learn straight C. It certainly can't hurt, and will make you a better programmer in the long run.

Joel Hooks
A: 

My answer is: maybe. These questions may help you decide:

  1. Do you have to solve tough mathematical problems involving numerical methods (calculus, linear algebra, diff-eq, finite element analysis, etc.)? Many of the best libraries are written in C, and understanding how to implement those algorithms in another language would require you to understand C so you could translate them.
  2. Do you need to devise compact data structures that waste no memory? My experience in C enabled me to create collection and string classes in Java that used much less memory than the standard classes provided in the J2SE library.
  3. Do you need to interface with legacy applications? Many are written in C or C++.

There are many other good reasons for learning C, but it depends on what kind of programming you intend to do, and whether there is an intersection between the skills thqat learning C will provide and the skills you need.

Paul Chernoch
A: 

Most of the time you are happy with knowing how to do something. But you will eventually get from how to why. When you are asking why you are doing something then C can often give you that answer due to it's low level nature. Of course, any other 'raw' language will give you the same answers. By raw I mean a language which allows you direct access to the computer, rather than hidden under a multitude of API layers and classes.

Of course, some people never ask why... how if often good enough for them. They are the ones who wont want to learn C.

Xetius