News for hackers. Stuff that matters.
Re:Meet the new Light Table by aoe on Tuesday November 06, 2012 @11:18AM (#4749034)
Looks like a good concept, but I really cannot see how this would work for functions with side effects? What if I write `File.rm("something")` and press enter?

And how would this work with, say, Ruby on Rails development?

Can anyone throw some light?

Re:Meet the new Light Table by spjwebster on Tuesday November 06, 2012 @12:25PM (#4749409)
This is an issue[1] that SublimeLinter ran into when syntax checking Perl modules. Code in a BEGIN block (which gets executed at compile-time) could actually delete files when using `perl -c` to handle syntax checking:

BEGIN { `rm -rf $ENV{HOME}` }

They had to switch to using static analysis rather than relying on Perl's built in syntax checking to avoid executing code in BEGIN blocks.

[1] https://github.com/SublimeLinter/SublimeLinter/issues/77

Re:Meet the new Light Table by ibdknox on Tuesday November 06, 2012 @12:22PM (#4749396)
As with all tools you have to consider if it's the right place to use it. Things like the instarepl aren't very valuable in highly side-effecting code, but being able to evaluate some block on command still is. You still have to test if that code that removes a file is doing what you think it is as you write it. That being said, you have full control over what does and doesn't end up eval'd - just don't press cmd-enter :)
Re:Meet the new Light Table by tlrobinson on Tuesday November 06, 2012 @01:18PM (#4749647)
just don't press cmd-enter

That seems like a dangerous approach. People could get in the habit of hitting cmd-enter, and accidentally run some destructive code.

Perhaps you could sandbox the execution environment so destructive operations are logged but not actually performed.

Re:Meet the new Light Table by ellyagg on Tuesday November 06, 2012 @01:31PM (#4749719)
There are environments that have been behaving just this way for decades (emacs elisp buffers, Satimage Smile for AppleScript text windows) and no one complains or claims it's not well worth the risks. How is typing in any destructive code anywhere or command lines at the shell and just hitting enter different? If you don't know approximately what your functions are doing, you should never call them under any circumstances.

In practice, this has just not been a legitimate concern. Yes, you have to look both ways before you cross a busy street; people are pretty good at looking both ways.

Re:Meet the new Light Table by calibraxis on Tuesday November 06, 2012 @01:57PM (#4749929)
Yes, in SQL and filesystems, such security relies on permissions at a lower level than your shell/REPL.

(BTW, this post is written using Light Table, rather than the usual emacs. Nice feel! :)

Re:Meet the new Light Table by joesb on Tuesday November 06, 2012 @05:08PM (#4751087)
> If you don't know approximately what your functions are doing, you should never call them under any circumstances.

Then why would I use an editor that its main selling point is how easy it is to do that?

Re:Meet the new Light Table by calibraxis on Tuesday November 06, 2012 @07:01PM (#4751522)
Well, if you really want to be on the safe side of that particular power vs. safety tradeoff, the repl code could run from (say) clojail. (https://github.com/flatland/clojail)
Re:Meet the new Light Table by chr1 on Tuesday November 06, 2012 @12:15PM (#4749355)
But why would you do that? Press enter only where it makes sense. It's just like with other tools, you can cut your finger with knife, but that doesn't make knives less useful.
Re:Meet the new Light Table by joesb on Tuesday November 06, 2012 @05:04PM (#4751066)
If I can do it only when it makes sense, I would default to "don't do it". So what's the point of binding it to oh-so-convenient shortcut key, when I have to think about when I can do it? What's the different from using terminal or Makefile to run it then?
Re:Meet the new Light Table by chr1 on Wednesday November 07, 2012 @04:46AM (#4752842)
You can't do it only for very specific cases. And even `File.rm("something")` usually works because if you are removing something, you have code for creating it too, and can quickly test both with command+enter, instead of opening whole application and trying to invoke that through your gui or something.
Re:Meet the new Light Table by seanmcdirmid on Tuesday November 06, 2012 @12:06PM (#4749312)
If File.rm("something") is undoable, then its not a problem right? We are talking about developer tools anyways, its not inconceivable that a mock environment would be setup for the program with undoable side effects or what not. However, this would require serious programming model changes, which are probably not in the scope of Light Table.
Re:Meet the new Light Table by TuringTest on Tuesday November 06, 2012 @05:18PM (#4751134)
Which is a shame. As joesb points out above, this severely reduces the benefits of the "instant execution&feedback" features.

Given that this is an alpha release, maybe it's still time to rethink that approach and allow for sandboxed environments.

Re:Meet the new Light Table by ibdknox on Tuesday November 06, 2012 @05:21PM (#4751145)
There's absolutely nothing preventing a sandboxed environment :) Connections are just processes that talk over tcp, if the client wants to sandbox whatever it evals, it can definitely do that.
Re:Meet the new Light Table by seanmcdirmid on Wednesday November 07, 2012 @12:24AM (#4752265)
Sorry I wasn't clear, but the ability to "undo" an operation definitely requires a programming model change. The sandbox is only one part of that.

Rolling your own magic sandbox isn't going to help much without more buy in from the environment (though, I'm sure most of us test in sandboxes anyways).

Re:Meet the new Light Table by pufuwozu on Tuesday November 06, 2012 @02:21PM (#4750120)
Even GHC's (Haskell) REPL executes side-effects.
Re:Meet the new Light Table by lallysingh on Tuesday November 06, 2012 @01:26PM (#4749686)
I'd expect that instead of eval, you'd want to run some sort of unit test for effectful code.
Re:Meet the new Light Table by slewis on Tuesday November 06, 2012 @12:46PM (#4749490)
The child process could be run inside a chroot jail, or a virtual machine.
Re:Meet the new Light Table by frugalfirbolg on Tuesday November 06, 2012 @04:13PM (#4750785)
To that end the developer could anticipate that their code has a lot of side effects and just run light table in a test vm with snapshots to hop back to in case they really mess up. Setting one up isn't hard, and you only pay the overhead cost of a vm or separate test machine if your use case demands it that way.