Re: When static typing is worth it
- From: philip.armitage@xxxxxxxxx
- Date: Wed, 03 Oct 2007 02:04:12 -0700
On 3 Oct, 00:50, Jon Harrop <j...@xxxxxxxxxxxxxxxxx> wrote:
Consequently, unit testing is comparatively rare in these languages. For
example, I wrote 50kLOC of custom object marshalling code in OCaml and the
client insisted on unit testing it. OCaml's powerful static type system
caught many bugs and 24hrs of running unit tests caught precisely zero
bugs. From experience, I already knew the unit tests would be a waste of
time.
Well that's the classic error of writing unit tests that you know will
pass. It gives you (or your client) a warm and fuzzy feeling when the
light goes green but in actual fact you've proved nothing at all about
your programs correctness. By admitting that you wrote these tests
knowing they were pointless you were maybe sub-consciously falling
into this trap.
But I'm interested in this idea that unit testing is unnecessary with
"modern functional languages" and I'm not dismissing it as I genuinely
fear becoming a Blub programmer. So if you don't mind, can you look at
this example of the sort of work I do and possibly give me some
pointers to how OCaml's static type system and pattern matching could
reduce my need for testing by 100x:
Our client asks us to code up a new model for our algo-trading
software. Let's say that this is some sort of spread arbitrage model.
It's quite complex so ideal for a powerful language like Lisp or
OCaml. I need to ensure that the rules of this are followed exactly
when certain market conditions arise. So firstly I need to be able to
simulate the market condition. I also need to be sure that the orders
I submit to the trading hosts at the various derivatives exchanges'
execute simultaneously or my client is going to lose lots of money.
Over to you: I'd genuinely love to know how to save myself a lot of
testing time here. And I'm sure a number of other people on c.l.l can
come up with example from their domains for which they would like to
know how OCaml or F# can help them too.
Why can't you just test for the empty list in the function and act
accordingly?
If the test fails then you already gave your client buggy software.
No I haven't!! I said test for the condition and act accordingly. If
I'm stupid enough to think "act accordingly" means "dump core" then I
should find a different profession...
--
Phil
http://phil.nullable.eu/
.
- Follow-Ups:
- Re: When static typing is worth it
- From: Rainer Joswig
- Re: When static typing is worth it
- References:
- Re: Flamebait if I ever saw it
- From: Don Geddis
- Re: Flamebait if I ever saw it
- From: are
- Re: Flamebait if I ever saw it
- From: Pascal Costanza
- When static typing is worth it
- From: Jon Harrop
- Re: When static typing is worth it
- From: philip . armitage
- Re: When static typing is worth it
- From: Jon Harrop
- Re: Flamebait if I ever saw it
- Prev by Date: Re: When static typing is worth it
- Next by Date: Re: Lisp in the US
- Previous by thread: Re: TDD and what tests do other than try to find bugs
- Next by thread: Re: When static typing is worth it
- Index(es):
Relevant Pages
|