7 ms·
Very naive question as someone who last wrote production JavaScript in 2008: so basically web developers are reinventing debug symbols?
by GuiA 9y ago
Very naive question as someone who last wrote production JavaScript in 2008: so basically web developers are reinventing debug symbols?
- ateesdalejr 9y agoNow that you put it that way it sounds funny now.
- acemarke 9y agoPretty much, yeah. Today's web applications go through multiple forms of compilation and transformation. Conversion from ES6 modules to CommonJS, compilation of newer JS syntax into equivalent older syntax supported by more browsers, minification that renames symbols to cut down on the total byte size delivered, and bundling of hundreds of individual modules into a single output JS bundle (or possibly several code-split bundles). Because of that, debugging the delivered source as-is isn't feasible. Sourcemaps allow the browser's devtools to display the original source, and a developer can debug the code as it was before any compilation steps were applied. I saw a post a couple years back that suggested that DWARF debugging symbols could be used as an inspiration for improving sourcemaps: http://fitzgeraldnick.com/2015/06/19/source-maps-are-insufficient.html http://fitzgeraldnick.com/2015/06/19/source-maps-are-insuffi... .
- emh68 9y agoNow I’m wondering when the term “debug symbols” came along and if there was something they called it before that. Google shows no results for “debug symbols” from before 1990, but I have definitely heard of fortran-to-lisp tools and whatnot that are definitely comparable from the 70s.
- gumby 9y agoI first encountered debugging symbols in 1977, so it's an old idea (and I designed objdump, bfd etc to dredge through them).
- abiox 9y agosort of, but not exactly. debuggers in the browser work fine with plain javascript and have the source directly available. js source maps remind me more of stuff like linespecs that you can give to gdb/lldb for mapping.
- the_mitsuhiko 9y agoAnd badly. I rrally wish JavaScript would just use DWARF. Sourcemaps are quite broken, do not contain scope infos and cannot be used to map function names wirhout doing stupid things.
- khuey 9y agoDWARF is kind of a shitshow and it's not really suited for doing this sort of source to source transformation anyways.
- the_mitsuhiko 9y agoI do not see why not. You can compile javascript into a single line and then use the column index as memory address and dwarf should work almost unchanged. Also not sure why DWARF is a shitshow.
- Peaker 9y agoDWARF is terribly designed. It is far more complicated than it needs to be. For example, to map binary locations to line numbers -- it uses its own opcodes and registers in a custom VIRTUAL MACHINE(!!) When it could have had a simple table like: Line Offset 1 0xa 2 0x14 4 0x2a ... Then just compress that with an ordinary compression algorithm rather than inventing silly virtual machines. The debug info itself is encoded in a very cumbersome encoding of debug-information-entries that point to one another. A much simpler method would have been RLP, for example.
- the_mitsuhiko 9y agoThe line number programs of DWARF are pretty well working for the problems they should solve. Out of all things in DWARF that are weird, these are not the issue. We use DWARF at Sentry just fine and I am quite a big of a supporter of the format as ypu can guess. In particular it was designed and specified unlike sourcemaps which are a random google docs page and don’t even solve basic problems such as finding out which function a token belongs to.
- arkh 9y agoThat's kinda sorta the web dev world: reinvent all the wheels! Once they're done a new generation will feel it is too complicated and go back to basics with a new language. And reinvent all those wheels again. This is the magic of software: every decade you can pick low hanging fruits again to improve your resume.