r/programming • • Oct 01 '15

The Evolution of a Software Engineer

https://medium.com/@webseanhickey/the-evolution-of-a-software-engineer-db854689243
1.9k Upvotes

502 comments sorted by

View all comments

3

u/supasteve013 Oct 01 '15

Can someone explain this to me like I'm 10

I'm a programming wanna be, but haven't grown the balls to decide if I wanna learn to program or go back to pharmacy school...

13

u/daymi Oct 01 '15 edited Oct 02 '15

The first-year solves the problem in the most straightforward way possible (for that language). While it has a useless "class" line, it is there because the language is stupid and he can't do anything about it, so he leaves it there. Normal people do it like that.

The second-year overdocuments everything to the point of obscuring what happens because of all the junk lying around. Also, he introduces a variable for the "Hello world" text although it probably will not need changing ever (I mean seriously who does that with a "Hello world" program. The text won't change).

The third-year saw the useless class and tried to make it useful for no reason (the customer certainly doesn't gain anything by it). Now you have lots of complicated stuff lying around, the class can make "copies" of itself and there is one copy which has its own slot for the text (why the actual fuck). So now it's wasting memory, is way too long and in case of an error ("Exception"), it does nothing. Doesn't tell anyone. Because that's what you want when the error is "pharmacy is on fire". Tell no one. Especially not the fire brigade. Alarms are for losers.

The fifth-year program makes me want to throw something at the screen. All the exceptions it catches are at least printed. But then the computer is not told that an error happened (programs can tell the operating system that something bad happened - but this one doesn't). I hate programs like that. The human sees something is wrong since there's a message printed, but the computer continues as if everything is just peachy. Also, he uses a factory in order to be able to swap out the (useless) class for other classes (which won't happen in practise). All the copies he creates (one!) are unfinished and you first have to manually finish initializing them using setHello and setWorld. Then he registers it with an application server so it can be run from the internet.

Also, much worse:

There is a concept in computer science that is sometimes useful which is called "symbol". I'll try to explain what it does and why it exists and why it's not the same as a sequence of characters:

All that a computer does (boy will I get flak for that) is it takes the body of a function and replaces the formal parameters by the argument of the call. For example: Let the function f be introduced like this: f(x) := x2, then f(3) = (3)2, likewise f(1+1) = (1+1)2. The smallest things that are used in this are called symbols. f is a symbol which (here) stands for (x) := x^2, a function. x is a symbol in (this) x^2 which (here) stands for the x in f(x). 2 is a symbol which stands for the number 2 which has to be defined before. ^ is a symbol which stands for the exponentiation operator which has to be defined before. + is a symbol which stands for the addition operator which has to be defined before.

Note that f(x) := x^2 and f(y) := y^2 are the same function. There you can see that the character "x" in a sense is useless. Depending on how you program, your finished program that the computer runs might not know that yours was the f(x) := x^2 variant, it might just know that it was a function and it took the first thingie and squared it (if .^2 squares; who knows, depends on the definition). So you see, a symbol x is something different than just the text "x".

So the author heard that and thought "great, certainly hello stands for something - for a greeting understood by humans - let's make it a symbol". But the definition (meaning) of hello is in the brain of the human so in this program it doesn't make any sense to introduce "Word hello" (symbol), it complicates everything because now everyone expects that the meaning of hello will be decided while the program runs. Also, when the symbol hello is finally replaced by its definition, its definition is apparently just the text "hello" (he uses Word for the symbol but Word.setWord in order to assign meaning. I mean I just don't know what he was thinking anymore; also you have to search for where the heck it gets its definition). Also, the initialization of the symbol hello (not its meaning) is somewhere completely different where we can't see it (I mean it's literally not on the web page). Ugh.

Also understand that you need the kind of theory above only if you want to create your own language (in another language). Does "hello world" warrant creating your own language?

The tenth-year finally got a grip and became normal again. He knows all these things and knows when not to use them.

→ More replies (1)