Question
I program in C (ANSI C89/ISO C90) in a *n*x environment on a regular basis. I am now in a position where it would be beneficial for me to learn a web-development language. In particular, I'm looking to learn a language which:
- ...exploits my background as a C programmer.
- ...can produce the level of interactiveness of a web-site like stackoverflow.com.
I hear many good things about PHP. Do any of you have other suggestions?
Notes
- Other languages I am familiar with: Java, Perl, Tcsh, and Scheme.
- I forgot to mention that I'm interested in learning a web-development language which is capable of doing things on the client-side. I'm sorry if this was unclear.
- I plan to use my knowledge of the language to develop a web-site which is stylistically similar to stackoverflow.com (with a very different concept, of course).
A lot of people here are saying stuff about PHP, .NET, java, whatever.
But I'm going to make a new argument:
For the web, the server side is fast becoming irrelevant, especially when you consider your criteria (the interactivity of SO.COM). You want to learn 4 core technologies. And if you think you know them or can figure them out without study, you're probably wrong. The standards have evolved for too long, and it's way too easy to get a clouded picture of "how things should be done" if you just try to learn by rote.
1) Modern, STANDARD (x)HTML. Know what's in and what's NOT in HTML/xHTML 4. Think you know it? Do you know the difference between a block level element and an inline element? Do you know which elements are allowed in which other elements?
2) CSS 2.1 or greater. I recommend O'Reilly's "CSS: The Definitive Guide". Know CSS selectors inside and out. You'll need them for Technology #4. You'll be stunned at what can be accomplished in CSS, which you thought you could only do with tons of tags in HTML.
3) Javascript. No, I'm not kidding. It's no longer a joke language that doesn't work. It works. It's what's running the most responsive, most interactive, and interesting sites around (Google Maps, SO.COM).
4) JQuery. It's so glorious I find myself not able to even speak of it. Maybe the commenters will be less overcome with it's glorious aura and will be able to breathe its name.
Since all of the really impressive stuff, IMO, is on the client side nowadays, the server-side language doesn't mean as much. I love .NET's LINQ syntax. I doubted it at first, but I am drinking that Kool-aid by the gallon these days. But if you choose PHP or RoR or Java or whatever, fine. But that should be a secondary decision. Learn the 4 technologies above first -- you'll need them no matter what you're doing on the server.
I like all the options mentioned previously. Just want to add that if you already know PERL, then you can use it to produce all Web Sites you can think of.
It depends on the complexity of what you want to do.
PHP, as mentioned by almost every poster, is just great for server side web development, the simple stuff is simple the complex is handled reasonably well. PHP syntax is C like and logically consistant -- you will hardly ever need to refer to the syntax section of the excellent documentation.
However php just serves up pages, you will need to learn HTML, CSS and probably some Javascript to put in those pages.
I personally made the mistake of thinking Javascript was just another basic scripting language and missed out on the power, elegance and possibilties that JavaScript can bring for several years. Almost all the interactive good stuff you see in sites like gmail and stackoverflow is down to Javascript.
Likewise almost all the "cool" visual presentation on these sites is down to CSS.
For extremly complex back end stuff (especially if you need to keep state between pages) you may be better off with Java and assorted frameworks (Tomcat or Jetty, plus Spring with Freemarker templates, and IBATIS is my personal winning combo!). The problem here is there is a steep learning curve to this and you only want to go there if you really need the power of a Java back end.
If you settle on PHP, do your sanity a favour and use a decent framework. I highly recommend CakePHP, but I don't want to start any holy wars.
You mention experience in Java though - why not apply that? Or, as a C programmer, how about C# and .NET?
The world is your mollusc, friend.
I am pretty strictly a C programmer. Its not that I have a narrow scope or fear other languages, its just the language that my work demands. Most of what I do is back end automation for virtualization, cloud computing, etc.
Occasionally, I have to put together some kind of web front end to tie everything together. When I do that, I really like to use PHP. In fact, I find most people using PHP with a strong C background can be very productive and creative.
This is why I like PHP, and why coming to PHP with a good knowledge of C is cool:
PHP is very easy to extend. While PHP does come with a very rich set of libraries, you'll often find (at least I do) that you need it to work with some other library natively. A good example of this would be libvirt. Rather than calling and scraping a bunch of shell forks, you can just turn the functions that you need in libvirt into PHP functions.
PHP Doesn't push OO concepts on you As others have said, PHP does quite well as an object oriented language. However, its syntax doesn't push an OO approach on you. In other words, your code won't look like someone using an OO language procedurally. It will read pretty much like C.
PHP explains itself If you can't find a function reference and example in the vast documentation on php.net, grab the source to PHP and look for yourself. The Zend core is rather cryptic, but extensions aren't that difficult to read.
In short, until you get used to a dynamically typed language with a garbage collector .. you'll feel like you're driving without a seat belt. However, I think you would pick it up quickly and feel satisfied with your productivity.
If you want to work on the client side, then picking up Javascript is a must. It is well supported by all the major browsers, and there are a variety of rich frameworks available (jQuery, dojo, ASP.net). Some folks are still using Java applets, but overall applets are pretty moribund.