各种语言的REPL模式

这段时间不是在学Java基础么(偷笑),发现每写一段代码都需要编译再执行,速度太慢了,我只是想测试一下一些运算和逻辑是否正确,看看类里有什么方法而已。

还是脚本语言的REPL模式好用,收集几个,不过,我刚刚也找到了java的repl扩展包,也好用。

php
[shell]
shuhai@Aspire$ php -a
Interactive mode enabled

php > echo "hello world\n";
hello world
[/shell]

ruby
[shell]
shuhai@Aspire$ irb
2.0.0p0 :001 > puts "hello world"
hello world
=> nil
[/shell]

python
[shell]
shuhai@Aspire$ python
Python 2.7.4 (default, Apr 19 2013, 18:28:01)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hello world"
hello world
[/shell]

javascript
[shell]
shuhai@Aspire$ node
> "hello world";
‘hello world’
[/shell]
这里我用的是nodejs来运行的,最简单的方法还是在浏览器地址里执行javascript:alert(“Hello world”);

java
[shell]
shuhai@Aspire$ groovysh
六月 28, 2013 4:17:00 下午 java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
Groovy Shell (2.1.5, JVM: 1.7.0_21)
Type ‘help’ or ‘\h’ for help.
————————————–
groovy:000> System.out.println("Hello World");
Hello World
===> null

[/shell]

java本身是需要编译的,搜了一下java repl,发现好几个据说不错的工具。

https://github.com/albertlatacz/java-repl
Jython 看起来很强大,但不太会用
groovy 不错哟,使用中
groovy for Eclipse Plugin
beanshell 单文件,管理测试都很方便,java -jar bsh-2.0b4.jar,有提示但好像无法产生交互的数据,System.out.println(“Hello World”);没有返回任何内容

scala
[shell]
shuhai@Aspire$ scala
Welcome to Scala version 2.11.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25).
Type in expressions to have them evaluated.
Type :help for more information.

scala> 1+1
res0: Int = 2

scala>
[/shell]

发表评论