Tuesday 10 August 2004 — This is over 20 years old. Be careful.
After a small project of mine was converted from Python to C#, I have a new-found admiration for Python’s dynamic typing, and other cool features like named arguments in function calls. I have come to believe this about static typing:
Static typing prevents certain kinds of failures. Unfortunately, it also prevents certain kinds of successes.
Comments
I'm not sure what such a language would look like, but when writing in static languages I frequently wish I had more dynamicism (is that a word?) for just some parts of the code.
The current fuss about adding function decorators to the Python language suggests that Python is on the way towards adding optional static type declarations to the language...
for stepclass in [step1, step2]: stepclass().run()
In VB.Net, that's:
Dim NoArgs as Object() = {}
Dim CommitSteps As Type() = {GetType(StepType1), GetType(StepType2)}
For Each StepType As Type In CommitSteps
Dim ThisStep As CommitStep = StepType.GetConstructor(Signature).Invoke(NoArgs)
ThisStep.Run()
Next
Objective-C is often forgotten, but Apple (or NeXt, rather) got it right with Cocoa. Check it out.
Oh, and the PyObj-C bridge seems to work well. best of both worlds (almost).
Don't get me wrong. I really like python. I'm just not sure I would use it for a really big project.
Where it starts to get interesting, though, is when you stack a Python up against a more modern static language with a rich type system and type inferencing: at least an O'Caml or Haskell, but preferably a Nice or a Scala or a Cayenne or an Epigram.
I've spent decades with Common Lisp and Scheme and, to a lesser extent, Smalltalk. Did all of my recreational programming in them until about two years ago, at which point I discovered O'Caml in the process of stumbling across Ensemble. I find O'Caml to strike a really nice balance between being functional and imperative, and between static-typing-with-inference and dynamic checking. And I have to say that I like the safety. For example, there are OpenGL bindings in O'Caml that are type-safe where the native C APIs are not, thanks to the use of phantom types.
I should also add that the thing that I thought I was getting from my dynamic languages, which had a lot to do with interactive, incremental development, I also get from O'Caml: it has an interactive toploop, a bytecode compiler, and a native compiler. It also has an awesome time-travel debugger for the bytecode compiler and a profiler for the native compiler, so it really can take you all the way from type-and-go to tweaking to get those last few CPU cycles out. It's got a goodly number of great libraries (not like Perl or Python, though, admittedly!) and it's quite easy to link C/C++ in (in fact, current O'Caml has great support for loading DLLs on the fly). So if you think that C#/Java/C++/C are the state of the art in statically-typed languages, let me recommend giving O'Caml a try.
People believe all kinds of things. It's more interesting to hear about the evidence they use to support those beliefs.
Add a comment: