views:

830

answers:

20

As a web developer, is it worth me learning the programming language C? Will I ever need to use it? I am currently using PHP and Ruby on Rails.

Thank you in advance to all you good people out there

+5  A: 

Not really. If anything, learn C because it is fun, and a great language to help you learn more about system internals. Working on web development is very high-level, and you won't get much chance to really get in-depth with the system. Using C can help you better understand how instructions are executed at a low level, how memory management works, and how to create a lot of the things that PHP / Ruby have built in.

b14ck
+1  A: 

You'll probably never have to use it, so if you just aim at "usability" just forget it. However, learning C is a good way to get a grasp on the fundamentals of programing. You'll probably gain a much deeper understanding of PHP and RoR for free.

Bug generally, if you feel confident in your languages, no -- it's not worth the price ;).

Kornel Kisielewicz
No, learning is never "not worth the price."
Chris Lutz
I was mentioning in terms of benefits vs. time invested.
Kornel Kisielewicz
+3  A: 

Learning Latin has it's benefits for understanding the structure of modern derived languages; so in that vein, I say why not?

Pierreten
+4  A: 

I don't think learning ANY new language is ever a "bad" idea. Specifically to C, it can only give you a better understanding of how the languages you are using run "underneath the hood".

jaywon
+7  A: 

The unending pain of getting C programs to actually work reliably will teach you a lot about why PHP is a more civilized way to write software.

And yes, you'll use it eventually.

Some day you'll run across a problem ill-suited to PHP or Ruby. You'll be able to fall back to C and look like a hero because you know something more than other folks.

S.Lott
Making C work reliably isn't nearly as painful as having to Google any time you want to call a function in PHP because you can't remember the argument order (or the name).
Chris Lutz
Ahh come on, there's only a few thousand PHP functions, that's not too hard to remember! LOL
Kaleb Brasee
Make C work is remarkably painful. The unreliability of some C constructs is remarkable. The awfulness of `a[i++]= i;` is hard to understand.
S.Lott
@S.Lott - Why are you writing lines like `a[i++] = i;` in the first place? Sounds like you're confusing writing C and maintaining legacy C.
Chris Lutz
Man: Doctor, it hurts when I `a[i++] = i;`! Doctor: Don't do that, then!
caf
@Chris Lutz: Statements like that are syntactically legal, semantically meaningless. C is full of that -- that's just an easy example of particularly evil stuff in C. That kind of thing -- not that literal sequence of characters -- is what makes C remarkably painful to get working.
S.Lott
@S.Lott, what in the hell are you talking about. I've never seen anything like that in the many tens of thousands of lines of C that I have seen from other developers. Also, it is not semantically meaningless, it has a very specific meaning. Furthermore, I don't see why a line like that couldn't be written in any other language.
tster
@tster: Sadly, then, I've been forced to look at worse code than you. Please open a blog and post any sensible meaning for `a[i++]= i;` followed by a series of compilations (with different optimizations) that *all* do what you claim. This (and it's equivalents) have always puzzled me because they are semantically meaningless, syntactically legal, and compile into varying kinds of trash. When teaching C, I always downplayed `++` and `--` because of the care required to use them properly.
S.Lott
@S.Lott: No need to downplay them, there is a simple rule: Do ONE write operation per statement, avoid side effects. There is nothing wrong with a[i]=i; i++; or a[i]=i+1; i++;, whatever was the intention. If you then still need them or instead write i+=1; is another question. And if you teach C, you better know the ANSI Standard and what implementation defined and undefined behaviour is all about and when they occur.
Secure
@Secure: That is the way I taught it -- one side-effect per line of code. It worked, but every class had someone who thought I was doing them a disservice by not teaching "the whole language" or "all the tricks". In an intro to C class it's easier to teach the defined stuff and provide the caveat that the standard is bigger than this reliable subset.
S.Lott
If he won't use C on a regular basis, it won't do him much good when the time to do so comes.
Geo
+6  A: 

I've found it very useful knowing C as a web developer. For example, one web app I've written includes a photo gallery. It stores the photos outside of the webroot so that it can check the user's permissions before showing the actual images.

Eventually, I discovered that the overhead for displaying a page full of image thumbnails was incredibly high using the web app in PHP. So, I rewrote the actual photo display code in C as a cgi program, which reduced the overhead to almost nothing.

Jason
+1  A: 

Although I don't use C anymore, I find it useful to be able to talk to other programmers in their language. You may not have the expertise to solve a particular problem yourself, but you can talk intelligently to someone who can.

The same goes the other way, of course.

And, as pointed out above, C is the foundation of just about every other language that has come after it.

uotonyh
+4  A: 

Speaking from my own experience, insofar as going from Python to C (and back again, woo!): Yes - learn it.

If you haven't already, learn fundamental, low level data structures; learn them well.

Learn what really makes an HTTP post tick, maybe write some low level debugging tools for yourself and others. It's amazing at how "under the hood" you can get in web development, when you can write an apache module. (Huzzah, bucket brigade!)

Learn the in's and out's of setjmp/longjmp, and perhaps come out with a better understanding of exception handling - that is, how it really works under the hood - in higher level languages.

You might never find yourself writing a line of C code for web development, but if you learn the language well, you'll be giving yourself an edge, all the same. Just be sure not to cut your toes off with it. (:

jsandell
+7  A: 

Joel Spolsky urges computer science students to learn C:

"Advice for Computer Science College Students" (January 2005)

