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.

TLDR explains what a piece of code does

226 pointsby aaws11over 2 years ago

35 comments

hn_throwaway_99over 2 years ago
FWIW, when I&#x27;m doing a code review, these are the <i>exact</i> kind of comments that I would tell a committer to remove.<p>That is, it&#x27;s like it generates these kinds of comments:<p><pre><code> &#x2F;&#x2F; initializes the variable x and sets it to 5 let x = 5; &#x2F;&#x2F; adds 2 to the variable x and sets that to a new variable y let y = x + 2; </code></pre> That is, IMO the whole purpose of comments should be to tell you things that <i>aren&#x27;t</i> readily apparent just by looking at the code, e.g. &quot;this looks wonky but we had to do it specifically to work around a bug in library X&quot;.<p>Perhaps could be useful for people learning to program, but otherwise people should learn how to read code as code, not &quot;translate&quot; it to a verbose English sentence in their head.
评论 #32945937 未加载
评论 #32948541 未加载
评论 #32946238 未加载
评论 #32949128 未加载
评论 #32946134 未加载
评论 #32945944 未加载
评论 #32949559 未加载
评论 #32948491 未加载
评论 #32962136 未加载
评论 #32945920 未加载
评论 #32949924 未加载
评论 #32945941 未加载
worbleover 2 years ago
I just don&#x27;t trust it, I&#x27;ve worked with GPT-3 before and it sure does a real good job of <i>sounding</i> convincing, but if you don&#x27;t understand the code there&#x27;s no way to know if what it&#x27;s saying is accurate, or whether it&#x27;s just regurgitating random nonsense that sounds plausible.<p>It knows how to create sentences that sound like something a human would write, and it&#x27;s even good at understanding context. But that&#x27;s it, it has no actual intelligence, it doesn&#x27;t actually understand the code, and most importantly, it&#x27;s not able to say &quot;Sorry chief, I don&#x27;t actually know what this doing, look it up yourself.&quot;
评论 #32945717 未加载
评论 #32951518 未加载
评论 #32948336 未加载
评论 #32945600 未加载
curl-upover 2 years ago
How come general developer audiences aren&#x27;t more acquainted with GPT-3 (and Codex in particular) capabilities? People in the twitter thread all seem completely mind blown over an app that basically just passes your code to an existing API and prints the result.<p>I don&#x27;t want to sound negative of course, and I expect many of these apps coming up, until Codex stops being free (if they put it on the same pricing as text DaVinci model, which Codex is a fine-tuned version of, it will cost a ~cent per query). I&#x27;m just wondering how come the information about this type of app reaches most people way before the information about &quot;the existence of Codex&quot; reaches them.<p>For all the publicity around Codex recently (and especially on HN), it still seems like the general IT audience is completely unaware of the (IMHO) most important thing going on in the field.<p>And to anyone saying &quot;all these examples are cherrypicked, Codex is stupid&quot;, I urge you to try Copilot and try to look at its output with the ~2019 perspective. I find it hard to beileve that anything but amazement is a proper reaction. And still, more people are aware of the recent BTC price, than this.<p>Source: have been playing with Codex API for better part of every day for the last few weeks. Built an app that generates SQL for a custom schema, and have been using it in my daily work to boost ma productivity as a data scientis&#x2F;engineer&#x2F;analyst <i>a lot</i>.
评论 #32945233 未加载
评论 #32946040 未加载
评论 #32945220 未加载
评论 #32948693 未加载
评论 #32946819 未加载
hoobyover 2 years ago
The question is - can this actually explain the code which really needs explanation - or can it only explain code that should be easy and straight forward to read anyway?<p>And does having this reduce the amount of discomfort badly readable code creates, and thus make you less inclined to take care the code is and stays easily readable?
bloppeover 2 years ago
Why not just type the code into DALL-E 2 and have it paint a picture of what the code does?
评论 #32947801 未加载
billsmithaustinover 2 years ago
So it translates the code into COBOL. That&#x27;s awesome.
PennRoboticsover 2 years ago
... until it gets to<p><pre><code> i = 0x5f3759df - ( i &gt;&gt; 1 );</code></pre>
评论 #32945347 未加载
评论 #32945235 未加载
评论 #32947012 未加载
angst_riddenover 2 years ago
The kinds of comments that are <i>useful</i> are less about what the code already tells you is happening, and more things like:<p>&#x2F;* we don&#x27;t use the actual price but the discounted price, as per email from Manager Bob on 2022-09-16 *&#x2F;<p>subtotal += price * customer_discount_factor;<p>or<p>&#x2F;* note there&#x27;s a 2ms delay while relays settle; this is subtracted from sample time, so timeout is not what you might expect *&#x2F;<p>select(0,&amp;readfd,NULL,NULL,&amp;timeout);
galangalalgolover 2 years ago
Can we get this for legal documents? Maybe with the ability to spot things that might be loopholes?
评论 #32944824 未加载
f1shyover 2 years ago
No only I find the tool not useful, as it just state the obvious. My personal opinion is the code should be already very near what the tool gives. The code should be clear enough for not needed such tool. If you need it, you have a very different problem, my friend.
评论 #32949418 未加载
naruhodoover 2 years ago
Garbage. It generates a line-by-line translation of code into English, rather than a concise summary, so we end up needing a TLDRTLDR.<p>Actual human documentation would read something like:<p><pre><code> &gt; Return true if the X-HELPSCOUT-SIGNATURE request header matches the &gt; base-64 encoded SHA1 hash of the raw request data.</code></pre>
评论 #32947327 未加载
wudangmonkover 2 years ago
TLDR but you actually end up reading even more than the original. I could be wrong and this might actually work and condense a big function but if that is true, why showcase such an example.
评论 #32945250 未加载
Waterluvianover 2 years ago
This looks like it has potential value for beginners who are looking to learn what code syntactically means.
dalmo3over 2 years ago
I know there&#x27;s such thing as idiomatic code, but I can&#x27;t help but think the code in the tweet would be much more readable - and no ai needed - if the variables&#x2F;methods&#x2F;args were better named.
metalrainover 2 years ago
I think tool like this can make sense if you cannot read the code.<p>Probably this still gets confused like humans do when variables and functions are named less clearly or even plainly wrong.<p>I wonder if reading explanation like this makes you more likely to believe code is correct, even if some details are wrong.<p>In this signature example, you can read the wrong header, calculate hash the wrong way, compare hashes wrong way, etc. there are some many tiny mistakes.
iLoveOncallover 2 years ago
Reading the code explains what a piece of code does.
xwowsersxover 2 years ago
I don&#x27;t know that I have much of a need for this and, although I&#x27;m hesitant to provide crutches to people especially when they&#x27;re in the early stages of their learning, this might be helpful for more junior people who are ramping up, especially in a large project. Is there a way to use this or something similar today in PyCharm, etc?
ianbutlerover 2 years ago
I wrote something similar before, my friend had a nice technique to do code analysis and remove everything but the critical path to the point in code you had your cursor over. Then I fed that code path into gpt3 to generate an explanation of that critical path.<p>Wound up being useful for explanations of long code paths across file boundaries in large code bases.
reidjsover 2 years ago
That’s cool but I don’t think it’s very useful once you’re familiar with the codebase. It’s quicker to scan the code at that point.<p>If it could give you some context about the implications I could see it being handy for static analysis one day.
fortyover 2 years ago
I know it&#x27;s completely missing the point here but: it&#x27;s a good habit to verify signature using constant time comparison rather than == to avoid timing side channel attack :)
CrendKingover 2 years ago
Imagine this tool could reverse engineer minified Javascript code. Depending on the result, it has potential to defeat minification as whole.
hot_grilover 2 years ago
Seems more useful for finding bugs in code than for explaining properly working code. &quot;Returns false if the signature matches.&quot;
stokesrover 2 years ago
Compsci first years are definitely going to use this to complete &quot;Recreate this algorithm in pseudocode&quot; assignments
codeenlightenerover 2 years ago
looks great, reminds me of our product, <a href="https:&#x2F;&#x2F;denigma.app" rel="nofollow">https:&#x2F;&#x2F;denigma.app</a> that explains the business logic of code and technical concepts, which recently launched an extension for all Intelli-J based IDEs (except Android Studio- there&#x27;s a compatibility issue with it)
评论 #32950048 未加载
einpoklumover 2 years ago
I&#x27;m sure there are enough valid uses of GPT-3 without undertaking this gratuitous and useless endeavor.
gardenhedgeover 2 years ago
I could see it being useful for regex
评论 #32946464 未加载
评论 #32949242 未加载
heratyianover 2 years ago
This could be helpful for debugging&#x2F;refactoring legacy spaghetti code.
tayloramurphyover 2 years ago
Before clicking through I thought this was for this great command line tool [0]. I&#x27;m skeptical about GPT-3 generated comments, but I can recommend the other TLDR whole heartedly!<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;tldr-pages&#x2F;tldr" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tldr-pages&#x2F;tldr</a>
howmayiannoyyouover 2 years ago
This would be invaluable for communicating with my teenagers.
imperio59over 2 years ago
This could maybe be nice for accessibility?
waynesonfireover 2 years ago
like the auto summarize feature from MS Word that helped me do my homework back in high school
bbno4over 2 years ago
this is ok, github copilot has had this for a while now so it&#x27;s nothing new :)
jerezzprimeover 2 years ago
Can it write tests for me?
cptnapalmover 2 years ago
At first, I thought tldr, the *nix lister for popular CLI options,had engaged in some serious feature creep.
jopnvover 2 years ago
Very fancy but, in my opinion, completely useless as a development tool. I can’t see how reading natural language is better than reading code.
评论 #32945413 未加载
评论 #32945284 未加载
评论 #32945308 未加载