MiniScript脚本语言扩展

脚本语言个人评价说明
Groovy+++
Jython/python的java实现
Rhino++javascript的java实现
JudoScript-
Beanshell+
Jess/
Jelly/
BeanScriptingFramework/
Tcl/Java/
JRuby/Ruby的java实现
Pnuts/
ObjectScript+++
Seppia--
Sleep+类似perl
PHP/Java Bridge/
Inline:Java/
LauJava-
Yoix++
Hecl-
JBasic-Basic的java实现

Benchmarks:

Results for ObjectScript: bench.os
TestTime (ms)
simple loop: 646
simple fxn: 1426
simple fxn with arg: 4079
simple fxn with local: 3185
member dereference: 1026
string concat: 3
java class access: 1511
total: 11876
Results for Rhino: bench.js
TestTime (ms)
simple loop: 1676
simple fxn: 2640
simple fxn with arg: 3090
simple fxn with local: 2645
member dereference: 1881
string concat: 6542
java class access: 2944
total: 21418
Results for Jython: bench.py
TestTime (ms)
simple loop: 4492
simple fxn: 5901
simple fxn with arg: 6591
simple fxn with local: 6044
member dereference: 5917
string concat: 285
total: 29230
Results for BeanShell: bench.bsh
TestTime (ms)
simple loop: 15986
simple fxn: 28547
simple fxn with arg: 35311
simple fxn with local: 36185
member dereference: 17227
string concat: 5275
java class access: 50757
total: 189288
Results for JudoScript: bench.judo
TestTime (ms)
simple loop: 29302
simple fxn: 390743
simple fxn with arg: 403152
simple fxn with local: 618718
string concat: 4617
total: 1446532

-------------------------------------MiniScript + Feature----------------------------------

引入
import abc.ddd;
import java.util.Collections as CC;
CC.sort(...);


class Dog{
 name
 @Property address

 getName(){
  name+"tt";
 }

 abc(){
  println "ccccc";
 }
};

闭包Closure
sit={ name1,name2 -> println name1+name2+" Sit, Sit! Sit! Good dog"}
sit.call();

集合
aCollect = [5, 9, 2, 2, 4, 5, 6]

Map 映射
myMap = ["name" : "Groovy", "date" : new Date()]
println myMap["date"]
println myMap.date


范围

myRange = 29...32
myInclusiveRange = 2..5
aRange = 'a'...'e'
for (i in aRange){
  println i
}
负索引
aList = ['python', 'ruby', 'groovy']
println aList[-1] // prints groovy
println aList[-3] // prints python
用范围分割
fullName = "Andrew James Glover"
mName = fullName[7...13]
print "middle name: " + mName // prints James
Ruby 风格的集合
collec = [1, 2, 3, 4, 5]
collec << 6 //appended 6 to collec

 

带有迭代器的闭包
[2, 4, 6, 8, 3].find { x |
     if (x == 3){
       println x
     }
}

javascript正则表达式
 var p=/^adfsdaf$/

字符内 ${变量}
println "My Lamp has a ${myLamp.baseColor} base"


Groovy 中的新语法
def nfile = ["c:/dev", "newfile.txt"] as File
def val = ["http", "www.vanwardtechnologies.com", "/"] as URL
def ival = ["89.90"] as BigDecimal
println ival as Float
 


Groovy的switch语句能够处理各种类型的switch值
case值为类名,匹配switch值为类实例
case值为正则表达式,匹配switch值的字符串匹配该正则表达式
case值为集合,匹配switch值包含在集合中,包括ranges

 


---------------------
printMapClosure = { key, value -> println key + "=" + value }
[ "yue" : "wu", "lane" : "burks", "sudha" : "saseethiaseeleethialeselan" ].each(printMapClosure)
Produces:

yue=wu
lane=burks
sudha=saseethiaseeleethialeselan

fullString = ""
orderParts = ["BUY", 200, "Hot Dogs", "1"]
orderParts.each {
  fullString += it + " "
}

println fullString

synchronized n.旗语
semaphore acquire release


操作符重载
For example, a + b is the same as a.bopPlus(b).

MiniScript参考:Groovy 、 Sleep 、 ObjectScript 、Yoix、JBasic

GOOD Script:  Groovy、ObjectScript、Rhino、Yoix(AT&T)

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值