views:

1801

answers:

23

Hello all,

I was having a look at a few different web servers this morning when I came across G-WAN. As I understand, its a web server written in C and you have to make use of it by writing your websites/webapps in C. One clear benefit is speed as the G-WAN site suggests.

However, on the forums, the creator of G-WAN asked why not use C for web based apps and I can not think of a single reason apart from it being difficult (for me anyway, I am newbie when it comes to C). There must be more reasons why we all use PHP, Python, Ruby etc apart from it being easy to develop in these languages. I don't see that as a good reason.

So I put it to you: Why do you not use C for your web apps?

+28  A: 

The same reason we don't use C for most programming. The benefits (which are mostly performance) don't outweigh the costs (development time, lack of automatic memory management, lack of automatic protection from buffer overflows, having a compile stage between the edit and test stages, etc).

David Dorward
Was typing the same thing and you beat me to it. I just want to add that protecting websites from malicious behavior is enough of a challenge as is, we don't need to add potential attack vectors from a misuse of memory management, pointers, etc.
Rob Allen
@Kinopiko - Honestly I have no idea - but leave a C novice to the task of building the site and there will almost certainly be an exploit somewhere.
Rob Allen
@David: So you do not have any reason whatsoever? I am using C in most programming, and so do most of the programmers in our company (thousands of them).
PauliL
@PauliL — no, clearly the answer above contains no words and is just some white space.
David Dorward
Kinopiko: ever heard of a buffer overflow? ;)
Stefan Monov
I'm not sure that arguing about numbers of programmers is an important distinction in this case.
Rich Bradshaw
@Kinopoko: the same way you would attack any other program susceptible to buffer overflows and incorrect mallocs: you pass terrible data into the input, flood it, and wait to see if the server returns something hackable.Every programming language contains insecurities, but given the frequency of errors attributed to bad memory management in C/C++ especially, I wouldn't trust most programmers to ensure my server isn't going to completely die because a user typed lots of characters and the programmer forgot boundary and type checking. Expensive problem to solve if you stick with C.
Jordan
@Jordan: I get the feeling you haven't done any web programming in C. What you're saying doesn't fit the model of how web programming is done.
Kinopiko
Sure it does, assuming that your website has any place for user interaction, whether by URL or form input. Once that data is handed to the server, it's up to the programmer to make sure to correctly allocate memory. G-WAN has some abstraction around query parameters but that's not going to completely save you.I'm not saying that correctly done, C web programming can't be secure and fast, but it is more susceptible to harsher errors.
Jordan
**sigh** @Kinopiko: If you don't know what a buffer overflow is, you shouldn't be coding in C. **'nuff said.** For more info: https://www.securecoding.cert.org/confluence/display/seccode/CERT+C+Secure+Coding+Standard
Longpoke
+31  A: 

It takes a great deal of care to get a C program correct and secure. That care means that you need to have really good people writing your programs. That means you pay more.

Also, C doesn't have the benefit of drawing from an enormous standard library of functionality as .NET (and the other major web-centric platforms) has. So you may have to either buy components, or perform interop, or roll your own functionality which comes "for free" with a more, shall we say "web-centric" language like PHP or C# or Ruby or whatever. That means you pay more.

Add all of that to the fact that single-threaded computational speed just isn't that important on the web. If you need more scalability, most organizations can economically just throw more cores at the problem and be fine. This is not true for everyone, of course. I'd imagine that the core of Google's engine is written in C or a similar language not only for speed, but to save real money in power costs.

Dave Markle
+1 Good libraries are critical.
Andres Jaan Tack
@Dave, bingo! "most organizations can economically just throw more cores at the problem and be fine" - so why bother with the difficulty of C. That is a very good point.
Abs
Wow, an argument for .NET against C because of *libraries*? Sure, the stdlib is smaller, but we have decades of libraries (many open-source) in C. I'm having trouble thinking of anything in the .NET stdlib that there isn't a mature and free C library for.
Ken
I don't think he was arguing for .NET specifically, I think he just meant there are languages out there that have lots of cohesive libraries. I am sure C has loads but to be honest I haven't come across any sort of repo which gathers them all in a single place or packages them.
Abs
@Ken String manipulation is a really common web-app task. C libraries exist for that, but they're not nearly as numerous or usable as libraries in [pick a high-level language].
Andres Jaan Tack
@Ken: There's a universe of difference when you have a single, well supported set of functionality vs a plethora of small libraries which differ widely in feature set, licensing, and support.
Dave Markle
perhaps is Ken Thompson
Hernán Eche
+3  A: 

