Saturday, November 24, 2007

In my previous post about what people use computers for, I stated that computers are for saving state.  Duh.  I felt I needed to make that clear to myself as I explored functional programming languages like Erlang, F# and Scheme.  State seems to be a dirty word relegated to second class citizenry in a functional world.

I think that functional language have an uphill battle for mainstream acceptance.  A bit bolder, I think they are a small niche and always will be a small niche.  In fairness, I think most of literature on functional languages portray them as a special purpose languages.  As the saying goes, the right tool for the job.  Microsoft is looking for F# developers to write driver validation software. 

My goal is to find languages that are applicable to general purpose problems.  I'm not a mathematician and I don't need so solve theorems.  Most of the programming jobs I've completed involved storing and manipulating some shared stated, a database.

Yet another realization courtesy of a man seeking to explain the failure of the best language on earth

Local state in programming is just like scratch paper for mathematics.  Some rare gifted individuals don't need it and can do the calculus in their head.  For the rest of us scratch paper and number two pencils are the only alternative.

While debugging, I can inspect the state of the system, either with the debugging facilities or with well placed print statements. 

So local state helps us understand our systems.  Global state, again databases, are the reason our systems exist.  Some in the Erlang camp want to wish this away.  However, I think Erlang advocates understand that Erlang was built for telecom switches.  Erlang's usefulness in general purpose programming is yet to be determined.  If you're building a system that manipulates global shared state (most of the web applications in existence), choosing a language that waves its hands at shared state in the name of concurrency might not be your best choice.

Now we come to the revelation stage of our journey.  What can we do in mainstream languages to deal with global  shared state (databases) effectively?  I've found something in my own development work that is effective for me.  It's not a new language, but in fact, works in many languages, including C# and Python.

My solution may not be a silver bullet, but then I might not be hunting werewolves.  I can't claim to have invented it.  For from it.  All I can claim is that I've seen this pattern work across languages.  I can also tell you that it might be a wooden stake, useful if you are hunting vampires.

 

Saturday, November 24, 2007 10:16:25 AM (Central Standard Time, UTC-06:00)  #    Comments [2]
 Friday, November 23, 2007

For a (brief) while, I was learning F#.  It proved an interesting excursion.  If you into mathematical correctness F# and OCaml maybe just the languages for you.  Myself?  Well I'm looking for something with a little more to offer in the functionality department.  I want a language where I can do most anything.  I'm willing to sacrifice mathematical niceties.

Python seems to be that language.  Python is one of the languages I knew I would love when I tried it, so I've held off diving into it until I had gone through almost every other one.  I've journeyed through Lisp, Scheme, C++, C#, Java, Ruby, F#/OCaml and dabbled in a few less known like Factor and Cat. 

Python Advantages:

  • Available and almost every platform (every platform I'm interested in)
  • Terse clear syntax
  • Whitespace (yes, I do enjoy the whitespace!)
  • Easy to learn, easy to teach (I taught C++ to undergrads during my time in Hell)
  • More complete than Ruby
  • Better documented than Ruby
  • Good riddance to the Edit/Compile/Wait/Debug loop (hello Edit/Test, Edit/Test, Edit/Test...)
  • Python is available on the CLR as Iron Python and on Java as Jython.

Disadvantages

  • It's not C# (heh)
  • It's not Java (heh, heh)
  • Performance (slower than the above)

I believe that Gabriel is correct and that worse is better.  Worse as in Python is not Lisp.  Even Dr Norvig, chief brain in a jar at Google, thinks Python is good for something.

Note that Python is one of the four languages in use at Google.  Google has, in fact, hired the Frost Giant.

Python is used in game scripting.  My favorite game series of all time uses Python as the scripting engine.

I've also found one of the best Web Frameworks to date to use with Python.  I'll detail that it a future post. 

Right now Project X is moving forward on rockets fueled by Python.  This is the most complete proof of concept I've completed in an alternate language (not C#) and I'm LOVING it.

 

Friday, November 23, 2007 9:59:18 PM (Central Standard Time, UTC-06:00)  #    Comments [0]