6 ms·
Elm's Time-Traveling Debugger
- dekhn 12y agogdb already has had reverse debugging for 5 years. http://sourceware.org/gdb/wiki/ReverseDebug http://sourceware.org/gdb/wiki/ReverseDebug
- adamnemecek 12y agoWhat's your point?
- pekk 12y agoThe title would suggest to someone not already well-versed that this is a unique feature of Elm's debugger, certainly not that one of the most common and popular debuggers does this. It's hype
- dekhn 12y agoMy point was that the first paragraph of the post is simply misleading. Now that I understand Elm is an esoteric system and these results are irrelevant outside its solution domain, I don't really care.
- rybosome 12y agoSurely the fact that such a valuable tool can be implemented due to Elm's "esoteric" nature (not sure I agree) is of interest?
- mbrubeck 12y agoSystems like gdb process-record-and-replay rely on logging machine state with every instruction [0]. This imposes limitations; for example gdb's record-and-replay system is not implemented on all platforms where gdb runs. Record-and-replay systems can also be impractical for many systems; for example VMWare record-and-replay debugging technically works on Firefox, but it's a tool of last resort because of the performance penalty. The browser can take several minutes just to start up in the record-and-replay debugger. [1] Because of this, Mozilla developed its own record-and-replay system that is lower-overhead, but that again does CPU-specific and platform-specific work that needs to reimplemented for every OS and architecture, and relies on CPU features that aren't available at all on some processors and add some limitations of their own (like no recording of multiple threads with shared memory). [2] In contrast, the Elm debugger apparently takes advantage of the language's pure FRP design to record and replay only input streams, rather than low-level machine/program state - a very different approach, with its own limitations, but also very different possibilities like interactively rewriting history by running different code on the same input stream. [0] https://sourceware.org/gdb/wiki/ProcessRecord https://sourceware.org/gdb/wiki/ProcessRecord [1] http://blog.pearce.org.nz/2009/03/setting-up-vmware-to-record-replay-and.html http://blog.pearce.org.nz/2009/03/setting-up-vmware-to-recor... [2] http://rr-project.org/ http://rr-project.org/
- mbrubeck 12y agoI should note that Mozilla's "rr" is actually similar conceptually to the Elm debugger, since it records an input stream rather than a snapshot of the program's states or actions. But the mechanism is quite different, since C++ doesn't naturally isolate nondetermistic "inputs" in the way Elm does.
- seanmcdirmid 12y agoReplay frameworks are common in the systems community; the trick is to capture and record non-determinism somehow.
- th3iedkid 12y agointellij and many java IDEs do something similar with utils like mvl to change stack-history ,replay and to a minimal extent hot-swap byte-code in all standard-JREs. With JVMs like Zing , however a lot more of hot-swap seems possible!
- monokrome 12y agoWhat do you mean, "finally implemented"? I thought that Bret Victor himself was doing it using his own Tangle.JS library? http://worrydream.com/Tangle/ http://worrydream.com/Tangle/
- corysama 12y agoAt the Elm Workshop 2013 ( https://www.youtube.com/channel/UCzbnVYNyCwES9u3dqYZ-0WQ/videos https://www.youtube.com/channel/UCzbnVYNyCwES9u3dqYZ-0WQ/vid... ) several interesting features like this one were demonstrated. Many of which were brought to proof-of-concept level in 1-3 man-weeks each.
- wheatBread 12y agoThat was a really fun and inspiring workshop! If you are interested in concurrency in browsers, there were two interesting talks about that ( https://www.youtube.com/watch?v=PBDJYkSwVFs https://www.youtube.com/watch?v=PBDJYkSwVFs and https://www.youtube.com/watch?v=JQeqfSGc9q0 https://www.youtube.com/watch?v=JQeqfSGc9q0 ). I'm hoping more people in the browser world come around to the idea that concurrency and parallelism aren't so tricky if you start with language design. Passing immutable objects cheaply between web workers would be a huge deal for projects like Elm!
- adamcanady 12y agoHow much overhead does this add and how difficult would it be to implement in another language like Python or even C? I imagine implementing it for an interpreted language would be much easier if you could save and recover states at any given point. For example, in a project I just completed where we implemented Scheme in C, perhaps we could just memcopy everything and add it to a stack upon each expression evaluation (much easier in Lisp dialects since expressions are nested and you could 'edit as you go' by just changing an inner expression).
- skybrian 12y agoVery large amounts of overhead, and it's quite a difficult project. Elm runs in a browser and is designed to be accessible to beginners, but there is still plenty of work to do. Don't expect it to scale very well yet.
- kevinnk 12y agoFor C, you could use something like GDB's checkpoint which uses fork to save the current state.
- rybosome 12y agoAs they note in the section entitled "How Elm Makes this Possible", the design of the language lends itself to this feature. Functional purity and immutability mean that functions can be evaluated speculatively, as demonstrated in the video where Mario's jump trajectory is altered as the gravitational force is weakened or strengthened. There is no need to save any state beyond the user inputs (mouse position and clicks, keys pressed) and the time at which they occurred. Once saved, they can be reevaluated safely (due to the purity and immutability), and live-modifying the code or adjusting the time is a simple matter of rerunning. It's a wonderfully designed feature, but the ability to implement with relative ease is a natural consequence of strict FRP. In an impure, mutable, stateful language this would be quite challenging, and potentially dangerous. Given a line of code that spawns a thread, for instance, how would it be made clear that the inverse of this state is shutting the thread down? What if the thread has already modified shared memory - how will you track that? If you were to attempt to preserve the entire state of the running program (threads, open files, etc.), how would you quickly reproduce it upon modification?
- j_s 12y agoIs this a souped-up version of Visual Studio Ultimate's[1] IntelliTrace[2]? [1] retailing for over $10,000: http://www.microsoftstore.com/store/msusa/en_US/pdp/Visual-Studio-Ultimate-2013-with-MSDN/productID.284832100 http://www.microsoftstore.com/store/msusa/en_US/pdp/Visual-S... [2] http://msdn.microsoft.com/en-us/library/dd264915.aspx http://msdn.microsoft.com/en-us/library/dd264915.aspx
- seanmcdirmid 12y agoMore like live programming: http://research.microsoft.com/apps/pubs/default.aspx?id=179365 http://research.microsoft.com/apps/pubs/default.aspx?id=1793... http://research.microsoft.com/apps/pubs/default.aspx?id=211297 http://research.microsoft.com/apps/pubs/default.aspx?id=2112... The former (2007) applies live programming to an FRP language; the latter is newer and supports imperative update along with time travel and retroactive update via a concept we call managed time. It is quite easy to do this with FRP, but harder to scale up to richer languages. Videos are linked into the last paper (and embedded in the first...) but I haven't tried releasing a language yet.
- pnathan 12y agoA brief survey of time-travelling debuggers[1]. What [1] does not note is that it was heavily studied in relation to Prolog in the late 80s and early 90s. Some very fancy shenanigans were possible including scripts watching variable bindings and actions. Some of this becomes evident if the Pancake bibliography is scanned[2]. It's exciting seeing the dream of the 70s come alive. :-) [1] http://jakob.engbloms.se/archives/1554 http://jakob.engbloms.se/archives/1554 [2] http://web.engr.oregonstate.edu/~pancake/papers/biblio/ http://web.engr.oregonstate.edu/~pancake/papers/biblio/
- paperwork 12y agoI'm a big fan of Chronon[1] for Java. Run a program and record everything about it. Use the same eclipse debug interface as always, but also have the ability to re-wind to an earlier point. Check out the state of any variable in the code, at any time. It knows about threads, can reproduce inputs/outputs, etc. I believe it is now integrated with intellij as well. No connection to the product, other than the fact that I paid for it. Unfortunately it doesn't seem to be very well marketed. From what I recall (last few months I've been away from Java), you can't modify anything and re-run it (which Elm's debugger seems to be able to do). [1]http://chrononsystems.com/ http://chrononsystems.com/
- mateuszf 12y agoI'm not sure about it, but AFAIR it comes for free for Intellij Idea Ultimate users.
- crazysaem 12y agoYes, it was added in 13.1. And only in the Ultimate version, as you mentioned. http://blog.jetbrains.com/idea/2014/03/try-chronon-debugger-with-intellij-idea-13-1-eap/ http://blog.jetbrains.com/idea/2014/03/try-chronon-debugger-...
- mgkimsal 12y agoWould love for it to support Groovy, and/or there to be something similar for PHP.
- girvo 12y agoCodebug for the Mac isn't time travelling, but coupled with Xdebug and some break points it'll drop you into an interactive console at various points you want to explore. I'm hooked :)
- mgkimsal 12y agophpstorm and intellij are enough for me already, but would love the 'time traveling' aspect (I think of it more like a code DVR). chronon works OK for java, but I do grails work, and the groovy metaprogramming stuff isn't supported in chronon.
- eipipuz 12y agoIf you are interested in this, check Factor's toolchain it's a great environment. See: http://factorcode.org/ http://factorcode.org/ & http://concatenative.org/wiki/view/Factor/Features/The%20environment http://concatenative.org/wiki/view/Factor/Features/The%20env...
- davexunit 12y agoThis is some incredible work. I am writing a game engine and Elm has been a major influence. I've written a functional reactive programming API, but I'm far away from having such awesome interactive debugging. Thank you, Elm, for the awesome software and providing such good learning material. I was struggling to understand FRP until I came across Elm's "What is FRP?" page. http://elm-lang.org/learn/What-is-FRP.elm http://elm-lang.org/learn/What-is-FRP.elm
- Trufa 12y agoWhat is the limitation of this? I mean if I'm reading a text file that is a map, and I delete part of it, I'm guessing this is quite impossible to reverse debug correct?
- omphalos 12y agoOne improvement that this has over most of the "conventional" reversible debuggers mentioned in the comments is the ability to instantly see the effect of your change over time. For example, with Mario example, after jumping up and down, you can adjust the gravity parameter to see what paths Mario would have taken with different gravities and the same input stream.
- pnathan 12y agoI'm loathe to say with confidence, but you're right, that does seem to be a relatively novel contribution. It's certainly unusual! I spent some time reading Hewitt's PLANNER paper recently. I am tempted to think that something drawing from his ideas on hypothetical explorations could be implemented for debugging (more than just numerical adjustments). But it's been a while since I reviewed the debugging literature to say with confidence if such a thing once existed.
- seanmcdirmid 12y agoStrobing and scrubbing, retroactive update have been done since the 70s. The problem has been scaling up beyond toys.
- pnathan 12y agoI'm not familiar with the strobing/scrubbing terminology. I don't think my memories have decayed that badly. :-) I don't suppose you have a paper you'd mind linking to about this?
- seanmcdirmid 12y agoIt is terminology that the live coding and live programming communities (well, at least Alex McLean and myself) are just adopting, and related to analogous capabilities in tools for video editing (like FinalCut Pro, AfterEffects). The terminology is meant to help us describe older work and the newer experiences like those illustrated by Bret Victor. I use these terms a bit in my recent papers, but I don't go into much detail: http://research.microsoft.com/apps/pubs/default.aspx?id=211297 http://research.microsoft.com/apps/pubs/default.aspx?id=2112... http://research.microsoft.com/apps/pubs/default.aspx?id=189802 http://research.microsoft.com/apps/pubs/default.aspx?id=1898... For the first paper, here is an annotated video that perhaps shows it better: http://youtu.be/xmWJsTTOvkU http://youtu.be/xmWJsTTOvkU You would be correct in thinking they are hardly standard. Time travel is such a sexy term alternative that most people just use that, even if it isn't very descriptive.
- psibi 12y agoIs Elm production ready or is more of a hobby kind of project? I would invest some time in learning this if it's good for production ready applications.
- wheatBread 12y agoThe project is supported by Prezi with the aim of making it production ready ( http://engineering.prezi.com/blog/2013/05/21/elm-at-prezi/ http://engineering.prezi.com/blog/2013/05/21/elm-at-prezi/ ) and all development effort is focused on that. With the two most recent releases ( http://elm-lang.org/blog/announce/0.11.elm http://elm-lang.org/blog/announce/0.11.elm and http://elm-lang.org/blog/announce/0.12.elm http://elm-lang.org/blog/announce/0.12.elm ) it is really easy to drop an Elm component into an existing JS application, which we are experimenting with both at Prezi and in the general Elm community. So I'd (biasedly) say to give it a try. Even if it's still too young for you, I think you'll come out of it writing way better JS :)
- jashmenn 12y agoIf you're interested in this sort of code editing with live feedback of results, checkout Choc http://www.fullstack.io/choc/ http://www.fullstack.io/choc/ - a project we worked on earlier this year. You can use vanilla javascript, step through the execution of each line of code, get a human readable description of what the line is doing, scrub constants, etc. There's even a minecraft-like demo building a tower in voxel.js.
- jimktrains2 12y agoSeriously? This is essentially a static HTML page, why is it completely useless unless JavaScript is enabled? EDIT: Useless meaning there is 0 content that can be seen. It's not that it's ugly w/o JS, there is nadda, zilch, nothing without it.
- y0ghur7_xxx 12y agoBecause who made it decided he liked to do it with js instead of serving static html. There is nothing wrong with that. It's not an api, it's designed to be consumed by browsers. And browsers have js enabled by default and make it very difficult to disable it. It's a problem only for you because you willingly decided to browse in crippled mode.
- jimktrains2 12y ago> And browsers have js enabled by default Not all of them. It's just disturbing that people move so far away from the basics for such simple tasks as static HTML. What about those with disabilities and use screen readers or braille displays? I guess the author doesn't care about the blind or those who choose not to execute arbitrary code on their computers.
- dkersten 12y agoSince Elm is a system for creating interactive, visual things that run on javascript... the author probably doesn't care about the blind or those who choose not to execute arbitrary code in this case. Why would he? They wouldn't be able to use Elm anyway.
- jimktrains2 12y agoFair enough. It's just sad to see technology create barriers between people.
- koide 12y agoWhy did you mention the blind? Some can certainly create visual things [1] and run Javascript. Having a limitation sucks at least two times, the first when you find you can't do something and the second time, after learning to do that thing, when people assumes you can't even try. [1]: http://www.armagan.com/ http://www.armagan.com/
- Tomte 12y agoHow does it compare to OCaml's time-travelling debugger? Is the feature set and the debugging experience basically the same?
- seanmcdirmid 12y agoThere are about 50 or so time travel debuggers in existence. I want detailed comparisons now. Just joking. Really, you can examine both systems and make your judgments. It's not like this is a paper with a comprehensive related work section.
- dspillett 12y agoNow? They are time travelling, I want a comparison yesterday.
- fzltrp 12y agoI don't think that the OCaml debugger let you do the things demonstrated by Bret Victor in his talks, and implemented there. As explained elsewhere in this thread, these features let you replay a conputation sequence in a loop, and bind certain values of the computation context to visual inputs (sliders or more simply input boxes for instance) to modify these values during the replay loops. This let you observe how the computation sequence reacts to those changes. It allows a more playfull testing and tuning of a program. Of course it is way more useful in the case of a visual rendering performed by said computation. Please watch the Bret Victor's video for insight (maybe that one: http://vimeo.com/m/36579366 http://vimeo.com/m/36579366).
- mamcx 12y agoAny resource in how made a debugger? This is a step where I can't find a simple explanation (ie: for a self-made language: how make a debugger for it?)