欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
Groovy
小 (→图集) |
小 (→文档) |
||
(未显示1个用户的14个中间版本) | |||
第14行: | 第14行: | ||
Apache Groovy | Apache Groovy | ||
− | + | Groovy 语言核心由 [https://github.com/apache/groovy/tree/master/src/main/java Java] 语言编写而成。 | |
==新闻== | ==新闻== | ||
+ | *[https://www.oschina.net/news/96828/groovy-2018-roadmap Groovy 2018 Roadmap:下一步主打 lambda 和模块化] (2018.06.07) | ||
*The Groovy project graduated on 2015-11-18 | *The Groovy project graduated on 2015-11-18 | ||
*[http://incubator.apache.org/projects/groovy.html Groovy进入Apache项目孵化阶段] | *[http://incubator.apache.org/projects/groovy.html Groovy进入Apache项目孵化阶段] | ||
+ | |||
+ | ==版本== | ||
+ | *4.0.x | ||
+ | *[https://docs.groovy-lang.org/docs/groovy-3.0.7/ 3.0.x] | ||
+ | *2.6.x | ||
+ | *[https://docs.groovy-lang.org/docs/groovy-2.5.14/ 2.5.x] | ||
==为什么Groovy== | ==为什么Groovy== | ||
第25行: | 第32行: | ||
* 因为[[Domain-specific language|DSL]](Groovy是Java平台的DSL,它是有限领域的Java开发的理想选择;可以将Groovy视为 “简略的Java语言” 更能说明Groovy与Java语言之间的关系); | * 因为[[Domain-specific language|DSL]](Groovy是Java平台的DSL,它是有限领域的Java开发的理想选择;可以将Groovy视为 “简略的Java语言” 更能说明Groovy与Java语言之间的关系); | ||
* 因为[[Gradle]], [[Moqui]] 等优秀项目; | * 因为[[Gradle]], [[Moqui]] 等优秀项目; | ||
+ | * 因为[[Grails]]快速开发框架; | ||
* 因为[https://github.com/apache/groovy Apache顶级项目]。 | * 因为[https://github.com/apache/groovy Apache顶级项目]。 | ||
第114行: | 第122行: | ||
* Maven Plugin — Integration of Groovy with Maven | * Maven Plugin — Integration of Groovy with Maven | ||
+ | ==DSL== | ||
+ | [[Domain-specific language|DSL]] | ||
+ | *[http://www.craigburke.com/groovy-dsl/ Practical and Stupidly Impractical Groovy DSLs] | ||
+ | |||
+ | ==IDE== | ||
+ | *[https://github.com/groovy/groovy-eclipse Eclipse Groovy Development Tools] [[Eclipse]] | ||
+ | |||
==问题== | ==问题== | ||
Groovy常见问题 | Groovy常见问题 | ||
第135行: | 第150行: | ||
*[https://github.com/JFrogDev/artifactory-user-plugins Groovy user plugins] for Artifactory. | *[https://github.com/JFrogDev/artifactory-user-plugins Groovy user plugins] for Artifactory. | ||
*[https://github.com/gaelyk/gaelyk Gaelyk] is a lightweight Groovy toolkit for Google App Engine Java. | *[https://github.com/gaelyk/gaelyk Gaelyk] is a lightweight Groovy toolkit for Google App Engine Java. | ||
+ | *[https://github.com/geb/geb Geb] is a browser automation solution. | ||
+ | *[https://github.com/SmartThingsCommunity/SmartThingsPublic SmartThings] | ||
==文档== | ==文档== | ||
+ | *[https://docs.huihoo.com/groovy/Data-Science-with-Groovy.pdf Data Science with Groovy] | ||
+ | [https://github.com/GR8Conf GR8Conf] dedicated to the Groovy Ecosystem | ||
*[http://docs.huihoo.com/javaone/2015/CON3346-Building-DSLs-in-Groovy-the-2016-Way.pdf Building DSLs in Groovy the 2016 Way] | *[http://docs.huihoo.com/javaone/2015/CON3346-Building-DSLs-in-Groovy-the-2016-Way.pdf Building DSLs in Groovy the 2016 Way] | ||
*[http://docs.huihoo.com/javaone/2015/CON2591-The-Epic-Groovy-Puzzlers-Season-II-The-Revenge-of-the-Parentheses.pdf The Epic Groovy Puzzlers S02: The Revenge of the Parentheses] | *[http://docs.huihoo.com/javaone/2015/CON2591-The-Epic-Groovy-Puzzlers-Season-II-The-Revenge-of-the-Parentheses.pdf The Epic Groovy Puzzlers S02: The Revenge of the Parentheses] | ||
第142行: | 第161行: | ||
==图集== | ==图集== | ||
<gallery> | <gallery> | ||
+ | image:apache-groovy-users.png|Groovy用户 | ||
image:groovy-keywords.png|Groovy关键字 | image:groovy-keywords.png|Groovy关键字 | ||
image:groovy-math-operations-resulting-types.png|数学操作结果类型 | image:groovy-math-operations-resulting-types.png|数学操作结果类型 | ||
+ | image:Groovy-Interceptions.png|拦截器 | ||
image:GroovyConsole.png|GroovyConsole | image:GroovyConsole.png|GroovyConsole | ||
+ | image:Groovy-AST-Browser.png|AST浏览器 | ||
+ | image:Groovy-Object-Browser.png|对象浏览器 | ||
+ | image:smartthings-architecture.png|SmartThings | ||
+ | image:smartthings-demo-app.png|SmartThings | ||
</gallery> | </gallery> | ||
2022年4月11日 (一) 02:52的最后版本
您可以在Wikipedia上了解到此条目的英文信息 Groovy Thanks, Wikipedia. |
Groovy于2003年8月由James Strachan(与Bob McWhirter开发,开发以开放源代码的形式进行。“Java是非常强大而且优秀的语言,但源代码量往往很大”(Strachan)。而脚本语言的优点就是简单方便,在Java中描述非常复杂的部分,如果使用脚本语言可以提高效率。不过,目前的脚本语言中还存在问题,“要想使脚本与Java应用共存,必须通过脚本生成Java的字节码,而如果语法差异很大开发人员就很费劲。我们还希望使用J2EE与J2SE的API”(Strachan)。但符合这一要求的脚本语言并不存在。“因此通过开发人员,使Java的开发和运行环境更加符合‘groovy’”(Strachan)。如果使用Groovy,有时开发时间要比Java缩短一半。由于Groovy的代码中也有描述Java代码的机制,因此两者合用非常容易。
Groovy不仅继承了Java的语法,还吸取了Ruby、Python、Perl等其他脚本语言的特征。如List(列表)与数组等使用特有的语法,提高了描述效率。在会议中,使用从列表中收录的多个字符串中搜索4个字符以下的字符串并显示出来的处理,演示了Groovy的效率。在Java中必须要15 行以上,在Groovy中4行便可以描述。
当然与Java相比,Groovy也有不足之处,比如性能,目前“根据不同的使用方法,为Java的20~90%左右。今后还将进行细节调整”(开发 Groovy的Rod Cope)。此外Groovy还存在不支持内隐类(Inner Class)、调试(Debug)有困难等课题。不过“对小型且不太关键的系统特别有效。也非常容易掌握,因此请务必试一试”(Cope)。Groovy 的运行环境可以从官方网站下载。
目录 |
[编辑] 简介
Apache Groovy
Groovy 语言核心由 Java 语言编写而成。
[编辑] 新闻
- Groovy 2018 Roadmap:下一步主打 lambda 和模块化 (2018.06.07)
- The Groovy project graduated on 2015-11-18
- Groovy进入Apache项目孵化阶段
[编辑] 版本
[编辑] 为什么Groovy
- 因为JVM;
- 因为Java动态语言;
- 因为DSL(Groovy是Java平台的DSL,它是有限领域的Java开发的理想选择;可以将Groovy视为 “简略的Java语言” 更能说明Groovy与Java语言之间的关系);
- 因为Gradle, Moqui 等优秀项目;
- 因为Grails快速开发框架;
- 因为Apache顶级项目。
[编辑] 安装
[编辑] OS X
通过Homebrew安装groovy
$ brew install groovy $ brew upgrade groovy
通过port安装groovy
sudo port install groovy groovy -v sudo port upgrade groovy // 升级到新版本 groovysh // Groovy Shell
[编辑] Linux
wget http://dist.groovy.codehaus.org/distributions/groovy-binary-1.5.1.zip GROOVY_HOME=C:\groovy-1.5.1\ or /usr/local/groovy-1.5.1 add path %GROOVY_HOME%\bin or %GROOVY_HOME%/bin groovyConsole.bat In the top part of the window of the groovyConsole, type the following println "Hello, World!" type <CTRL-R> groovy> println "Hello, World!"
安装成功
[编辑] 测试
class Greet { def name Greet(who) { name = who[0].toUpperCase() + who[1..-1]} def salute() { println "Hello $name!" } }
g = new Greet('world') g.salute()
显示结果
Hello World!
[编辑] 指南
通过 Groovy web console 快速熟悉 Groovy
$groovysh
定义方法
groovy:000> def hello(name) { groovy:001> println("Hello $name") groovy:002> } groovy:000> hello("Huihoo")
定义类
groovy:000> class Foo { groovy:001> def bar groovy:002> def baz() { groovy:003> :display 000> class Foo { 001> def bar 002> def baz() { groovy:003> :show variables
$groovyConsole
[编辑] Examples
Groovy 入门经典 (Groovy Programming) 的随书例子
[编辑] Modules
- COM Scripting — script Windows ActiveX and COM components with Groovy
- Gant
- GFreeMarker — an integration of the FreeMarker template engine for Groovy
- Google Data Support — makes using the Google Data APIs easier from within Groovy
- Gram — a simple xdoclet-like tool for processing doclet tags or Java 5 annotations
- GraphicsBuilder — GraphicsBuilder is a Groovy builder for Java 2D
- Grapplet
- Griffon — Dekstop Enhancements for Groovy
- Groosh — Provides a shell-like capability for handling external processes.
- Groovy Jabber-RPC — allows you to make XML-RPC calls using the Jabber protocol
- Groovy Monkey — is a dynamic scripting tool for the Eclipse Platform
- Groovy SOAP — create a SOAP server and make calls to remote SOAP servers using Groovy
- GroovyLab — Provides a domain specific language (DSL) for math engineering (matlab-like syntax).
- GroovySWT — a wrapper around SWT, the eclipse Standard Widget Toolkit
- GroovyWS — GroovySOAP replacement that uses CXF and Java5 features
- GSP — means GroovyServer Pages, which is similar to JSP (JavaServer Pages)
- GSQL — supports easier access to databases using Groovy
- JideBuilder — JideBuilder is a Groovy builder for the open source JIDE Common Layer
- Native Launcher — a native program for launching groovy scripts
- Windows NSIS-Installer — a Windows-specific installer for Groovy
- Windows Services — framework for Groovy-based WinNT (Windows) Services
- WingSBuilder — WingsBuilder is a Groovy builder for the wingS Framework
- XMLRPC — allows you to create a local XML-RPC server and/or to make calls on remote XML-RPC servers
- Grails — a Groovy-based web framework inspired by Ruby on Rails
- GORM — the Grails Object-Relational Mapping persistence framework
- GroovyPlugin — A Groovy plugin for JSPWiki
- Maven Plugin — Integration of Groovy with Maven
[编辑] DSL
[编辑] IDE
[编辑] 问题
Groovy常见问题
Groovy控制台不能“记住”任何变量,总是报“unknown property”?
groovy:000> := interpreterMode groovy:000> def x = "huihoo" ===> huihoo groovy:000> x ===> huihoo
[编辑] 项目
- Awesome Groovy
- Groovy sub projects
- Grails
- Gradle
- GPars
- sdkman
- ratpack
- jenkins-scripts
- Groovy user plugins for Artifactory.
- Gaelyk is a lightweight Groovy toolkit for Google App Engine Java.
- Geb is a browser automation solution.
- SmartThings
[编辑] 文档
GR8Conf dedicated to the Groovy Ecosystem