I can't remember which file it was in so I could give the example, but last night I found an old folder with loads of unfinished projects of mine from highschool. Six nested loops anyone?
I look at old code and remember "Oh yeah, I didn't know how to do X so I did this workaround instead". People tell me they can't understand their old code, but I can still understand my old code from 3+ years ago.
I can understand my old code, but what I always say to myself "Hahah, how stupid was I. Why would I write 50 lines of code when I can do that liek in 5"
That makes me think of a file I did back in '96 (that I actually keep on all my hard drives to remind how much of idiot I was starting out) when I started doing C++ for DUMMIES (how I miss Rhide sometimes). It is one of the things I refer back to in order to keep me from getting a big head and to try and not get short with beginners. It is the proof that some experiments should stay thoughts and not be implemented.
On that note, Don't smoke pot and code. Smoke pot and listen to music, have an epiphany of how to micro optimize that one algorithm, write
it down, sober up and THEN code.
"why is it bad to smoke before your brain stops developing?"
The majority of the studies I've read that have shown negative side effects from smoking pot have shown them in participants who are adolescents. The rest were ill defined or funded by lobbysts against pot.
I thought I was a C++ guru and wrote bad code and thought I was 1337, I know this isn't exactly healthy, but I feel like inventing a time machine just to punch my younger self in the face. I used to use macros and raw pointers directly without any sort of pool allocator, and use the graphics API directly without any sort of abstraction layer. Now that I've seen what I've done wrong, I've almost completely changed my coding style. (I also used to use SDL 1.2 blindly and claim it's the best lib ever. I'd much rather use 2.x)
My younger self is the type of person that I seriously despise, lol.
_________________________
Why does everyone think it's cool to smoke pot? Your mother isn't going to be very happy when she finds out that her flower pots burned. Not worth the grounding. Lol.
@cire
Thanks for pointing that out. C++ for DUMMIES back then said it was legal, but was frowned upon due to not returning anything to the system. When I joined Allegro, most of the games I looked at the source to was using void main, but never heard it was bad. Guess the only dummy was me for believing the book without question.
As far as I understand it, the original stating of C99 actually had poor wording when it came to the declaration of program entry. It claimed that it required a type of int but that other types would be implementation defined.
Unfortunately, I've found it impossible to find a draft of the C99 standard that doesn't have the various revisions applied to it so I can't be sure.
In the C89 ANSI standard, it doesn't mention return type at all. It just says "The function called at program startup is named main". It provides an example of what the function may look like but no written definition of what it's supposed to be otherwise.
The void main dispute is because many compilers for small microcomputers actually do require you to use void main since there is no operating system to return to. This is the "implementation defined" clause of the C standard - unfortunately C++ completely forbids it is difficult for there to be C++ compilers for these small microcomputers. I have worked with such compilers and such microcomputers.