You think being easy is not a good reason. I think it's a good reason. If you need ultimate performance then C is ok, but other languages abstract away the hard stuff to improve productivity, maintainability and reduce defects.

Craig
To get ultimate performance you need not only C, but also ultimate C programmer. And those guys typically want ways more money than Java/P* programmers.
el.pescado
+18  A: 

Most network applications, especially web servers, are far more "I/O bound" - ie they are capable of pumping out data far faster than the network can accept it. Therefore something that is highly CPU efficient is not a huge win, whereas something that is scalable and maintainable is. So there is no reason to accept the drawbacks of C and lose the advantages of a managed environment like Java, .NET, Python, Perl or other languages.

Paul Tomblin
C is tons faster though.
Kinopiko
If I can fill the network pipe with Java or Perl (and I can), the fact that C is faster is irrelevant.
Paul Tomblin
@Kinopiko, are you saying you have a bigger pipe, more page hits and more data to ship than eBay (Java), Stack Overflow (C#/.NET), Google or any of a million highly used web sites written in higher level languages?
Paul Tomblin
@Paul Tomblin: The purpose of a web application is not to fill the network pipe but to do some processing. If you only need to serve some text and images, you should use static html pages, which give superior performance. In most cases, the static pages are served from cache, so your server needs do nothing. OTOH, when processing is needed, it may well be the bottleneck (although more commonly the disk is the bottleneck).
PauliL
You need to remember that web applications are only a fraction of a "server-stack" that handles user requests, and is not a part that is performance-critical. There are other parts - OS kernel (usually written in C), filesystem (C), web server (usually C), language interpreter (C), database (usually C or C++). Web application usually only passes data from one part to another, applying some basic operation on it, and it's performance is not crucial at all.
el.pescado
@PauliL - The examples I gave are not "static pages served from cache", they are highly dynamic sites where every page view involves retrieving things from databases, performing calculations on them, and putting all that information together and firing it down the pipe. And all of those sites use high level languages, not C. So show me a site that is CPU bound and needs to be written in C?
Paul Tomblin
@Kinopiko, don't change the subject. Of course you want your servers to be fast and efficient, but that wasn't the question, the question was "why not use C for web based apps", and I believe I have explained sufficiently why there is no need to do so.
Paul Tomblin
You don't think Google writes web apps? Google Mail, Google Calendar, Google Documents? They're written in higher level languages. And they handle billions of page hits per day.
Paul Tomblin
-1 Not true: http://art-blog.no-ip.info/cppcms/blog/post/42
Artyom
+8  A: 

C isn't a convenient language for manipulating strings.

Compare C#:

string foo = "foo";
string bar = "bar";
string foobar = foo + bar;

Corresponding C:

const char* foo = "foo";
const char* bar = "bar";
char* foobar = (char*)malloc(strlen(foo)+strlen(bar)+1);
strcpy(foobar, foo);
strcat(foobar, foo);
//todo: worry about when/where the foobar memory
//which was allocated by malloc will be freed
ChrisW
not to mention handling unicode (multibyte) strings!
RobS
PHP does not handle Unicode properly either, but is very popular Web-oriented language.
el.pescado
So we should use C++, as it gets about the same performance as C, but compiles your C# example like a charm?
tstenner
As of string manipulation - web applkication usually only output strings, so C's `printf` should do the job.
el.pescado
C handles multibyte and unicode just fine via runtime library functions. Using the safe functions like strncpy and so on makes it pretty safe too.
justinhj
@tstenner I'm not saying you shouldn't; arguments against C++ might be that there are run-time-libraries or frameworks for web applications, which are intended for languages other than C++: for example, the functionality you get from using ASP.NET is more intended for (and easier to use from) C# than C++.
ChrisW
@ChrisW fastcgi, Wt, CppCMS. They are not as exhaustive as ASP.NET, but they do exist.
tstenner
@tstenner Do you think you get better performance from C++ than C#? I would have guessed, "You can: if you restrict yourself to a subset of C++ that involves mostly preallocated memory instead of using the heap" (which isn't the case when you use std::string etc., i.e. it's more true for embedded programming that for pplicatin programming).
ChrisW
@ChrisW C++ has always been fast enough for me, the one major advantage I see over C# is, that I can rent a cheap linux box and that's it, I don't need Windows hosting.
tstenner
A: 
  • it's insecure
  • it's hard to read
  • it's hard to maintain, development time is slower on the order of a magnitude
  • most of your web stuff is probably I/O bound, so the would be speedup doesn't even matter, especially when you use a fast language like Java or C#
Longpoke
what does "fast language like Java or C#" mean?
RobS
@RobS: Java and C# implementations are faster than they typical dynamic languages used for web programming, and as fast or faster than C/C++ depending on what you're doing. @Kinopiko: you're being naive.
Longpoke
@Kinopiko: what weaknesses do dynamic languages have? When a noob programmer explicitly says he wants to execute arbitrary code via `eval` and php's `include`? Please, in C/C++ you don't state that you want to execute arbitrary code, it just does. `eval` isn't a bug, it's the programmer's intent. In C/C++, any bug can lead to remote code execution, in dynamic languages, this isn't the case unless some fool is messing with `eval`.
Longpoke
@Kinpiko: The link I provided proves (even gives real examples of vulnerable applications) that you have to follow a bunch of unintuitive rules (even I didn't find them all intuitive, after programming assembly for years before starting C) in order to have safe C code. This is not the case for any modern safe language.
Longpoke
"and as fast or faster than C/C++ depending on what you're doing" maybe, but you are still dealing with a managed memory environment with both Java and C# which can become quite a drawback in high traffic scenarios.
RobS
"and C certainly doesn't have as many security weaknesses as any dynamic language does" _That_, my friend, is complete nonsense. Why does that comment have 3 upvotes?
Longpoke
I'm not sure I can explain in the length of a comment box. Please ask that as a separate question.
Kinopiko
@Kinopiko: Well actually, you can't explain it anywhere. There is no explanation for it. C has a **much** bigger problem than any dynamic language. The worse thing that can happen in a dynamic language is "attribute not found, whoop dee doo".
Longpoke
A: 

http://stackoverflow.com/questions/3079350/things-that-are-easy-for-dynamic-languages

If you end up requiring something from that list, (mostly you them in web development), there's no sense using C for the task.

Cheery
A: 

PHP is written in C. You're basically (under the hoods) already using C for webapps. When you write a webapp in pure C, you would only end up with too bloated/verbose/complex code. That's why PHP exist.


I understand that I will stamp on the toes of some die hard C developers with the above statement (the quick downvotes prove that). But face it, try to create a simple CRUD webapp in both C and PHP which functions exactly the same. When finished, you'll realize that the C code ends up to look like a reinventation of the PHP wheel.

BalusC
Verbose, complex and bloated are three words I would not use to describe C.
Dominic Bou-Samra
I would. If you think C isn't unnecessarily verbose, complex and bloated, you've never seriously tried an OOP language like C++, Java or C#.
DeadMG
@Dominic: bloated/verbose/complex **for the purpose** to easily create webapps :)
BalusC
Verbose? yes. complex? yes. bloated? not as much as PHP is. Anyone who claims C is not complex probably doesn't really know C, or as DeadMG said.
Longpoke
@Longpoke: well, create a simple CRUD webapp in both pure C and PHP and show the code :)
BalusC
I don't think you understand what bloated and verbose mean.
David Lively
@LongPoke "doesn't really know C..." My first development job was writing an embedded C cross-compiler. I know C. It's not complex.
David Lively
"complex adj. 1. Consisting of interconnected or interwoven parts; composite." Sounds like C to me.
Longpoke
+1, we stand on the shoulders of giants. Not knowing who they are doesn't deserve a down-vote. Albeit that it would be a better answer if we knew. Hard to keep track of those Berkeley grass smokers :)
Hans Passant
The C language is not complex or bloated by any reasonable definition. The entire reason it's verbose for Web apps is because the C itself is very spartan and doesn't provide you with all the help that other languages do. Ruby, PHP, C# and Java are all far more complex than C — and that additional complexity is there to help you.
Chuck
@Chuck: thanks to your comment I realize that I didn't write what I actually meant. I didn't meant to say that C as language at its own is complex/verbose/bloated, I more meant to say that when you write a webapp in pure C, you would only end up with complex/verbose/bloated code.
BalusC
+3  A: 

