The limits of weak typing

Hecl is a weakly typed programming language, which, for a scripting language is often an advantage. Instead of cluttering your code with lots of (casts) or performing.to_s all the time, things “just work” depending on the context (and assuming that you’ve verified your data or have error handling for when things go wrong).

I’ve been pondering a weakness of this model that Tcl doesn’t adequately solve, discussed here:

The summary is that if anything can and will be converted to a string at some point in its lifetime, GC’ing “complex objects” (things that can’t be represented by a string) gets difficult. In order to be able to go back to an object from a string, you have to maintain a hash table with string handles that point at the actual objects in whatever language you are using, and that in turn requires that you somehow keep track of the lifetime of those objects. Doing GC in Hecl itself is something I’d hoped to avoid – up until now, we have managed to get by ok with Java’s GC.

The ‘best’ solution seems to be Salvatore’s, discussed here:

But even that is relatively complex, and at least initially, involves a couple of tours through the entire string-space of the running program.

Unfortunately, I don’t think there’s really a clever way around the problem, though… what the weak typing giveth, the weak typing taketh away (or something along those lines).

I am not sure what this means for Hecl at this point, whether we simply say “clean up after your own objects”, introduce some sort of string typing, or something else entirely…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s