这个 Scala Perl/Python 架构有意义吗?
在另一个问题中,我要求为特定目的提供“最佳”语言。意识到这个目标有点难以开始,我简化了我的想法:)但是有非常有用的语言提示。因此,我决定在桌面应用程序中使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你问我,我认为Scala最适合服务器端。 Scala 运行在 JVM 上,而 Java 在服务器端有一个非常大的生态系统。您拥有适合各种口味的多种应用程序服务器(tomcat、jetty、glassfish 等)。
聊天是演员的一个经典用例。我认为 Akka 可以在这方面给你带来启发。
您可以使用出色的 Scala Web 框架,例如 Lift。您甚至可以进行基于网络的聊天。以下是使用 comet(服务器推送)的聊天应用程序的示例:
http://demo.liftweb.net/chat
关于 REST:如果您觉得它不安全,那么
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 步:找出答案。实际上写一些东西,看看你能构建什么。
没有意义。所有互联网通信都是通过套接字完成的。去掉这句话,你不会失去任何意义。
一些有用的信息。然而,套接字是不言而喻的。
正确的。再说一次,套接字并没有多大意义。
在套接字之上还有数十种协议。 FTP、Telnet、HTTP、SMTP 等等。
第 2 步是弄清楚您要使用哪种协议。顺便说一句,REST 是 HTTP 的一种特殊用途。在放弃 HTTP 和 REST 之前,您真的应该仔细研究一下它们。
不清楚你为什么这么说。我只能猜测你不了解 HTTP 安全功能。
懒惰的程序员可能会这样做。
安装 Python、Django、MySQL-Python 和 Piston。
定义 Django 模型,配置默认值,以便将模型公开为安全的 RESTful 服务集。
服务器端消息 GET、POST、PUT 和 DELETE 都是由 Django、Piston 和 Django ORM 层提供的。认证可以是多种机制中的任何一种。我非常喜欢 HTTP 摘要式身份验证。
Step 1. Figure that out. Actually write some stuff and see what you can build.
Not meaningful. All internet communication is done with sockets. Leave this sentence out and you don't lose any meaning.
A little useful information. Sockets, however, go without saying.
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.
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.
Install Python, Django, MySQL-Python and Piston.
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.
要实现类似的功能,您需要使用 MQ 系统(例如 ActiveMQ),而不是使用普通套接字。
To implement something like that you would need to go through a MQ System like perhaps ActiveMQ instead of using plain sockets.