LWN.net Logo

Python slithers into Wesnoth

Python slithers into Wesnoth

Posted Jan 14, 2009 22:13 UTC (Wed) by elanthis (subscriber, #6227)
In reply to: Python slithers into Wesnoth by ncm
Parent article: Python slithers into Wesnoth

So true.

I particularly loved how when I proclaimed a love for static typing to Python fanatics, I was told that Python is so much better because I "don't have to type superfluous argument type names into function definitions." They conveniently leave off the fact that said typing removes the need for a ton of unit tests for each and every caller of said function to ensure they're passing in the right types.

Every single call to every single module has to be tested _in addition_ to the testing of the module's behavior itself. If you aren't testing everything, you're going to get bit in the ass when you use a fully dynamic language for large-scale application development.

It's wholly different scenario than when using such a language for tasks like serving web pages, where the modules have little interaction. In something like a game, every module interacts with almost every other module. Instead of a simple tree of dependees and dependents, you have a huge web. Unit testing all those interactions is a major PITA, and is so much worse in a dynamic language were you have to test all the things the language can't bother to enforce for you.


(Log in to post comments)

Python slithers into Wesnoth

Posted Jan 15, 2009 12:51 UTC (Thu) by liljencrantz (subscriber, #28458) [Link]

True enough. I've tried to explain to dynamic typing lovers that static typing is just a special, very powerful meta-language used for creating unit tests that perform input validation. Very useful that; especially how you annotate the code itself with these little unit tests.

On the other hand, Python does have some nice features like lambdas, continuations, etc..

Python slithers into Wesnoth

Posted Jan 15, 2009 15:25 UTC (Thu) by lysse (guest, #3190) [Link]

Funnily enough, I'm a preferrer of dynamic typing who got shouted at by fans of static typing for saying more or less the same thing... oh well.

Python slithers into Wesnoth

Posted Jan 15, 2009 18:21 UTC (Thu) by cyd (subscriber, #4153) [Link]

When programming with a dynamical language, you can simply check the type of the argument in the function body, which gives you most of the advantages of type checking (albeit at run-time). The main advantage of dynamic typing, in my mind, is not that you don't have to enter the type of the argument in a function definition. It's that you can write functions that explicitly accept arguments that can be of several possible (carefully specified) types, without messing around with kludges like class inheritance.

Python slithers into Wesnoth

Posted Jan 15, 2009 21:35 UTC (Thu) by njs (subscriber, #40338) [Link]

>It's that you can write functions that explicitly accept arguments that can be of several possible (carefully specified) types, without messing around with kludges like class inheritance.

NB, every statically typed language more recent than C allows for this. (Even C++, via overloading and templates, and C++ is way behind the state of the art in static type systems.)

Python slithers into Wesnoth

Posted Jan 15, 2009 22:00 UTC (Thu) by boudewijn (subscriber, #14185) [Link]

Aw, and that already was a pretty polite and respectful discussion,
especially compared to some others...

Python slithers into Wesnoth

Posted Jan 15, 2009 22:58 UTC (Thu) by njs (subscriber, #40338) [Link]

I've read your comment several times, and maybe I'm just being slow today, but I can't figure out what you're implying :-). (Was that intending criticism, compliment, random observation, posted in the wrong place...? I'm lost!)

Python slithers into Wesnoth

Posted Jan 16, 2009 16:01 UTC (Fri) by boudewijn (subscriber, #14185) [Link]

I thought the qt is lgpl discussion on lwn was pretty respectful and flamefree compared to some
other discussions I've read recently.

Python slithers into Wesnoth

Posted Jan 16, 2009 8:14 UTC (Fri) by liljencrantz (subscriber, #28458) [Link]

Sure it's possible to type check in dynamically typed languages, but but statically typed languages offer a much more compact syntax to do the same thing, so it's much more convenient to do it there. And doing it at compile time is a distinct advantage as well, since it means that even code paths like esoteric error handlers that are extremely rarely run, still get at least some checking.

As to duck typing, it's very convenient sometimes, sure. But as another poster said, many modern statically typed languages support it as well. And quite frankly, it's really easy to mess duck typing up, so I'd much rather do it in a language where it's easy to check that the supplied types are reasonably suitable for the task at compile time.

Python slithers into Wesnoth

Posted Jan 18, 2009 12:19 UTC (Sun) by rwmj (guest, #5474) [Link]

They conveniently leave off the fact that with type inference you don't need to annotate all the
functions.

Such an opportunity to use a decent functional language here, especially since functional languages
are so much better at handling complex data structures.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds