Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567



Simplifying HTTP invocations – DZone Web Dev

The C# boilerplate code to (correctly) create an HTTP GET request is staggeringly complex. Async/await syntax, IDisposable objects, IHttpClientFactory dependency injection configurations, etc, etc, etc. This simple task is actually so complex to correctly implement that I’ve never seen it correctly done during my 20+ years as an enterprise software developer. In fact, even senior software developers often mess things up in these regards. In addition to getting the syntax correct, the developer needs to learn dozens of complex subjects before he can even start out wiring his code together; IoC, using patterns, HttpClient internals, etc, etc, etc. However, if you think about it, it shouldn’t be all that hard. Purely from a syntactical point of view, nothing more than the following should be necessary.


The above of course is Hyperlambda, and the syntax for retrieving a URL using Magic. Interestingly, internally Magic will (of course) dispose objects, invoke the HTTP endpoint asynchronously, correctly wire up your IoC container, and use the IHttpClientFactory. The complexity of these parts are simply hidden, and completely irrelevant from the end developer’s perspective. And before you ask, POSTing an object is just as simple.


Internally of course, Magic will transform the above “lambda” object into its JSON equivalent, and invoke your endpoint. And if you need variables in your payload, this is done as follows. Notice, you’ll need at least version 9.9.5 of Magic to make the above work.


In the last example above, the funny syntax of :x:@.userId will resolve to the value of the [.userId] node, allowing you to easily parametrise your JSON, without any “funny” string.Format code. No types, no classes, no problems!

Of course you could use C#, create a POCO/model type – However, that would inflate your code base by at least 10x. Since we know for a fact that the number of lines of code is proportional to the amount of resources required to maintain said code, this implies 10x as much “cognitive energy” (at least) to maintain the C# equivalent – In addition to that (duh!) you wouldn’t let a junior developer even close to the abstraction layers actually implementing your HttpClient wrapper library, since the statistical probability of that he or she would mess something up is probably close to 100%.

It’s easy to become amazed by Magic’s automatic CRUDify abilities – However, these are just part of the story. In fact, most of our partners are barely using these parts at all, but rather chooses to manually write Hyperlambda code. Their reasons …?

Because it is 10x easier than PHP, Python, C#, Java, NodeJS and “whatever”

Next to Hyperlambda the average “high level programming language” literally looks like CISC x86 assembly code – Which of course is Hyperlambda’s “purpose”. The idea of the language is to make everything 10x easier, without compromising execution speed, scaling, performance, maintainability and flexibility. But don’t believe me, maybe I’m just full of it. Go check out your own HttpClient usage in your own C# code, and come back and compare its complexity to the above syntax. If you can somehow invoke an HTTP GET request, and/or an HTTP POST request as easy as I illustrated in the above snippet, I will give you my address, such that you can send me your dirty socks in mail, and I will eat your dirty socks for breakfast, while YouTubing myself and sharing it publicly for all to see ^_^

Credit: Source link

Previous Next
Test Caption
Test Description goes like this