Fort de ses 1.7 millions de téléchargements l'an passé, Groovy continue son bonhomme de chemin en tête parmi les langages de programmation alternatifs pour la JVM.
Groovy 2.0, sorti l'an passé, introduisait dans son offre de la modularité, le support de JDK 7 au niveau syntaxique avec "Project Coin" autant qu'au niveau JVM avec l'utilisation d'"invoke dynamic", et proposait des fonctionnalités de typage et de compilation statique.
Groovy 2.1, quant à lui, s'appuie sur ces bases pour compléter le support d'"invoke dynamic" pour plus de performances. Il propose des améliorations permettant de documenter, d'aider les IDEs, et de vérifier statiquement les Domain-Specific Languages construits avec Groovy. Vous pourrez créer des méta-annotations regroupant d'autres annotations, pour éviter l'annotation "hell". Et enfin, vous irez encore plus loin dans la customisation du compilateur !
Accrochez votre ceinture, paré au décollage !
"Groovy 2.0 and beyond" presentation given at the Groovy/Grails eXchange conference.
Video can be seen here:
http://skillsmatter.com/podcast/groovy-grails/keynote-speech
Fort de ses 1.7 millions de téléchargements l'an passé, Groovy continue son bonhomme de chemin en tête parmi les langages de programmation alternatifs pour la JVM.
Groovy 2.0, sorti l'an passé, introduisait dans son offre de la modularité, le support de JDK 7 au niveau syntaxique avec "Project Coin" autant qu'au niveau JVM avec l'utilisation d'"invoke dynamic", et proposait des fonctionnalités de typage et de compilation statique.
Groovy 2.1, quant à lui, s'appuie sur ces bases pour compléter le support d'"invoke dynamic" pour plus de performances. Il propose des améliorations permettant de documenter, d'aider les IDEs, et de vérifier statiquement les Domain-Specific Languages construits avec Groovy. Vous pourrez créer des méta-annotations regroupant d'autres annotations, pour éviter l'annotation "hell". Et enfin, vous irez encore plus loin dans la customisation du compilateur !
Accrochez votre ceinture, paré au décollage !
"Groovy 2.0 and beyond" presentation given at the Groovy/Grails eXchange conference.
Video can be seen here:
http://skillsmatter.com/podcast/groovy-grails/keynote-speech
Ленивые итераторы для разбора разнородных данных. Михаил Озеров. Moscow.pm 6 ...Moscow.pm
— От циклов к коллбэкам
— От коллбэков к итераторам
— Борьба со сложностью, изоляция аспектов
— Гибкость и модифицируемость кода
— Преимущества и недостатки
Ленивые итераторы для разбора разнородных данных. Михаил Озеров. Moscow.pm 6 ...Moscow.pm
— От циклов к коллбэкам
— От коллбэков к итераторам
— Борьба со сложностью, изоляция аспектов
— Гибкость и модифицируемость кода
— Преимущества и недостатки
35. どうなってるの?
クイックソートのメインとなるメソッドです。
def quicksort(int[] a, int L, int R) {
int m = a[(L+R) >> 1]
int i=L
int j=R
while (i<=j) {
while (a[i]<m) i++
while (a[j]>m) j--
if (i<=j) {
swap(a, i, j)
i++
j--
}
}
if (L<j) quicksort(a,L,j)
if (R>i) quicksort(a,i,R)
}
36. どうなってるの?
@Typed 付けない場合です。
public Object quicksort(int a[], int L, int R) {
CallSite acallsite[] = $getCallSiteArray();
Integer m = (Integer)ScriptBytecodeAdapter.castToType(acallsite[19].call(a, acallsite[20].call(acallsite[21].call(DefaultTypeTransformation.box(L), DefaultTypeTransformation.box(R)), $const$3)), $get$$class$java$lang$Integer());
Integer i = (Integer)ScriptBytecodeAdapter.castToType(DefaultTypeTransformation.box(L), $get$$class$java$lang$Integer());
Integer j = (Integer)ScriptBytecodeAdapter.castToType(DefaultTypeTransformation.box(R), $get$$class$java$lang$Integer());
do {
if(!ScriptBytecodeAdapter.compareLessThanEqual(i, j))
break;
while(ScriptBytecodeAdapter.compareLessThan(acallsite[22].call(a, i), m)) {
Integer integer = i;
i = ((Integer) (acallsite[23].call(i)));
Integer _tmp = integer;
}
while(ScriptBytecodeAdapter.compareGreaterThan(acallsite[24].call(a, j), m)) {
Integer integer1 = j;
j = ((Integer) (acallsite[25].call(j)));
Integer _tmp1 = integer1;
}
if(ScriptBytecodeAdapter.compareLessThanEqual(i, j)) {
acallsite[26].callCurrent(this, a, i, j);
Integer integer2 = i;
i = ((Integer) (acallsite[27].call(i)));
Integer _tmp2 = integer2;
integer2 = j;
j = ((Integer) (acallsite[28].call(j)));
Integer _tmp3 = integer2;
}
} while(true);
if(ScriptBytecodeAdapter.compareLessThan(DefaultTypeTransformation.box(L), j))
acallsite[29].callCurrent(this, a, DefaultTypeTransformation.box(L), j);
if(ScriptBytecodeAdapter.compareGreaterThan(DefaultTypeTransformation.box(R), i))
return acallsite[30].callCurrent(this, a, i, DefaultTypeTransformation.box(R));
else
return null;
}
37. どうなってるの?
@Typed 付けた場合です。
public Object quicksort(int a[], int L, int R) {
do {
int m = ArraysMethods.getAt(a, L + R >> 1);
int i = L;
int j = R;
do {
if(i > j)
break;
for(; ArraysMethods.getAt(a, i) < m; i++);
for(; ArraysMethods.getAt(a, j) > m; j--);
if(i <= j) {
swap(a, i, j);
i++;
j--;
}
} while(true);
if(L < j)
quicksort(a, L, j);
if(R > i) {
R = R;
L = i;
a = a;
this = this;
} else {
return null;
}
} while(true);
}
51. コンパイル時にエラー
Groovy は実行時にエラーになります。
Caught: groovy.lang.MissingMethodException: No signature of
method: java.lang.String.toStrings() is applicable for argument
types: () values: []
Possible solutions: toString(), toString(), toString(),
contains(java.lang.CharSequence), contains(java.lang.String),
substring(int)
at example.ex02.run(ex02.groovy:4)
58. アクセス修飾子
Groovy では private のプロパティ・メソッドもア
クセスできます。
package example
class Person {
private String name
private int age
public Person(String name, int age) {
this.name = name
this.age = age
}
private dump() {
println "name = ${name}, age = ${age}"
}
}
def p = new Person("Mike", 25)
p.dump()
59. アクセス修飾子
Groovy++ では
@Typed
package example
class Person {
private String name
private int age
public Person(String name, int age) {
this.name = name
this.age = age
}
private dump() {
println "name = ${name}, age = ${age}"
}
}
def p = new Person("Mike", 25)
p.dump()