Live data from Hacker News

OpenAI is good at unminifying code

glama.ai

161–170 of 321 posts

Re: OpenAI is good at unminifying code

#161
post #93
post #87

Earlier quoted context omitted.

This is something I always disagreed with. In my experience, I rather read a short comment explaining what is the purpose of a block of code, than trying to decipher it. Yes, code "should speak for itself", but reading a comment is almost always faster than reading blocks of code. And then there is also documentation (if you include it in what you define as comment). I much rather go through a website, with a search…

But the purpose is the Why; forced comments tend to tell you What the code does, which is better explained by the code itself. A comment that is incorrect can do a lot of damage, and they tend to get confused about implementation details over time.

For forced comment I fully agree, especially for function or class when the name already says whats on the tin.

Re: OpenAI is good at unminifying code

#163
post #68

Earlier quoted context omitted.

Better Hoover it up!

All jokes aside, I've never heard anyone call vacuuming hoover. I wonder if that was a older statement?

Everyone I know from the UK says "hoovering" 100% of the time instead of vacuuming.

Re: OpenAI is good at unminifying code

#164
post #121

It is good at unminifying and "minifying" as well. I have been doing the Leetcode thing recently, and even became a subscriber to Leetcode. What I have been doing is I go through the Grind 75 list (Blind 75 successor list), look for the best big O time and space editorial answer, which often has a Java example, and then go to ChatGPT (I subscribe) or Perplexity (don't subscribe to Pro - yet) and say "convert this to…

This does seem to be a smart use of the tools available to skip the grind and get to the point of the leetcode questions.

However, I wonder about this: What will you do in a live interview situation? Will you pull up ChatGPT?

Re: OpenAI is good at unminifying code

#165
post #146
post #87

Earlier quoted context omitted.

This is something I always disagreed with. In my experience, I rather read a short comment explaining what is the purpose of a block of code, than trying to decipher it. Yes, code "should speak for itself", but reading a comment is almost always faster than reading blocks of code. And then there is also documentation (if you include it in what you define as comment). I much rather go through a website, with a search…

It's just a rule of thumb, like anything else. In most code, "why" is the hard part; I see that you are incrementing that account by a penny from out of the blue, but why? When you are in code where "what" is the hard part, like an implementation of a book algorithm or some tricky performance optimization, then by all means comment that. Really all this rule amounts to is // Increment by a penny accountValue += 1 is…

I do agree that documenting the why is way more important than the how/what. But having a short comment to summarize a block of code like:

    // Parse the filename and remove the extension
    let fext_re = Regex::new(r"(.\*)\.(.+)$").unwrap();
    let page_cap = fext_re.captures(fname).unwrap();
    let page_base_filename = page_cap.get(1).unwrap().as_str();

Is still useful. Instead of having to read the next few line of code, I already know what they are suppose to do and expect. It makes discovery, later down the line, easier.

Re: OpenAI is good at unminifying code

#166
post #150

Earlier quoted context omitted.

Of course, it is not generalizable! In my experience though, most minifiers do only the following: - Whitespace removal, which is trivially invertible. - Comment removal, which we never expect to recover via unminification. - Renaming to shorter names, which is tedious to track but still mechanical. And most minifiers have little understanding of underlying types anyway, so they are usually very conservative and rare…

I feel you’re downplaying the obfuscatory power of name-mangling. Reversing that (giving everything meaningful names) is surely a difficult problem?

I would say the actual difficulty greatly varies. It is generally easy if you have a good guess about what the code would actually do. It would be much harder if you have nothing to guess, but usually you should have something to start with. Much like debugging, you need a detective mindset to be good at reverse engineering, and name mangling is a relatively easy obstacle to handle in this scale.

Let me give some concrete example from my old comment [1]. The full code in question was as follows, with only whitespaces added:

    function smb(){
      var a,b,c,d,e,h,l;
      return t(function(m){
        a=new aj;
        b=document.createElement("ytd-player");
        try{
          document.body.prepend(b)
        }catch(p){
          return m.return(4)
        }
        c=function(){
          b.parentElement&&b.parentElement.removeChild(b)
        };
        0
Many local variables should be easy to reconstruct: b -> player, c -> removePlayer, d -> playerDiv1, e -> playerDiv2, h -> playerVideo, l -> blob (we don't know which blob it is yet though). We still don't know about non-local names including t, aj, lc, Mia and m, but we are reasonably sure that it builds some DOM tree that looks like ``. We can also infer that `removePlayer` would be some sort of a cleanup function, as it gets eventually called in any possible control flow visible here.

Given that `a.resolve` is the final function to be executed, even later than `removePlayer`, it will be some sort of "returning" function. You will need some information about how async functions are desugared to fully understand that (and also `m.return`), but such information is not strictly necessary here. In fact, you can safely ignore `lc` and `Mia` because it eventually sets `playerVideo.src` and we are not that interested in the exact contents here. (Actually, you will fall into a rabbit hole if you are going to dissect `Mia`. Better to assume first and verify later.)

And from there you can conclude that this function constructs a certain DOM tree, sets some class after 200 ms, and then "returns" 0 if the video "ticks" or 1 on timeout, giving my initial hypothesis. I then hardened my hypothesis by looking at the blob itself, which turned out to be a 3-second-long placeholder video and fits with the supposed timeout of 5 seconds. If it were something else, then I would look further to see what I might have missed.

[1] https://news.ycombinator.com/item?id=38346602

Re: OpenAI is good at unminifying code

#167
post #91

>I apologize, GPT-4, for mistakenly accusing you of making mistakes. I am testing large language models against a ground truth data set we created internally. Quite often when there is a mismatch, I realize the ground truth dataset is wrong, and I feel exactly like the author did.

Apologizing to a program seems rather silly though. Do you apologize to your compiler when you have a typo in your code, and have to make it do all that work again?

Re: OpenAI is good at unminifying code

#168
post #135

Earlier quoted context omitted.

ChatGPT is trained well enough on all things AWS that it can do a decent job translating Python based SDK code to Node and other languages, translate between CloudFormation/Terraform/CDK (in various languages). It does a well at writing simple to medium complexity automation scripts around AWS. If it gets something wrong, I tell it to “verify your answer using the documentation available on the web”

>>ChatGPT is trained well enough on all things AWS It was scary to me how to chatting with GPT or Claude would give me information which was a lot more clear than what I could deduce after hours of reading AWS documentation. Perhaps, the true successor to Google search has arrived. One big drawback of Google was asking questions that can't be converted to a full long conversation. To that end. LLM chat is the ultimat…

ChatGPT is phenomenal for trying new techniques/libraries/etc. It's very good at many things. In the past few weeks I've used it to build me a complex 3D model with lighting/etc with Three.JS, rewrote the whole thing into React Three Fiber (also with ChatGPT), for a side project. I've never used Three.JS before and my only knowledge of computer graphics is from a class I took 20 years ago. For work I've used it to write me a CFN template from scratch and help me edit it. I've also used it to try a technique with AST - I've never used ASTs before and the first thing ChatGPT generated was flawless. Actually, most of the stuff I have it generate is flawless or nearly flawless.

It's nothing short of incredible. Each of those tasks would normally have taken me hours and I have working code in actual seconds.

Re: OpenAI is good at unminifying code

#169
post #49

Earlier quoted context omitted.

I see your point, but I think there's more to it. It's kind of like saying "all humans can do is perceive and produce sound, any other ability is just a side-effect". We might be focusing too much on their mechanism for "perception" and overlooking other capabilities they've developed.

Sure, but that claim wouldn't be true for humans, right? So it's a nonsequiteur. The relevant claim would be: all humans can do is move around in their environments, adapt the world around them through action, observe using adaptive sensory motor systems, grow and adapt their brains and bodies in response to novel and changing environments, abstract sensory motor techniques into symbolic concepts, vocalize this using…

> all they can do is, in fact, sample from a compression of historical texts

To me, results like the Othello paper make any sort of "stochastic parrot" thinking completely untenable.

https://thegradient.pub/othello/

Re: OpenAI is good at unminifying code

#170
post #68

Earlier quoted context omitted.

Better Hoover it up!

All jokes aside, I've never heard anyone call vacuuming hoover. I wonder if that was a older statement?

It might just be a regionalism, it's not uncommon that such genericization only applies to specific dialects (Like calling all sodas coke)
Post reply on HN