DEV Community

Discussion on: Frameworks, Libraries and Languages

 
gtanyware profile image
Graham Trott • Edited

When theory shows a thing to be X, practice often demonstrates it's Y. I'm not a theoretician, just an old-fashioned engineer who makes things that work. In this case, user interfaces, which today mostly means websites. Any website that can't be described clearly in English probably can't be used by human beings, so I code them entirely using my own formal English-like imperative syntax originally inspired by Apple's HyperTalk. Like English, this is unambiguous if coded sensibly and it can be used by any person with an understanding of what the UI is for and what it does, whether their native tongue is English, French, German or whatever. Devising a clear and unambiguous syntax and then writing a compiler for it are not trivial tasks, and the future can come along and bite you, as the authors of JavaScript have found. But that's no reason for not doing what works best now.

A typical example might be "while Count is less than the json count of TheDataArray gosub to AddAnotherRow". One might argue about its linguistic purity but ten years down the road it will still be instantly readable while a React or Angular solution will have the reader diving into the discarded book pile to find out where to locate and how to set up the IDE, never mind changing the code. I exaggerate, perhaps, but not by much.

And that's what lies behind the articles I write on the subject of appropriate language - real-world experience of something that works now and goes on working indefinitely while the rest of the world changes. And I have satisfied customers able to testify to the effectiveness of the approach.

Thread Thread
 
jessekphillips profile image
Jesse Phillips

"while Count is less than the json count of TheDataArray gosub to AddAnotherRow"

Any chance you could explain what this is checking?

Thread Thread
 
gtanyware profile image
Graham Trott

It's the head of a 'while' loop that counts from the current value of Count up to the number of elements in a string that's a JSON-encoded array (held in a variable called TheDataArray). Each time through the loop it executes a statement, which might be a single command or a block (these use begin...end); here it's a subroutine call; the code assumes Count will be incremented there. (I'm not saying I would actually code like that; it's just an artificial one-liner.) All variables are global but there are rarely more than a few dozen in any one script. The language allows scripts to invoke other scripts and share variables with them; unshared variables remain private.

I originally wrote the compiler and runtime in Java some 20 years ago. Last year I rewrote it in JavaScript as a website coding engine, and I'm now doing a version in Python (as a learning exercise). None of them have ever been widely used by anyone but myself, but that's the fate of most custom languages. The performance is quite good, especially when complicated functionality is wrapped up as script objects (as happens in English). I accept it breaks all sorts of conventions regarding the 'right' way to do things but I'm only interested in what works. Most importantly I can return years later and quickly pick it up again, something I struggle to do even with my own code written in Java or PHP, for example.