选择编程语言的建议

发布于 2024-10-11 15:52:12 字数 406 浏览 6 评论 0原文

几天前,我用 Python 创建了一个程序,用于从 Internet 下载内容,执行 HTTP POSTGET 并解析 JSON 对象。我注意到性能有些缓慢,我正在考虑使用另一种语言从头开始编写它,所以我开始用 C++ 编写它以使其更快。最后我放弃了,C++ 不是为互联网而生的,而且很难让某些东西发挥作用。

我正在考虑尝试 C# 或 Java,您会推荐哪一个? (我需要我的程序完全跨平台,其他编程语言也有效)

编辑:您可以在此处查看源代码:http://code.google.com/p/grooveapi/

Days ago I created a program in Python to download stuff from the Internet, doing HTTP POST and GET and parsing JSON objects. I noticed some slow performance and I was thinking about writing it from scratch using another language, so I started to write it in C++ to make it faster. Finally I give up, C++ wasn't made for the Internet and it's very difficult to get something working.

I was thinking about giving C# or Java a try, which would you recommend? (I need my program to be fully cross-platform, other programming languages are valid too)

Edit: You can check the source code here: http://code.google.com/p/grooveapi/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

失而复得 2024-10-18 15:52:12

用不同的语言重写 IO 密集型应用程序不太可能对其执行速度产生任何影响。

Rewriting an IO bound application in a different language is unlikely to make any difference in its execution speed.

满身野味 2024-10-18 15:52:12

如果您需要跨平台:(即您只需编写一次,它就可以在任何地方运行)那么 Java 或 Python 是您唯一的选择。这是因为任何 C 变体都需要专门针对您打算使用它的平台进行编译。

我的建议:在这两个建议中,我建议Python。我在大学接受过 Java 教育,并且自己学习了 Python。 Python 是我用于 Web 编程项目(以更大规模的 Django 形式)的语言,也是我工作过的公司在其 Web 应用程序内部使用的语言。

If you need it to be cross-platform: (i.e. you just write it once and it can run anywhere) Then Java or Python are your only options. This is because any C variant will need compiling specifically for the platform you intend to use it on.

My suggestion: Out of the two I would suggest Python. I have be educated in Java at University, and have learnt Python myself. Python is the language I turn to for web programming projects (in the form of Django on a larger scale) and the language used at companies I have worked for inside of their web applications.

装纯掩盖桑 2024-10-18 15:52:12

在切换到另一种语言之前...您确定性能问题是由于语言本身造成的吗?问题很可能出在程序、网络延迟或任何其他原因上。

在仔细分析你的应用程序之前,不要责怪语言,也许你在某个地方遇到了瓶颈。新开发的成本总是非常高,特别是与在代码中发现问题时进行几行更改相比。

Before you switch to another language... are you sure the performance problems are due to the language itself? It can very well be possible the problem is in the program, or the network latency or any other reason.

Don't blame the language before you've profiled your application carefully, maybe you have a bottleneck somewhere. The cost of a new development will be always very high, specially compared to a few line changes if you've found a problem in your code.

撧情箌佬 2024-10-18 15:52:12

使用 python 时您是如何注意到“性能缓慢”的?我的意思是,Python 很慢,但是对于你的用例来说这应该不重要。你分析过代码吗?您能否将代码粘贴到此处,以便我们查看并改进它?

how did you notice "slow performance" when using python? I mean, python is slow, ok, but for your use case it shouldn't matter. Did you profile the code? Can you paste the code here so we can take a look and maybe improve it?

罪#恶を代价 2024-10-18 15:52:12

我不知道你的Python程序有什么样的性能问题,但它通常对我来说很有用(例如,解析巨大日志文件的脚本只需要很少的时间......)。
现在这一切都取决于此的总体目的。如果它只是一个脚本,没有 gui 等,那么你绝对应该考虑优化 python,或者做一些 perl 或 php-cli 脚本。
我对它并不熟悉,但 ruby​​ 似乎有很多追随者,而且似乎也非常面向“互联网”。

如果你确实想创建比脚本更多的东西,你有很多选择,c# 就是其中之一,但它不会跨平台,我会选择 java。

最后我建议重新检查你的 python 代码,这似乎很奇怪,它没有做你想要的性能明智的事情...... python 真的很好。

I don't know what kind of performance issues you had with your program in python but it usually does great for me ( scripts parsing log files that are huge take really little time for instance...).
now It all depends on the general purpose of this. If its just a script, no gui etc.. then you should definitely look into optimizing python, or doing some perl or php-cli script.
I'm not familiar with it first hand but ruby seems to have a big following and seems very "internet" oriented aswel.

If you do want to create something more than a script you have lots of options, c# is one of them, but it won't be cross platform, i'd go with java.

In the end I'd recommend rechecking your python code, it seems odd that its not doing what you want performance wise.... python is really good.

素罗衫 2024-10-18 15:52:12

您应该选择您觉得最舒服的语言。大多数情况下,脚本语言的性能并不是瓶颈。更重要的是快速完成工作并保持其可维护性。我建议你选择 Ruby 或 Python。如果您必须更快地使用 Python,您仍然可以选择使用像 PyPy 这样的 JIT 实现。实际上,相当高流量的网络应用程序(例如 YouTube)都使用 Python。

You should choose the language you feel most comfortable with. In most cases the performance of the scripting language is not the bottleneck. It is more important to get things done quickly and keep it maintainable. I would recommend you to choose Ruby or Python. If you have to get Python faster you still can choose to use JIT implementation like PyPy. Actually quite high traffic webapps, like YouTube, use Python.

云之铃。 2024-10-18 15:52:12

我会选择好的、旧的 PHP!它一次又一次地证明,它完全有能力做到这一点,而且非常容易学习。

所以我的建议是:使用 PHP!

I'd go with the good, old PHP! It has proven time and time again, that it is more than capable of doing this, and is quite easy to learn.

So my advice: Go with PHP!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文