4 ms·
Why isn't C used for web development?
- orian 12y agoDo 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.
- davismwfl 12y agoFirst, 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 12y agoWhy 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.
- davismwfl 12y agoI'd agree C could be used with a framework. But it is still not going to be as productive, specifically, think about all the memory management and overall resource management you will need to write code for. Even inside of Go you have a GC to help you as well as a concurrency model that already steers you in the right direction without the need to write a lot of code managing it. Go while sharing a lot of C does a huge amount of lifting and gluing for you that in C you would be writing or managing. Back in that late 90's early 2000's we wrote ISAPI extensions in C/C++ quite often for performance critical problems, e.g. searching etc. IIRC, ebay was also doing that because performance was so critical. But the difference between writing single extensions versus a full website in C is pretty significant. Not saying it is impossible, but I just don't think the tooling and frameworks are there yet to make it practical or productive in comparison to say Go/Node/ASP.net/PHP/Python etc. Not saying any of those are better languages, just that they are more setup for the web model.
- krapp 12y agoThere already is a C framework for web development, it's called PHP.
- _RPM 12y agoMy question was about C, not Go. I think you are confused.
- melling 12y agoNo, I'm not confused. I'm trying to go a little deeper in people's answers than hammer/screwdriver analogies. Read what I wrote again. If C and Go are somewhat similar and Go can be used for web development then perhaps C can be enhanced for web development. Go provides templates and and an http library, for example. People aren't really answering the question.
- yzzxy 12y agoC and Go are similar in design goals, but extremely different otherwise. As others have mentioned, Go has things like a GC that make development significantly simpler for apps that follow standard web patterns.
- dragonwriter 12y ago> 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 12y agoBut 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 12y agoI 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 12y agoOther 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?
- convivialdingo 12y agoI 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 12y ago> 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.
- informatimago 12y agoWho 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-framework-library-for-c-c-web-programming http://stackoverflow.com/questions/1453665/what-is-good-fram...
- forgottenpass 12y agoThere 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.
- vparikh 12y agoA 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 12y agoNot trying to nitpick, but Grails is a Groovy framework. I agree with your post.
- vorg 12y ago> 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 12y agoHey! Look at me learning something! Good info. Thanks.
- hoggle 12y agoOne 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
- digitalzombie 12y agoOkcupid is coded in C++... Those math people are crazy.