To a seasoned developer, the above sentence might sound like a Haiku. Something a computer might have generated automatically by following the rules of grammar, to create random sentences, incapable of communicating meaning. However, here’s an example of what I mean. Feel free to browse the “imp” folder to understand what I mean.
Hyperlambda has no namespaces, no classes, no private or protected keywords – Still, I’d argue it allows you to create much better encapsulation of your code. Simply since I can evaluate files as if they were functions. I can pass in arguments to my files, and do something resembling the following.
eval ("/backend/tickets/model/get-ticket.hl", id:5)
The above code is of course pseudo code, however its actual implementation is surprisingly similar in syntax. You can see it below. What it returns, is pretty obvious I assume.
Let’s use another example, how I build the toolbar in the top right corner of the system.
micro.widgets.file class:strip themepark-top-buttons folder:@INGEN/imp/common/toolbar-buttons/
It doesn’t require a rocket scientist to understand what that code does, or? Here is the folder it’s pointing to. If you take a look at one of its buttons, you’ll see something like this.
button innerValue:@"<span class=""icon-key""></span>" oninit whoami if:x:/@whoami/*/default?value !=:bool:true delete-widget:x:/../*/_event?value onclick desktop.authentication.login
Even without its comments, I believe most 10 year olds would instantly understand what the above code does. Below is a screenshot of what happens when I click the button. Notice, the screenshot below, including the button to trigger it, was created with no more than 9 lines of code.
Creating a new toolbar button, is as easy as creating a new Hyperlambda file, and putting it in the “/imp/common/toolbar-buttons/” folder. How many lines of code would you need to create something like the above in C#? Let’s try to imagine that as a thought experiment …
- Factory methods and classes to dynamically populate toolbar ==> easily 300 – 500 lines of code
- Interface for buttons ==> probably 50 – 100 lines of code
- Each button’s C# file ==> between 50 and 500 lines of code, depending upon what the button does
And we’d end up with a solution where even the smallest change in one of our parts, often would result in cascading effects, forcing us to change every single button, and every single part of our solution. For instance, adding another argument to our interface method results in having to change every single code file. Even with a conservative estimate, the above would result in 800 lines of code for three simple buttons – Possibly as much as 2,900 lines of code. I don’t think many seasoned developers would object to these numbers. If you don’t count the comments, the Hyperlambda equivalent becomes
- 3 lines of code for the toolbar
- 35 lines of code for all buttons
That’s 38 lines of code! Versus 800-2,900 lines of code. If we were to use our worst possible estimate from our C# solution, it would require 82 times as much code! Since the amount of cognitive energy you have to apply to a software project is directly proportional to the number of lines of code your solution contains, this results in that a pure C# solution would require possibly 82 times as much cognitive energy to be understood as its Hyperlambda equivalent. This translates into that if you require 5 minutes to understand the Hyperlambda code, you’d need almost 7 hours to understand the C# solution.
- Hyperlambda ==> 5 minutes, 38 lines of code
- C# ==> ~7 hours, 2,900 lines of code
While for the Hyperlambda solution, all you’d have to do would be to change the [micro.widgets.file] invocation from above, to resemble the following.
micro.widgets.file class:strip themepark-top-buttons folder:@INGEN/imp/common/toolbar-buttons/ style:"padding:3rem;"
One additional line of code, compared to spending an entire afternoon rewriting interfaces and implementations. The above addition to my toolbar changed my buttons from this …
… to this …
It doesn’t take a rocket scientist to understand the advantage here … 😉
So while the C# developer is changing his interface to pass in style arguments to the instantiation of his buttons, editing literally every single code file in his solution, spending the better parts of an entire afternoon – Assuming he understands the code in the first place, and don’t need 5 days to simply understand the class hierarchy. I’ve moved on to the “next problem” literally after 2 seconds!!
Didn’t like my style argument? Well, OK – Let’s create an [onmouseover] event, that displays the title attribute in an “information bubble” window for our buttons.
micro.widgets.file class:strip themepark-top-buttons folder:@INGEN/imp/common/toolbar-buttons/ onmouseover get-widget-property:x:/../*/_event?value title micro.windows.info:x:/-/*/*?value
4 additional lines of code, and all of a sudden every single button in our toolbar displays something resembling the following when the mouse is hovered over the button.
In case you didn’t like my above example, let’s do something more “hard core”. In fact, let’s invoke a web service, and let’s PGP encrypt our invocation and cryptographically sign our invocation. And just for the fun of it, let’s have the client supply the code that we evaluate on the web service endpoint. For then to have the web service verify the signature of our PGP key used to cryptographically sign our invocation, and allow specific PGP key signers to have “extended rights” during evaluation on our server.
/* * Invoking web service, passing in Hyperlambda to * be evaluated on my server. */ micro.web-service.invoke:"https://home.gaiasoul.com/hypereval/lambda-ws" fingerprint:ea630b9a61448b7f647045c210e1e050ce6feb1d encrypt:true lambda .foo:This code was evaluated on the web service endpoint split:x:/-?value =:" " return:x:/-/*?name
8 lines of code. In fact, I am so certain about that you’d need thousands of lines of code to be able to do something even closely resembling the above in C#, that I am willing to bet a kidney on that you can’t without at least some 5-10,000 lines of C# code! 8 lines of code replacing 10,000 lines of code. That’s an increase of 1,250 times the cognitive load to implement the above in C#. And for the record, the above code is working code. If you download Phosphorus Five, you can immediately paste it into “Hypereval” and execute it. It will evaluate the code inside of its [lambda] node on my server for the record!
If it takes 5 minutes to implement the above in Hyperlambda, it would require 104 hours to do it in C#!
A seasoned software architect and software developer might laugh of Hyperlambda, proclaiming it’s not a “real” programming language, since it doesn’t contain x, y or z. However, none of that matters, because when somebody skilled enough to understand it puts themselves behind the controls of that thing, they’re doing warp 10, and have crossed half the galaxy and returned – Before the competition has even managed to start up his steam engines …
It has no wheels, no visible engines, and no gearbox – How can you claim it’s a vehicle …?
Well, since a picture is worth more than a thousand words, I’ll finish this article with a picture and a simple question …
How would you want to travel today Sir …?