views:

994

answers:

13

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:

  1. ...exploits my background as a C programmer.
  2. ...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

  1. Other languages I am familiar with: Java, Perl, Tcsh, and Scheme.
  2. 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.
  3. 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: 

By far, I would recommend C#. OOP in it is amazing, and you can easily work with Design Patterns well. It is built from the ground up to be OOP. It is also a {} language.

Dr. Zim
I like "{} language".
Thomas L Holaday
I dunno, it seems like C#/.NET/Windows would be a big paradigm shift for a C/Unix guy...
Bob Somers
Is C# available on any *n*x? It seems interesting...
Anthony Cuozzo
Yes. See the Mono project. It's not perfect, but it's something.
Matt J
Matt J. is knowledgeable. C# compiles in to the Intermediate Language (IL), similar to Java but runs faster, and is platform independent. The Common Language Runtime (CLR) executes IL. www.go-mono.com is the Mono website and an attempt to make .NET open to other platforms.
Dr. Zim
+6  A: 

PHP's syntax is quite similar to C. However, it has its differences, you can't manage pointers and memory (at least, not that I know). It is also very easy.

PHP is a server side language, so browsers do not have anything to do with it. They'll all get the same HTML/CSS information and there is where they differ.

If you want to have a level of interactiveness like this website, you should take a look at Javascript (and it's frameworks (i.e.: jQuery). This language is responsible for the client side in web-development.

Gerardo
PHP is easy to learn, especially for a C developer, it's almost trivial - the language constructs are the same. Being a good PHP developer is harder, there's a lot to learn about software and website engineering to avoid a mess of code. The same is true for any other web-dev environment though.
Alister Bulman
But someone who can write large C programs probably has the discipline to write large PHP programs without creating spaghetti.
Nosredna
+1  A: 

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.

Tom Wright
I don't use any framework and I get along perfectly fine... why use one?
Logan Serman
PHP *is* a framework. Well, a templating system.
Thomas L Holaday
@tlholaday. PHP *is* a framework???? Just because you can embed it in HTML pages doesn't make it a framework. PHP *is* a programming language which which you can build a framework if you wanted to.
Luke
Ugh, frameworks. Just give me the language rather than building all these meta-languages on top of it.
Bob Somers
@Bob: +1. I hate this attitude of adding frameworks before there is a need. It's a classic solving a problem before you have a problem mistake.
cletus
When I build a web app there are certain things I need every time I do it. I need a Front controller, decent security, clean-urls, db abstraction, logging, validation etc. In short, a reusable code library or ... a.k.a, a framework...
Luke
Frameworks in PHP are especially icky, because PHP is not meant for writing application code, but is instead a templating language. The whackiest thing I've seen is Smarty: a templating language implemented in PHP, which is a templating language.
singpolyma
Yeah I still don't get thew hole add a templating language to your templating language thing (ie Smarty).
cletus
+3  A: 

You need to consider both language and platform. ASP.NET MVC in C# would be my recommendation. The syntax will be very familiar. MVC is a good pattern with support for jQuery baked in, giving you good cross-browser support for javascript. MVC also gives you a lot more control over the HTML that's generated. It is, in fact, the platform the SO is based on.

tvanfosson
+18  A: 

If you already know C, Perl and Java then in all honesty you already know PHP, you just don't know it yet. Make sense? Perhaps not. But it will once you start playing with it.

You don't say why you're learning a Web development language or what it's for. That's key information in providing any sort of recommendation like this. In the absence of such information I would suggest PHP for several reasons:

  • It's Web-centric;
  • It's extremely popular. Finding answers to problems is very easy;
  • As Cal Henderson put it in his keynote "Why I Hate Django" (at DjangoCon 2008 no less) "PHP is a serious language". It powers 4 of the top 20 sites on the internet (Wikipedia, Flickr, Facebook and one other I forget;
  • It's not too dissimilar to Perl although Perl does have a somewhat differen typing system and regular expressions are more first-class in Perl. Plus PHP doesn't have the $_ operator but in spite of all that there are many similarities;
  • As a dynamic scripted language, it'll help you get out of the strongly-typed mould, which should make for a bit of a change and useful experience;
  • In spite of PHP supporting objects (I subscribe to the view that PHP is not object-oriented), most PHP is written in a procedural fashion, making it more familiar to the C programmer;
  • It has an incredibly rich set of libraries;
  • Requiring only Apache, it's extremely lightweight and, as a result, hosting is extraordinarily cheap compared to Java or ASP.NET hosting; and
  • There is something satisfying about just saving your text file and clicking reload on your browser to see what happens rather than having separate compile, build and deployment steps.
cletus
Lest we be lead away from Design Patterns and OOP best practices, review Uncle Bob's Agile book. Rob Conery would agree that getting back to basics is good, but only after you master the principles of Agile (and others). That it works AND that you can maintain it are what matters most.
Dr. Zim
+1  A: 

With Perl and C background I would think that PHP is going to come easy. The learn about frameworks and that sort of things.

rupert0
+6  A: 

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.

Pablo Santa Cruz
Advantage here is, you already know Perl and it is fully capable of doing everything you'd want to do with a web site. No need to learn any other server-side languages.
Danny
+5  A: 

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.

Dave Markle
jQuery is a fantastic Design Pattern (Builder). Model View Controller is another fantastic design pattern. Together, you can do some wonderful Ajax websites, especially if you use jQuery plug-ins. Oh and C# is part of that too.
Dr. Zim
+2  A: 

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.

Charles E. Grant
+3  A: 

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.

James Anderson
+1  A: 

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.

Tim Post
+1  A: 

If you're a good C programmer, why not simply continue to code in C? There are valid reasons to use a different programming language, but just because you are going to be coding for the web is not one of them. There are two popular ways to use C for web development:

  • (F)CGI, where data is passed in the environment and on the command line
  • Write your own mini-webserver that either talks to port 80, or some higher port and use mod_proxy or nginx
singpolyma
+1  A: 

I worked with several colleagues who've learned PHP after C and/or JAVA. They are really happy with it. If you want to be a .net guy and hve knowledge about that environments, you'll find the C# familiar, but for me, it is full of l'art pour l'art stuff.

Csaba Kétszeri