Saturday, July 07, 2012

Types and Bugs

There are certain discussions in our biz that are so played out they provoke instant boredom upon encounter. A major one is the old dynamic vs. static skirmish, recently resurfaced in a blog post by Evan Farrer. Which is a shame as the post is quite interesting, describing his results transliterating well-tested code in a dynamic language to a static language to see if the type system found any bugs. Which it did.

The full-length paper is a great read as well. He describes his translation methodology and gives some detail on each bug found. At first it may seem the author could be stacking the odds towards the static language as the translation was manually done by himself, but I found his description of the process pretty convincing of its fairness. The choice of Python as a source language probably helped given the pythonic inclination towards straightforward code that avoids sophisticated abstraction and metaprogramming mechanisms.

But the real meat of the paper is in the description of the bugs he found. Upon a not particularly discriminating reading, a clear pattern jumped out. Most of the bugs fell into one of two categories:
  • Assuming that a variable always references a valid value when it can contain a null value. 
  • Referencing constructs that no longer exist in the source.
The first category is also the largest, comprising several places where the original code could be coerced into letting a variable be set to a null value, usually by just leaving it uninitialized, and a subsequent call would attempt to derefence it assuming it contained a valid value. Haskell's type system avoids the problem as it  simply doesn't have any notion of null. Code that has to deal with optional values must do it trough algebraic data types.

How the second category of bug comes about is easy to guess from the projects histories: some method or variable was present but changed, perhaps it was renamed or subsumed, and not all references were updated to reflect the change. Even pervasive unit tests can't hope to catch these kinds of regressions, as the problem is found on the integration between units of code; the units themselves are just fine. A type system helps when the change affects the signature of the referenced construct, which is often but not always.

If the study's findings are generalizable and my observations are correct, these are the main takeaways:
  • If you have a type system at your service, it's prudent to structure code such that behavior-breaking changes are reflected on the types.
  • End-to-end integration tests are a necessary complement to both a suite of unit tests and a type system. In my experience how far should these tests stray off the happy path is a difficult engineering trade-off.
  • If your type system allows nulls — such as Java's, for instance — its role in bug prevention is greatly diminished. The proportion of null-dereference bugs on the analysed code bases helps to makes it clear just how big a mistake it is to allow nulls in a programming language. 

44 comments:

Unknown said...

Why watch for a period of time suddenly go fast, travel time is not stable? Automatic mechanical watches with shockpro of omega replica ability, but if the impact Too large, such as vigorously waving wrist, the impact will make spring up together, to watch too fast or even shut down; more impact will let out of hublot replica watch hairspring,Damping device off, the speed of the needle dislocation, which is fatal for the speed control system. Often suffer from great impact, will make winding efficiency, even failure.What is the "luminous table"? And what is the difference between the electroluminessent table Commonly known as the "luminous table" refers to the nail on the hands or word coated with fluorescent powder, in the dark or light visible hand nail hand Table. There is also a kind of luminous watch is in the middle of 90s appeared to make the entire surface of the fluorescent light. The difference between the two is as follows: 1.luminous watch by Absorption of natural light energy, while the power of yha-travel-insurance the electric meter can be relied on the battery. 2.luminous watch the "glow" light is visible only in the dark, but as long as the electric fluorescent table The corresponding according to the system at any time can shine. 3 light emitting time luminous watch by absorption time and light intensity limit, the electric battery power limit by fluorescence.

vigneswaran said...

There are lots of information about Selenium Testing have spread around the web automate, but this is a unique one according to me.
Selenium Training in Chennai

Unknown said...

When I took possession of the Rolex Submariner,a couple things jumped out at me. First, and this is always nice to find, it had its original Origina Replica Breitling Twinlock crown (Triplocks came later at around the 3M serial number). So many 1:1 Replica Rolex Watches have lost their original crowns to Triplocks along the way,In a weird twist of irony, the Omega Watches Robert-Jan wrote about from this year’s Baselworld contained a Cyclops for the first time in its history. Hermes handbags , in its self-pronounced desire to push innovation.

Ammu said...

Great post.

Thanks,
Lakshmi,
Best Angular Training Institute in Chennai

Pankaj Singh said...

Thank you much for this tutorial; this is an informative and valuable blog. Visit for
Offshore Anonymous Hosting

alex said...

I play a lot and win, what are you capable of? best online casino games with us Play, win or be defeated.

service care said...

Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definitely interested in this one. Just thought that I would post and let you know. Nice! thank you so much! Thank you for sharing.
samsung service centres in chennai
samsung mobile service center in velachery
samsung mobile service center in porur

jvimala said...

Really awesome blog. Your blog is really useful for me
Regards,
Best Selenium Training Institute in Chennai | Selenium Course in Chennai

luckys said...

whatsapp groups

luckys said...

1movies

luckys said...

gomovies

whatsapp plus said...

mobile whatsapp groups

whatsapp plus said...

mobile whatsapp groups

Devender Gupta said...

dtc bus app
dtc bus
dtc bus app download
dtc bus pass
dtc bus route
dtc bus route app
dtc bus app download

