为什么不将 C 用于 Web 应用程序?

2021-12-28 00:00:00 c web-applications php

今天早上我在查看几个不同的网络服务器时遇到了 G-WAN.据我了解,它是一个用 C 编写的网络服务器,您必须通过用 C 编写您的网站/网络应用程序来使用它.一个明显的好处是 G-WAN 网站建议的速度.

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.

然而,在论坛上,G-WAN 的创建者问为什么不将 C 用于基于 Web 的应用程序,我想不出除了难之外的任何一个原因(对我来说,无论如何,我是新手C).除了易于使用这些语言进行开发之外,我们都使用 PHP、Python、Ruby 等肯定还有更多原因.我不认为这是一个很好的理由.

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.

所以我告诉你:你为什么不在你的网络应用程序中使用 C?

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

推荐答案

要使 C 程序正确且安全,需要非常小心.这种关心意味着您需要有非常优秀的人来编写您的程序.这意味着你支付更多.

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.

此外,C 没有像 .NET(和其他主要的以 Web 为中心的平台)那样从庞大的单一标准功能库中提取的好处.因此,您可能不得不购买组件,或执行互操作,或者推出您自己的免费"功能,我们可以说以网络为中心"的语言,如 PHP 或 C# 或 Ruby 或其他什么.这意味着您要支付更多费用.

Also, C doesn't have the benefit of drawing from an enormous single 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.

将所有这些添加到单线程计算速度在网络上并不那么重要的事实中.如果您需要更高的可扩展性,大多数组织可以经济地将更多内核用于解决问题并解决问题.当然,并不是每个人都这样.我认为 Google 引擎的核心是用 C 或类似语言编写的,不仅是为了速度,而且是为了节省电力成本.

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.

相关文章