And…
In my other life, I work for New York City (Housing Preservation and Development, in particular), where code writing rules are enforced: these demand “very clean, clear,terse syntax” so that the code approaches this ideal of “describing what it is doing.” That particular environment demands such a use-case. Software developers come and go; the code they leave behind has to be readable by an influx of new-hires. ‘Sensible programming’ puts a premium on these readability ideas.
But G’MIC comes from a research environment — and very different use-cases prevail. Sometime last December, in a riff off of @David_Tschumperle 's How to write clean G’MIC code ? I veered into a post on G’MIC’s raison d’être: as stenography for graphical pipeline builders. A bit tongue-in-cheek of me, perhaps, but I can make my case: David (and colleagues) are very much involved in testing graphical ideas. From David:
So a tool that gets past the junk-thinking very quickly is desirable. Above all, that puts a premium on terseness, and, in a priority stacking, it’s terseness above clarity, by very deliberate design. The aim is to test ideas without the damn code getting in the way, without exasperating code ⇒ compile ⇒ test cycles, without leaving the shell. So syncopation rules: status
⇒ u
, append
⇒ a
, fill
⇒ f
, and — my favorite! — input
⇒
As with most design decisions, there are prices to be paid for a particular priority stacking:
Amen. The newcomers have to climb a steep learning curve.
However, there are silver linings. So while I am inventorying the various shortcomings in Tutorial Land, here is one of the most significant: “The Power of the Colon ( :
)”, as in:
< a nice, apt, and memorable name > : < hundreds of lines of terse, syncopated G’MIC code, full of weird, incomprehensible constructs that — dammit! — does very useful things, now if I can only figure out how it does it. >
The colon “operator” lies at the heart of custom command definitions. It is G’MIC’s language extension mechanism. Among other things, one may write a comprehensible left-hand name to represent a right-hand horror show. You have already recounted your ventures into gmic_stdlib.gmic and have probably noticed that in its twisty, darkened hallways there are these one-line custom command definitions that give rise to the ‘short-cut’ names for common commands:
You can push that pea in directions other than syncopation, come up with custom command names that better suit your taste and put them in your local G’MIC extensions file: %AppData%\user.gmic
(Windows) or ${HOME}/.gmic
(Unix-like). In that file, you could even be so bold as to override the default, but empty, cli_start
custom command. G’MIC references this particular command, automagically, on every startup. It’s a hook. You can redefine cli_start
to include various *.gmic
files and introduce site-specific constructs without using -command
inclusions. These syncopation tools, used in the service for People Who Hate To Type, are amendable to other kinds of language extensions.
The only cautionary that I should make is that in sharing environments such as this Discourse server, the canonical G’MIC must rule; it can be hard enough for people to figure out what other people are doing without the babel of regional dialects cropping up.
That’s it for now. Good luck with finger exercises and spelunking gmic_stdlib.gmic
.