I am most excited about this, where a language supports two modes 1) interpreter for development, and 2) compilation for performance. Never thought about this, but reading this, it makes perfect sense on large projects
I am most excited about this, where a language supports two modes 1) interpreter for development, and 2) compilation for performance. Never thought about this, but reading this, it makes perfect sense on large projects
go run main.go
or: go run ./cmd/server
When invoked this way, Go compiles your code behind the scenes, but you don't have to create a binary.This means Go lends itself pretty well to ad-hoc scripting or writing small script-like tools.
Unfortunately, Go doesn't support shebang lines, but with gorun [1] you can:
#!/usr/bin/env gorun
package main
func main() {
println("Hello world!")
}
[1] https://github.com/erning/gorun #!/usr/bin/env dub
/+ dub.sdl:
name "allthepythons"
dependency "d-glob" version="~>0.3.0"
+/
import std.stdio : stdout;
import glob : glob;
void main () {
foreach (entry ; glob("/usr/local/bin/python*")) {
stdout.writefln("%s", entry);
}
}Scala (Ammonite) works like this.
The author isn't complaining about keystrokes; he wants the compile + run process to be faster. Using an interpreter instead of a compiler would make it faster.
java build ./app/ ./app
That's impressive if true as last I worked with Java it was a mess
For AOT there is this JEP: https://openjdk.java.net/jeps/295 and a different project: the GraalVM
So I'd say that Java can do "this" since recently (JDK 9 in 2017) via JShell (I wouldn't count BeanShell or Groovy), i.e. it always had the compiler part but added the interpreter.
Although its usage is still quite rare, whereas the blog post would suggest a different pattern.
GCJ improved very slowly and around 2009 lost most of its developers with the release of OpenJDK.
It starts interpreted, but if you run for very long, it runs compiled.
But that costs memory and startup time.
People usually don't do it because JITs are heavy so they'd prefer to share them.