Should I be using Strict Compilation mode ?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Should I be using Strict Compilation mode ?

Post by Simon Knight » Wed Jul 22, 2020 7:34 am

Hi All,

My question is in the title : should I be using Strict Compilation mode when writing scripts?

I have tried it and very occasionally it has help identify a typo in a variable name and consequently I have got into the habit of using copy and paste more. Also I try to keep the length of each of my handlers short enough to be displayed in full on the screen which is an aid to debugging

I find using the mode breaks my code writing flow so I don't use it. But I wonder if I am missing something so what are your thoughts and opinions?
best wishes
Skids

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Should I be using Strict Compilation mode ?

Post by FourthWorld » Wed Jul 22, 2020 7:56 am

It's implemented as a preference option for good reason. Some prefer it, some don't.

My own experience is like yours: I see where it can be useful, but in an xTalk I find the impact on my flow more than offsets the modest benefit.

For me the bigger issues with scripting aren't the sorts of things Strict Compilation can detect. I'm more interested in exploring support for those, like Clang-level error diagnostics, or optimization suggestions, or just having an IDE that can switch out of debug mode in less than 20 seconds.

I'm pretty good with spelling and naming conventions; what bogs me down is far outside of what that can address.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Should I be using Strict Compilation mode ?

Post by bogs » Wed Jul 22, 2020 9:20 am

FourthWorld wrote:
Wed Jul 22, 2020 7:56 am
what bogs me down...
I did not! :wink:

As Richard says, there is no right or wrong in this, it really depends on your background / workflow. If you come from a background where structure / exactness counts, by all means turn it on and run with it.

I like it in loosely typed languages like this, but even I often run without it for short span code.
Image

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Should I be using Strict Compilation mode ?

Post by Simon Knight » Wed Jul 22, 2020 9:24 am

Thanks Richard for confirming that I'm not missing some hidden feature of the mode. I shall continue with it switched off. Of course it will be interesting to hear a counter view.

Err what time is it in your neck of the woods - I thought you were on the wrong side of the pond so it must be early ;-)

Bogs - titter! I find that whenever I use it I wish it reported something like "Oi dummy, you declared these variables then did not use them"
best wishes
Skids

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Should I be using Strict Compilation mode ?

Post by bogs » Wed Jul 22, 2020 9:49 am

Simon Knight wrote:
Wed Jul 22, 2020 9:24 am
Err what time is it in your neck of the woods - I thought you were on the wrong side of the pond so it must be early ;-)
4:30 am here at the moment, I keep weird hours though having spent 3/4 of my life on the graveyard side of the day. Now that I'm going for a trade that operates mostly in the day time, I do indeed feel I am on the wrong side of a LOT of things.
Simon Knight wrote:
Wed Jul 22, 2020 9:24 am
I find that whenever I use it I wish it reported something like "Oi dummy, you declared these variables then did not use them"
It does a lot of different little things, but primarily it tells you when you didn't declare a variable. Since this language thrives on variables created on the fly, I think in this case it is mainly for catching typos.

You mentioned 'copy / paste', well, way back in my earlier days when starting out programming, before text editors had evolved to what they are now, I used to keep two of them open and write variables I was using with a brief description of why I was using them in one, and as I was writing code would reference that in the other.

Before GUI text editors (when edlin was king more or less), I did the same thing as a chunk at the beginning of whatever I was coding. Of course, it is hard to compare those times to now hahah. Most text editors are capable of auto-complete that takes things you typed in previously and suggests them as your typing, something a lot of IDEs do as well (but not this one as far as I can tell).

Since that is the case, whenever I'm writing something complex (for me), I tend to go with strict just so I don't make an "ID10T error", otherwise known as a stupid mistake.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10341
Joined: Wed May 06, 2009 2:28 pm

Re: Should I be using Strict Compilation mode ?

Post by dunbarx » Wed Jul 22, 2020 1:39 pm

I never use it. I find it trips me up in the very middle of writing incorrect code, and I will not tolerate that at all.

Craig

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Should I be using Strict Compilation mode ?

Post by bogs » Wed Jul 22, 2020 2:14 pm

Heh, and thats one of the reasons I do like using it, I don't want to make the engine 'guess' at what I meant for it to do :P
Image

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Should I be using Strict Compilation mode ?

Post by jacque » Wed Jul 22, 2020 5:57 pm

I don't use it. Like the OP, I like to keep my handlers as trim as possible, and the declarations at the top seem like a waste of space to me. I don't make many typos because I use copy paste most of the time, though I do occasionally get caught out, but it's pretty obvious when that happens and rare enough that it doesn't bother me.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Should I be using Strict Compilation mode ?

Post by jacque » Wed Jul 22, 2020 6:05 pm

My own experience is like yours: I see where it can be useful, but in an xTalk I find the impact on my flow more than offsets the modest benefit.
I wonder if it depends on your background. Those who came from older xtalks where not only wasn't it required but it wasn't even possible, have developed self-preservation methods. Those who come from other languages where it was required can't imagine working without it.

This has come up before and is something of a religious argument. There are occasional strong opinions.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Should I be using Strict Compilation mode ?

Post by bogs » Wed Jul 22, 2020 6:34 pm