Bill Karwin
+1 because, while it's not immediately relevant, it's a good article.
Chris Lutz
Yeah I realized it had only a slight connection, so I marked my answer CW.
Bill Karwin
Community Wiki isn't for potentially irrelevant answers - it's for answers requiring community involvement.. If an answer isn't relevant, don't post it. This is a perfectly valid answer (non-CWiki'd)
dbr
-1 for assuming the poster is a Computer Science student as an excuse to link to a Spoolsky article.
GreenieMeanie
+5  A: 

As others have stated you may not use C, but there are still a number of important concepts relevant to computers and computer science. Some insights can be gained from such classic texts as C Programming Language, by Kernighan and Ritchie.

This includes

  • Example of very good documentation and writing style in explaining a language in a brief document. You'll find that the complete language is explained in a book not much more than 100 pages. Compare this with some of the tombs of books sold today which position themselves as teaching a language and yet are often more than rehashed API manuals.

  • Understanding pointers, memory management, arrays and character indexes. All good information which aligns with core computer subjects; albeit low level, but a worthy piece of information for an professional programmer.

  • Its an easy quick reference book. Again you won't break an arm lifting it and yet gain a lot of knowledge from it.

In general C is useful for those occasions when you really do have to get closer to the machine or need to extend a language through use of a C-API.

Grant Sayer
+1 For suggesting using a classic book to write something low-level to gain _perspective_, which is just as important as increased specific technical knowledge.
charstar
+1  A: 

Learning a new language is always a pleasant experience and have a positive impact on the way you program.

Are you going to use C in web development. The answer is, most likely, no. Unless you are going to code a PHP extension or a custom web server.

Sergey Kornilov
+2  A: 

Firstly, you have to define "web developer." Are you building websites or web-based software? While both of these tasks easily can fall under the category of "web development," they are somewhat different in terms of the skills set you need to be successful at it.

You're more likely to run into background processing and file/operating system interaction with software than "just" a website, and thus increasing the probability of using a low-level language like C.

Having said that, will you ever use it? Unlikely. High-level languages have been introduced by the dozens to tackle web development. From a web development point of view, if you're having to resort to C, it's most likely because you don't have the necessary skills in more suitable languages. Remember the massive amount of sites and software solutions of varying sizes that run fine on PHP and Rails.

Is it worth learning? Maybe. If you feel like you need hardcore programming skills to complement your web development skills and you have time to spare; go for it. If not, don't. You're probably better off getting really good at Ruby/Rails instead.

vonconrad
+1  A: 

Its always good to learn a new language , since you are already using Ruby and Rails framework . Knowledge about C programming will come handy when you are trying to learn in depth about Ruby scripting language , Since Matz Ruby Interpreter or MRI is written in C . And also most of the Web servers are written in C and C++ programming language .

Once you have an Idea how Web Servers works , you have an edge in creating a scalable applications , and will also able to analyze plus and minus of the Web Servers above which you are deploying your application.

"Be Jack of all you can be Master at any programming language and at any point of time in your Career" ....:)

YetAnotherCoder
+1  A: 

Learning more languages is always a good idea. C is great, because a ton of languages are officially or unofficially based on it, and knowing what happens at a lower level can only help.

OTOH, to really advance your knowledge, I'd suggest learning a language that is as drastically different from what you know as possible - Erlang, LISP, Haskell, Smalltalk...

kyoryu
A: 

The opportunity cost of learning C is high - you can learn something practical instead.

If you are a web developer and wish to continue to be one, it would probably make more sense for you to learn something more applicable to your field: Ruby and figure out how Ruby On Rails works, Python and how Django works, C# and how the MSFT MVC works. Or Flex. Or JavaScript and mooTools/JQuery.

While you can get a lot of basic computer science concepts out of learning C, you will probably never have to touch it. When/if you do, you'll learn it then.

If you wish to learn computer science ( not just slightly lower-level programming ), you can try Project Euler or some algorithms, operating systems, etc literature.

George
A: 

Learning languages is never a bad thing. But as a web developer I think your time would be better spent honing on another technology. I've delved in Rails, and Java, but think if I really wanted to learn something new as a web developer, I'd be all over Django, google app engine, javascript, silverlight, flash ... and a handful of other technologies before I even thought about c.

dquail
+1  A: 

I'll put it this way. C is nuts. It was written in a time before people thought in entirely object-oriented ways. It will frustrate the crap out of you. Its hard to understand AFTER learning things the way you know them now.

But it is immensely helpful in understanding how everything else runs. Its a great language to help you transition to other languages because most modern languages inherit from or are built on it (syntax, data constructs, etc).

Moreover, both Ruby/Rails and PHP are based heavily in C. A lot of supporting libraries are written in C for those languages. Its crazy fast because it's compiled and is quite a bit lower-level, has a much smaller API than either PHP or Ruby/Rails.

I would definitely recommend learning it, even if its just for the fun of learning a new language. My prof always told me: "If you can give me a manual and a project worth working on, and I'll learn any language." So if you can find those two things, go for it!

Lukas
If it was easy to learn after what the OP already knows, it wouldn't be as worthwhile, would it?
David Thornley
+1  A: 

I say, I say, I say: Yes... but just a bit.

Just least some very basics: strings, pointer manipulation...

Even if you never actually use it, you'll get much better understanding about performance issues in higher lever languages. Consider strings we're working with all the time: links are hard by Joel Spolsky

Wojciech Kruszewski
+1  A: 

If you learn there is a great chance of achieving success, otherwise there will be no doubt.

lsalamon
A: 

In my opinion, for someone who writes software that runs on a computer, learning C is like learning Latin or Greek for a scholar of anthropology or literary science.

A significant body of the work that has been achieved in software development today has been done in C and that is what you really want to learn: it's not so much about writing your software in C, it's about being able to understand. Both what is possible and what has been done. Were everything comes from and also why we are moving more and more away from C in many areas.

Happy Segfaults! ;-)

VoidPointer