Monday, September 26, 2011

On Being a Better Programmer


After a few years of evangelizing different languages which are “better” than whatever language it is that I am currently paid to develop in, I came to a realization which was triggered by a conversation with a co-worker. He said I wasn't doing myself any favors by looking to other languages and comparing them to whatever language I am working in. In his opinion, doing so would lead to dissatisfaction with the language I am supposed to be working in, and eventually with the job I am paid to do in general.
It was an interesting point.
So I began looking at the reasons that I look to these other languages. By and large, it is that the languages I have espoused over the current language du jour were more succinct, or less verbose in nature. For instance, when I was a C# developer, I was hung up on Python. When I moved to Java, I began looking at others such as Groovy, Ruby, and lately, Scala. But try as I might, I never found a magic bullet in any of those languages. What was I looking for? Some mystical programming language that would instantly cure my faults as a programmer.
The truth is this: the fault is not with the language; it's with the programmer.
I am a Java developer. Professionally. Do I like Java? Meh. Why not? Because I have been lazy. I can't think in Java yet. (I'm getting there.) Instead of taking the time to read and learn Java, to grok it, to “take it to the head”, I saw things in the way the language is used at my current job that are confusing, convoluted, and seemed to be a step back from my days as a C# dev. Instantly I tried to find something “better”, instead of making me better, rising to the challenge set by the architect of our code.
Not any more. I have put away the Scala book. Not that I won't code in Scala, just not now. Before I can use Scala, I must first master Java. I closed my PHP applications. I know PHP. It's comfortable. It's easy. It's a (no offense) way less powerful language than either C# or Java. I close the books on JavaScript. JavaScript is my bread and butter. Simple, dynamic, powerful, fast. Someday I will return. But right now, I realize, I have one job to do.
I have to code Java. I have to become a Java programmer. There is no “better” language. And this is what they pay me to do.

Tuesday, September 06, 2011

Functional Programming? or Here We Go Again....


I am very interested in functional programming languages and their “no iteration, no mutable state, immutable objects only” way of doing things. Recursion, in Functional Programming (FP), is divine, and we should all aspire to divinity. Iteration is direct from the devil, as it makes for convoluted, difficult to maintain, crappy code. If you don't believe that, read some Java.

