Lua vs PHP/Python/JSP/等

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1303270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 21:53:58  来源:igfitidea点击:

Lua vs PHP/Python/JSP/etc

phppythonweb-applicationslua

提问by Norman Ramsey

I'm about to begin my next web development project and wanted to hear about the merits of Lua within the web-development space.

我即将开始我的下一个 Web 开发项目,并想了解 Lua 在 Web 开发领域的优点。

How does Lua compare to PHP/Python/JSP/etc.. for web development?

在 Web 开发方面,Lua 与 PHP/Python/JSP/etc.. 相比如何?

Any reason why Lua would be a poor choice for a web application language vs the others?

有什么理由说明 Lua 是 Web 应用程序语言与其他语言的糟糕选择?

回答by Norman Ramsey

In brief:

简单来说:

  • Lua gives you a smaller, simpler system that you can understand in its entirety, but it is in a much smaller ecosystem; Kepler is all you get, and you will probably have to build some of your own stuff. I find this easy and fun (I make heavy use of the Lua bindings to the Expat parserand the Lua Object Model, which are part of Kepler), but others may prefer to use what everyone else is using.

  • PHP started out as more of a macro processor than a language, and although it has improved over the years, when people say "Xhas really gotten a lot better", I tend to be wary of X. I find PHP offputting, but there is a huge ecosystemfor web development.

  • Python is a nice language but muchbigger than Lua, and in the throes of a major revision (transition from 2.5 to 3.x). Again you get a big ecosystem; the problem I have with Python is that the language and system are too big for any one person to understand all of. I don't like to be in this situation if I don't have to.

  • Ruby is a bit of a cleaner language design, and the large Rails ecosystem is a winner. Ruby is less complex than Python but more complex than Lua. Rails is a bit of a beast.

  • Lua 为您提供了一个更小、更简单的系统,您可以完全理解它,但它位于一个更小的生态系统中;开普勒就是你所得到的,你可能需要构建一些你自己的东西。我觉得这既简单又有趣(我大量使用Lua 绑定到 Expat 解析器Lua 对象模型,它们是 Kepler 的一部分),但其他人可能更喜欢使用其他人正在使用的东西。

  • PHP 一开始更像是一种宏处理器,而不是一种语言,尽管多年来它有所改进,但当人们说“ X真的变得更好了”时,我倾向于对X保持警惕 。我发现 PHP 令人反感,但Web 开发有一个巨大的生态系统

  • Python是一种不错的语言,但比的Lua做大了,在一个主版本(从2.5到3.x的过渡)的阵痛。你又得到了一个庞大的生态系统;我使用 Python 的问题是语言和系统太大,任何人都无法理解所有. 如果没有必要,我不喜欢处于这种情况。

  • Ruby 是一种更简洁的语言设计,大型Rails 生态系统是赢家。Ruby 没有 Python 复杂,但比 Lua 复杂。Rails 有点像野兽。

It comes down to this question:

归结为这个问题:

  • Would you rather understand allthe software in your system, even if you have to build a lot of things yourself?

  • Or would you rather have a lot of things already built for you, even if you wind up not understanding exactly how every piece works?

  • 即使您必须自己构建很多东西,您是否宁愿了解系统中的所有软件?

  • 还是您宁愿已经为您构建了很多东西,即使您最终不了解每个部分的工作原理?

If you want to understand everything, Lua is your game. If you want a lot of stuff already built for you, I can't advise you how to pick among PHP/Python/JSP/Rails and so on.

如果你想了解一切,Lua 就是你的游戏。如果你想要很多已经为你构建的东西,我不能建议你如何在 PHP/Python/JSP/Rails 等中进行选择。

More on Lua and Python at Which language is better to use, Lua or Python?

更多关于 Lua 和 Python 的信息,Lua 还是 Python 哪种语言更好用?

回答by Glitz

Using Lua for web development is pretty rare...you coulddo it, but it will be a lot more time consuming than using a language that has matured as a web developing language (PHP) or has good web related libraries (python/ruby/etc.) If you do go with Lua, this means you may end up "recreating the wheel" a lot for what may be easily available in mature web languages.

使用 Lua 进行 Web 开发非常罕见......你可以这样做,但它比使用已经成熟为 Web 开发语言 (PHP) 或具有良好 Web 相关库的语言 (python/ruby) 花费的时间要多得多/etc.)如果您确实使用Lua,这意味着您最终可能会“重新创建轮子”,以获得在成熟的网络语言中可以轻松获得的内容。

The better question is, what does Lua offer that you need which is not offered in the other languages you listed? Or do you want to help Lua become a better web development platform by creating a Lua MVC framework like Rails did for Ruby?

更好的问题是,Lua 提供了您需要的哪些其他语言没有提供的服务?或者您想通过创建一个 Lua MVC 框架来帮助 Lua 成为一个更好的 Web 开发平台,就像 Rails 为 Ruby 所做的那样?

回答by RBerteig

The Kepler projectis probably the best known starting point for web application development in Lua. They have a mailing listwhose archives will have a lot of discussion of the merits of various approaches.

开普勒项目是可能是在Lua Web应用程序开发最有名的出发点。他们有一个邮件列表,其中的档案会讨论各种方法的优点。

The Kepler site is itself built in a CMS framework called Sputnikwritten almost entirely in Lua, and based on the Kepler project.

Kepler 站点本身建立在一个名为Sputnik的 CMS 框架中,该框架几乎完全用 Lua 编写,并基于 Kepler 项目。

The typical approach with Lua is to use a language suited to interfacing to various system components to implement those interfaces, and to use Lua for business logic and glue. Kepler provides libraries written largely in C that provide access to file systems, databases, and the network to Lua code. It also provides a defined API layer to interface with the web server, with implementations for Apache, any CGI capable server, and Xavante which is a complete web server implemented mostly in Lua.

