为 Jabber 机器人选择哪种语言?

发布于 2024-08-13 08:52:31 字数 231 浏览 1 评论 0原文

我将编写一个 XMPP (Jabber) 机器人,我需要决定应该用哪种语言编写它。目前我正在考虑Python、Java 和PHP。

由于我预计机器人大部分时间都在运行(即 23.5/7),是否有一些支持或反对使用其中一种语言的具体论据? (例如,不是“$x 很糟糕”,而是“$y 有良好的守护程序库”或“$z 泄漏内存”)

机器人的目的主要是响应用户输入。

如果这些语言都不适合您,您会推荐什么语言?

I'll be writing an XMPP (Jabber) bot, and I need to decide in which language should I write it. Currently I'm considering Python, Java, and PHP.

Since I'm expecting the bot to be running most of the time (i.e. 23.5/7), are there some specific arguments for or against using one of these languages? (e.g. not "$x sucks", but "$y has good daemon library" or "$z leaks memory")

The bot's purpose will mostly be responding to user input.

If none of these languages seem suitable to you, what would you recommend?

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

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

发布评论

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

评论(6

柒七 2024-08-20 08:52:31

我想说的是带有 Twisted 框架的 Python。 Twisted 是一个令人惊叹的异步网络框架,大多数时候它已经支持您正在寻找的协议。由于反应器模式,存在轻微的学习曲线,但一旦克服,您就可以用最少的代码做一些令人惊奇的事情。至于IRC协议twisted已经有了,所以虽然我不是IRC机器人方面的专家,但我肯定会推荐Python和Twisted。

顺便说一句,这是谷歌提出的第一个: Python使用 Twisted 的 IRC 机器人

I would say Python with the Twisted framework. Twisted is amazing framework for asynchronous networking and most of the time it already has the support for the protocol you are looking for. There's a slight learning curve because of the reactor pattern but once overcome you can do amazing things with the littlest amount of code. As for the IRC protocol twisted already has it, so while I'm not an expert on IRC bots, I would definitely recommend Python and Twisted.

BTW, this is the first one that came up with google: Python IRC bot using Twisted

梦太阳 2024-08-20 08:52:31

如果您想同时为多个用户提供服务(可能您想要),PHP 可能不是一个好的选择,因为它不支持(或实验性地支持)线程,您必须为每个用户创建应用程序的副本。

为此我推荐 Java。 Sun 将 Java 描述为“简单、面向对象、分布式、解释性、健壮、安全、架构中立、可移植、高性能、多线程和动态”。

在我看来,除了时间关键的工作之外,Java 最适合客户端-服务器架构。

If you want to service for multiple users at the same time(probably you want), PHP may not be a good choice, since it does not support(or experimentally support) threading, you have to fork a copy of your application for each user.

I recommend Java for this purpose. Sun describes Java as "simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, and dynamic.".

In my opinion with exception of time critical jobs Java best suits for client-server architecture.

幸福%小乖 2024-08-20 08:52:31

在您发布的选项中,我不得不建议 Java。首先,PHP 根本不会做你想做的事情;它是一种网络脚本语言,而不是其他任何脚本语言。 Python 能够做你想做的事情,但我认为 Java 将为你想要实现的功能提供更多开箱即用的支持。

Of the options you posted, I would have to suggest Java. PHP, for one, simply isn't going to do what you want it to; it's meant to be a web scripting language, not an anything-else scripting language. Python is capable of doing what you want, but I think Java will provide more out-of-the-box support for the functionality you're trying to achieve.

橘和柠 2024-08-20 08:52:31

就我个人而言,我会从 ejabberd 代码库开始,并从那里开始工作 - 对于无头网络服务器代理,Erlang将是我首先选择的语言/平台,除非有令人信服的论据支持另一种技术。不可变的数据和基于参与者的并发将所有正常的内务处理代码推送到平台中,让您可以自由地专注于应用程序真正的内容。

Personally I'd start with the ejabberd codebase and work from there -- for a headless network server agent, Erlang would be the language/platform I'd reach for first, unless there were compelling arguments for another technology. Immutable data and actor-based concurrency pushes all the normal housekeeping code down into the platform, leaving you free to concentrate on the bits that are really what your app is about.

抹茶夏天i‖ 2024-08-20 08:52:31

几年前使用delphi为IRC编写了机器人。它比解释语言好得多 - 消耗更少的内存,工作速度更快,并且您可以确信,如果您将来需要添加越来越多的功能 - 解析用户短语,处理它们,它将具有很大的速度储备。例如,我的机器人特别记录了所有聊天并根据用户请求执行快速搜索(用户只需编写!搜索单词/短语 - 机器人执行搜索并将结果作为简短引用发送给用户,因此用户可以选择其中之一引用并从日志中获取更多有关它的帖子)。使用例如 php 几乎无法实现,因为它太慢了。
如果建议机器人在 *nix 下工作 - 只需使用 c/c++ :)

如果您只想使用帖子中列举的语言 - 那么我认为只能使用 Java。阅读上面的原因。

Wrote some years ago bot for IRC using delphi. It is much better than interpreter languages - eats less memory, works much faster, and you can be sure that it will have great reserve of speed if you will need add more and more features in future - parsing users phrases, process them. For example my bot particularly logged all chat and performed quick search by user request (user just wrote !search word/phrase - bot performed search and sent to user results as short quotations, so user could select one of quotations and get more posts around it from log). It is almost unimplementable using for example php because it is too slow.
If bot is proposed to work under *nix - just use c/c++ :)

If you want to use only languages enumerated in your post - then only Java to my mind. Read above why.

恬淡成诗 2024-08-20 08:52:31

Python Jabberbot

这是使用 python 创建 jabberbot 的相当简单的方法。

Python Jabberbot

This is a fairly easy way to create a jabberbot with python.

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