Live data from Hacker News

OpenAI is good at unminifying code

glama.ai

151–160 of 321 posts

Re: OpenAI is good at unminifying code

#151
post #139
post #97

Author of HumanifyJS here! I've created specifically a LLM based tool for this, which uses LLMs on AST level to guarantee that the code keeps working after the unminification step: https://github.com/jehna/humanify

Is it possible to add a mode that doesn't depend on API access (e.g. copy and paste this prompt to get your answer)? Or do you make roundtrips?

There is a fully local mode that does not use ChatGPT at all – everything happens on your local machine.

API access of ChatGPT mode is needed as there are many round trips and it uses advanced API-only tricks to force the LLM output.

Re: OpenAI is good at unminifying code

#152
post #12

LLMs are excellent at text transformation. It's their core strength and I don't see it being used enough.

The problem is the use case is where you don't care about the risk of hallucinations or you can validate the output without already having the data in a useful format. Plus you need to lack the knowledge/skill to do it more quickly using awk/python/perl/whatever.

I think text transformation is a sufficiently predictable task that one could make a transformer that completely avoids hallucinations. Most LLMs have high temperatures which introduces randomness and therefore hallucinations into the result.

Re: OpenAI is good at unminifying code

#153
post #147
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…

> reading a comment is almost always faster than reading blocks of code Not to a competent programmer when reading well-written code. This also means that you read what the code does, rather than what a comment says the code does. Otherwise you will be blind to bugs. Any experienced developer will tell you that code very often doesn't do what the original programmer thought it did.

> Not to a competent programmer when reading well-written code.

No, literally reading a one line about what the next 4 lines do is mechanically faster. It does not matter that you are good or bad, it is about simple reading speed.

> This also means that you read what the code does, rather than what a comment says the code does. Otherwise you will be blind to bugs. Any experienced developer will tell you that code very often doesn't do what the original programmer thought it did.

I am an experience developer. I have worked on several "legacy" projects, and started many from 0.

1. It does not make you blind to anything, it is just a way to learn/direct yourself in the code base faster.

2. Knowing what the original developer wanted is often as useful as knowing what the code actually does. More info is better than no info.

Even outdated comment can be useful.

For me, this type of thinking that comment are unnecessary, that competent ppl can just read the code, etc. is actually a sign of younger dev who never had to work on a long-lived codebase.

Re: OpenAI is good at unminifying code

#155

Earlier quoted context omitted.

Possible that this is the mistake. However, I don't think I miscopied the original code. https://reactive.network/assets/index-8b4ef4ac.js If you look for `oahkbdpqwmZO0QLCJUYXzcvunxrjft` in the output, you should see that those characters appear exactly like that. Maybe an issue with encoding of the script file?

Most definitely; if I use "View >> Repair Text Encoding" in Firefox, it shows the block characters. But I have to admit, it's strange that Firefox does not choose UTF-8 by default in this case.

If no character set is specified, plain text content is assumed to be 1252. This probably extends to application/javascript as well but I'd have to check to be sure.

The web pre-dates utf-8, although not by much. Ken Thompson introduced utf-8 at winter Usenix in 1993 and CERN released the web in April, but it would be several more years before utf-8 became common. The early web was ISO 8859-1 by default. But people were pretty lazy about specifying character sets back then (still are actually) and Microsoft started sending or assuming their 1252 character set where 8859-1 was required by the spec. Eventually the spec was changed to match de facto behavior. I guess the assumption was that if you're too stupid or lazy to say what character set you're using, then it's probably 1252. (Today the assumption would be that it's probably utf-8). I'm not sure what the specs say today, but I think html is assumed to be in utf-8, and everything else is assumed to be 1252 (if the character set is not explicitly declared).

Re: OpenAI is good at unminifying code

#156

Should the title say ChatGPT or gpt-4 (the model) instead of OpenAI (the company)?

There is a certain justice in the use of OpenAI as a name for their product, given that OpenAI has turned the generic technical GPT name into a brand.

GPT is not a brand. A court ruling turned down that notion. It's a technology.

Re: OpenAI is good at unminifying code

#157

JS minification is fairly mechanical and comparably simple, so the inversion should be relatively easy. It would be of course tedious enough to be manually done in general, but transformations themselves are fairly limited so it is possible to read them only with some notes to track mangled identifiers. A more general unminification or unobfuscation still seems to be an open problem. I wrote handful of programs that…

> JS minification is fairly mechanical and comparably simple, so the inversion should be relatively easy. Just because a task is simple doesn't mean its inverse need be. Examples: - multiplication / prime factorization - deriving / integrating - remembering the past / predicting the future Code unobfuscation is clearly one of those difficult inverse problems, as it can be easily exacerbated by any of the following pr…

As a point of order Code Minification != Code Obfuscation.

Minification does tend to obfuscate as as side effect, but it is not the goal, so reversing minification becomes much easier. Obfuscation on the other hand can minify code, but crucially that isn't the place it starts from. As the goal is different between minificaiton and obfuscation reversing them takes different efforts and I'd much rather attempt to reverse minification than I would obfuscation.

I'd also readily believe there are hundreds/thousands of examples online of reverse code minification (or here is code X, here is code X _after_ minifcation) that LLMs have ingested in their training data.

Re: OpenAI is good at unminifying code

#159
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?

I've also never heard anyone call photocopying "xeroxing". I'm guessing maybe it's an age thing.

Re: OpenAI is good at unminifying code

#160
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 was the fashion at the time, even if the hoover did keep bumping the onion.

(This is actually really interesting, I had no idea that 'hoover' was specifically a U.K. thing that didn't make it to the U.S.)

Post reply on HN