Devender Gupta said...

dtc bus app
dtc bus
dtc bus app download
dtc bus pass
dtc bus route
dtc bus route app
dtc bus app download

Devender Gupta said...

funny WiFi names
cool WiFi names
claver WiFi names
cool and claver WiFi names
funny WiFi names list
Good wifi names
wifi names 2020
Disney wifi names
wifi name for gamers
bollywood movies funny WiFi names

shivam said...

Flying Shift - Packers & Movers in Bhopal

easylearn said...

Hi,
Good job & thank you very much for the new information, i learned something new. Very well written. It was sooo good to read and usefull to improve knowledge. Who want to learn this information most helpful. One who wanted to learn this technology IT employees will always suggest you take python training in pune. Because python course in pune is one of the best that one can do while choosing the course.

Abhishek rajpoot said...

WhatsApp Status Video Download :WhatsApp introduced the status feature in 2015, in which we can share images, videos, and gifs as our story for 24 hours. Before this feature, WhatsApp had only text status option in which we can write our bio, but the new status feature is different. The story or status disappears after 24 hours and can’t be archived as still in WhatsApp.

Boy attitude status video download for whatsApp
Boy attitude status video download
Boy attitude status video download

Most romantic status video download for whatsApp
Sad video status download
Most Romantic status video download

video status download for whatsApp


we have latest & best collection of video status download for whatsapp

khushboo said...

The registrations and auditions for the Bigg Boss 13 are going to start soon. The official list of contestants is not yet announced by the officials. That will be announced by the makers on the inaugural day which is 15 the of September. bigg boss 13 contestants name list with photo Though a few rumored names are coming up as the expected celebrity contestants of the year. They are Nia Sharma, Raghav Juyal, Punit Pathak, Divyanka Tripathi, Garima Chaurasia, Ridhima Pandit, Aditya Narayan, Jasmin Bhasin, Zain Imam, Bhuvan Bam, Chetna Pande, Krystle D’Souza, and Devoleena Bhattacharjee. This year too, the show will be back with a new theme and the star host, Salman Khan. Though the theme is not declared yet officially. Stay tuned with us to know more about the show Bigg Boss 13.

gokul said...

Thanks for this informative blog
Top 5 Data science training in chennai
Data science training in chennai
Data science training in velachery
Data science training in OMR
Best Data science training in chennai
Data science training course content
Data science certification in chennai
Data science courses in chennai
Data science training institute in chennai
Data science online course
Data science with python training in chennai
Data science with R training in chennai

Vijiaajith said...

Very nice
freeinplanttrainingcourseforECEstudents
internship-in-chennai-for-bsc
inplant-training-for-automobile-engineering-students
freeinplanttrainingfor-ECEstudents-in-chennai
internship-for-cse-students-in-bsnl
application-for-industrial-training

Vijiaajith said...

nice
interview-

questions/aptitude/permutation-and-

combination/how-many-groups-of-6-persons-can-be-

formed


tutorials/oracle/or

acle-delete


technology/chrom

e-flags-complete-guide-enhance-browsing-

experience/


interview-

questions/aptitude/time-and-work/a-alone-can-do-1-

4-of-the-work-in-2-days


interview-

questions/programming/recursion-and-

iteration/integer-a-40-b-35-c-20-d-10-comment-about-

the-output-of-the-following-two-statements


Devender Gupta said...

WhatsApp group links

MIUI theme

Devender Gupta said...

Dr Driving is one of the my favourite game ever and today I am going to share Dr Driving Mod Apk
https://www.drdrivingmodapk.xyz/

Nicolay said...

Nice article

Bulletproof Domain Registration

Vijiaajith said...

how to hack flipkart payment
react native developer resume
group selector css
chemistry interview questions
sample complaint letter to bank for wrong transaction

Vijiaajith said...

javascript int max value
passage writing in fiserv
vijay invested rs.50,000 partly at 10% and partly at 15%. his total income after a year was rs.7000. how much did he invest at the rate of 10%?
residue on ignition
the simple interest earned on a certain amount is double the money

mary Brown said...

Great Article. Thank you for sharing! Really an awesome post for every one.
Project Centers in Chennai

JavaScript Training in Chennai

Final Year Project Domains for IT

JavaScript Training in Chennai

Swetha K said...

Such a nice article thanks for sharing this with us. Really so impressible and interesting post. You’re doing a great job Man, Keep it up.
Excel Training in Chennai
Excel Course in Chennai
Tableau Training in Chennai
Linux Training in Chennai
Oracle Training in Chennai
Advanced Excel Training in Chennai
Job Openings in Chennai
Oracle DBA Training in Chennai
Pega Training in Chennai
corporate training in chennai
Power BI Training in Chennai
Excel Training in Anna Nagar

pnjsharptech said...

