Justified Programming

I think it would be an interesting project to make a language that refuses to run any code that isn't justified by tests. This would basically enforce test-driven development. What I'm thinking of is something like Jester, but built into the compiler (or interpreter).

For example, take this simple function:

  (define (add x y) (+ x y))

This would cause an error saying that since there are no tests, the body of the function could be absolutely anything and nobody would be able to tell the difference. So we have to add a test:

  (expect-equal 0 (add 0 0))

This would still cause an error message, because the same test would also accept a similar function that used * instead of +. In other words, the use of + isn't adequately justified. So we improve our test somewhat:

  (expect-equal 0 (add -2 2))

And finally the code is accepted.

It would be interesting to see how far you could get in such a language. I would probably go about implementing it as a DrScheme language level -- it would be comparatively easy to implement, and it would fit in with the pedalogical tendencies of the PLT scheme community.

Posted on July 15, 2006 01:56 PM
More languages articles

Comments

Interesting, but I'm not clear on how the "adequately justified" part would work. Wouldn't the second test accept this function?

(define (foo x y) (+ 4 (* x y)))

And thus not be "adequately justified"? You would have to try all possible arguments to make sure that no other function would fit the tests.

Posted by: Ian at July 15, 2006 09:16 PM

It would probably go over as well as Ada did.

Posted by: Sean Conner at July 15, 2006 10:15 PM

Ian, the idea is to do something like what Jester does -- it has a library of mutations to apply to code, and if you survive all those mutations, then the code is "good enough". Examples include negating the test of an if statement or while statement, changing a zero to a one, and a few others. I just made up the idea of replacing + with * because it kept the example simple. I would also expect the language to allow programmers to define their own mutations for functions they've written.

Sean, the point isn't to make a commercially successful language. Commercially successful languages are rarely interesting. If such a project became as successful as Ada, I would count it as successful beyond my wildest dreams.

Posted by: Kim at July 16, 2006 08:32 AM

Hm. You know in Smalltalk debuggers there's a button you can press to create a nonexistent method that you had tried to call. How about a programming environment where that's the only way to create a function? It'd be less strict about forcing you to test, but feel less like a nanny making you jump through hoops, perhaps. Could this be generalized so you could only introduce IF statements, etc., by supplying examples?

I haven't used Epigram, but this reminds me of how its environment is said to expand code-in-progress based on types.

Posted by: Darius Bacon at July 17, 2006 11:33 AM

Darius: That Smalltalk feature is quite a bit like the Eclipse "Quick Fix" feature. It allows one to write code that doesn't compile (eg, by referencing a method that doesn't exist) and then hit C-1 to fix the issue by adding a method with an empty body. This style of development is how I write most of my code these days.

