The Industry choice

Hans Nowak hans at zephyrfalcon.org
Sat Jan 1 14:24:14 EST 2005


Donn Cave wrote:
> Quoth Hans Nowak <hans at zephyrfalcon.org>:
> | Paul Rubin wrote:
> |
> |> You should write unit tests either way, but in Python you're relying
> |> on the tests to find stuff that the compiler finds for you with Java.
> |
> | As I wrote on my weblog a while ago, I suspect that this effect is 
> | largely psychological.  You jump through hoops, declaring types all over 
> | the place, checking exceptions, working around the language's 
> | limitations, etc.  So when your code compiles, it *feels* safer.  Like 
> | you're at least part of the way towards ensuring correctness.  All that 
> | work must be good for *something*, right?  Never mind that when writing 
> | unit tests for a dynamic language, you don't check for these things at 
> | all.  How often do you explicitly check types in Python unit tests? 
> | IMHO, when using a dynamic language, you don't need most of the checks 
> | that Java, C# and their ilk force upon you.
> 
> I have been fooling around with strongly, statically typed languages
> for a couple of years, in my spare time - Objective CAML, Haskell,
> O'Haskell.  This is a little different experience than what you two
> are talking about - I don't think Java, C# and their ilk are quite as
> rigorous, nor do they use type inference - but as much as it would
> probably gag an FP enthusiast to say this, the basic idea is the same.
> 
> I can only believe that if you think the benefit of static typing is
> psychological, either something is very different between the way you
> and I write programs, or you're not doing it right.

I do think it makes more sense in functional languages like the ones you 
mention... that's one of the reasons I am trying to learn OCaml.  I 
don't think the type systems in OCaml, Haskell etc can quite be compared 
to what's used in Java, C#, C++ or Delphi.  So far, I am getting the 
impression that the type system in OCaml is actually there to help you, 
rather than something that gets in your way.

I concur that in my OCaml experiments so far, errors pointed out by the 
compiler made a lot more sense, because they pointed to actual problems, 
rather than being a case of "you didn't declare this method as public 
static final".

Of course, it helps that, like Python, said languages (OCaml, Haskell) 
are higher-level than Java/C#/etc, so you can express things concisely 
and clearly.  That might be one of the reasons why static, strong typing 
in VHLLs has a much higher "return on investment" than it has in 
lower-level languages, where you have to write acres of code just to get 
something done (availability of libraries notwithstanding).

-- 
Hans Nowak
http://zephyrfalcon.org/




More information about the Python-list mailing list