C is quite low level languages for many purposes: no-OOP, lots of manual resource management.

There is limited use of C for web, for example Klone. It is mostly used for low resource embedded application cases.

However there are C++ web frameworks like CppCMS that are used for high performance web applications developments.

C++ allows you to enjoy high abstraction and fine grained access to what you are doing exactly giving much better option for deploying and developing large applications.

But you use them in case when performance and resource usage is much more critical then time-to-market and development costs as generally web development is faster using good web frameworks for languages like Java, Python or PHP. Also generally there less competent programmers for C++ then Java/P* languages for same salary.

So it is question of priorities, also there less tools for C++ Web development then for PHP/Python/Perl or Java.

Artyom
Interesting, I didn't know about CppCMS a low level web framework written in C++. Might be the best of both worlds, sitting in between C and the Web Languages.
Abs
It is now low level framework, it is MVC web framework that is very FAST.
Artyom
Sorry, I just refer to anything that isn't a web language as low level. I understand though its a MVC web framework.
Abs
There is no such thing as "Web Language", probably only PHP can be called web one. All other languages including Java, Python, Perl, Ruby and C# are general purpose languages that are used for Web.
Artyom
Well if we want to be specific like that there are no such thing as general purpose programming languages. There are only Procedural, Structured, Object-Oriented, Functional...etc...
Abs
+2  A: 

