On being a Roman in Rome
kishorelive.com
kishorelive.com
This was all of the experience in coding I had for the next 4 years. I became extremely good at TI-BASIC and ASM. But in High School I started fooling around with Python and the world of Object Oriented programming bewildered me.
In TI-BASIC you get 27 float variables, 6 lists of floats, all limited to 999 elements, 10 strings, and 6 matrices of floats. That is all the data one gets. Very quickly one becomes a wizard of string manipulations (because strings were the only datatype without a default memory cap; they could be as long as your RAM could hold) and whatnot.
Whenever I moved to Python, I found myself following the same paradigm. I didn't make a single Python class until I was in college. I would use tuples and lists and just organize my data that way.
After my collegiate conversion to OOP (and subsequently writing heavily OO Python), I later found out that it is somewhat encouraged to use the built in datatypes over custom classes for performance reasons.
I was accidentally acting Roman without realizing it!
Of note is that Java instincts are a bad thing for Python. Similar principles apply to other language combinations, and even services (eg SOAP vs REST) in addition to data as PJ wrote (eg XML vs JSON).
Ask, "how does Python already solve my problem?" and "What Python language feature most resembles my problem?"
Time will tell if this is horrible or genius. I suspect it will be neither since I'm just writing a toy app for now and probably won't run across any problems of a huge-incomprehensible-codebase nature.
Thank you for this post, I've felt like the OO police have been closing in on me and will burst through the door at any moment to force getters and setters on me.
It is easier for me to write Java/C#/C++ code and then Python code and adhere to the conventions of each than it is for me to write Go code and then switch to Java/C#/C++ code. This is true for the larger architectural differences as well as for more minor syntax-related differences (eg. if I've been writing a lot of Go and then I switch to maintaining some C#, I'll often leave semicolons off statements in the C# code until the compiler complains about it).
The author is saying that when he is "in Rome" he finds himself not doing what the Romans do, but rather doing what the Parisians do or what the Berliners do, since he has spent so much time in his metaphorical Paris and Berlin.
The "abstract" keyword is forbidden (I know a lot of OO "experts" that are going to explain how bad this is). No public constructor (they do break encapsulation and hence it's a gigantic no-no). Every single class is final.
Liberal use, everywhere, of multiple (interface) inheritance.
@NotNull everywhere. Really. I hardly know what a NullPointerException is since 5 years or so.
The final keyword is used nearly everywhere.
Most classes do throw a Runtime exception if you try to call hashcode() or equals() on an object (because in anything but the simplest case, where there's only one level of inheritance, the hashcode() and equals() contract cannot be guaranteed -- This fact was explained in "Effective Java" by Joshua Bloch back in the days and is not open to discussion).
Basically I'm doing "OO over immutable objects" and it's much easier to reason about the state while programming this way.
The most laughable thing of them all is that years and years ago when you'd talk about that on comp.lang.java.programmer people like Jon Skeet (you know, the StackOverflow user with the biggest reputation of all StackOverflow) would call you crazy and explain why the "common" way was the one true way. These were the kind of people explaining how James Gosling was a god for not adding enums to Java and why Java applets were the best thing since sliced bread.
One IBM JVM engineer would regularly hand Jon Skeet's arse to him by the way.
And now... Oh the irony, Jon Skeet on StackOverflow is basically rewriting exactly what these precursors where telling on c.l.j.p. years and years ago.
So, slowly, people are starting to accept that it may not have been that great an idea to allow the addition of mutable, extendable objects in a hashmap.
Thankfully things are changing for the best, at last... : )
If you think it's hard to not be a roman in Java Rome today, you have zero idea what it was like to not be a roman in Java Rome during the Usenet days.
Maybe I'm too drunk instead of being just high (blame Italy for that [can't get properly high here]). But I really think programming languages tare way to messy to accomplish anything useful without getting in our own way. I mean, what if instead of proving a point our real goal was just to be really effective? I think that would shift the state of things a tiny bit.
But who am I beyond just a drunk programmer?
Also, you're saying all this in a rather obnoxious manner, talking about how you're "drunk instead of high" and what-have-you. Nobody wants to hear about how drunk or high anybody else is -- and if you don't feel like you can compose a decent comment in your current state of mind, you can't be too surprised if you go ahead anyway and end up downvoted.
But do it quickly, because I'm pretty sure you're going to get hell-banned for this. And for reasons that will be painfully obvious to you once you are sober.