Lua 的典型方法是使用适合与各种系统组件接口的语言来实现这些接口,并使用 Lua 进行业务逻辑和粘合。Kepler 提供了大部分用 C 编写的库,这些库提供对文件系统、数据库和 Lua 代码网络的访问。它还提供了一个已定义的 API 层来与 Web 服务器交互,其中包含 Apache、任何支持 CGI 的服务器和 Xavante 的实现,Xavante 是一个主要在 Lua 中实现的完整 Web 服务器。

回答by back2dos

I'm coming a little late ... but i wanted to throw in another language: Haxe

我来得有点晚......但我想用另一种语言:Haxe

why?

为什么?

  1. Haxe is an open source language, driven by a quite small, but active community

  2. Haxe is a platform indepented language ... targets are:

    • flash player 6-8 and 9-10 bytecode or ActionScript 3 source code
    • JavaScript source code
    • PHP source code
    • NekoVM bytecode or Neko source code (NekoVM is a lightweight and extensible VM, suitable for both server developement, and desktop apps)
    • C++ source code
    • Android Java source code is currently being worked on

    this means, that as a web developer, you can write both rich clients as well as servers in the same language ... the same code can be later reused for desktop/mobile apps

  3. Haxe is a very expressive and powerful language, featuring:
    • first class functions (anonymous functions and methods, which are the same in Haxe) and closures as well as Enums with parameters (much like algebraic types) that allow the use of functional approaches
    • good type system, including generics, structural subtyping etc. ... to simplify its use, the compiler has a very helpful type inference, that ensures code is strictly typed, but saves you a lot of redundancy (variable type is determined by initialization, function return type by type of returned expressions) ...
    • cross-platform API, including everything from dynamic arrays, to reflection/introspection and a remoting package, that alows you to send whole objects from client to server, from one platform to another ...
    • consistent and radical language design ... of course it has a few flaws, but these mostly come from the fact, that it targets extremely different platforms ...
  4. girls love it and it'll make you real rich ... :D
  1. Haxe 是一种开源语言,由一个相当小但活跃的社区驱动

  2. Haxe 是一种独立于平台的语言......目标是:

    • flash player 6-8 和 9-10 字节码或 ActionScript 3 源代码
    • JavaScript 源代码
    • PHP源代码
    • NekoVM 字节码或 Neko 源代码(NekoVM 是一个轻量级且可扩展的 VM,适用于服务器开发和桌面应用程序)
    • C++源代码
    • Android Java 源代码目前正在开发中

    这意味着,作为 Web 开发人员,您可以使用相同的语言编写富客户端和服务器……相同的代码以后可以重用于桌面/移动应用程序

  3. Haxe 是一种非常有表现力和强大的语言,具有:
    • 第一类函数(匿名函数和方法,在 Haxe 中相同)和闭包以及带参数的枚举(很像代数类型),允许使用函数方法
    • 良好的类型系统,包括泛型、结构子类型等......为了简化它的使用,编译器有一个非常有用的类型推断,它确保代码是严格类型的,但为你节省了很多冗余(变量类型由初始化决定,函数返回类型按返回表达式的类型)...
    • 跨平台 API,包括从动态数组到反射/内省和远程处理包的所有内容,它允许您将整个对象从客户端发送到服务器,从一个平台发送到另一个平台......
    • 一致和激进的语言设计......当然它有一些缺陷,但这些主要来自这样一个事实,即它针对极其不同的平台......
  4. 女孩们喜欢它,它会让你真正富有...... :D

the biggest flaw about Haxe is, that it allows untyped coding, at the cost of platform specific execution of untyped code ... when well typed (which is not a lot of work with Haxe in fact), code will be executed the same way on all platforms ... if not, result vary depending on runtime handling of the platform itself ...

Haxe 的最大缺陷是,它允许无类型编码,代价是特定于平台的无类型代码执行......当类型良好时(实际上 Haxe 的工作量不大),代码将以相同的方式执行在所有平台上......如果不是,结果会因平台本身的运行时处理而异......

to put it in a few words: it's a great language, that allows you to target many platforms ... it's young, it's growing, and you can participate ...

简而言之:它是一种很棒的语言,可以让您面向许多平台……它很年轻,正在成长,而且您可以参与……

回答by back2dos

As far as Lua web frameworks, there is also LuCI. It is mostly used for small embedded systems. We're just starting a project using it, so I can't comment on it too much right now. We're just doing some simple configuration screens similar to what is already provided as examples, so I'm sure it will be sufficient for our needs.

就 Lua Web 框架而言,还有LuCI。它主要用于小型嵌入式系统。我们刚刚开始一个使用它的项目,所以我现在不能过多评论它。我们只是做一些简单的配置屏幕,类似于已经作为示例提供的内容,所以我相信它足以满足我们的需求。

回答by grokus

If it's only the language, then I agree with Norman. If the web development framework is important to you, then you have to consider Ruby because RoR is a very mature framework. I love Python, but there seems to be quite a few frameworks to choose from, none of them is dominant. CherryPy, Django, Pylons, web2py, Zope 2, Zope 3, etc. One important indicator to me is that there are more RoR jobs on the market than any other (language, framework).

如果只是语言,那么我同意诺曼的观点。如果 Web 开发框架对您很重要,那么您必须考虑 Ruby,因为 RoR 是一个非常成熟的框架。我喜欢 Python,但似乎有很多框架可供选择,但没有一个是主导的。CherryPy、Django、Pylons、web2py、Zope 2、Zope 3 等。对我来说一个重要的指标是市场上的 RoR 工作比任何其他工作(语言、框架)都多。