Java Grails 值得吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/397228/
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
Is Grails worth it?
提问by Steve Kuo
This is half rant, half question.
这一半是咆哮,一半是疑问。
Is it worth using Grails? I'm trying to develop a relatively simple database-driven web application. My expertise is in Java, so naturally Grails seemed like a good choice. At first I thought of using Spring, JPA and Hibernate, but I've used that previously and have run into all sorts of tedious configuration and coding work. Grails advertises itself as solving this.
值得使用 Grails 吗?我正在尝试开发一个相对简单的数据库驱动的 Web 应用程序。我的专长是 Java,因此 Grails 自然是一个不错的选择。起初我想使用 Spring、JPA 和 Hibernate,但我以前使用过,并且遇到了各种繁琐的配置和编码工作。Grails 宣称自己解决了这个问题。
My biggest frustration with Grails is all of the little things that don't work. What I mean is that it doesn't work as one would intuitively think it should. It's very rough around the edges. I run into problems constantly. Sometimes it's my lack of Grails understanding — other times I've discovered legitimate Grails bugs.
我对 Grails 最大的挫折是所有的小事情都不起作用。我的意思是,它并不像人们直觉上认为的那样工作。边缘非常粗糙。我经常遇到问题。有时是因为我缺乏对 Grails 的理解——有时我发现了合法的 Grails 错误。
One major issue is the lack of good Eclipse integration. There is a Groovy and Grails plugin, but it doesn't do much other than syntax highlighting. Calling Groovy from Java and vice versa is very painful to configure. Not having good IDE support is a major bummer.
一个主要问题是缺乏良好的 Eclipse 集成。有一个 Groovy 和 Grails 插件,但它除了语法高亮外没有其他作用。从 Java 调用 Groovy,反之亦然,配置起来非常痛苦。没有良好的 IDE 支持是一个主要问题。
What happens is I sit down trying to develop my web application. At the end of the day I realize that I've spent about 85% of the day debugging Grails-related issues. If it isn't Eclipse problems then it's eager loading, fetching in the view, one-to-many relationships, weird empty file bug behavior, a weird property/getter bug— it just goes on and on. This is just a sample of the issues I ran into today. My last sit-down with Grails yielded a whole bunch of different issues.
发生的事情是我坐下来尝试开发我的 Web 应用程序。一天结束时,我意识到我花了大约 85% 的一天时间调试与 Grails 相关的问题。如果不是Eclipse的问题,那么它的预先加载,在视图中获取,一个一对多的关系,怪异的空文件的错误行为,怪异的财产/消气错误-它只是不停去。这只是我今天遇到的问题的一个示例。我与 Grails 的最后一次坐下来产生了一大堆不同的问题。
I sometimes wonder if it's worth it. I'm curious if others have experienced this. Are there people actually using Grails to productively crank out a web application? Are there other frameworks for rapid web development that I should be considering?
我有时想知道这是否值得。我很好奇其他人是否经历过这种情况。真的有人使用 Grails 来高效地开发 Web 应用程序吗?我应该考虑其他用于快速 Web 开发的框架吗?
回答by j pimmel
We had a team of 12 people all seasoned senior Java devs who learnt Grails from 0.6B and we are all still working on projects based on Grails. I wouldn't go back to Java willingly, and we are all relieved to have broken the back of how to get somewhere quick with a Grails app.
我们有一个由 12 人组成的团队,他们都是从 0.6B 开始学习 Grails 的经验丰富的高级 Java 开发人员,而且我们都仍在开发基于 Grails 的项目。我不会心甘情愿地回到 Java,我们都为打破了如何使用 Grails 应用程序快速到达某个地方而感到欣慰。
It was a struggle, it was not easy and there was/is frustration.
这是一场斗争,这并不容易,并且有/正在沮丧。
Nevertheless we delivered something very quickly given our ongoing efforts.. There are bugs, many which have workarounds.
尽管如此,鉴于我们的持续努力,我们还是很快交付了一些东西。存在错误,其中许多都有解决方法。
I have heard of several instances of developers who are good at Java trying to dive into deep, complex incantations of Grails projects. We eschewed all Java and went pure-Grails and Groovy. We made sure we started simple, built up the complexity as manageably and as practically as possible.. We dared not dive in the deepest end and hope that our Java knowledge was enough to carry us.
我听说过几个擅长 Java 的开发人员试图深入研究 Grails 项目的深入、复杂的咒语。我们避开了所有 Java,转而使用纯 Grails 和 Groovy。我们确保从简单开始,尽可能以可管理和实际可行的方式构建复杂性。我们不敢深入到最后,希望我们的 Java 知识足以支撑我们。
We had eventually created something huge and complex that worked fabulously and did so far faster than writing pure Java/Spring/Hibernate version; and thats without decent IDE support and a far worse situation in terms of bugs than today.
我们最终创造了一个巨大而复杂的东西,它工作得非常好,而且比编写纯 Java/Spring/Hibernate 版本快得多;那就是没有像样的 IDE 支持,而且在错误方面比今天更糟糕的情况。
As regards Eclipse support, the only real IDE to use for Grails/Groovy is Intellij - the Eclipse support is way behind, sadly: I was an Eclipse lover and am far from being an Intellij convert - the Grails/Groovy support blow everything else away though.
关于 Eclipse 支持,用于 Grails/Groovy 的唯一真正的 IDE 是 Intellij - Eclipse 支持远远落后,遗憾的是:我是 Eclipse 爱好者,而且远非 Intellij 转换者 - Grails/Groovy 支持吹走了其他一切尽管。
Yes, Grails is immature compared to Spring perhaps. Or Hibernate. And I would wager that in the first 1.5 years of their existence they were equally as fraught with issue.
是的,与 Spring 相比,Grails 可能还不成熟。或休眠。我敢打赌,在它们存在的头 1.5 年里,它们同样充满了问题。
That being as it is, places the onus on you, to take care that you keep complexity to the absolute minimum, to carefully test-first (in our opinion) and build up to complexity gradually and with care.
事实就是如此,你有责任注意将复杂性保持在最低限度,仔细测试优先(在我们看来)并逐渐小心地建立复杂性。
There is no fast code solution with Java once you involve Spring/Hibernate in the stack. The complexity Grails embodies is a reflection of Spring's / Hibernate's own complexity. If you feel that you time is better spent doing it with pure Java, I wouldn't argue otherwise.. I still have my WTFs but now that the steep learning curve is behind me I think I will stick w Grails some more.
一旦在堆栈中使用 Spring/Hibernate,Java 就没有快速的代码解决方案。Grails 所体现的复杂性反映了 Spring/Hibernate 自身的复杂性。如果你觉得你的时间最好用纯 Java 来做,我不会反驳..我仍然有我的 WTF,但是现在陡峭的学习曲线已经过去了,我想我会继续使用 Grails。
回答by duffymo
I think Spring's support of Grails is going to be a big boost. If anybody can move it past CRUD on the web, it's those guys.
我认为 Spring 对 Grails 的支持将是一个巨大的推动力。如果有人可以在网络上将其移过 CRUD,那就是那些人。
I also think it's reaching a critical mass. There are several new books that will be hitting the market in 2009. I think those will help the adoption rate.
我也认为它正在达到临界质量。有几本新书将在 2009 年投放市场。我认为这些将有助于提高采用率。
回答by branchgabriel
It will be worth it when they finish the eclipse plugin. The sooner the better I say. Trying to sell groovy to my boss isn't going to be simple until that happens.
当他们完成 eclipse 插件时,这将是值得的。我说的越快越好。在这种情况发生之前,试图将 groovy 卖给我的老板并不容易。
回答by Ole
I very much enjoy writing grails application for two reasons:
我非常喜欢编写 grails 应用程序,原因有两个:
- I don't have to use Java
- I can use Java
- 我不必使用 Java
- 我可以使用Java
I think after having become familiar with grails one gets his things done very quickly and elegantly.
我认为在熟悉了 grails 之后,人们可以非常快速和优雅地完成他的工作。
So much for the plus side. The minus side is performance, which hits me on two aspects: deployment and testdriven development.
好的一面就这么多。缺点是性能,它在两个方面打动我:部署和测试驱动开发。
I haven't managed to run more than 3 grails applications on a single (rented) server, because I quickly hit the memory and performance limits. There are simply too much frameworks included.
我还没有设法在单个(租用)服务器上运行超过 3 个 grails 应用程序,因为我很快就达到了内存和性能限制。包含的框架太多了。
Plus, the testrunner of grails isn't worth that name. When I run unit tests, they should be done in an instant, not in 10 to 20s. So I find myself all the time writing business logic in plain java, because I can test it much faster. But I guess that this can be addressed with a better integration into the IDE (eclipse).
另外,grails 的 testrunner 不值那个名字。当我运行单元测试时,它们应该在瞬间完成,而不是在 10 到 20 秒内完成。所以我发现自己一直在用纯 Java 编写业务逻辑,因为我可以更快地测试它。但我想这可以通过更好地集成到 IDE (eclipse) 来解决。
回答by Ed.T
I was an Eclipse user before I started using Grails. It was quickly apparent that wasn't going to cut it. So I tried Intellij and NetBeans. At the time Intellij was better as far as Groovy and Grails were concerned. However, NetBeans was free and that made it good enough for me. Since then all three have had new versions or new plugins released. I am still using NetBeans because of the cost of Intellij. With the acquisition of G2One by Spring Source one of the expectations is more support for Groovy and Grails in Eclipse. This will be necessary for increased adoption.
在开始使用 Grails 之前,我是 Eclipse 用户。很快就很明显这不会削减它。所以我尝试了 Intellij 和 NetBeans。就 Groovy 和 Grails 而言,当时 Intellij 更好。然而,NetBeans 是免费的,这对我来说已经足够好了。从那时起,这三个版本都发布了新版本或新插件。由于 Intellij 的成本,我仍在使用 NetBeans。随着 Spring Source 对 G2One 的收购,期望之一是在 Eclipse 中更多地支持 Groovy 和 Grails。这对于提高采用率是必要的。
Using Grails for a new project is wonderful. So much of the Enterprise Java baggage is no longer necessary. I can imagine trying to port something would be difficult because until you understand where a framework strength's and weaknesses are it is hard to utilize it efficiently. It is promised that JSP support will come easier in Grails 1.1, I don't know if using a beta version while trying to grok a new framework is a good idea. The testing has also gone through a major revision for the new version. If time allows you may consider waiting as the 1.1 release should be very soon.
在一个新项目中使用 Grails 非常棒。如此多的企业 Java 包袱不再是必需的。我可以想象尝试移植某些东西会很困难,因为除非您了解框架的优势和劣势在哪里,否则很难有效地利用它。承诺在 Grails 1.1 中 JSP 支持会更容易,我不知道在尝试了解新框架时使用 beta 版本是否是个好主意。测试还对新版本进行了重大修订。如果时间允许,您可以考虑等待,因为 1.1 版本应该很快就会发布。
If you have an opportunity to give Grails a try in a different IDE when starting a project from scratch I think you will see it in a different light.
如果您有机会在从头开始一个项目时在不同的 IDE 中尝试 Grails,我想您会从不同的角度看到它。
回答by tcurdt
I am totally with you! Grails still feels so rough around the edges that it's almost a joke to compare it with Rails. If at least the error reporting was a little bit better. But I guess that's probably also due to the huge amount of libraries that it uses under the covers. One word: stacktrace! I am also not a big fan of the model->db approach (Rails has db->model). The scaffolding also leaves much room for improvements. Then "no restart required" also does not work as advertised. (I am not sure what's worse - having to restart all the time or sometimes finding weird behaviors that go away when you do restart) And don't get me started on GORM. (When it takes hours to find a way what would have been a simple SQL you start to wonder whether this whole ORM really saves you time) Maybe as long as it is simple.
我完全和你在一起!Grails 的边缘仍然感觉如此粗糙,以至于将它与 Rails 进行比较几乎是一个笑话。如果至少错误报告好一点。但我想这也可能是因为它在幕后使用了大量的库。一个字:堆栈跟踪!我也不是模型-> db 方法的忠实粉丝(Rails 有 db->model)。脚手架也留下了很大的改进空间。然后“无需重新启动”也不能像宣传的那样工作。(我不确定更糟糕的是什么 - 必须一直重新启动,或者有时会发现重新启动时会消失的奇怪行为)而且不要让我开始使用 GORM。(当需要花费数小时才能找到一种简单的 SQL 方式时,您会开始怀疑整个 ORM 是否真的能节省您的时间)也许只要它很简单。
I mean: it's still one of the better choices of a framework when you are coming from the java world. (So much useless crap out there that calls itself a web framework) ...it has potential. I just wish it wouldn't have build on top of so much other complex stuff.
我的意思是:当您来自 Java 世界时,它仍然是框架的更好选择之一。(这么多无用的废话,自称是一个网络框架)......它有潜力。我只是希望它不会建立在这么多其他复杂的东西之上。
Anyway - let's hope these things get sorted. At the moment I am lurking at playframework.orgwhich also looks very slick and promising.
无论如何 - 让我们希望这些事情得到解决。目前我潜伏在playframework.org 上,它看起来也非常漂亮和有前途。
回答by hendrixski
Totally. There are so many Java frameworks that the bar is set quite high for newcomers, and it's a testament to Grails that it was able to rise above in such a crowded space.
完全。有如此多的 Java 框架,以至于对于新手来说,门槛设置得相当高,这证明了 Grails 能够在如此拥挤的空间中脱颖而出。
It still has a few edges that are sharp, but those are just a matter of time before they're matted down, the underlying project is VERY much worth it.
它仍然有一些锋利的边缘,但这只是时间问题,基础项目非常值得。
回答by Karsten Silz
I find that the biggest advantage of Grails is that I don't have to care about the database anymore - the schema is automatically created / updated, and the persistence is largely done for me (no more writing SQL queries). This is a huge relief. The other thing that is rather nice is that once you settled on the templates for controllers and views, adding new domain objects is pretty fast. Although I suspect that you will do ongoing changes for your views at least, back-fitting them to the existing ones.
我发现 Grails 的最大优点是我不必再关心数据库了——模式是自动创建/更新的,并且持久化基本上为我完成(不再编写 SQL 查询)。这是一个巨大的解脱。另一件相当不错的事情是,一旦您确定了控制器和视图的模板,添加新的域对象就会非常快。尽管我怀疑您至少会对您的视图进行持续的更改,将它们重新安装到现有的视图中。
As for the IDE - it seems that IntelliJ is the best option, but I'm happy using Netbeans 6.5. I use MyEclipse for all other development, but Netbeans just has better Grails support now.
至于 IDE - 似乎 IntelliJ 是最好的选择,但我很高兴使用 Netbeans 6.5。我将 MyEclipse 用于所有其他开发,但 Netbeans 现在有更好的 Grails 支持。
回答by Rollo Tomazzi
I'm not sure they will ever be able to make Grails right you know. And by right I mean address all the details (small and big ones) which in the end makes it feel brittle and fragile. I'm not even sure that there is a real development team (meaning more than 2 people) behind it.
我不确定他们是否能够使 Grails 成为正确的,你知道的。我的意思是解决所有细节(小的和大的),这最终会让它感觉脆弱和脆弱。我什至不确定它背后是否有一个真正的开发团队(意味着超过 2 人)。
Every single time I iterate over a feature of my Grails projects, trying to improve something, it is the same workflow: everything falls apart, then it's a hundred of 'google' test cycles, then you find out the reason you can't do what you want and you do something else.
每次我迭代我的 Grails 项目的一个特性,试图改进某些东西时,它都是相同的工作流程:一切都崩溃了,然后是一百个“谷歌”测试周期,然后你找出你不能做的原因你想要什么,然后做别的事情。
In the end, you're frustrated because you don't even want to touch anything that runs. And things that don't well, you drop them!
最后,您会感到沮丧,因为您甚至不想碰任何正在运行的东西。和事情不顺利,你放弃他们!
I'm considering a switch to Rails via JRuby. That may be the best of both worlds: a capable web framework with an active and large community, a dedicated team of developers, a platform which is not based on questionable and complex frameworks like Spring or Hibernate, a quick and ambitious release cycle. And JRuby because frankly, so many Java assets in my backpack, I can't just throw them away.
我正在考虑通过 JRuby 切换到 Rails。这可能是两全其美的:一个功能强大的 Web 框架,拥有活跃的大型社区,一个专门的开发团队,一个不基于 Spring 或 Hibernate 等有问题和复杂的框架的平台,一个快速而雄心勃勃的发布周期。还有 JRuby,因为坦率地说,我背包里有这么多 Java 资产,我不能把它们扔掉。
回答by Rollo Tomazzi
I have just started using grails on a new project...not having to write ANY xml files yet still have the power of Spring and Hibernate is truly amazing.
我刚刚开始在一个新项目中使用 grails……不必编写任何 xml 文件,但仍然拥有 Spring 的强大功能,Hibernate 真的很棒。
Use IntellijIDEA for the IDE though, I actually discovered Grails through the IDE (I might be biased though, I hateeclipse).
虽然在 IDE 中使用 IntellijIDEA,但我实际上是通过 IDE 发现了 Grails(不过我可能有偏见,我讨厌eclipse)。