I know this question has already been answered to death, but there are 2 things not mentioned so far that are extraordinarily important to success in any programming paradigm, and especially in web development where you get a lot of people that aren't necessarily programmers, working with the code.

  1. Involved, useful community, aka People That Have Solved My Problem Already. It's pretty easy for even the noobiest of noobs to Google why they're getting "headers already sent" errors in PHP, whereas that information might not be available for a framework or language that is new to the scene, or otherwise doesn't have critical mass.
  2. Frameworks, so that most programmers can get to solving business problems and not hacking code together.

If I had a critical app that required extreme performance, I would use C, but it would take so much longer to write, that I would never get to market. Until there is either #1 or #2 it's not feasible for me to use it.

Jordan
+3  A: 

If difficulty and complexity were not an issue at all (ha!), then I wouldn't stop at C. I'd write x86 assembly. It's been years since I've used any web server that wasn't x86, and it's looking less and less likely every day.

To use C (instead of assembly, or something higher-level) is to suggest that C is the sweet spot of programmer efficiency and computer efficiency.

For the programs I write, this is not the case: C is a poor match to the kinds of programs I want to write, and the advantages of it over a decent macro assembler just aren't that significant. The program I'm writing right now is not hard in my HLL of choice, but the complexity of it in either assembly or C would be so high that it would never get finished. I acknowledge that a sufficiently smart programmer with enough time could make it run faster in assembly or C, but I am not that programmer.

Ken
+2  A: 

Here is some more web-related code written in C that is worth a look when building your own C library for the web:

  • cgic: an ANSI C library for CGI Programming
  • cgit: a web frontend for git repositories
  • wbox: HTTP testing tool
  • wget html-parse.c
  • curl cookie.c
  • Discount, David Parsons' C implementation of John Gruber’s Markdown text to html language
  • Protothreads (esp. for embedded systems), http://www.sics.se/~adam/software.html
  • protothread, Google code project by LarryRuane
  • uriparser sourceforge project
  • http-parser, http request/response parser for c by Ryan Dahl on github
  • nginx
  • ...
ceeit
A: 

String handling in C can be made easier using:

Data Types (part of libslack)

Libslack provides a generic growable pointer array data type called List, a generic growable hash table data type called Map and a decent String data type that comes with heaps of functions (many lifted from Perl). There are also abstract singly and doubly linked list data types with optional, "growable" freelists.

or:

Managed String Library (for C)

