这个 Scala Perl/Python 架构有意义吗?

发布于 2024-10-15 16:31:00 字数 703 浏览 1 评论 0原文

在另一个问题中,我要求为特定目的提供“最佳”语言。意识到这个目标有点难以开始,我简化了我的想法:)但是有非常有用的语言提示。因此,我决定在桌面应用程序中使用 Scala,并在网络服务器上考虑在 Perl 和 Python 之间进行选择。

我想编写类似异步聊天(有点像电子邮件)之类的东西。因此,您启动程序,选择您的名字并使用他的唯一 ID 添加一个朋友。然后你可以给他写一条简单的消息,当你的朋友启动他的电脑时,启动“chat.exe”,他会收到邮件(需要互联网)并能够回复。没有特殊功能、笑脸或文本格式,只是简单的学习目的。

我的概念是:使用Scala作为“chat.exe”(或者只是一个“chat.jar”可能吗?),它通过SOCKET与处理请求的Perl/Python框架进行通信。 因此,您输入“Hello There”并单击“发送”。该消息通过 SOCKET 传输到 Perl/Python 脚本,该脚本读取请求并将该消息放入 MySQL 数据库中。另一方面,您朋友的 chat.exe 检查是否有新消息,如果有,Perl/Python 脚本就会传输该消息。也通过 SOCKET。

你认为这可行吗? SOCKET 是否合适且适合?或者也许休息一下?但我认为对于 REST 请求,您必须使用 URI (http://example.com/newmessage/user2/user3/Hi_how_are_you)。这看起来非常没有安全感。

期待您的评论!

祝你有美好的一天,

库尔特

In another question I asked for "the best" language for a certain purpose. Realizing this goal was a bit too much to start, I simplified my idea :) But there were really useful language hints. So I decided on Scala for the desktop-app and consider between Perl and Python on the webserver.

I want to program something like an asynchronous chat (little bit like an email). So you start your program pick your name and add a friend with his unique id. Then you can write him a simple message and when your friends start up his pc, launches the "chat.exe" he receives the mail (internet is required) and is able to answer. No special functions, smiley's or text formatting, just simple for learning purpose.

My concept is: Use Scala for the "chat.exe" (Or is just a "chat.jar" possible?) which communicates via SOCKET with a Perl/Python Framework which handles the requests.
So you type "Hello there" and click on send. This message is transfered via SOCKET to a Perl/Python script which reads the request an put this message in a MySQL database. On the otherside the chat.exe of your friend checks for new messages and if there is one, the Perl/Python script transfer the message. Also via SOCKET.

