可以使用 ANSI - C 脚本编写 Web 应用程序吗?
我想使用 ANSI C 开发一个 Web 应用程序。因为,我希望该应用程序比其他应用程序足够快,并且它应该支持正常脚本 php、python 或任何脚本语言提供的所有类型的操作。即使您有使用数据库而不是 C 进行最快访问的想法,请推荐更好的东西。
如果有人有想法,请分享教程以开始。
I want to develop a web application using ANSI C. Since, I want have to have the application to be fast enough than others and also it should support the all kind of operations as the normal scripting php, python or any scripting language provides. Even if you have idea for fastest access with database rather than C, please recommend anything better
If anyone have idea please share the tutorials to start.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不知道任何 C Web 应用程序框架,因此如果您确实希望用 C 语言编写应用程序,您将需要通过 Web 服务器接口处理应用程序/框架和 Web 服务器之间的所有通信 - 这是最简单的起点为了理解这一点,可能需要阅读 CGI,但是一旦您了解了 CGI 的工作原理,您就会想要继续理解FastCGI,虽然FastCGI更复杂,但CGI却是出了名的慢。
但是,我强烈建议您不要打扰,除非您是出于学术目的而尝试这样做!:
您建议的路径涉及低级内容 - 它很有趣,但是很多< /strong> 的工作来实现可以在任何半体面的 Web 应用程序框架中轻松完成的事情。
对于网络应用程序来说,重要的是吞吐量(在给定时间段内可以处理的请求数量),而不是速度(处理单个请求所需的时间) - 它看起来用 C 编写的网站会快得多,但实际上,与(例如)缓存和其他优化相比,C 的执行速度的影响微乎其微。
其他框架已经存在,经过验证且速度快如闪电!
最终的结果是,您想出的任何东西几乎肯定会比使用“慢速”脚本语言需要更多的工作和更慢的速度。
I'm not aware of any C web application frameworks, and so if you did wish to write your application in C you will need to handle all communication between your application / framework and the web server through a web server interface - the easiest starting point for understanding this is probably to read up on CGI, however once you understand how CGI works you will want to move onto understanding FastCGI instead, as although FastCGI is more complex, CGI is notoriously slow.
However I strongly recommend that you don't bother unless you are attempting this for academic purposes!:
The path you are suggesting involves low level stuff - its interesting, but a lot of work to achieve things that can be done incredibly easily in any half-decent web application framework.
With web applications is that the thing that matters is throughput (number of requests you can handle in a given time period), not speed (the time it takes to process a single request) - it might seem that a web site written in C would be much faster, however in reality the execution speed of C counts for incredibly little vs (for example) Caching and other optimisations.
Other frameworks already exist that are proven and lightning fast!
The end result is that anything that you come up with will almost certainly be more work and slower than using "slow" scripting languages.
任何类型的“脚本”都不会为您提供您可能正在寻找的“原始速度”。
不过,我通常会强烈反对这整个思路。有很多 Web 框架,您可以在其中生成运行非常高效的代码。即使是“脚本化”Web 框架也经常缓存脚本并减少解析和执行过程中涉及的初始减速。
使用编译字节码/IL 的框架在加载/JIT 后可以非常快。
不过,如果您打算用 C 语言编写自己的 HTTP 引擎;我怀疑你是否能够像其他任何东西一样快地获得远程接近的东西,直到你非常熟悉已经存在的东西;它们是如何工作的,所涉及协议的所有变化,等等......
Any kind of 'scripting' won't give you the 'raw speed' it seems you might be looking for.
I would generally strongly discourage this whole train of thought, though. There are plenty of web frameworks out there where you produce code that runs very efficiently. Even 'scripted' web frameworks often cache the scripts and reduce much of the initial slowdown involved in parsing and executing.
And frameworks that use compiled bytecode/IL can be quite fast once loaded/JIT'ed.
If you plan to write your own HTTP engine in C, though; I doubt you would be able to get something remotely close to as fast as anything else out there until you were very familiar with what's already out there; how they all work, all the variations in the protocols involved, etc, etc...
我听说过很多关于 FastCGI 的好消息。也许你应该尝试一下?
I've heard a lot of good things about FastCGI. Maybe you should try that?
您应该通过 trustleap 检查 g-wan。它允许您编写 servlet
ansi-c,负责处理有关 http 协议的所有细节。
http://www.trustleap.com/
You should checkout g-wan by trustleap. It allows you to write servlets in
ansi-c, taking care of all the nitty gritty regarding the http protocol.
http://www.trustleap.com/