jacque wrote:
Wed Jul 22, 2020 6:05 pm
This has come up before and is something of a religious argument.
Bless you young lady... :P

Just kidding. I have no firm conviction on it either road, if you use it and like using it, it works, if not, that works too, but you brought up some interesting points.
jacque wrote:
Wed Jul 22, 2020 6:05 pm
Those who came from older xtalks where not only wasn't it required but it wasn't even possible, have developed self-preservation methods. Those who come from other languages where it was required can't imagine working without it.
I come from the latter group for the most part, but I can well imagine working without it (because I sometimes do). Most of the Basics I used after C had ways to work around primary declaration, but it was still recommended. In Delphi, at least when I used it, much like C, you had to have pointers to the memory you were going to use for a variable, and you had to remember to remove the same.

SmallTalk, which I also spent some time in, where everything and anything is an object unto itself, was a completely different bag. I don't remember enough about Hypercard really to say much about it.

I still think it is a good idea to pre-declare vars and setup the memory for them, regardless of whether your handling the gc or the language is, but that is probably just me.
jacque wrote:
Wed Jul 22, 2020 5:57 pm
I don't use it. Like the OP, I like to keep my handlers as trim as possible, and the declarations at the top seem like a waste of space to me.
Heh, I can't imagine how many vars your going to declare in one handler that make up such waste. At declaration, after all, vars can go one after the other separated by a comma, heh, and if it is a global var(s), you have to declare that at least anyway. Whether you do it at the top of the script, within a handler, or between handlers as you think about needing them, I don't see much that your saving.

Disclaimer: Much of what is written above is from the "...as if you don't already know this..." department. Brush your teeth at least twice a day. An apple a day *might* keep the doctor away, but if not, Limburger cheese certainly will do the job!
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Should I be using Strict Compilation mode ?

Post by FourthWorld » Wed Jul 22, 2020 7:50 pm

jacque wrote:
Wed Jul 22, 2020 5:57 pm
I don't use it. Like the OP, I like to keep my handlers as trim as possible, and the declarations at the top seem like a waste of space to me. I don't make many typos because I use copy paste most of the time, though I do occasionally get caught out, but it's pretty obvious when that happens and rare enough that it doesn't bother me.
Reminds me: what key modifier do you use in your plugin to copy mouseText to the current selection, and what do you call that feature?

I've been commission to write a script editor, and I'd like to include that, with a mention in the About box 'cause it's super handy.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Should I be using Strict Compilation mode ?

Post by jacque » Wed Jul 22, 2020 9:25 pm

I use Cmd-Shift-space (you have to train your hand to contort that way) and it's part of a larger dev backscript so it doesn't have its own name, it's just part of a switch construct. But the idea wasn't mine, someone on the list mentioned it years ago and I believe they called it "scriptPaint". It does screw up the LC script editor's Undo function pretty badly so I have to be aware not to use Undo until I've saved the script (which is why I don't advertise it.) You'll want to revise your editor to account for that because its behavior is invisible to the LC editor.

If anyone wants to try it, someone else got around the problem by issuing a "type" command that types a space and then deletes it, which jogs the editor into recognition. I just never bothered, I'm so used to it now.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Should I be using Strict Compilation mode ?

Post by bogs » Wed Jul 22, 2020 10:52 pm

FourthWorld wrote:
Wed Jul 22, 2020 7:50 pm
I've been commission to write a script editor...
For the IDE ? You know, that would be fascinating enough for me to actually download whatever one it winds up in, just to see your take on it :D
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10055
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Should I be using Strict Compilation mode ?

Post by FourthWorld » Wed Jul 22, 2020 11:44 pm

bogs wrote:
Wed Jul 22, 2020 10:52 pm
FourthWorld wrote:
Wed Jul 22, 2020 7:50 pm
I've been commission to write a script editor...
For the IDE ?
It's a plug-in, but yes, it's a drop-in replacement for the IDE's SE. It won't have all the same features, by design. The emphasis is on simplicity, for performance and robustness. In some ways it'll be a minimal take on editing, but at least you'll be able to stop debug mode without waiting for 30 seconds. ;) (Though that particular issue isn't exactly a fair comparison, because this one completely separates editing and debugging into two different tools, like MC did originally, and like most editors and debuggers do; attempting one tool doing multiple roles which are very different is where a lot of complexity comes from.)
You know, that would be fascinating enough for me to actually download whatever one it winds up in, just to see your take on it :D
Motivating - thank you. It's been so busy over here with commercial client work that this editor has taken longer than I'd prefer, but it's nearing the point where I'll be using it for my work so shortly after that it should be tidy enough to share.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Should I be using Strict Compilation mode ?

Post by bogs » Thu Jul 23, 2020 12:42 pm

Sounds intriguing, as a plugin, how far backwards would it be compatible?

You know, I always wondered something that is kind of related to debugging as well as strict mode, and that is this. Lots of languages I've used previously had a way to strip the debugging code and symbols from the final exe file, even after it was assembled into an executable/standalone. I was looking for the last year, off and on, but haven't found any such in this language. You've been in xtalks a long time, you know of any such?

If the question isn't clear, feel free to say it isn't, I'll try to come up with an example of what I'm referring too.
Image

Post Reply