Do you think this works out? Is SOCKET appropriate and fits in? Or perhaps REST? But I think for REST-Requests you have to use the URI (http://example.com/newmessage/user2/user3/Hi_how_are_you). This looks very unsecure.

Look forward to your comments!

Have a nice day,

Kurt

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

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

发布评论

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

评论(3

没有伤那来痛 2024-10-22 16:31:00

如果你问我,我认为Scala最适合服务器端。 Scala 运行在 JVM 上,而 Java 在服务器端有一个非常大的生态系统。您拥有适合各种口味的多种应用程序服务器(tomcat、jetty、glassfish 等)。

聊天是演员的一个经典用例。我认为 Akka 可以在这方面给你带来启发。

您可以使用出色的 Scala Web 框架,例如 Lift。您甚至可以进行基于网络的聊天。以下是使用 comet(服务器推送)的聊天应用程序的示例:

http://demo.liftweb.net/chat

关于 REST:如果您觉得它不安全,那么

  1. 使用 HTTPS 与服务器进行通信
  2. 在您的示例中,您的意图是将消息发送到服务器(至少我是这么理解的),所以很可能您想要使用 PUT 请求,在这种情况下,消息文本将位于 POST 请求正文中。

If you ask me, I think Scala is most suitable for the server side. Scala runs on the JVM and Java has a really big ecosystem at the server side. You have a big variety of application servers for every taste (tomcat, jetty, glassfish, etc.).

Chat is a classical use case for actors. I think Akka can inspire you in this area.

You can use wonderful Scala web frameworks like Lift. You can even make a web-based chat. Here is an example of a chat application that uses comet (server push):

http://demo.liftweb.net/chat

About REST: If you feel that it's not secure, then

  1. Use HTTPS to communicate with server
  2. In your example, your intent is to put the message to the server (at least that is how I understood it), so most probably you want to use PUT requests, and in this case the message text would be in the POST request body.
虚拟世界 2024-10-22 16:31:00

使用 Scala 作为“chat.exe”(或者只是一个“chat.jar”可能吗?)

第 1 步:找出答案。实际上写一些东西,看看你能构建什么。

它通过 SOCKET 与处理请求的 Perl/Python 框架进行通信。

没有意义。所有互联网通信都是通过套接字完成的。去掉这句话,你不会失去任何意义。

该消息通过 SOCKET 传输到 Perl/Python 脚本,该脚本读取请求并将该消息放入 MySQL 数据库中。

一些有用的信息。然而,套接字是不言而喻的。

另一方面,您朋友的 chat.exe 会检查是否有新消息,如果有,则 Perl/Python 脚本会传输该消息。也通过 SOCKET。

正确的。再说一次,套接字并没有多大意义。

在套接字之上还有数十种协议。 FTP、Telnet、HTTP、SMTP 等等。

第 2 步是弄清楚您要使用哪种协议。顺便说一句,REST 是 HTTP 的一种特殊用途。在放弃 HTTP 和 REST 之前,您真的应该仔细研究一下它们。

这看起来很不安全

不清楚你为什么这么说。我只能猜测你不了解 HTTP 安全功能。


懒惰的程序员可能会这样做。

  1. 安装 Python、Django、MySQL-Python 和 Piston。

  2. 定义 Django 模型,配置默认值,以便将模型公开为安全的 RESTful 服务集。

服务器端消息 GET、POST、PUT 和 DELETE 都是由 Django、Piston 和 Django ORM 层提供的。认证可以是多种机制中的任何一种。我非常喜欢 HTTP 摘要式身份验证。

Use Scala for the "chat.exe" (Or is just a "chat.jar" possible?)

Step 1. Figure that out. Actually write some stuff and see what you can build.

which communicates via SOCKET with a Perl/Python Framework which handles the requests.

Not meaningful. All internet communication is done with sockets. Leave this sentence out and you don't lose any meaning.

This message is transfered via SOCKET to a Perl/Python script which reads the request an put this message in a MySQL database.

A little useful information. Sockets, however, go without saying.

On the otherside the chat.exe of your friend checks for new messages and if there is one, the Perl/Python script transfer the message. Also via SOCKET.

Right. Sockets, again, don't mean much.

On top of sockets there are dozens of protocols. FTP, Telnet, HTTP, SMTP, etc., etc.

Step 2 is to figure out which protocol you want to use. REST, by the way is a particular use of HTTP. You should really, really look very closely at HTTP and REST before dismissing them.

This looks very unsecure

Not clear why you're saying this. I can only guess that you don't know about HTTP security features.


A lazy programmer might do this.

  1. Install Python, Django, MySQL-Python and Piston.

  2. Define a Django Model, configure the defaults so that model is exposed as a secure RESTful set of services.

That's sort of it for the server side message GET, POST, PUT and DELETE are all provided by Django, Piston and the Django ORM layer. Authentication can be any of a variety of mechanisms. I'm a big fan of HTTP Digest authentication.

野味少女 2024-10-22 16:31:00

要实现类似的功能,您需要使用 MQ 系统(例如 ActiveMQ),而不是使用普通套接字。

To implement something like that you would need to go through a MQ System like perhaps ActiveMQ instead of using plain sockets.

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