No lie, after taking about 2 weeks of my first programming course in university, I did almost exactly this, trying to make a poker game.
I hadn’t learned about objects, or functions, or even loops. Just one big method that had an
if
for every hand permutation.I hadn’t ever been exposed to programming before, and I loved it, but I knew nothing about it. Those were the only tools I had in my toolbox, and you know what they say about how when you only have a hammer everything looks like a nail.
I’m a professional dev now, so I really hope I grew out of it lol
Back when I was learning, I made a flashcard program. It had a class that was essentially a constant array, so you could call get(int i), and it would return an object describing both sides of the card.
How did I implement such a class you ask? First, I made a spreadsheet with 2 collumns to hold the data, with a third collumn of incrementing integers. Then, in the 4th column, I used string concatanation to right a java if statement that compared a variable against the index collumn; and if they match, return an object constructed from the 2 data columns.
Click and drag the 1 cell I wrote in the 4th collumn to replicate it in all the rows, then copy and paste the 4th collumn into notepad++.
I’d like to say I’ve moved past this; but my most successful projects have mostly been code generation ones; so really I’ve just moved past Excell.
I mean, moving past Excel is still an excellent development.
Signed, a guy that keeps dealing with people who need my code to spit out weird spreadsheets.
Same thing with me and chess in high school. I learned TrueBASIC, and I didn’t learn about arrays or subroutines. But, I did manage to make a chess application that two people could play a game of chess on. It highlighted legal moves when you clicked on a piece and ensured that only legal moves were made. It also showed the captured pieces to the side of the board. I think I had it set up so that you could only promote to a previously captured piece, but all the other rules were implemented properly (or at least, I assumed they were).
The implementation involved a bunch of variables for each individual chess piece and a bunch of if statements inside a loop. I remember describing arrays and explaining that I wished they existed, but never actually found out they did until I was finished. I don’t know how many lines of code it was, but when I copied it into Word, and it spanned about 350 pages in total.
Part of me is proud of the accomplishment. Another part is horrified.
I’m a professional dev now, so I really hope I grew out of it lol
I was reading your comment and wondering if I’ve outgrown it. I’ve been a programmer for 20 years…
I’m going on 15 years. Some times I’m not so sure.
I still remember when “the light went on” as realized how variables worked. I was on my way to school and couldn’t focus on mundane things and started hating school.
Now I live in a van down by the river. But I’m still coding!
Time to get some qbasic coding in, your if and goto experience will do wonders
I really hope this is satire. Otherwise I’m scared to ask how long it took.
It’s definitely satire. 2 million lines of code is an absurd under-exageration. This post had me looking up the number of possible chess games, because if you coded chess like above you would have to have an if statement for every outcome, and it’s 10^120 different possible games.
The way I understood it, it’s two million lines and nowhere near finished.
Anyway, satire.
You only have to code a fraction of those as the computer should take the same move for several of the user inputs.
That’s the number of possible games, the number of possible board states is much lower, 10^40.
Although you’re still clearly correct in the end anyways because it’s still an absurd number of board states and it’s not even formatted to be one state per line.
Today I will remind everyone of DRAGON: A Game About a Dragon
This game was developed by someone who didn’t know anything about programming outside of IF statements, integers, and strings. Here is an excerpt of the massively long source code
For a second there I thought the 100% science-based dragons game had been made.
My eyes! The
globalvariable list is huge!Edit: nm, I looked again and they’re in a class. Still insane either way.
There’s a mathematician that figured that there’s 10^120 possible chess games, as a lower bound. https://en.m.wikipedia.org/wiki/Shannon_number#:~:text=Shannon showed a calculation for,a Computer for Playing Chess". That’s a 1 followed by 120 zeros for just the number of possible games. With this method they’d have to manually go through every move for every one of those games. If we say a game lasts 30 turns on average and they’d take 1 second to code each turn (realistically it’d be longer) it’d take 6.9*10^109 (69 followed by 108 zeros) times as long as the age of the universe.
So it’s doable? That’s all I needed to hear.
The post is satire, but I remember being ~8-9 and trying to create a “game” in Microsoft Word with hyperlinks between documents and nothing else. I had hundreds of documents (each representing a game state) before I got tired of that project.
Literally impossible to code every bosrd state, so forever
I feel like this person could finally implement an artificial general intelligence, given an infinite amount of time and memory space.
Don’t stop now, there are only 7,728,772,977,965,919,677,164,873,487,685,453,137,329,736,519 more legal positions to code.
Lol… stupid junior-devs… in such case you should go with switch-statements instead… much cleaner.
Switch-statement (called match) was added to Python 3.10 in late 2021. This is a reasonable, albeit older style of enumerated branching.
Switch statements and differently named but similarly purposed statements have been around since the 60s. Get outta here with this “switch is a newer style because python only just got them” nonsense.
Nobody is doubting that. The code in the meme is python…