http://www.cert.org/secure-coding/managedstring.html

ceeit
A: 

Similar to G-WAN, but for Cocoa / Objective-C is Bombax, a web applications framework.

http://www.bombaxtic.com

Speaking of Objective-C I can't resist pointing out MacRuby, which has the potential to revolutionize the way we will make web apps one day.

gregg
A: 

Consider that I'm not a web developer but will ask these questions anyways and offer a point or two.

What web site is only written in one language? Seriously this thread seems to assume one hammer fits all nails.

When was the last time anybody seriosly stated that C was complex? I mean really guys you can't get much more low level. I'm not talking C++ here as the two are often referenced collectively.

C has security concerns, that can't be denied but are they any less than what is seen in the kludges called PHP & Perl? In either case a secure web site is a function of programmer discipline.

In any event off to the comments. The difficulty of using any given language is very dependant on the problem at hand C & especially C++ can lead to fast solutions to a problem in experienced hands.

Industrial uses for web servers, that is embedded servers/sites simply don't have the language choices a normal web server might have. So you end up using a variant of C or possibly something like BASIC. Your goal is to offer up the functionality the device requires and not to worry about languages. On a mainstream web server the way to do that is with high level languages most of the time. Walk away from big iron and your programming freedom goes out the door.

Without the right Libraries it would be foolish in most cases to do a ground up web project in C. The lack of good standardized libraries is a big negative here.

David Frantz
+2  A: 

Hum...

It seems that I am a bit late in this discussion -but I just discovered it now.

And I am grateful to all of you for so much input.

I am G-WAN's author, which makes it clear that I have seriously worked on the matter: G-WAN is both faster than all other Web servers (no processing) AND all other Web App. servers (any processing you can imagine).

Yes, ANSI C also made it possible to process more static content - with less powerful CPUs (ANSI C is not only about making dynamic contents fly).

By the way, G-WAN uses C scripts (no C compiler and linker needed) so the compiling/linking cycle/delay does not exist.

In the process of comparing G-WAN to .Net Java and PHP, I wrote SIMILAR Web applications in all 4 languages:

http://gwan.ch/source/

And, to my dismay, the modern scripting languages were NOT easier to use.

One part of the job which is especially frustrating is to DESPERATELY SEARCH for the 'magic' API call that will do what you want to do.

Think about how to do 'pretty thousands' in:

C# String.Format("{0:n}"... Java DecimalFormat("0.00"); ... PHP number_format($amount, 2); ... ANSI C snprintf("%'.2f", amount);

The "..." mean that some pre-configuration -or post processing- is necessary.

ANSI C is clearly easier to use (and to remember).

