Programming language features that help to catch bugs early [closed]

Do you know any programming language features that help to detect bugs early in the software development process – ideally at compile-time or else as early as possible at run-time?

Examples of well-known and effective bug-reducing features are:

  • Static typing and generic types: type incompatibility errors are detected by the compiler
  • Design by Contract (TM), also called Contract Programming: invalid values are quickly detected at runtime (through preconditions, postconditions and class invariants)
  • Unit testing

I ask this question in the context of improving an object-oriented programming language (called Obix) which has been designed from the ground up to ‘make it easy to quickly write reliable code’. Besides the features mentioned above this language also incorporates other Fail-fast features such as:

  • Objects are immutable by default
  • Void (null) values are not allowed by default

The aim is to add more Fail-fast concepts to the language. If you know other features which help to write less error-prone code then please let us know. Thank you.

3

Go has a few:

  1. Any unused imports are errors (not sure if this is bug catching, certainly good code style)

  2. No implicit conversions, var i int = .5 is an error, not a warning or an automatic truncation.

  3. Keying off of 2, being strongly statically typed serves to catch many errors.

  4. Everything is 0 initialized (sensibly so) so there are no null pointers.

  5. Some sort of unit test support built in. I haven’t dug too deeply into this.

Another one that pops into my head is Haskell

  1. Strongly statically typed. Ask any Haskeller about the type system, it catches 99% of my haskell errors before I even get to running it.

  2. Design by contract to an extent Int->Int->Int though this would be encapsulated in most function declarations in languages

  3. Purely Functional. If a function works once in a scenario, it’ll always work.

However in general, good practices in a language with poor safety beat a careless programmer in a safe language. Take for example C (Not a jab at C, but it leans more on the user to double check that things are sane) clearly it is possible to write good robust code in C despite it’s lack of features for this. In the end the programmer>programming language.

1

Start by taking a long, hard look at the original Ada programming language, from 1983. Ada was designed specifically for writing highly reliable systems that would have very long life cycles.

Strong static typing. Strong semantics. Easily readable. Tasking built-in.

You can hack ’til you crack, but you have to WORK at it, and the resulting code LOOKS like it. This is a feature: it warns the next poor maintenance schlub that Here Be Dragons.

There’s a remark from the dawn of computing: Running with subscript checking enabled during checkout, and turning it off for production, is like wearing your lifejacket in the harbor and then taking it off when you go out onto the open ocean. Note that Ada required that subscript checking be turned ON by default, and required programmers to turn it off explicitly if they were so bold.

Some test I would like to have (probably not all of them all the time):

  • Boundary testing: Many errors occur on the bounds of the domain (like putting < in stead of <=). So if you could somehow support this, it would be grate. (Let the programmer define int[0-90] and so no value above 90 or below 0 will be allowed).
  • Robustness testing: Is almost the same as the above, but aims to test values that should not be supported, and see that the app doesn’t crash.
  • The above may be combined to one test -> the software doesn’t crash, and just testing random values from the whole domain (random integers, random strings)
  • Domain knowledge: A convenient way to insert tests by domain experts will be good. That means someone that has very good knowledge in banking but no clue in programming should be able to write some tests, according to his knowledge.
  • Program graph: Build a program graph, including branches and loops. And while running a set of tests, mark the lines of code tested, and those that where never touched. So the programmertester can know what part of the code was never tested. (May be time and space consuming)
  • Asserts: Give the programmer an option to make an assert while testing, that will be taken out by the compiler in production. This is a very old idea no one really implemented in a nice way (if at all).

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật