Recommendation: use strict

BlitzMax Forums/BlitzMax Programming/Recommendation: use strict

Warren(Posted 2005) [#1]
Trust me, use strict. Even if you only turn it one once, clean up the errors, and turn it off again.

I'm converting a bunch of old Blitz code that seemed to work perfectly fine - and strict has uncovered 3 bugs so far that I never noticed before...


Jeremy Alessi(Posted 2005) [#2]
Nice!


Bot Builder(Posted 2005) [#3]
lol. Yeah, I've seen a number of bugs in code people hae postd that didnt cause a crash or malfunction but caused bad efficiency. Could have been prevented with strict.


RexRhino(Posted 2005) [#4]
Or better yet, make strict the default, and make people have to declare "nonstrict"! :)


ImaginaryHuman(Posted 2005) [#5]
I think that in the bigger picture it's good to give people the option to choose for themselves whether they want something to be `enforced` or not. Just making strict be a default that can't be turned of is, to me, offensive. I would of course have to play along but reluctantly. I also don't think it is always necessary. It might be a good recommendation for newbies to help to produce better code. But as always, what suits one person doesn't suit them all. I prefer that they've given us the option of freedom.


Warren(Posted 2005) [#6]
Strict always helps, it never hurts.


VIP3R(Posted 2005) [#7]

Strict always helps, it never hurts.


Until you need to use 'Goto' within several nested For-Next loops eh Warren :P

Good idea to use it as a temporary debugging method though, I'll bet there is quite a bit of old BB code out there containing a multitude of passive bugs that Strict would've prevented.


Warren(Posted 2005) [#8]
Until you need to use 'Goto' within several nested For-Next loops eh Warren :P

Yeah, that sucks, but it's like taking a sports car back to the dealership because you don't like the color of the ash tray.


Craig Watson(Posted 2005) [#9]
Strict is good, but I think we need more options than just strict. It will allow people to program more in the manner they are most comfortable with.

Something like strict declaration, strict case, and strict basic. You'd be able to combine them so you could force people to declare variables in the same case and not use old basic style programming. Or vice-versa. Programming in a stricter manner could lead to faster code for those who care.


Bot Builder(Posted 2005) [#10]
Faster? Why would it be faster? Perhaps faster compilation. Not faster execution.


Craig Watson(Posted 2005) [#11]
Even though I know you know the answer, for completeness anyone else can look on this thread for comments from Mark as to why strict can produce faster code.

I still think we need more compiler options anyway by the way :P


Warren(Posted 2005) [#12]
I think it's because strict doesn't have to allocate variables it doesn't come across, whereas non-strict code has to allocate everything "just in case" or something along those lines.

So it will run faster, but I doubt it makes enough of a difference to really matter all that much.


Craig Watson(Posted 2005) [#13]
Kind of, but also because you'll require less support instructions for some of the features you can't use.

I'm guessing that strict would use some assembly code routines that are more efficient and shorter than non-strict because you have less surprises to expect.

It's like with some other compilers you have the option to for example drop array bounds checking, which can speed things up a little if your code is well behaved.

You're right though, it'd be unlikely to make that much of a performance difference but it may become more important as the compiler matures.