PNJ Sharptech is a leading Social Media Optimization company in India, specializing in handling both organic and paid Social Media Marketing (SMM) campaigns successfully. We have many years of experiencing increasing online social presence on various social media platforms such as Facebook, Twitter, LinkedIn and Pinterest, and many others. Our SMO experts have a rich knowledge of increasing traffic and maintaining the online social reputation for a long period. How our SMO services make you different from others? Our low-cost social media marketing services are very helpful to build your online reputation and increase sales.

BB Arora said...


40 Lakh mp3 song download pagalworld, tik tok viral song ,Mr jatt. GetSongName.com – Presenting the audio song ” 40 Lakh ” this song by Jerry Burj Ft. Ellde Fazilka , song is been written Ellde Fazilka40 Lakh mp3 song download pagalworld

BB Arora said...

Presenting Latest New Bollywood Song Lyrics of Fauj Ki Dahaad Song Lyrics Mr. BratBea From Kartikeye Ojha & Pranshu Jha . The latest Upcomin Movie Code M Song Fauj Ki Dahaad Lyrics are written by Kumaar Mr. BratBeat and Music Directed by Kartikeye Ojha & Pranshu Jha

Fauj Ki Dahaad Song Lyrics Code M | Mr. BratBeat

Unknown said...

Good post....thanks for sharing.. very useful for me i will bookmark this for my future needs. Thanks.
Aloha Browser Turbo For PC

web design company said...

thanks for your information.it's really nice blog thanks for it.keep blogging.
web design company in nagercoil
website design company in nagercoil
web development company in nagercoil
website development company in nagercoil
web designing company in nagercoil
website designing company in nagercoil
digital marketing company in nagercoil
digital marketing service in nagercoil

python coaching said...

Check for full practical courses:
python course in coimbatore
java course in coimbatore
python training in coimbatore
java training in coimbatore

Daniel Bryan said...

Graceful written content on this blog is really useful for everyone same as I got to know. Difficult to locate relevant and useful informative blog as I found this one to get more knowledge but this is really a nice one.
digital marketing service provider

glass artwork said...

thanks for your details.
glass art work in pondicherry
glass painting work in Pondicherry
glass artwork in Puducherry
glass painting work in Puducherry
glass wall art in Pondicherry
glass artist in Pondicherry
church glass artwork in pondicherry
wedding hall glass artwork in Pondicherry
temple glass artwork in Pondicherry
mosque glass artwork in Pondicherry
interior glass artwork in Pondicherry
marriage brokers in nagercoil
nadar matrimony in nagercoil
thirumana thagaval maiyam in nagercoil
nagercoil matrimony
csi matrimony nagercoil
hindu matrimony in nagercoil
christian matrimony from nagercoil
matrimony in kanyakumari
matrimony in marthandam

renshiya said...

thanks for your information.
web design company in nagercoil
best web design company in nagercoil
website design company in nagercoil
web development company in nagercoil
website development company in nagercoil
web designing company in nagercoil
website designing company in nagercoil
digital marketing company in nagercoil
digital marketing service in nagercoil
seo service in nagercoil
seo company in nagercoil
social media marketing in nagercoil
ppc service in nagercoil
web design company in nagercoil
best web design company in nagercoil
web design company in nagercoil
website design company in nagercoil
web development company in nagercoil
website development company in nagercoil
web designing company in nagercoil
website designing company in nagercoil
digital marketing company in nagercoil
digital marketing service in nagercoil
seo service in nagercoil
seo company in nagercoil
social media marketing in nagercoil
ppc service in nagercoil

renshiya said...

thanks for your information.nice blog.
glass art work in pondicherry
glass painting work in Pondicherry
glass artwork in Puducherry
glass painting work in Puducherry
glass wall art in Pondicherry
glass artist in Pondicherry
church glass artwork in pondicherry
wedding hall glass artwork in Pondicherry
temple glass artwork in Pondicherry
mosque glass artwork in Pondicherry
interior glass artwork in Pondicherry
marriage brokers in nagercoil
nadar matrimony in nagercoil
thirumana thagaval maiyam in nagercoil
nagercoil matrimony
csi matrimony nagercoil
hindu matrimony in nagercoil
christian matrimony from nagercoil
matrimony in kanyakumari
matrimony in marthandam
glass art work in chennai
glass painting work in chennai
glass artwork in chennai
glass painting work in chennai
glass wall art in chennai
glass artist in chennai
church glass artwork in chennai
wedding hall glass artwork in chennai
temple glass artwork in chennai
mosque glass artwork in chennai
interior glass artwork in chennai

Photo Tour said...

I don’t know if it’s just me or if perhaps everyone else encountering problems with your blog. It appears as if some of the written text in your posts are running off the screen. Can somebody else please comment and let me know if this is happening to them too? This may be a issue with my web browser because I’ve had this happen before. Thanks https://royalcbd.com/product/cbd-oil-1000mg/

shane lee said...

With so many to choose from it can be difficult knowing which one is the best service for you. how to choose best stocks for next day

merlin said...

It's very useful blog post with inforamtive and insightful content and i had good experience with this information.
Selenium Training in chennai | Selenium Training in annanagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery

Data Analytics Cerification Training Course in Hyderabad said...

Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also.
Data Analytics Course in Hyderabad