C#或C ++中的Web服务器逻辑 [英] Web Server Logic in C# or C++

查看:52
本文介绍了C#或C ++中的Web服务器逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

我已经厌倦了PHP,现在花了近一个月的时间试图为一个不仅速度慢而且很难开发的应用程序编写后端.我曾经曾经用PHP编写过代码,后来我成长时曾为许多小型站点编写代码,但显然是在转向结构化编程之后,它具有变量类型(WOW!)和理智的API-您可以直观地了解自己的身份.''在每种情况下都会得到,我只是无法回去.

我正在尝试改变这种情况,将项目移至更适合我的编程语言(并实现更快的代码执行和更好的性能).

我的最佳人选是使用CGI运行C ++代码或ASP.NET(并通过将功能导出到C#,尝试尽可能地减少类似于脚本的编码方法).

我的使用需求很简单,向我发布JSON数据(一个请求),我处理该数据,然后简单地回显"(用PHP术语)一个JSON响应-因此这次不需要我进行任何网站开发.

我的问题是:什么更适合我的需求?我想C#开发比C ++开发要短得多,那么性能问题呢?我已经看到了一项性能测试,该测试表明这两种技术的性能非常相似,我是否缺少比较的任何方面?

非常感谢.

Hey,

I''m sick of PHP, I spent almost a month now trying to write a backend for an application which not only is slow, but hard to develop. I once was used to write in PHP, I wrote code for many small sites when I was growing up, but apparently after moving to structured programming, with variable types (WOW!), and sane APIs - where you know intuitively what you''ll get in every case, I simply just can''t go back.

I''m trying to change that, move the project to a programming language which is more suitable for me (and achieve faster code execution and better performance).

My top candidates are using CGI to run C++ code, or ASP.NET (and attempt to lose the script-like method of coding as much as possible, by exporting the functionality to C#).

My usage needs are simple, JSON data is posted at me (a request), I process the data, and simply "echo" (in PHP terms) a JSON response - so no site development is required from me this time.

My question is: What is more suitable for my needs? I guess that C# development will be much shorter than in C++, what about performance issues? I have seen a performance test that showed that the performances of both the technologies are quite similar, are there any aspects of comparison that I''m missing?

Thanks a lot.

推荐答案

忘记C ++,并使用C#进行ASP.NET.性能差异在很大程度上可以忽略不计. ASP.NET和C#设计为可以协同工作,因此使用它们可以缩短您的开发时间. ASP.NET网站 [ ^ ].
Forget C++, and go for ASP.NET with C#; the difference in performance will be largely negligible. ASP.NET and C# have been designed to work together so your development time will be shortened by using them. There are plenty of samples on the ASP.NET web site[^].


互联网上散布着一些基准,似乎表明C ++是一种速度更快的语言因为它比其他任何高级语言(如C#)都更接近内核.但是这些基准非常有限,因为它们会遇到一系列小的重复性问题,这些问题似乎需要大量计算,并且除非您要构建科学或数学计算系统或某种类型的重数据系统(例如Facebook),您将不需要高性能,因为它不会被充分利用.

话虽这么说,出于您的目的,即构建一个服务器端程序,该程序将根据请求明确地回显JSON字符串,因此C#的性能几乎可以与C ++相提并论.与IIS一起运行的ASP.NET引擎使用以低级C编写的本机API,这些API已针对Web服务器AFAIK进行了优化.但是话又说回来,每个用例都是不同的,并且每种技术都比其他问题更适合一组问题.

我的建议是从小规模开始,然后用C#构建另一个2,另一个使用C ++,并在一段时间内自己分析性能.最后,根据您的长期使用策略,从顶部选择一个.

我将很高兴得到纠正或补充. :)
There are benchmarks strewn all over the internet that seem to suggest that C++ is a much faster language simply because its much closer to the kernel than any other high level languages like C#. But these benchmarks are quite limited, in that, they are run over a small repetitive set of problems that seem to be computation intensive and unless you are building a scientific or mathematical computation system or heavy data system of some kind (like Facebook does), you won''t need that high performance because it won''t be utilised fully.

That being said, for your purpose which is building a server side program that will plainly echo a JSON string based on a request, C# will give almost comparable performance to C++. ASP.NET engine that runs with IIS uses native APIs written in low level C that are quite optimised for web servers AFAIK. But then again, every use case is different and every technology suits one set of problems more than others.

My recommendation is to start small and build 2, one with C# and the other with C++ and analyse the performance yourself over a period of time. At the end of it and based on your long term usage strategy, pick one that comes out at the top.

I will be glad to be corrected or added to. :)


这篇关于C#或C ++中的Web服务器逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