So what is the barrier to entry? Well, most of (if not all) the functional languages are considered “esoteric”. The most popular pure functional language seems to be Scheme, which is itself a stripped down, simplified descendant of Common Lisp. Every programmer I have talked to hates Lisp. Why? Simple: parentheses. Also, to a strongly typed mind (someone who is trained first on C#, Java, C++, C, Visual Basic, or whatnot) the fact that there are only two types in Lisp, the atom and the list, makes little to no sense.

Ruby comes close to integrating Functional Programming with Object Oriented Programming... but not really. It allows some functional programming concepts to slip in, but it doesn't really support “Functional Thought”.

Python? Not really. Plus both of these languages are really scripting languages, Not compiled, not optimized, not ready for the kind of speed one needs on the Enterprise level. (Not that Java is a speed demon, mind you.) No, if you want Enterprise speed (Warp 1, engage!) you have to settle for Java, or (shudder) suck at the teat of Microsoft. Or do you?

Enter Scala.

Scala is specifically designed to integrate functional programming and object oriented programming, while providing strongly typed variables, first class functions, and type inference. So what, you ask? Here's the really cool part. It runs on the Java JVM. That's right. It compiles to Java bytecode. Optimized. Ready for the enterprise. Java-like syntax. True integration of iterative and functional thought.

Using Scala, you can even leverage Java libraries. They completely inter-operate with each other. So all that code you Java developers have laying around... keep it. Import it. Leverage it.

As if that were not enough... All you C# junkies... you now have another functional programming option besides F#... Scala is available for the CLR as well. So you can compile Scala down to MSIL and let it fly on your Microsoft Web stack, or with your WPF application, or as, I don't know, a class library.

But I sense that you guys really wanna know “Why do I care about Functional Programming to begin with? What's wrong with good ole imperative OOP?” Well...

Nothing, really. FP just makes it easier to write thread safe applications. It makes code more maintainable by not allowing mutable objects. What I mean is, when you hand a function a set of parameters, you get the same response every time those parameters are given to the function. Functions are not allowed to alter the innards of Objects. They can take that object, and create a new object based on it with different values, but the original object is not altered. At best, it still exists. At worse, it is deleted and replaced by the altered clone.

Think about what that does for your unit testing. You get predictable results every time a function runs. If you have ever tried to write a test harness for complex imperative code, you know what a nightmare that is. Small changes in one part of an application can effect the state of objects on the other side of the app. And that can be really difficult to track down if it causes a test to crash.

Do some reading on it. Seriously. FP, once you understand it, will make you a better coder. Even if you choose not to use it, it's one of those things that will change the way you understand software.

Monday, September 05, 2011

Developmental Issues.

So, anyone who knows me on a developer basis knows that I am always looking for a magical bullet language. One that will solve all my shortcomings as a programmer.

Over the last week or two, as I developed a project in the old standby (PHP), A thought occurred to me. It is not the language that is lacking. It's my mind. So, I am working towards a deeper understanding of programming in general, and patterns in specific. Minds that are greater than mine have attacked the problems that I face on the day to day level, massaged lacking languages, built patterns that work, and conquered problems that I have not even yet foreseen.

Just a thought. The place where the lack is, it's with me, not the languages I use.

Thursday, August 04, 2011

A conversation with Oracle...

(09:00:23 AM) Me: 
Dear Oracle,

When will we get a multi-threaded java compiler?

Thanks,
Brett


(09:01:40 AM) Mike: 
Dear Brett,

We are too big too care about what you want.
Don't even bother sending any other questions.

Thanks for your concern,
Oracle


(09:02:41 AM) Me: 
Dear Oracle,

F you.
I'm switching to Ruby on Rails.

Sincerely,
Brett


(09:04:01 AM) Mike: 
Dear Brett,

Good luck with Ruby. Once you actually enjoy it we will buy it out and ruin your life again.

You are SOL,
Oracle

Thursday, January 27, 2011

The value of Quirkiness

One of the things that I treasure the most about growing up with my mom is her quirkiness. I have been awash in a sea of normality. Let me tell you, it gets old.
Mom always had, and still has, a one-liner for almost any situation, a quick witticism, a masterful pun, or just a play on words. She understands the need to put fun into life. Lets face it: there's not enough fun in the world.

Some examples:

Mom referred (and probably still does), to the monthly bills as "William"s. She said she "didn't want to get to friendly with them".

Our vacuum cleaner, when I was a kid, had a name. It was Malcom. Malcom the Vacuum. Pronounced so that it rhymed. Malcom the Valcom. (this causes me to chuckle to this very day.)

Mom required me, from the age of about 11, to watch all the original SNL, Almost all of Mel Brooke's films and everything with Gene Wilder in it. She even let me listen to Richard Pryor (eventually, he's not for the super young... obviously). The puns, quotes and one liners flew fast and furious in our house.

The best of our punning together created the classic oneliner "I shot Chopin, But I did not shoot Debussy." To the tune of "I Shot the Sheriff." If you don't get that, go study some music history.

Another of mom's fav's: What's in the bag Dad? a: Iraq.

Thanks Mom, for teaching me the value of wit and humor. You can do it like no one else.

Tuesday, January 04, 2011

HAPPY NEW YEAR!!

Here, recorded for all of time is a list of this year's resolutions:


  1. Eat better and exercise more.
  2. Get more into Lisp, Python, Ruby, and functional programming in general.
  3. Write at least one page per day on one of my stories.
  4. Only do those things that are important.
  5. Finish the things I start.
The last two are pretty vague, I know, but as others have pointed out, I take on too many things at one time and have a tendency to not get any of them done. This is the year that comes to an end. I took a long hard look at my life and realized that there are a lot of things that I "like" to do, that I really don't care that much about. Amongst them were watching television, playing video games, and watching copious amounts of movies. I also decided to reduce the amount of distraction added by trying to draw, write screenplays, shoot comedy skits, shoot music videos, write music and do 3D modeling.

I mean, honestly, who can do all that at the same time?

SOOO, here is a new and improved list of things I am going to focus on this year:
  • Programming
  • Writing
  • Exercise and Diet.
I hope that this reduction of BS will make life simpler and better.

Current Music: Mirage - Armin van Buuren