Scala as shell script alt

151 views
Skip to first unread message

Marc Haubenstock

unread,
Nov 9, 2013, 5:58:57 PM11/9/13
to scala-...@googlegroups.com
Hi,

As I recently discovered scala can be used as a shell script language (btw. how cool is that?!? )

 [http://scala-lang.org/documentation/getting-started.html]

Has anyone tried using scala as such? Whats the user experience / performance i.e. noticeable execution degradation?

Yago Alonso

unread,
Nov 9, 2013, 7:36:22 PM11/9/13
to scala-...@googlegroups.com
I use Scala scripting to manipulate XML files and it's great, specially since you can very easily combine it with sed / awk thanks to the scala.sys.process package. But yeah, startup time is a nuisance. It gets much better if you add the -savedcompiled option on your script at the head of your script. 

#!/bin/sh
exec scala -savecompiled "$0" "$@"
!#

 #your scala script goes here

Marc Haubenstock

unread,
Nov 10, 2013, 7:14:56 AM11/10/13
to scala-...@googlegroups.com
Ah, thanks for that flag. Ill try it out once I have the time to convert my bash script into scala!

Sebastian Nozzi

unread,
Nov 10, 2013, 10:48:12 AM11/10/13
to scala-...@googlegroups.com
Does -savecompiled produce a compiled file in the same directory as the source file?
Or in some hidden temp directory?


2013/11/10 Marc Haubenstock <marc.dha...@gmail.com>
Ah, thanks for that flag. Ill try it out once I have the time to convert my bash script into scala!

--
You received this message because you are subscribed to the Google Groups "Vienna Scala Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-vienna...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yago Alonso

unread,
Nov 10, 2013, 3:31:03 PM11/10/13
to scala-...@googlegroups.com, sebn...@googlemail.com
It saves a .jar file on the same directory, and checks the script for modification every time it runs. If there have been changes, it will recompile

Yago Alonso

unread,
May 7, 2014, 11:27:36 AM5/7/14
to scala-...@googlegroups.com, sebn...@googlemail.com
At yesterday's meetup, someone was asking about how to handle dependencies on scripts. This link is  the whole story on how to do it with sbt. 
Reply all
Reply to author
Forward
0 new messages