6 ms·
I don't know if anyone from the team is reading this, but I'll tell you want I want from a Javascript debugger: I want to be able to modify/add code, try it ou
by ars 10y ago
I don't know if anyone from the team is reading this, but I'll tell you want I want from a Javascript debugger:
I want to be able to modify/add code, try it out, then rewind, and try something else. Then save my changes once they work perfectly.
Simply setting breakpoints and watching variables is nice, but I can do basically the same thing by echoing/console.log'ing things. If you are going to go to the effort of making a debugger, then make it do something I can't do another way.
- espadrine 10y agoThe following bug may be of interest to you: https://bugzilla.mozilla.org/show_bug.cgi?id=1207696 https://bugzilla.mozilla.org/show_bug.cgi?id=1207696 It will support replaying and help go towards rewinding, although live code editing is not in there.
- mintplant 10y agoWebReplay! One of the coolest projects at Mozilla right now, IMO. You can record and rewind the entire state of the browser and do reverse-stepping etc like with rr. https://developer.mozilla.org/en-US/docs/Mozilla/Projects/WebReplay https://developer.mozilla.org/en-US/docs/Mozilla/Projects/We...
- renke1 10y agoSaving changes may be a bit harder these days with all the transpiling going on.
- BinaryIdiot 10y agoThat's something the community will simply have to deal with. Transpiling already creates issues when you're debugging code since what you debug is different than what you wrote. Honestly this is one of the biggest issues I have with transpiling everything; you don't have to transpile even though our industry seems to be standardizing on it.
- revelation 10y agoThat's because integrated debuggers are a rather crass design error. Windows doesn't come with a debugger. Linux doesn't come with a debugger. The JVM has no right-click launched debugger. CPython doesn't jump you into an interactive debug console. But all of those have a debug interface. Leave building debuggers to others who have a clear picture of how they are using your platform.
- Chyzwar 10y agoLinux and windows comes with multiple different debuggers. Linux comes with strace, kdb, kgdb. You also have gdb by virtue having C compiler. Only by tight integration with VM/compiler you can get decent debuggers. For example Smalltalk debuggers are class above to what JS can offer today. Crass design error is ignoring debugging needs until it is too late. Adding needed hooks and state managers is expensive, just look how much effort it is now: https://bugzilla.mozilla.org/show_bug.cgi?id=1207696 https://bugzilla.mozilla.org/show_bug.cgi?id=1207696
- jasonlaster11 10y agoThanks for the feedback. (project maintainer) I agree that "live edit" is an exciting feature. It supports a tighter feedback loop that lets you iterate in the correct context. There are two challenges 1. transpiling, which would require a tighter integration with the project's build tools. Not impossible, but something that would require the correct UX. Chrome DevTools supports live edit now, but that is only for non source-mapped sources. 2. mapping to project sources. VS Code has done a lot of great work with source maps to map to the on disk sources with source maps. In theory, this should be easy, but there are many build tools and some edge cases with nested source maps, imagine an ember app that pulls in ember libraries which are also mapped. With that said, this is definitely exciting and with the new front-end we can begin to work on an ambitious projects like this!
- randomfool 10y agoIt would be great if 'save' from the devtools could just post the updated version back to server where it came from. Let my server handle getting it onto disk- it knows where it came from in the first place!
- kristopolous 10y agoI'm just looking for an accurate symbol table to be exported in something like ctags format for code navigation. I've seen tools that capture somewhere between about 1% and 9% of large projects. [1] I know it's a hard problem that can't be solved with static analysis like in C, indeed! I know people could do var x = "do", y = "something", z[x + y] = function() {}; ... z[x + y] = (some other function now) Contextual reassignments, various forms of composability, yep! This thing is still important. The goal is to reduce the "Wtf is going on here" phase of diving into existing code. I have had to honestly abandon projects and back out of jobs with good friends because I couldn't get to that answer fast enough. You can do so many cryptic layered indirect things with javascript, it makes unraveling it really quite hard - especially if there's a language barrier (as there was in the one I'm thinking of where I had to resign after 6 weeks in shame for a guy I had worked with for 2 years on a previous company). I tried to build this claimed introspection tool myself in vain over the course of about 2 weeks, but diminishing returns hit and things got pretty hard. Javascript can be beautiful and simple - but it can also have cascading chains of action-at-a-distance with layers of framework scaffolding obscuring the business logic code so that the caller and the callee are not 1 frame, but 10 or 15 frames apart. [2] My campaign to encourage people to write code in the plain in a way that hopefully any future junior developer will understand is a lifetime project. Until I get there, tools like this would be truly invaluable. Back in the C/C++ days, it saved my butt daily. --- [1] Excuse me for not finger pointing to specific projects. I don't find it courteous or productive. I aggressively surveyed [probably] all of them, including those offered by IDEs, in 2015. [2] This leads to two easier tools which are (1) the "stack and step collapser" - essentially a way to tell the debugger to ignore entire directories of code when stepping through code or printing stackdumps. Having to go through stack traces that can be literally over 100 levels with only 1 or 2 being your code is certainly a system we can improve on. (2) a stack of stacks ... so that if an error is caught, the stack isn't smashed and replaced, but preserved in a second dimensional stack so when an error is just "some error occurred in these 1,000 lines" you can still see the previous stack. I've often just seen stack dumps be the frameworks error handler (or the error handler erroring) and have no indication as to the actual source of the error. It's crazy how useless it can be. A stack of stacks would solve this (again, as would not coding silly things like this in the first place). I can't imagine I'm the only person who has to deal with these problems on a daily basis. They waste so much time and leave me so flabbergasted as to how to address problems sometimes.
- paulirish 10y agoFirefox has done awesome work here, so I apologize for stepping in as a "competitor", but Chrome DevTools can do what you're asking for with the combingation JavaScript LiveEdit and Workspaces for persistence: https://www.youtube.com/watch?v=WQZio5DlSXM https://www.youtube.com/watch?v=WQZio5DlSXM https://developers.google.com/web/tools/chrome-devtools/debug/breakpoints/step-code?hl=en https://developers.google.com/web/tools/chrome-devtools/debu... https://developers.google.com/web/tools/setup/setup-workflow?hl=en https://developers.google.com/web/tools/setup/setup-workflow...
- nojvek 10y agoLive edit is great. It has its limits though. From a developer what I want is to mark some files / library for 'MRI execution'. When every line is hit in the file / function, it records the variable states, I can know what are the callers, callees, their states. I can go back in time, visualize call stacks as frame graph with the parameters invoked.
- deleted 10y ago[deleted]
- ars 10y ago> can do what you're asking for That's quite nice, but it's only part of what I was asking for - it doesn't let you rewind. You have to reload the page each time if your edit was wrong. It's not necessary to save state by each instruction, it's enough that it would be able to restart the current function. Ideally it could walk back up the stack and restart other functions, but even if it was limited to just the function with the breakpoint that would be huge.
- sillysaurus3 10y agoYou have to reload the page each time if your edit was wrong. You'd have to do that anyway. If code is wrong, it corrupts state. Unless you're saying you want it to keep track of diffs of the heap, which might be interesting. But how would it handle, say, a socketIO connection that a bad edit terminates? There'd be no way to rewind that. Maybe it doesn't matter for most work, since most work doesn't interact with persistent objects (sockets, file handles...)
- pbosko 10y agoThis reminded me of Timeless debugger that I heard of over here on HN (https://news.ycombinator.com/item?id=11385241 https://news.ycombinator.com/item?id=11385241): http://qira.me/ http://qira.me/ Having all the states and being able to see execution in the past blows my mind. Every debugger should support this.
- nachtigall 10y ago> I want to be able to modify/add code Yes, but I want to do that in my editor, not in the browser. > try it out, then rewind, and try something else. Then save my changes once they work perfectly. Certainly I do not want to copy'n'paste the code then back from browser to my editor. Let me all do this in my editor of choice. The browser is only where I execute stuff, a debugger belongs into the editor/ide. FWIW, I think it's planned by debugger.html project that the debugger can be used by different editors/IDEs. See the presentation at React Rally (relevant snippet is at https://www.youtube.com/watch?v=Fk--XUEorvc&feature=youtu.be&t=2h40m32s https://www.youtube.com/watch?v=Fk--XUEorvc&feature=youtu.be...) showing the integration into emacs or even using debugger.html as CLI tool.
- taeric 10y agoIsn't this basically asking for skewer mode? https://github.com/skeeto/skewer-mode https://github.com/skeeto/skewer-mode That is, you can already integrate quite well with some editors. I think IDEA has something similar, as well. Most of this is not in creating all new protocols and whatnot, but simply setting up reasonable defaults in tools you are already using.
- leurfete 10y agoThey are building what you're asking for I think. See this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1207696 https://bugzilla.mozilla.org/show_bug.cgi?id=1207696 The demo I saw of it -- I'm a former Mozilla employee -- was incredible. Indeed, you could step backward. It's RR for the web.