this article is incredibly long and rambly, but please enjoy as this asshole struggles to select random items from an array in presumably Javascript for what sounds like a basic crossword app:
At one point, we wanted a command that would print a hundred random lines from a dictionary file. I thought about the problem for a few minutes, and, when thinking failed, tried Googling. I made some false starts using what I could gather, and while I did my thing—programming—Ben told GPT-4 what he wanted and got code that ran perfectly.
Fine: commands like those are notoriously fussy, and everybody looks them up anyway.
ah, the NP-complete problem of just fucking pulling the file into memory (there’s no way this clown was burning a rainforest asking ChatGPT for a memory-optimized way to do this), selecting a random item between 0 and the areay’s length minus 1, and maybe storing that index in a second array if you want to guarantee uniqueness. there’s definitely not literally thousands of libraries for this if you seriously can’t figure it out yourself, hackerman
I returned to the crossword project. Our puzzle generator printed its output in an ugly text format, with lines like
"s""c""a""r""*""k""u""n""i""s""*" "a""r""e""a"
. I wanted to turn output like that into a pretty Web page that allowed me to explore the words in the grid, showing scoring information at a glance. But I knew the task would be tricky: each letter had to be tagged with the words it belonged to, both the across and the down. This was a detailed problem, one that could easily consume the better part of an evening.
fuck it’s convenient that every example this chucklefuck gives of ChatGPT helping is for incredibly well-treaded toy and example code. wonder why that is? (check out the author’s other articles for a hint)
I thought that my brother was a hacker. Like many programmers, I dreamed of breaking into and controlling remote systems. The point wasn’t to cause mayhem—it was to find hidden places and learn hidden things. “My crime is that of curiosity,” goes “The Hacker’s Manifesto,” written in 1986 by Loyd Blankenship. My favorite scene from the 1995 movie “Hackers” is
most of this article is this type of fluffy cringe, almost like it’s written by a shitty advertiser trying and failing to pass themselves off as a relatable techy
shuf -n 100 /usr/share/dict/words
I would have expected JS standard library to contain something along the lines of
random.sample
but apparently not. A similar thing exists in something calledunderscore.js
and I gotta say it's incredibly in-character for JavaScript to outsource incredibly common utility functions to a module called "_
".Language bashing aside, there's something to enjoy about these credulous articles proclaiming AI superiority. It's not the writing itself, but the self-esteem boost regarding my own skills. I have little trouble doing these junior dev whiteboard interview exercises without LLM help, guess that's pretty impressive after all!
Absolutely this, shuf would easily come up in a normal google search (even in googles deteriorated relevancy).
For fun, "two" lines of bash + jq can easily achieve the result even without
shuf
(yes I know this is pointlessly stupid)cat /usr/share/dict/words | jq -R > words.json cat /dev/urandom | od -A n -D | jq -r -n ' import "words" as $w; ($w | length) as $l | label $out | foreach ( inputs * $l / 4294967295 | floor ) as $r ( {i:0,a:[]} ; .i = (if .a[$r] then .i else .i + 1 end) | .a[$r] = true ; if .i > 100 then break $out else $w[$r] end ) '
Incidentally this is code that ChatGPT would be utterly incapable of producing, even as toy example but niche use of jq.
It's so incredibly easy to randomly select a few lines from a file that it really doesn't need to be in the standard library. Something like 4 lines of code could do it. Could probably even do it in a single unreadable line of code.