Regarding a compiler that proves that code is tested, it seems like the analysis has to be dynamic, which means it could get very expensive. I wonder what static analysis you would add to it to make it efficient (ie, detecting what tests can't possibly test a block of code and not bothering to run them).

Posted by: Richard Tibbetts at July 18, 2006 08:58 PM

Darius, I like the idea of making examples be part of the required syntax for an if statement. Unfortunately I'm not sure it would work well for such a small piece as an if statement -- unlike functions, if statements aren't usually designed to have a small surface area.

Richard, a simple way of reducing the runtime overhead would be to syntactically tie the tests to the code. Then it would be immediately obvious which tests need to be run to validate the code, since they're right there next to it. One way to think of it is as an extension of the idea of a method signature.

Posted by: Kim at July 18, 2006 09:39 PM

I'm reminded of the Guantanamo tool for Java. It deletes any code not covered by tests.

Posted by: David Bremner at July 23, 2006 02:18 PM

Hm.ed hardy You know in Smalltalk debuggers there's a button you can press to create a nonexistent method that you had tried to call. How about a programming environment where that's the only way to create a function? links of london It'd be less strict about forcing you to test, but feel less like a nanny making you jump through hoops, perhaps. tiffany jewelry Could this be generalized so you could only introduce IF statements, etc., by supplying examples?

Posted by: daivd at September 30, 2009 03:28 AM

There is nothing that touches these for just lazing around at home. Bar sleeping I don’t take mine off now that its getting colder, they are not quite as stiff as they were when they first arrived but still extremely comfortable. It would be nice if they had a little more arch support but other than that I’m very pleased. I am finding a nice ugg boots!

Posted by: ugg boots at November 5, 2009 02:43 AM

Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far

Mukluk boots

Posted by: Mukluk boots at November 5, 2009 02:44 AM

Everything dynamic and very positively!

NIKE

Posted by: NIKE at November 5, 2009 02:49 AM

Good work, thanks! My sister received the Mbt Health shoes I bought her for her birthday, she adores them. I was a little worried the calf would be tight around her legs but it hasn’t been a problem. I’ll be back before Christmas.


Posted by: Mbt Health shoes at November 5, 2009 02:49 AM

I think I will try to recommend this post to my friends and family, cuz it’s really helpful.

Thanks for this nice post, i like it very much, write this article more.Nike Air Max 2003 Shoes
.

Posted by: Nike Air Max 2003 Shoes at November 5, 2009 02:50 AM

Only One word to characterize such a great post “WOW” that was a very interesting read
Adidas

Posted by: Adidas at November 5, 2009 02:51 AM

Find Jeans ?!UGG boots On Sale ,Enjoy free shipping + bargain sale now!

UGG Classic Short,100% Authentic UGG Australia Boots!ALL of

Jeans are the cheapest and best for you!Enjoy yourself of shoping , Find Cheap Sheepskin
Jeans !



Posted by: Jeans at November 5, 2009 02:51 AM

We also supply other products such as:

Mukluk boots


Shoes


NIKE


Jeans


Handbags


Lacoste Shoes


Jeans


Watches


Handbag


Adidas


DVD .Welcome to order it.

Posted by: surprise at November 5, 2009 02:52 AM

Hey, i am very happy today, I received my Mbt shoes

just now, very impressed. They are like sort of a massive slipper, soft, easy to wear and

light.

Posted by: Mbt shoes at November 5, 2009 02:52 AM

There is nothing that touches these for just lazing around at home. Bar sleeping I don’

t take mine off now that its getting colder, they are not quite as stiff as they were when

they first arrived but still extremely comfortable. It would be nice if they had a little

more arch support but other than that I’m very pleased. I am finding a nice
mbt shoes sale!

Posted by: Mbt shoes at November 5, 2009 02:53 AM

Uggs on sale now.UGG Classic Cardy Boot makes me different form the other

girls. The UGG Bailey Button Boot is a good choice for female.

Posted by: ugg classic cardy boots at November 17, 2009 12:40 AM

The 39.html">classic cardy uggs boots is another hot boots that worth of buying.And the classic tall ugg boots
will make your winter amusing.And now uggs on sale,if you are looking for such a boot,the ugg boots is good choice this year.

Posted by: UGG Bailey Button Boots at November 17, 2009 01:04 AM

www.enjoywholesale.com

china wholesale clothing,china wholesale shoes,china wholesale electronics,china wholesale suppliers,china manufacturers

china wholesale products,light in the box,wholesale lots,wholesale ipod
china direct,china dropship,china trade,made in china

electronics wholesaler,ebay wholesaler,financial wholesaler
fashion wholesaler,clothing wholesaler,wholesaler magazine

computer wholesaler,external wholesaler,dvd wholesaler,wholesaler definition,china wholesaler,mutual fund wholesaler,define wholesaler,insurance wholesaler


discount ugg boots
forture
ugg boots
Discount store

Posted by: wholesaler business website, net shopping site, external wholesaler,dvd wholesaler,wholesaler definition,china wholesaler,mutual fund wholesaler,define wholesaler,insurance wholesaler at November 18, 2009 02:52 AM

Mbt shoes are promotion now,Mbt sport shoes and Mbt m walk hot onsale

Posted by: mbt shoes at November 19, 2009 01:46 AM

Mbt shoes are promotion now,Mbt sport shoes and Mbt m walk hot onsale

Posted by: mbt shoes at November 19, 2009 01:47 AM

We are the best online sales for the china wholesale . Here you can have a large of choices of kinds Ugg Boots,Converse Shoes,Timberland Boots,puma shoes,Nike Shox Shoes ,Nike Dunk SB Shoes,Nike Air Max,Links Of London,Tiffany Jewelry,Dior Handbags?,jimmy choo handbags ,Cartier Watches, 8GB Mp4 Players,Bluetooth Car DVDs. All our cheap online cheap goods are high quality and original packages, and best service. We offer our customers the best service, 7 days arrive at your door.Enjoy your easy and happy shopping with us.

Posted by: cheap goods sale. at November 20, 2009 01:30 AM

Laptop Battery Laptop Battery Laptop Batteries
Laptop Batteries discount laptop battery
discount laptop battery
notebook battery notebook battery
computer battery computer battery
replacement laptop battery replacement laptop battery
notebook batteries notebook batteries

Posted by: Laptop Battery at November 24, 2009 11:00 PM

People all over the world know the abercrombie and fitch,but not everyone really knows how fashion the abercrombie is,hollister is the Legend maker. Everybody wears the hollister clothing would be the abercrombie mens and the abercrombie womens, if you want know you can search the Ruehl No.925 or abercrombie outlet in the www.google.com .

Posted by: fitch at November 25, 2009 09:45 PM

Ugg Classic Cardy

Boots

Ugg Classic Tall

Boots

Ugg Classic Short

Boots

Posted by: topuggshoes at November 26, 2009 02:35 AM

chaoying nfl jerseys
Giants Jerseys
Patriots Jerseys
Packers Jerseys
These things are good, I hope you can continue to maintain!


Posted by: jerseysleague at November 29, 2009 03:43 AM

Paul Smith has been collaborating with a few different organizations recently and his latest venture sees him teaming up with Japanese bicycle saddle, Paul Smith bag, on a limited edition leather saddle. The release features Smith’s signature stripes where only 20 will be available at Paul Smith Clothing store in Japan and 8 at the Floral Street store in London. Get on it quick

Posted by: dasf at November 29, 2009 11:45 AM

Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far
ugg bailey button
Wow, my ugg classic mini will not be coming off now! I’ve had them on for 12hrs strait and I do not want to take them off. Thanks for everything, well worth the wait.

Posted by: ugg bailey button boots at November 30, 2009 05:50 AM

It is no doubt that Replica Louis Vuitton Speedy 30 enjoys highest reputation in the world. Louis Vuitton Speedy 30, purses, shoes, watches, clothes, and belts successfully seize loving heart of a majority of people. Speedy 30 is filled with romantic and fantasy, and it is a symbol of noble and high quality of life for gucci ever! Today, let us talk about Tivoli PM.belts have different styles and colors, such as Monogram series belts, Graffiti series belts, both men and women love them crazily. All of them match with various leisure clothes, formal business suits, and beautiful clothes very well. Whenever you wear a Louis Vuitton belt to make your public appearance, you will be naturally concerned and admired by every body. When we talk of high quality, there is no other company to compare with Louis Vuitton Replica Speedy 30. All Louis Vuitton belts adopt top quality cow leather, high quality hard ware, and the color will never be faded. The belts are so durable, and you can wear them to match your clothes for several years. Also, you can clearly see an obvious LV logo as a buckle of each belt.

Posted by: fanqin at December 1, 2009 02:14 AM

uggs on sale
ugg classic tall

Posted by: ugg boots sale at December 1, 2009 02:55 AM

Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far
click here
auto profit launcher review
immediate list profits review
howies apprentice 5 review
ppcloophole review
list laundering review
my cash printer

Posted by: Allio at December 2, 2009 04:08 PM

ugg boots sale at a time when large heat has set off a winter 08/09 to Ewha.Outlines the

warm wool winter fashion degree to wool crocheted wool ugg boots uk to join after the

body does not stimulate your skin soft, soft comfort UP. Fashion can not without
ugg boots presence in Winter.and ugg boots have many series.such as:
ugg classic
UGG Bailey Button boots
ugg nightfall
ugg kids

Posted by: uggboots at December 2, 2009 08:44 PM
Post a comment









Remember info?




Prove you're human. Type "human":