TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why Isn't Debugging Treated as a First-Class Activity?

244 pointsby dannasalmost 7 years ago

36 comments

pdpialmost 7 years ago
One practice I don&#x27;t think I&#x27;ve ever really seen properly discussed is exploratory debugging. Given a large codebase I&#x27;m not familiar with, I&#x27;ve found that this workflow is an incredibly fast way to get familiar with the overall flow and structure of the code:<p><pre><code> - run the thing - grab an output string of some sort (either output proper or logs or whatever else) - grep for it - set a breakpoint where the string is generated - run again </code></pre> From there, you can explore the stack, and you start to get your bearings. How is this particular thing generated? Find the place in the stack where it first shows up, set a break point, start over and debug from there. Repeat until you have a sufficiently solid grasp of the codebase that you can just navigate the source tree searching for where things are.
评论 #17507215 未加载
评论 #17507915 未加载
评论 #17508038 未加载
评论 #17508427 未加载
评论 #17507320 未加载
评论 #17510250 未加载
评论 #17507689 未加载
评论 #17509127 未加载
评论 #17506480 未加载
评论 #17511725 未加载
评论 #17517900 未加载
评论 #17511619 未加载
josephvalmost 7 years ago
The omission is interesting only in that it highlights that programming and debugging are one in the same.<p>Us old folks that have been programming for 20 years don&#x27;t even separate the two, there is no meaningful distinction. Programming is not a write-only operation (Perl excepted).<p>If it&#x27;s an existing project&#x2F;product, I get it running and find the entry point. If it&#x27;s new, I write and entry point and get it running. Then I change something, or write something, and debug it. Is it working as expected? Maybe the execution flow isn&#x27;t what I expected. Why do I always forget to initialize things right. Probably because every language thinks their version of native v. abstract references are fancier.<p>Blah, I need to get to work cod... debug.... what am I doing today? Ah yea, writing documentation. Fack
评论 #17507502 未加载
评论 #17506512 未加载
评论 #17507218 未加载
评论 #17507824 未加载
评论 #17507305 未加载
评论 #17506560 未加载
评论 #17506610 未加载
reikonomushaalmost 7 years ago
Debugging is an extraordinarily first-class, up-front, frequent activity in Common Lisp, as the facilities are built into the language itself. While Lisp gets a lot of flak for basically (up to a few daring power-user exceptions) requiring Emacs, SLIME&#x2F;SLY [1,2] are environments that will make you feel closer to your program than you get in other environments, including graphical IDEs.<p>Given that the normal way to develop a Lisp program is to do it incrementally, your program (or someone else’s!) <i>will</i> break, and it will break often, and you’ll get launched into an interactive debugger. But it’s friendly, not requiring a completely separate, foreign toolchain, and much of the functionality works regardless of which editors&#x2F;IDEs you’re using (though Emacs makes the experience much more ergonomic).<p>I think this is perhaps a bigger selling point of Common Lisp than all the great, oft-quoted things like metaprogramming.<p>[1] <a href="https:&#x2F;&#x2F;common-lisp.net&#x2F;project&#x2F;slime&#x2F;" rel="nofollow">https:&#x2F;&#x2F;common-lisp.net&#x2F;project&#x2F;slime&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;joaotavora&#x2F;sly" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;joaotavora&#x2F;sly</a>
评论 #17508128 未加载
评论 #17507663 未加载
评论 #17507918 未加载
flohofwoealmost 7 years ago
I&#x27;m using IDE debuggers as integral part of my normal programming workflow, not for actual &quot;debugging&quot;, but for stepping through new code to check if it &quot;feels right&quot;. I hardly find bugs that way (that usually happens when the code is out in the wild and several unexpected things happen at the same time), but I add a lot of little changes based on the step-debugging... rename a variable here, add a forgotten comment there, and also think about what to do next. I&#x27;m quite sure I spend more time in the debugger then writing code.<p>I wish edit-and-continue, rewinding time, etc... would be better supported across IDEs. Programming should be a &quot;conversation with the machine&quot;, and ultimately with other programmers. When I&#x27;m stepping through my own code, I try to assume the role of an &quot;outsider&quot; and judge my code from the &quot;outside&quot;.<p>The debugger is also the most important tool for me to understand code written by others.
评论 #17507308 未加载
评论 #17508620 未加载
评论 #17516857 未加载
greymanalmost 7 years ago
From the article: &gt; One thing developers spend a lot of time on is completely absent from both of these lists: debugging!<p>I notice that times changed a bit. This was true in software engineering like 10 years ago, but in recent years there is much more emphasis on good practices, constant refactoring, implementing lots of tests alongside the production code, etc. I debug maybe 1-2 hours per month, as a full-time programmer.
评论 #17505739 未加载
评论 #17505997 未加载
评论 #17506199 未加载
评论 #17509085 未加载
评论 #17506923 未加载
评论 #17506301 未加载
评论 #17510865 未加载
carusoonelineralmost 7 years ago
More broadly, reverse engineering a codebase is a critical software activity. If you can&#x27;t reverse engineer a codebase you can&#x27;t debug it or add to it. Working with an existing code base is pretty much a given, unless you&#x27;re developer #1 on a startup. Your success as a software developer hinges on how well you can work with an existing codebase.<p>One less celebrated but very valuable approach to grasp a codebase is the way you document what you&#x27;ve learnt. While you can learn about a codebase through exploratory debugging (mentioned by someone on a separate comment) you have to persist that knowledge on &quot;paper&quot; in some way. My favorite ways to do that:<p><pre><code> - class diagrams (for static stuff like data structures, class relationships, etc.) - sequence diagrams (for dynamic stuff like which functions call which and data passed between them) </code></pre> With good documentation for your own learning purposes, it&#x27;ll become easier to start working on a codebase and especially when you context switch, it&#x27;ll help you return to a codebase more easily.
评论 #17507978 未加载
dborehamalmost 7 years ago
Reading the comments here I get the impression folks are thinking about &quot;debugging MY code&quot;. In my experience when you are debugging you are almost always looking at an issue in someone else&#x27;s code.
acrobackalmost 7 years ago
I see a disturbing trend in industry especially in Bay area from my experience.<p>Young engineers are bad at debugging, bad means real bad but good at programming puzzles.<p>This points to the fact that people value puzzles over experience and in turn miss the big picture.<p>Sure you can code up a balanced RB tree in 5 mins, but what will you do when packets start showing up in bursts on your service? Can you find out that on a live system?<p>I despise this new Bro culture of mugging programming puzzles from leetcode and hackerank. Faltering at first real world challenge is not only disappointing, but an insult to craft of engineering.<p>&#x2F;Rant over
评论 #17508425 未加载
评论 #17515720 未加载
评论 #17508450 未加载
评论 #17509285 未加载
pjmlpalmost 7 years ago
I use debuggers in anger since Turbo Vision based IDE for Turbo Pascal 6.0 on MS-DOS.<p>If everything that one can do with a graphical debugger is single-step, step-into and continue, then they are using like 1% of its capabilities.<p>Taking advantage of a graphical debugger, specially when the environment supports code reload, is quite productive for interactive programming.
评论 #17506183 未加载
评论 #17515735 未加载
mjw1007almost 7 years ago
He writes « Perhaps people equate &quot;debugging&quot; with &quot;using an interactive debugger&quot; »<p>I think it&#x27;s useful to think of two independent &#x27;axes&#x27; of debugging:<p>- single-stepping vs reading traces<p>- using specialist debugging software vs modifying the code<p>Most of the time I much prefer reading traces, and IDEs often have decent primitives for setting sophisticated tracepoints, but the UI support for them is often very weak (while adding a breakpoint might be a single key press).<p>So I&#x27;ve often found myself using &#x27;printf&#x27;-style debugging because (until compile times get very long) it&#x27;s more ergonomic then using the debugger&#x27;s tracepoints.<p>I haven&#x27;t tried rr yet. Does anyone know how good it is at this? I&#x27;d like to be able to do things like define a keypress for a given tracepoint and toggle its output on and off while I&#x27;m scrolling through a trace.
评论 #17505987 未加载
评论 #17505770 未加载
stcredzeroalmost 7 years ago
There were Smalltalk server processes that would catch an exception, snapshot their memory image. A developer could then come along, and open a full interactive debugger on a live, running version of the system, which they could then modify then run as a quick dev test.
azhenleyalmost 7 years ago
The academic Software Engineering community certainly does put a lot of attention on debugging.<p>See my list of publications for a number of empirical studies on debugging and tools to support more efficient debugging: <a href="http:&#x2F;&#x2F;austinhenley.com&#x2F;publications.html" rel="nofollow">http:&#x2F;&#x2F;austinhenley.com&#x2F;publications.html</a>
spenrosealmost 7 years ago
I worked on petabyte-scale data at Mozilla. Here is a talk I gave on the history of debugging and the ways in which doing distributed large data analysis requires moving beyond printf() and STEP:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QHJBPzfrokU" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=QHJBPzfrokU</a>
henrik_walmost 7 years ago
I agree with the author that a debugger is a poor fit for many systems. However, debugging is essential, and I think debugging by checking logs works very well in many cases (provided that the logging is good). Some of the advantages (over debuggers):<p>- Anybody can look at the logs, not just developers.<p>- The logs show the sequence of events, not just a snapshot.<p>- Feasible to do in a live system.<p><a href="https:&#x2F;&#x2F;henrikwarne.com&#x2F;2014&#x2F;01&#x2F;01&#x2F;finding-bugs-debugger-versus-logging&#x2F;" rel="nofollow">https:&#x2F;&#x2F;henrikwarne.com&#x2F;2014&#x2F;01&#x2F;01&#x2F;finding-bugs-debugger-ver...</a>
评论 #17507000 未加载
dm03514almost 7 years ago
I feel like it has a lot to do with the ambiguity involved in debugging, and the fact that it is hard to teach.<p>I have found debugging to be fuzzy and largely based on experience, mental models, and internal (scientific method based?) approaches.<p>There seem to be a relatively few debugging methodologies or frameworks. (ie in performance&#x2F;systems realm there are USE, RED, ...?). I have only started to recently create a formal framework (a google doc I update after each incident) after 9 years of engineering experience! Not because I wasn&#x27;t interesting in debugging, but it literally took 9 years worth of debugging incidents for patterns to start to become apparent to me (i work devops&#x2F;system so when there is a general feeling of a problem I&#x27;m usually tasked with finding root causes).<p>On a side note: so far the framework has been successful within my org and I hope to formalize it enough to write about it in the near future :)
paulsutteralmost 7 years ago
&quot;90% of coding is debugging. The other 10% is writing bugs” - Bram Cohen
LargeWualmost 7 years ago
Somebody once posted in a Slack channel I was part of asking for things they should include in a course they were teaching for new programmers. My #1 recommendation was how to read a stack trace. The second was how to put a logging statement into your code to capture state.
busterarmalmost 7 years ago
Just get them working on some mess of a WordPress project and you&#x27;ll get them all reaching for xdebug right quick :D
lolcalmost 7 years ago
The result of debugging will be summed up in a commit or a ticket in Gitlab. Why should Gitlab care about the process?
评论 #17506540 未加载
评论 #17505764 未加载
评论 #17506198 未加载
erik_seabergalmost 7 years ago
I&#x27;m afraid of building a habit of making haphazard tweaks until it seems to DTRT in one case. I don&#x27;t like the idea of needing the machine to explain to me how my own code actually works. The feeling of complete understanding is an important motivator to me.
评论 #17505446 未加载
评论 #17505675 未加载
评论 #17505774 未加载
评论 #17507098 未加载
评论 #17506085 未加载
vfc1almost 7 years ago
I used to spend my days in the Java debugger, stepping through framework code to troubleshoot application-level errors, as the stacktrace we had obfuscated the error, or everything was simply broken.<p>Depending on the situation, I might spend most of my day debugging, as a way to better understand the program and as a code analysis tool.<p>This was especially useful if dealing with a code base that I was not familiar with, while in code that I wrote myself most of the time logging is sufficient.<p>I&#x27;m not sure why the author thinks that debugging is not a priority for tool makers, the debuggers that we currently have are awesome and have been so for years.
watwutalmost 7 years ago
Debugging is hidden here:<p>Bug handling is easy, fast, and friendly Information on “code flow” is clear and discoverable<p>I use interactive debugger inside IDE or inside profiling tools. Debugging is something I do alone, so it does not need special process support.
eftychisalmost 7 years ago
I think the approach we should take is to pour more effort into minimizing the risk of debugging being necessary. Good practices, better type checkers and logic models (e.g. there was an article posted in the front page here about using linear logic to push the boundaries of file systems). Debugging can be a time sink and can become a painful task for fast distributed systems.<p>We should learn and hone that skill of course, as it does not only offer a solution when lightning strikes, but a way for the developer to gain comprehension of the &quot;internals&quot;.
nhoe98thnuoealmost 7 years ago
In my opinion the reason that debugging isn&#x27;t treated as a first-class activity is that it isn&#x27;t taught at all in schools. Or at least it wasn&#x27;t when I was in school. We were given about 2 sentences that said, &quot;the debugger is at &#x2F;usr&#x2F;bin&#x2F;gdb. It can help you step through your code to find a bug.&quot; And then we were thrown to the wolves with what is arguably one of the worst debuggers in the world with no documentation and no help.
wilunalmost 7 years ago
While we probably will always have to debug, and if not the &quot;code&quot; it will be a specification formal enough so that it can be considered code anyway, there are different ways to approach its role within the lifecycle of software development: on the two extremes, one can &quot;quickly&quot; but somehow randomly throw lines without thinking much about it, then try the result and correct the few defects that their few tries reveal (and leave dozen to hundreds of other defects to be discovered at more inconvenient times); or one can think a lot about the problem, study a lot about the software where the change must be done, and carefully write some code that perfectly implement what is needed, with very few defects both on the what and on the how side. Note that the &quot;quick&quot; aspect of the first approach is a complete myth (if taken to the extreme, and except for trivially short runs or if the result does not matter that much), because a system can not be developed like that in the long term without collapsing on itself, so there will either be spectacular failures or unplanned dev slowdown, and if the slowdown route is taken, the result will be poorer as if a careful approach would have been taken in the first place, while the velocity might not even be higher.<p>Of course, all degrees exists between the two extremes, and when going too far on one side for a given application is going to cause more problems than it solves (e.g. missing time to market opportunities).<p>Anyway, some projects, maybe those related to computer infrastructure or actually any kind of infrastructure, are more naturally positioned on the careful track (and even then it depends on which aspect, for ex cyber security is still largely an afterthought in large parts of the industry), and the careful track only need debugging as a non-trivial activity when everything else has failed, so hopefully in very small quantities. But it is not that when it is really needed as a last resort, good tooling are not needed. It is just that it is confined to unreleased side projects &#x2F; tooling, or when it happens in prod it marks a so serious failure that compared to other projects, those hopefully do not happen that often. In those contexts, a project which need too much debugging can be at the risk of dying.<p>So the mean &quot;value&quot; of debugging might be somehow smaller than the mean &quot;value&quot; of designing and writing code and otherwise organizing things so that we do not have to debug (that often).
nicostouchalmost 7 years ago
I often wonder why it&#x27;s not treated as a first class citizen when teaching programming. I think there should be a full CS course dedicated to it.<p>I put together <a href="http:&#x2F;&#x2F;www.debug.coach&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.debug.coach&#x2F;</a> because a guy I used to work with had better debugging skills than anybody and I noticed it was because he always knew the right questions to ask.
codedokodealmost 7 years ago
I think that is because there are no good free open source debuggers? In Visual Studio you just set a breakpoint and examine the variables; it works great. On Linux you are left alone against a command-line monster with outdated weird command syntax.<p>gdb has an awful interface; it requires you to read a long manual and learn outdated command syntax before even using it; it is often faster to add logging and rerun the program. It is not a debugger for humans.<p>For comparison, JS debugger in Chrome devtools works pretty good and is easy to use. It is really helpful and allows you to identify a problem very quickly (faster than reading an introduction page for gdb). But it has problems sometimes, when you try to set a breakpoint and it is set in another place or is not set at all without any error messages.<p>I saw some comments here against visual debugging; maybe their authors had experience with some buggy or poorly written debugger?<p>I also tried to use Firefox developer tools in several versions up to FF45 and almost every time something didn&#x27;t work. And when they work, they choke on scrolling large minified files or heavy sites with lots of ads.
评论 #17512469 未加载
deepaksurtialmost 7 years ago
Because most languages treat edit, compile, test, debug phases. No organic evolution of your idea to code to running app all the while tweaking it without restarts, which are pit stops that completely break your momentum.<p>That needs languages designed upfront with debugging etc as a first class live feature.
cuddlybaconalmost 7 years ago
One thing that may be relevant is that I was never introduced to debugging in university at all. You were expected to just invent useful techniques on your own. Without any exposure, it is hard to justify learning that over any other topic you feel like you aught to be learning.
enriqutoalmost 7 years ago
Because debugging is not a first-class activity.<p>If you are careful when you program (assertions, tests, logging) you rarely need to use a debugger. Time spend on a debugger is invisible and lost. It is much better to spend time adding assertions, levels of logging, and writing tests.
评论 #17506016 未加载
评论 #17507066 未加载
评论 #17507515 未加载
评论 #17506053 未加载
yitchellealmost 7 years ago
If you needed to debug, it is a sign that you have made a mistake. Who wants to admit to making the mistake? :-)<p>Seriously though, I imagine that the junior devs would have such a view of debugging. But the matured devs would plan for it as they know their limitations.
logfromblammoalmost 7 years ago
For the same reason that the water treatment plant gets more respect than the sewage treatment plant.<p>Everyone would prefer to provide something fresh and clean than to wade through other people&#x27;s poop.
bionsystemalmost 7 years ago
Ask Bryan Cantrill. He is a first grade debugger.
fierroalmost 7 years ago
has anyone written intelliJ plugins that deal with the debugger? I have an interesting idea wrt to this, but writing an IntelliJ plugin has so far been extremely painful. If anyone out there is interested send me a message and let&#x27;s chat
hannofcartalmost 7 years ago
I would go so far as to suggest that if you need a debugger, you&#x27;re probably doing it wrong.<p>I have found that code that needs a debugger is code that is written in an extremely stateful fashion.<p>The very reason why debuggers exist is to deal with code that has a dozen variables book-keeping complex state that you need to track closely to figure out how something works (or why something doesn&#x27;t). Debuggers even have &quot;watches&quot; to track something closely so that it doesn&#x27;t change underneath you, when you aren&#x27;t looking.<p>To me this is a code smell. I would suggest that instead of using a debugger, we ought to be composing small functions together.<p>Small and pure functions only need an REPL to test.<p>Once you make sure the function is behaving right, you can almost just copy paste over the test cases you ran in your REPL into unit tests.<p>The simplest way to enforce this discipline is to do away with assignments, and instead constrain oneself to using expressions. This forces one to break code into smaller functions. Code written this way turns out to be much more readable, as well as reusable.<p>I suggest that we eschew the debugger in favour of the REPL.
评论 #17509208 未加载
评论 #17509067 未加载
评论 #17509110 未加载
评论 #17509172 未加载
thecodeboyalmost 7 years ago
Prejudice. The same reason NASA janitors aren&#x27;t glorified as the astronauts are.
评论 #17506377 未加载