Live data from Hacker News

The Applied Theory of writing bug-free code

sites.google.com

31–32 of 32 posts

Re: The Applied Theory of writing bug-free code

#31

Earlier quoted context omitted.

Have you written in anything from the ML family? I strongly recommend you take a look at OCaml or Haskell. I believe you will find that static typing, when done right, is immensely helpful.

I'm using language without static typing for most of my work and I can hardly remember any bug that was caused by having wrong type of data in unexpected place. I remember very well redundancy of using language with static typing, I know how much boilerplate code is needed in languages such as java, and how complicated can generics become in C# if you want to achieve fairly simple architectural things that can be con…

Ok. Those languages do static typing incorrectly. Try a language that sports type inference. It isn't redundant. There isn't boilerplate. The type system is far more powerful than in Java or C# (polymorphic types, polymorphic variant types, algebraic types and constructors, functors, etc).

You owe it to yourself to learn these systems. In many cases, there are type-side symptoms of logic-side bugs. If Haskell's laziness and purity scare you, try OCaml -- it's fast and straightforward.

Re: The Applied Theory of writing bug-free code

#32
post #30
post #29

Earlier quoted context omitted.

OK, what if it is a flag variable that is either undefined or an integer? That is, do you need to initialize all variables? Also, how about this? foo = 10 ... if ... ofo = 20 ... formula = bah * ( ... foo ... ) Edit: Please tell me the second case isn't as catastrophic as it looks? That would give at least me no ends of problems -- I thought modern languages left that kind of sh-t in the 1990s? Better have a good cul…

1) If you want to read the variable in some way, you need to initalize it. If you want to do weird things involving setting random attributes on an object and check if they exist.. well, you're on your own. Generally, I'd recommend for the flag variable to have a definite uninitialized value (say, None), as this is far easier to check. 2) The opinion of a lot of people on python is that the lack of such (impossible[1…

My second example would bite me quite often.

Do I get this right?

You have to do really hard line testing to avoid simple problems that could be avoided if just variables had to be declared at first use? :-(

But like old C compilers, there is "lint"?

I'm all for nostalgia for old C compilers (except a buggy one, that stole weeks of my life). But that is strange.

I thought Python was all about safety and no problems because of a well designed syntax and coding standards akin to bondage?

Ah well, thanks for information!

Post reply on HN