Encapsulating your system through the file system

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.

    class:strip themepark-top-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.

  innerValue:@"<span class=""icon-key""></span>"

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 …

First we’d need support for dynamically loading up controls to populate our toolbar. This would probably require at least some 3-4 different design patterns, such as an Abstract Factory, Factory Methods, etc. Each button would have to implement some interface. Then we’d have to create some sort of JavaScript frontend part, allowing us to actually click the button, and creating an Ajax HTTP request, which does whatever the button does once clicked. A qualified guess would be.

  1. Factory methods and classes to dynamically populate toolbar ==> easily 300 – 500 lines of code
  2. Interface for buttons ==> probably 50 – 100 lines of code
  3. Each button’s C# file ==> between 50 and 500 lines of code, depending upon what the button does
  4. JavaScript to create our Ajax HTTP requests ==> At least 100-200 lines of code for each button

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

  1. 3 lines of code for the toolbar
  2. 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.

  1. Hyperlambda ==> 5 minutes, 38 lines of code
  2. C# ==> ~7 hours, 2,900 lines of code

All of these numbers I played around with here are numbers that most seasoned system developers could easily agree with me in regards to, so I cannot be blamed for having skewed the numbers in any ways. In addition to that purely mathematically the C# solution would require 82 times as much energy, it also contains 2 different programming languages (JavaScript and C#). On top of that, it contains several design patterns, to facilitate for creating a plugin architecture capable of dynamically loading buttons. Possibly some sort of configuration file (JSON/XML?) too, to declare which buttons you want to load. Hence, the C# solution would literally be scattered with dependencies, making even the tiniest change in any one of those files, possibly cascade into all 2,900 lines of code – Forcing you to effectively rewrite your entire solution, due to adding a single additional parameter to the instantiation of your buttons (style argument …?)

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.

  class:strip themepark-top-buttons

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.

  class:strip themepark-top-buttons

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.

How many hundreds or thousands of additional lines of C#/JavaScript/“whatever” do you think the above would need in literally any other traditional programming language …?

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.
    .foo:This code was evaluated on the web service endpoint
      =:" "

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 …?


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.