Lift是不是GAE上开发Scala应用的不二选择?
fineqtbull
2009-12-18
night_stalker 写道 ps:哪个 Java Web 框架最好? 无疑是 JRuby。
JRuby的速度怎么样,有没有在GAE上的成熟应用呢? |
|
yangzhan
2009-12-18
night_stalker 写道 不可能 …… lift 允许页面入侵逻辑,但逻辑不可能跑到页面上的。
ps:哪个 Java Web 框架最好? 无疑是 JRuby。 <lift:surround with="default" at="content"> <h2>Welcome to the <i>Lift</i> Web Framework</h2> <p><i>Lift</i> is yet another web development framework. <i>Lift</i> runs inside a Java web container and uses the <a href='http://scala-lang.org'>Scala</a> programming language for coding. <i>Lift</i> stresses security, developer productivity, ease of deployment, ease of maintainability, performance, and compatibility with existing systems.</p> <p><i>Lift</i> borrows from the best of existing frameworks including <a href='http://seaside.st/'>Seaside's</a> highly granular sessions and security, <a href='http://www.rubyonrails.com/'>Rails</a> fast flash-to-bang, <a href='http://www.djangoproject.com/'>Django's</a> "more than just CRUD is included", and <a href='http://erlyweb.org/'>Erlyweb's</a> scalability for Comet-style applications.</p> <p><i>Lift</i> is built on <a href='http://scala-lang.org'>Scala</a>, a hybrid Functional and O-O language that compiles code down to the Java Virtual Machine. Scala code can call any Java code and make use of all Java classes. Java code can call some Scala code. <i>Lift</i> applications are packaged as WAR files and can be deployed on any Servlet 2.4 engine (e.g., Tomcat 5.5.xx, Jetty 6.0, etc.)</p> <p><i>Lift</i> code is as clean and brief as Rails, yet performs 6 times faster and is multithreaded. Additionally, because Scala is strongly typed, the compiler catches type errors. For example:<br/> <code> <pre> User.find(By(User.email, "foo@bar.com")) // legal User.find(By(User.birthday, new Date("Jan 4, 1975"))) // legal User.find(By(User.birthday, "foo@bar.com")) // compiler error </pre> </code> And <i>Lift</i> has lots of helper methods to make things clean and simple:<br /> <code> <pre> User.find(20) // find the user with primary key 20 // find all the users that registered 4 days ago User.findAll(By(User.registered, 4.days.ago)) // activate the account or suspend it after 4 days State(NewAcct, On({case Activate =>}, Activated),After(4 days, Suspended)) State(Suspended) entry {sendSuspendedEmail} </pre> </code> But the LoC and total character count for <i>Lift</i> and Rails substantive code is similar, however, the LoC for <i>Lift</i> tests is about 60% compared to Rails because there's no need to write tests for type-related issues. </p> <p><i>Lift</i> is an open source project distributed under an Apache License V2.0</p> </lift:surround> |
|
night_stalker
2009-12-18
大哥 …… 那是页面上显示的介绍性文字而不是逻辑代码 …… 代码只在 .scala 文件中。scala 是静态语言,也没有 JSP 或者 GSP 或者 ERB 之类的页面模板引擎,不可能把 scala 代码写进 .html 文件里的 ……
你把这个 user.find 改成 php 代码都行 …… |
|
yangzhan
2009-12-19
哦,明白了,让你见笑了。我也在想这个html怎么可以执行呢,我还以为lift这么强大呢。。。
多谢night_stalker |
|
fineqtbull
2009-12-23
这两天把《Programming Google APP Engine》看完了,并且尝试了几个例子,总的感觉是在分布式计算和存储上有很强的扩展能力,而且入门门槛很低,刚开始时可以做到0投入,对于个人创业来说是个很不错的东西。但是弱点也很明显,就是限制非常多,比如一个HTTP请求只能持续30秒(包括后台处理,后台处理也需转换为HTTP请求);一次查询结果的记录数需小于1000(包括计数操作);对话上下文迁移(同一会话的请求会被分配到不同主机上,虽然GAE支持Session的持久化和迁移(通过memcache));不能创建外部网络连接;不能创建本地文件;不支持全文检索。不过看了GAE的开发网站,开发和用户反馈都很活跃,相信不久将来就会解决查询记录数限制和全文检索功能缺失的问题。
看了一下网上对Lift在GAE上应用的讨论,基本论调是Lift在GAE上虽然能够做到初步的正常工作(除了Comet功能),但是是否能够应对Session迁移等GAE的特点还有待验证。结合上文对GAE限制的论述,个人认为类似于Lift这种对服务器端状态敏感的框架在GAE上应用还是比较困难和有风险的,把GAE作为一个无状态的Web服务平台(比如RESTful)来用,同时结合富客户端的应用程序则因该是一个不错的选择。 PS:Lift和GAE相关讨论连接 http://old.nabble.com/Lift-works-on-Google-App-Engine-(within-the-confines-of-what's-possible)-td23106768.html#a23135514 |