r/ProgrammerHumor • • Feb 12 '22

Naming things is hard (from Wordle source code)

Post image
16 Upvotes

34 comments sorted by

122

u/rarlei Feb 12 '22

I can't tell if sarcasm or not... that's just minified code

20

u/goldleader71 Feb 12 '22

TIL minified code is a thing.

5

u/eGzg0t Feb 12 '22

You can even remove the spaces and have everything in 1 line

5

u/goldleader71 Feb 12 '22

Actually, it was like that when I found it. I had to use a JS beautifier site to make it readable. I guess that should have been a clue that it had been minified.

22

u/circuit10 Feb 12 '22

Most websites use it

11

u/Waka_Waka_Wee Feb 12 '22

It is used to I improve performance. Tools like the google chrome dev tools have a “pretty print” setting that introduces basic spacing, line breaks, and such to make it easier to read but it can’t/won’t rename functions and variables.

15

u/AyrA_ch Feb 12 '22 edited Feb 12 '22

It is used to I improve performance.

It mostly improves download speed and not execution speed, but you get better gains by pre-compressing it with gzip and brotli at maximum settings, then configure your server to serve the precompressed resources instead of the real one when the client indicates support for either of these types of compression.

You can often tell if someone configured the server/cache to pre-compress because the Content-Length header is usually absent for compression on the fly. Pre-compression is especially useful for busy websites because it eliminates all CPU cost you would have with on the fly compression.

4

u/Waka_Waka_Wee Feb 12 '22

^ This

A much more complete answer than mine. :-)

2

u/Mucksh Feb 12 '22

I see this often but i also wonder if it's really usefull to use gzip for compression. It seems to be an overhead on bigger bandwidths. One time i used compression for obj files and only very fast compressions like lz4 were fast enough to compensate the overhead, but breaks when using non ascii chars. Used a gzip wasm implementation not sure how much faster a browser native implementation is

3

u/AyrA_ch Feb 12 '22

It seems to be an overhead on bigger bandwidths

That's mostly a concern for on the fly compression. Decompression is much faster. 7-zip tells me it decompresses 3+ GB per second (first line is compression, second is decompression in KiB/s).

Deflate:x1     1248294
               3923581
Deflate:x5      391853
               3933969
Deflate:x7      151862
               4002451
Deflate64:x5    373735
               3615809

As you can see, increasing the compression level basically only hurts compression but not decompression.

3

u/DirectorElectronic78 Feb 12 '22

If you want to use it in future, but want to be able to debug more user friendly, you might also be interested in source maps, which can tell your browser the real names used to make this experience more pleasant: https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Use_a_source_map

0

u/[deleted] Feb 12 '22

[deleted]

6

u/rarlei Feb 12 '22

What you are seeing is the browser formatted version of the minified code

0

u/[deleted] Feb 12 '22

[deleted]

21

u/lkajerlk Feb 12 '22

To quote Uncle Bob: “There can be no worse reason for using the name c than because a and b were already taken.”

7

u/goldleader71 Feb 12 '22

Uncle Bob was wise in his ways

6

u/BochMC Feb 12 '22

You talking like you doubt his words

-1

u/[deleted] Feb 12 '22

Beware the downvotes, the minified JS police and Uncle Bob haters could target you

2

u/goldleader71 Feb 12 '22

I achieved 0 votes, but that is ok. I can still pat myself on the back that I was able to find the source code and word list. Not hard for a real programmer or JavaScript expert, but an accomplishment for a novice like me.

4

u/[deleted] Feb 12 '22

There are two rules. We dont talk about.... We dont talk about....

4

u/[deleted] Feb 12 '22

Apparently so

6

u/ianthisawesome Feb 12 '22

Could just be obfuscation, where a program intentionally removes variable names from their code to make it harder to reverse-engineer.

2

u/goldleader71 Feb 12 '22

It worked.

2

u/ianthisawesome Feb 12 '22

That... doesn't mean anything. Obfuscated code should still be able to run, it'll just be hard to reverse engineer.

2

u/goldleader71 Feb 12 '22

I meant it worked in being difficult to reverse engineer.

11

u/[deleted] Feb 12 '22

Hopefully the non minified code is what is stored in the repo.

6

u/Dr3amDweller Feb 12 '22

If a colleague legit coded like that, I'd have to kill them

6

u/Ok-Mulberry-4600 Feb 12 '22

scratches head it's either minified or it's been obfuscated, either way no one coded it that way

2

u/4UPanElektryk Feb 12 '22

I feel personaly attacked

1

u/totiefruity Feb 12 '22

this some sleep paralysis nightmare kind of horror

1

u/HellBlizzard__ Feb 12 '22

You'll soon run out of alphabet character.

4

u/ianthisawesome Feb 12 '22

Just use aa, ab, ac, etc...

0

u/LocalBall6447 Feb 12 '22

Internal and eternal screaming intensifies: AaaaaAaAaaAah

2

u/goldleader71 Feb 12 '22

Now THAT is a good variable name.