How about evolving the fiddle concept? The ordinary fiddles let you write something and then click "run" or "see results" or some such and then will show you the obvious. That's when you see that mistake you made in line 3...
I think computers should be there to assist us and we should not be limited by computing power and having to mouse click and this or that to see the results of our work. So, how about a real-time WYSIWYG fiddle? Sure, we have js-hint type stuff, that only checks the code you write syntactically, but how about also compiling it and even run it as you write it?
...especially for pure functional programming, i.e. the not the side effecting kind...?
Here it is:
1+2
Click for result
How is this different from the normal run of the mill fiddle? Just click at the end of the expression and continue writing 1+2-4+56
and so on. The result is re-calculated as you type. Although this is a Javascript fiddle executed in your browser (with no security implications for this blog's host), as it is customary in scala, the result of the last expression in the fiddle is the result displayed.
You can even type enter and go on multi-line and write a smart little algorythm, all ran as you type it. (You should probably make sure it doesn't transfer money out of your account!)
That's it! Why not? Why can't we see the results of our code as soon as it compiles successfully? Even if I have to define a mocked environment for it, during development? I'll surely have one for testing right?
This is a pet peeve of mine and you'll see more on that soon... including markdown previews and more.
Why not just modify someone else's code right there, where you found it until you like it better and then copy it?
One issue is, while you write it, the script will have all sorts of issues, not only syntax issue, so this all "instantaneous thing" is done in stages:
You'll notice the outline of the results box change as you type, while the expression contains errors: the outline changes to red and the result remains the last good result.
As soon as js-hint reports no problems, the color changes to green and the expression is evaluated and the new value printed.
I will let you analyze this page and figure out how this is all done. If you are interested in the scala implementation (it's all a play template) send a comment below and I will share the code...
There are of course issues such as having another one on the same page:
6+7
Click for result
You'll see that they don't conflict.
There is also a playground, one that also shows the results of jshint etc.
Play with that here: http://razie.dieselapps.com/sfiddle/playinbrowser/js (since you have no account, autosave and other goodies won't work for you).
And if you break it, let me know.
Why the putty fiddle - or maybe the creative fiddle is because when I feel creative, especially with merging data sets and putting them through a template and web look and feel and such, I feel like I'm molding the results directly, a mind-meld to the output and compilers and publishing maven artifacts and slow refreshes and all that just gets in the way. I think we can all accomplish more by hiding all this junk behind the scenes, where it belongs. Software technology still has a long way to go.
It often feels that we need more of an idea publishing platform rather than a coding platform... and most good publishing platforms are WYSIWYG!
To be fair, sbt helps to some extent, when run in continuous build mode, with ~run
, which is something I've enjoyed for years. Quite slow though... and isolated to development, not connected to much else (refresh, testing, builds, production).
This entire website is built around ideas such as this: it is a markdown wiki site with real time previews and other such goodies. It even has similar functionality for server-side code like scala itself. See some early prototypes for that at http://www.tryscala.com