

Why isn't C used for web development? - _RPM


======
informatimago
Who said it wasn't? There are various web frameworks written in C, to write
webapps in C.

As an example, the fossil DVCS is written in C and contains a web server
written in C. [http://fossil-scm.org/index.html/tree?ci=trunk](http://fossil-
scm.org/index.html/tree?ci=trunk)

See also: [http://stackoverflow.com/questions/1453665/what-is-good-
fram...](http://stackoverflow.com/questions/1453665/what-is-good-framework-
library-for-c-c-web-programming)

------
vparikh
A couple of reasons: \- The use of C requires much more skilled developers
then say Ruby or PHP. Note I am not saying smarter, I am saying skilled.

\- In web development - for most products - speed of development and
maintainability trump out right performance

\- Most languages abstract away the machine architecture (Ruby, Java, PHP) and
all simply with dealing with higher level primitives

\- While garbage collection is available in C, modern languages such as Ruby,
Python, PHP and Java have much nicer native implementations

\- Web frameworks are far more advanced for other languages then C (RAILS
(ruby), Yii(PHP), Django(Python), Grails(Ruby) just to name a few)

\- The other languages have a much richer native types/and object models then
C

Given these - there is nothing preventing you from using C for web
development, given sufficiently experienced and capable developers.

~~~
meat_fist
Not trying to nitpick, but Grails is a Groovy framework.

I agree with your post.

~~~
vorg
> RAILS (ruby), Yii(PHP), Django(Python), Grails(Ruby)

Groovy became a clone of Ruby within 2 yrs of its creation, what with similar
closure-based functions, the meta-object protocol, the paren-less DSL syntax.
The overall syntax is different, being like pre-version 8 Java's, and it
_must_ run on the JVM, but besides that Groovy (and Grails) are just clones of
Ruby (and Rails). Heck, their names even sound the same, that's because their
business purpose is to steal x% market share from Ruby & Rails.

~~~
meat_fist
Hey! Look at me learning something!

Good info. Thanks.

------
forgottenpass
There is no one dictating where levels of abstraction have to get drawn, just
that once they're there, they tend to stick. The layers of abstraction between
C out-of-the-box and the interfaces you would want to use when developing for
the web can be written, but as far as I know don't exist. The path of least
resistance to development is adopting languages and tools where the niceties
already exist.

The biggest influence of why the lines get drawn where they are is simply
evolution. Whatever tools and problem domains are hot at the same time get
married. The two both influence each-other and continue evolving on their own.
Which is why the interfaces on a fantastic framework still might not be as
nice in C. Once your database schema is autogenerated from introspection, do
you want to go back?

The stickiness of what tools are right for which jobs means that people
developing in C++ tend not to make the most of everything available to them.
(It's not C, but better for my example where...) On the other side, when I
build things in C++ and take advantage of everything at my fingertips, people
still assume I'm rubbing two pointers together to create fire.

------
convivialdingo
I worked on several early web systems, mostly shopping, POS, GIS and related
in various industries.

I did create a few systems in C, using many custom tools and the only way I
can describe the final results is that they were rather restrictive.

Even with a template system, plugin abilities and other modern features you
are essentially locked into your initial design goals. Code iteration is
limited by the change/compile/deploy cycle - with the compile cycle being
rather time heavy.

Secondly, the fragility of debugging crash bugs requires a full-blown debugger
environment or developing a nice stack-dump system ,which I eventually wrote.

In other words, the biggest problem was lack of tools, a lack of support for
quick dev cycles, and support for such a system.

If I had to do it over again today, I'd use an embedded compiler running in a
fastcgi like daemon. This would allow you to speed up the dev cycle and be
able to contain segfaults, memory leaks, and the like. QEMU or TCC would be a
good start. Perhaps even a stripped down docker environment.

Pure C in a fast-paced dev cycle is just too rigid and error-prone.

~~~
MrDom
> I'd use an embedded compiler running in a fastcgi like daemon.

Sounds like nginx's lua plugin. Anything non-performant can be written in lua.
Anything performant can be written and C and called from lua. Best of both
worlds.

------
davismwfl
First, I love C/C++, but for web development I have one word why it isn't
used: productivity.

It would take way to long to accomplish even basic updates and tasks. To me it
just makes it the wrong tool for the job, like using a screwdriver to drive a
nail into the wall. Just doesn't make sense when better tools exist.

~~~
melling
Why can't it be productive with a framework? What's missing? Go is used for
web development.

[https://golang.org/doc/articles/wiki/](https://golang.org/doc/articles/wiki/)

Go is not too far removed from C.

~~~
dragonwriter
> Go is not too far removed from C.

I think, where it comes to what is useful for web dev, Go is actually pretty
far removed from C. OTOH, much of that could be overcome with an appropriate
framework, and in fact there are C web frameworks. [0]

[0] e.g., [https://embedthis.com/esp/](https://embedthis.com/esp/)

~~~
ddorian43
But it's commercial. Does c or c++ have a django or flask or ruby-on-rails
alternative? Something that has some abstractions, is fast and has a nice
community. (i would prefer flask alternative)

------
bobajeff
I think the tools for developing in C (and C++) for the web are still in the
early stages. Emscripten doesn't have working source maps yet. It also doesn't
have support for dynamic linking anymore (since they've changed their
backend). Also browser's don't have that many tools for testing C/C++ compiled
code so most of the testing has to be done native using Linux tools first.

It's also geared more towards porting existing code right now so the libraries
are made to look like POSIX APIs (which are incomplete) rather than Web APIs.
Also games seem to be the focus rather than websites.

------
tjr
Other languages are much easier to work with for the sorts of programming
tasks useful in web development (e.g., string handling), and the things that C
is good for (e.g., direct memory access, extreme optimization) are not
terribly useful for web development. Getting every last bit of optimization
out of a C web program isn't a practical advantage if there's a much larger
time delay due to network access!

That plus it's much easier to make some really awful mistakes in C than it is
in languages more often used for web development, so why risk using C if what
it gains you isn't helpful?

------
hoggle
One of the most interesting and beautiful code bases I had to work with
recently was a modern, versatile and mobile-centric Intranet web application -
fully written in C++ with wt:

[http://www.webtoolkit.eu/wt](http://www.webtoolkit.eu/wt)

[https://github.com/kdeforche/wt](https://github.com/kdeforche/wt)

------
orian
Do you program C? Would you use it for web programming?

I would guess it's because the web evolve quickly and for most webdevs the
'moving fast' is more important than 'moving the right way'. C is less
forgiving language than PHP/Python/JS. Also the bar for C is higher than for
PHP.

------
digitalzombie
Okcupid is coded in C++... Those math people are crazy.