When PHP has more than 5900 API calls (C# and Java not far away), finding the RIGHT API call is a challenge on its own.

The time wasted to find this (and then to find how badly the NATIVE API call is implemented), the time to learn by hart it for the next time you need it, all this time is depriving you from the time necessary to resolve your application problems.

I have read (above) that PHP is more concise than ANSI C?

Why then use "//:: this is a comment ::" rather than "// this is a comment"?

Why have a so stupidly complex 'pretty thousands' syntax?

The other usual argument is that Java and the like provide dedicated calls for Web applications.

I was not able to find anything to escape HTML in Java so I wrote my version of it:

  // all litteral strings provided by a client must be escaped this way
  // if you inject them into an HTML page
  //public static String escape_html(String Name)
  {
      int len = Name.length();
      StringBuffer sb = new StringBuffer(len);
      boolean lastWasBlankChar = false;
      int c;

      for(int i=0; i<len; i++)
      {
          c = Name.charAt(i);
          if(c == ' ')  sb.append("&#32;");  else
          if(c == '"')  sb.append("&quot;"); else
          if(c == '&')  sb.append("&amp;");  else
          if(c == '<')  sb.append("&lt;");   else
          if(c == '>')  sb.append("&gt;");   else
          if(c == '\n') sb.append("&lt;br/&gt;");
          else
          {
             c = c&0xffff; // unicode
             if(c < 32 || c > 127)
             {
                sb.append("&#");
                sb.append(new Integer(c).toString());
                sb.append(';');
             }
             else
                sb.append(c);
          }
      }
      //return sb.toString();
      szName = sb.toString();
  }

Do you really believe that the same code in ANSI C would be more complex?

No, it would be both immensely simpler AND faster.

Java (derived from C) is REQUIRING programmers to link multi-line strings with a '+' C# (derived from C) is REQUIRING programmers to link multi-line strings with a '+' PHP (derived from C) is REQUIRING programmers to link multi-line strings with a '.'

ANSI C does not have this now completely stupid (obsolete) requirement.

So, were is the so obvious progress claimed by the modern languages?

I am still looking for it.

Sincerely,

Pierre.

Pierre
A: 

Another point might be the platform dependency. C needs to be compiled into native code. This code doesn't run on all platforms.

Interpreted languages run wherever an interpreter exists. Many providers for example provide PHP-Interpreters installed on their servers but with a Windows OS. If you now are developing on a Linux-machine. You've got a problem.

Of course this problem could be solved but you see the advantage of developing in PHP in this particular case.

Hope this helps, regards domachine

domachine
A: 

"domachine" wrote:

platform dependency: C needs to be compiled into native code. This code doesn't run on all platforms. Interpreted languages (like PHP) run wherever an interpreter exists. Of course this problem could be solved but you see the advantage of developing in PHP in this particular case.

Did you ever wonder in which language the portable PHP interpreter is written?

In ANSI C.

So, before you dismiss the portability of ANSI C again, ask yourself in which language your favorite programming language has been written... (tip: almost all were written in C/C++).

ANSI C compilers are available on all the platforms I had to work on -and the same is not true for PHP and its gigantic runtime.

So much for the portability argument.

CClue
Well, PHP is NOT my favourite language. I didn't code anything in PHP, yet. I'm a C and C++ programmer. I've never dismissed the portability of C! The only thing I mentioned, was the easiness to apply PHP-Scripts to an existing WebSpace. Show me the case where you can get a low-budget WebSpace where you have a compiler. Maybe I'm wrong but I think you're one of these fanatic Programmers who adore one language but do not see the advantages of other, maybe more appropriate languages. I love C and C++ but I'm able to think outside of the box.
domachine
A: 

Well, given the fact that Web development is a matter of having useful libraries (the kind used by PHP) then I do not see how C would not be useful.

After all, the procedural logic is the same: do while, for, if then else, etc. whether this is C, PHP, .Net or Perl.

And a C loop or test is not more difficult to write because it is written in C.

Most PHP libraries are made in C so the missing-C-libraries-for-the-Web argument does not look that much convincing.

My guess is that C was not advertised as a Web programming language by the promoters of Java (SUN) and .Net (MICROSOFT) because they had their own proprietary (heavily patented) intellectual asset to push for adoption.

As a free (unpatented) standard, C does not offer any 'lock-in' grip on developers... hence, maybe the heavy hand of lobbying in schools and universities to make sure that tax-payer money will fund the adoption of an inferior technology backed by private interests.

If C is good enough for IBM and MICROSOFT (they don't develop their products in PHP or .Net) but not good enough for end-users, then end-users might wonder why they are invited to suffer this double-standard.

Vince
A: 

PHP, Python and so on are easy to scale up by throwing hardware at the problem.

Suppose it costs 1 person 1 year of effort to develop an app in PHP, and it costs them 3 years to do it in C (as C requires more effort to do the same thing). That means the reduced hardware need of the C code has to represent 2 years worth of wages for C to become attractive. In practice that (almost) never happens.

Like with every rule, there is an exception. Facebook's scale is so large that hardware is a big enough cost to care. That's why they developed HipHop, which cross-compiles PHP to C++. It brings the best of both worlds: the simplicity of programming in PHP, and the raw performance of C++. Facebook is still developed in PHP, but when you use it, it's all native code.

Joeri Sebrechts
A: 

@Joeri Sebrechts

F.U.D. in action:

PHP, Python and so on are easy to scale up by throwing hardware at the problem.

Well, actually no. They don't scale at all vertically and scale very poorly horizontally. See: http://gwan.ch/en_scalability.html where it is explained how much trouble is ahead of bad-performers.

Suppose it costs 1 person 1 year of effort to develop an app in PHP, and it costs them 3 years to do it in C (as C requires more effort to do the same thing).

Wrong again. If PHP libraries have been written in C then they are directly usable from C -instantly providing the 'unique productivity' you are claiming PHP has.

That means the reduced hardware need of the C code has to represent 2 years worth of wages for C to become attractive. In practice that (almost) never happens.

Pure F.U.D. (see the answer above).

Facebook's scale is so large that hardware is a big enough cost to care. That's why they developed HipHop, which cross-compiles PHP to C++. It brings the best of both worlds: the simplicity of programming in PHP, and the raw performance of C++. Facebook is still developed in PHP, but when you use it, it's all native code.

HipHop is much faster than PHP, no doubts on that. But if you compare HipHop with a plain-C implementation you have two layers of overhead:

  • the PHP to C++ interfaces (which use the bloated C++ libraries);
  • the C++ bloat itself (which makes C++ 2-10 times slower than plain C).

Plus, HipHop has been written in the clueless inefficient Academic mode (detached from any real-world reality). sure, it can impress PHP coders but show this code to an embedded programmer and he will feel sorry for Facebook.

"A language that doesn't have everything is actually easier to program in than some that do" --Dennis M. Ritchie

Unlike (most of the) programming language END-USERS, Dennis knew a couple of things about the matter, it seems.

Pierre
(1) Don't take stuff so personally, I wasn't out to diss your product because I didn't even know your product. (2) You make an interesting proof of concept with G-wan, but I hope you'll excuse me if I take a wait and see approach until I see real-world web apps using it, and not just a few synthetic benchmarks. (3) You've mischaracterized facebook's complaint about horizontal scaling, because their issue is with memcache and database multi-core performance, the bottleneck of real-world web apps, which is something G-wan doesn't help solve. (4) HipHop welcomes your code contributions I'm sure.
Joeri Sebrechts
Speaking to the productivity issue. I've written web apps in C before, many moons ago, and at the time it required way more lines to do the same thing than PHP did, while having a much greater risk of crash / leak sorts of bugs. (I'm just "average" at those sorts of bugs, which is to say that I write them now and then.) I base my judgement on that experience until I see real apps that demonstrate otherwise (e.g. a wordpress port to C that doesn't require a lot more lines of code).
Joeri Sebrechts
A: 

The London Stock Exchange, reported that they have left MICROSOFT IIS / .Net to use Linux / C.

Maybe that's a (serious) trend for serious Web users after all.

James
Naw, you've got it all wrong. You see, Ada is the next trend in web development, not C.
Jason Whitehorn
A: 

There must be more reasons why we all use PHP, Python, Ruby etc apart from it being easy to develop in these languages

This is the entire reason and the only one needed. It has many benefits, chief of which is time to market. If you can get your Web app online in a month using PHP instead of two months using C, you might just win. If you can add a new feature in a week using Ruby on Rails instead of two weeks using C, again you win. If you can fix a bug in a day using Python instead of two days using C, you win once more. If you can add a feature because you are using language X that your competitors cannot add at all because they are using language Y and it's too hard in that language given their resource constraints, then you definitely win.

And by "win" I really mean you don't lose. Your competitors are using higher-level languages and frameworks to develop their sites, so if you use C, you are not competing with other people who use C, you are losing against other people who do not use C. Just to compete, you have to use tools with similar levels of abstraction.

If performance becomes an issue, you can rewrite the slow parts of your site in better-performing languages. Or you can just throw more hardware at it. Really, a performance problem is what we call a "nice problem to have" -- they mean you have already succeeded. But spending more time developing the basic functionality of your site is rarely an option. Writing it in C just so it will run faster is premature optimization, which, as Knuth tells us, is the root of all evil.

All this implies that if you can use a language with a higher level of abstraction than Python or Ruby, you could win against people using Python or Ruby. Paul Graham's story of how he and his team used LISP as a "secret weapon" in developing Web sites may be instructive. http://www.paulgraham.com/avg.html

Of course, if you are developing a site for your own amusement, do it in whatever language you want. And if your site is CPU-bound (hardly any are; they are usually I/O bound) then use the fastest-performing language you can. If you are trying to innovate, though, use a high-level language with the best abstractions you can find.

kindall