Scala Worksheet

We are announcing start of Scala Worksheet feature support. It’s available in scala plugin for Leda from v.0.6.368.

A worksheet is a scala file with .sc extension which you can run and  get evaluation results in a special view appeared in the editor.

Create worksheet by right-clicking on your Project and choosing ‘New’ -> ‘Scala Worksheet’.

Just type your code, press ‘Evaluate worksheet’ button and results appear.

Evaluation of Scala Objects is also supported.

‘Worksheet’ tab is available in ‘Project setting’ -> ‘Scala’. You can configurate output length before line break.

All features of Scala editor are supported because worksheet file is treated as simple scala file.

This entry was posted in Uncategorized. Bookmark the permalink.

34 Responses to Scala Worksheet

  1. Robin Cateran says:

    Good work! After using Eclipse for the Functional Programming in Scala course recently, I found this to be a really nice feature. Thanks guys!

  2. Jan says:

    Thanks ! Will be very useful indeed. :-)

    Btw, does this mean the “fast” compiler will be fixed for Leda ?

  3. Erik Pragt says:

    Very nice indeed. Will this also become available for Groovy? Or maybe even Java? Sometimes it’s really handy to be able to type in some code and see the results of that.

  4. Anna says:

    Great! Happy to read it! But unfortunately my scala plugin has v.0.5.983 and can’t be updated to v.0.6.368 yet. Hope it would be possible soon.

  5. Konrad says:

    Awesome, now there’s no reason at all to show eclipse to people at Scala trainings I do! :-)

  6. Jem Mawson says:

    Thank you to the beautiful people who made this happen.

  7. Trond says:

    This is truly a great feature! However – it is painfully slow! Is there some trick to make the worksheet work faster?

    • Matthew Pocock says:

      Same here. It’s a wonderful feature, and means that I don’t have to reach for eclipse for this kind of thing, but on both my systems it is excruciatingly slow. Ideally, it needs to be as-I-type, or at least interactive. I’m waiting several seconds for each line to be evaluated. The same code in a REPL session is instantaneous.

    • Ksenia Sautina says:

      Yes, currently we have to make worksheet much faster (for example, not to stop JVM after run to avoid running JVM and loading classes cost).

      • Peter Britishton says:

        Amazing feature indeed. But is there any update on the progress on improving the speed? It’s still painfully slow :( (Just bought the IntelliJ Ultimate for scala development; amazing IDE, but faster worksheet is a *must*! :)

    • Fabio says:

      I will add my thank you, and also that alas the Worksheet is still painfully slow. Is there a way to make it evaluate on save?

  8. Santeri Hiltunen says:

    This is a great first version. What it really needs is more speed as others have noticed. It would also be nice if the worksheet would be evaluated every time it’s saved (either by the autosave or manually) but this depends on speed improvements. These additions/fixes would really make it up to par or even better when compared to worksheets in Scala IDE.

    Keep up the good work!

  9. Bilbo says:

    Great stuff.

    One improvement: if the project you’re in has compile errors, the worksheet doesn’t function. It seems the worksheet tries to compile the whole project every time; maybe this is why it’s so slow. The Eclipse version works fine without you having to fix the whole of the rest of your project.

  10. Avatah says:

    I cannot use scala worksheet. When trying to run it it always gives me an error:
    Error running WS
    Cannot run program “/usr/java/latest/bin/java” (in directory “/home/avatah/projects/myproject”): error=7, Arguments list too long
    Probably classpath of my project is too long

  11. Yagiz says:

    This is really great. Last time I checked it, it was pretty slow. Is it planned to use fsc?

  12. levi says:

    This is seriously awesome. Installed it and having a lot of fun. It may be the best way to learn Scala. Zero setup required and it works pretty well. I think it would be nice if it were to be faster, but I’m sure there are issues with essentially redefining all of the functions that are left in worksheet everytime IntelliJ has to be invoke the repl. Not sure though. Either way, fantastic work making programming more enjoyable!

  13. Rao Venu says:

    Is there any possibility that this will be backwards compatible with IDEA Ultimate 11?
    I am not in a position to upgrade to 12 but would love to have this feature.

  14. Ben says:

    It’s a shame I can’t import classes from the current project. The names will autocomplete when typing in the worksheet, but when running, the compiler just gives the “object mypackage is not a member of com” error.

    • Ben says:

      Installing the SBT plugin, and compiling with SBT from within IDEA before executing the worksheet, seemed to fix this.

  15. Jim says:

    Doesn’t seem to work on Mac. I can edit the worksheet, however there is no output pane/area.

  16. Michael says:

    Unfortuantely worksheets do not work with namespaces/packages. Putting the worksheet in a package/subdir e.g. “examples” and defining a class in the worksheet does not work.

    Content of the scala worksheet inside the examples dir:

    class Foo {
    val a = 10

    new Foo().a

    Compiles, but generates no output.
    Adding a package statement leads to the IDE warning that the package structure does not correspond to the directories structure, compiling results in an error (illegal start of definition).


  17. Brent says:

    Unlike the Eclipse Worksheet that immediately updates when the file is saved, the IdeaJ Scala Worksheet plugin only re-evaluates the worksheet when you press Cmd-Opt-W.

    Note also that the SBT plugin is required.

    And… it’s very, very slow to update. The Eclipse Scala Worksheet updates immediately, while the Idea Scala Worksheet launches an external build, Scala process, then updates the results approx. 30s later.

  18. Jim Pivarski says:

    Um… This is not a worksheet. I’ve just installed IDEA and Eclipse for the sake of their Scala Worksheet plug-ins, puzzled through all the configuration steps, and only when everything was finally working did I find that they’re not even worksheets. Has anyone ever used Matlab, Mathematica, Maple, Sage, or even Emacs lisp-interaction mode?

    A worksheet is when you have a REPL running in the background with a front-end that alternates between user inputs and kernel outputs. Inputs are intended to be modified and re-run many times, but the REPL is not restarted, libraries are not reloaded, and if a no-longer-existing input line modifies the kernel’s state in some confusing way, that’s your own darn fault.

    The Eclipse Scala Worksheet plug-in is not even a REPL. You save the file and it evaluates the whole file in non-REPL mode (everything has to be in an object or a class). If you make a change, it re-evaluates everything from a clean slate, which is less confusing, but a show-stopper if some of your initial steps take a long time.

    The IDEA Scala Worksheet plug-in is a REPL (you can “println” outside of any objects or classes), but it cleans the slate every time you run. Not to mention that it takes 30 seconds to run each time, which makes even “println” a show-stopper. Is it re-loading libraries as part of the slate-cleaning? It would be better to turn that off. Let the user be confused: worksheets are like a first sketch of a program with lots of messy changes that will get cleaned up later.

    Both have the same strange format: input on the left, output on the right, with no geometric connection between the input and output.

    Maybe I should look at Scala Notebook again (, but I’d rather use a fully featured editor, not a web browser, because worksheet analysis sessions grow up in fits and stages into real programs. Maybe I have to go back to Emacs and write a mode for it.

  19. Dave Hill says:

    have freshly installed the latest Scala plugin, opened a worksheet, and get no output when I evaluate it.

    running IDEA 12.1.3 ultimate, JDK 1.6.0_33,, Win 7 pro

    first tried it inside a package (but no package declaration in the worksheet) then moved it out of packages to the root as some users here seem to be describing, no joy

    any suggestions?


  20. Hanxue says:

    The worksheet parser does not recognize a statement that is split over 2 lines. For example

    val strRepr1 = => u.toString)
    .reduceLeft( (u, v) => u+","+v)

    will result in a List[String], instead of a String (with each element in aList concatenated with “,”)

  21. Angel Ruiz says:

    There is a problem with the code editor scrolling in this worksheet mode. If I have code that do not produce any output at the bottom of my .sc file, I cannot scrolldown once the last output is showed in the right pane.

  22. society says:

    Please let me know if you’re looking for a writer
    for your blog. You have some really good articles and I feel
    I would be a good asset. If you ever want tto take ome of the load off, I’d
    love to write some articles for your blog in exchange foor a link back to mine.
    Please shoot me an email if interested. Regards!

    My page … society

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">