Hecl Syntax: A Survey

[ Taken and modified from a post to the hecl-devel mailing list ]

I’ve been talking with a company about a consulting job regarding a programming language for mobile apps. Sounds familiar, right?

There is, however, a bit of discussion regarding the syntax – my contact at said company maintains that Hecl‘s syntax is unfamiliar to many programmers, and I think on the face of it, I’d have to agree. Of course, Hecl’s syntax is like it is because when I started the project, being very small was a necessity, and a very simple syntax facilitated that goal nicely. Additionally, the syntax allows for extreme flexibility, letting you create new control commands, and “DSL’s” (domain specific languages) easily. Also, sticking with small/simple means that the interpreter and parser can both reside on the phone, instead of doing some kind of solution where the development/host computer compiles the scripting language to byte code, and the interpreter on the phone runs the byte code. That sort of strategy has some advantages, but has disadvantages too: if you don’t have an on-board parser, you don’t get “eval”.


A quick Hecl syntax refresher:

In Hecl, everything is a command, seperated by spaces, and grouped with {}:

if { ... } { ... }

Is a command that takes two arguments. It evaluates the first one, and if it’s true, evaluates the second one. This is different from languages like C, Python or Ruby, where ‘if’ is part of the language. For those unfamiliar with languages like Lisp, where this looks strangest is probably in conditions or other expressions:

if { = $foo 10 } { puts "foo is ten" }

Or

set foo [+ [* $bar 10] [- $beebop $doowah]]

Which is certainly a different take on things than most ‘mainstream’ languages. That radical simplification is, however, one of the ways that I used to save space in the interpreter.


Personally, I’m pretty happy with how Hecl looks, but I am sensitive to the ‘marketing’ argument: popularity helps, and this isn’t the first time I’ve heard complaints about Hecl looking “funny” to people.

What do you think?

A) “I like Hecl just the way it is and wouldn’t want to change it!”

B) “Hecl is quite useful, but I just want a mobile scripting language, the syntax doesn’t matter much.”

C) “I think the syntax is ugly, but I use it because I need an interpreter.”

Also related:

1) “I don’t care too much about code size. My current apps target N kb as an acceptable size.”

2) “Small is really important. The smaller the better.”

And:

I) “I don’t care about eval, or being able to run human readable code on the phone.”

II) “I really like the fact that you can download or even write code directly on the phone.”

And finally:

X) “I don’t care about midp1.0”

Y) “The fact that Hecl runs on midp1.0/cldc1.0 is important to me.”

Now, I am not going to run off and change Hecl! Code that currently runs ought to continue to run, modulo some tweaks here and there, api changes, and the normal stuff. If I do something ‘new’, it would probably be a clean break (although of course code that could be reused would be), and will be in addition to Hecl, rather than instead of Hecl, because I would be working on the ‘new’ language as a day job. I do that with Hecl too, but not all the time, as I often have consulting/contracting work.

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s