DEV Community

Discussion on: OOP a software development mass psychosis

Collapse
 
polterguy profile image
Thomas Hansen • Edited

Psst, here's a functional example of a code snippet taken from our website (Hyperlambda code). Try implementing the same in C#, Java or (sigh!) C++ ... :/

join
   fork
      http.get:"https://gaiasoul.com"
   fork
      http.get:"https://servergardens.com"
Enter fullscreen mode Exit fullscreen mode

I assume everyone reading the above code can instantly understand what it does ...

The above is 5 lines of code. Its C# or Java equivalent would probably require hundreds of lines of code, and at least half a dozen classes, in addition to (consuming) some 25 to 50 different existing classes ... :/

Collapse
 
moopet profile image
Ben Sinclair

strcpy is a bunch of lines if you don't have it in your standard library. Everything in this example is hiding complexity somewhere, just like all code ever written.

I like "less code" as a principle, but I'll add more SLOC if I think it makes what I'm trying to do clearer:

Collapse
 
jwp profile image
John Peters

Not in C#

Thread Thread
 
polterguy profile image
Thomas Hansen

Simply wiring up your HttpClient, ensuring you're disposing your ContentResponse object, and correctly parametrise it would require 10x as many lines of code as the Hyperlambda 5 liner above. Then do it twice (two invocations), add the required boiler plate code for threading, and ensure you wait for the code to return before you move beyond the join invocation, and you're probably looking at a lot more code, at least 10x as much code as the Hyperlambda example, probably even more than that. If you disagree, feel free to prove me wrong. You've got the Hyperlambda code up there - By all means, port it to C# and let's see what produces most code and complexity ...

Collapse
 
anuragvohraec profile image
Anurag Vohra • Edited
App.runAwesomNoBugApp();
Enter fullscreen mode Exit fullscreen mode

Every one can undertand what it does. Try implementing it in Hyperlambda, which will atleast require 100s of lines of code to implements this Awesome functionality. And hence by your logic it can be deduced Hyperlambda is psychosis.

You showed encapsulated code as an example, so did I.

Thread Thread
 
polterguy profile image
Thomas Hansen

You showed encapsulated code as an example, so did I.

No, I showed three of the fundamental building blocks in Hyperlambda (3 slots), which are similar to "functions" in structure, and how these 3 fundamentals solves an actual problem, being retrieving 2 HTML documents in parallel, and waiting for both documents to download.

Thread Thread
 
anuragvohraec profile image
Anurag Vohra

I have demonstrated a better example of how to run any app with just one line of code. It does all you say and do in just one line.
If reducing number of line is yard stick.

Thread Thread
 
polterguy profile image
Thomas Hansen

Reducing the LOC is always a "yard stick" yes.

Thread Thread
 
anuragvohraec profile image
Anurag Vohra

One of the yard stick yes, but definitely not the most important of all. A sane programmer would and should choose modularity, for a non trivial programm, always over LOC. A few extra lines which gives better extensibility and readability is instead good and promoted as a good programming atticate.

Collapse
 
siy profile image
Sergiy Yevtushenko

Actually, your code does nothing useful beside generation of useless traffic (result of the operation are ignored) :)

In the Java framework I'm working on, your code will look like this:

import static org.pragmatica.lang.Promise.all;
...
all(
    HttpClient.get("https://gaiasoul.com"),
    HttpClient.get("https://servergardens.com")
);
Enter fullscreen mode Exit fullscreen mode

Wish I have more time to work on this framework...

Thread Thread
 
polterguy profile image
Thomas Hansen • Edited

Beautiful, but of course creating libraries that simplifies things is possible in all languages. When I was doing my LOC count, I considered the bare bones implementation using HttpClient from .Net ...

Najs code though :)

Edit;

result of the operation are ignored

I didn't see this one before now, but no, my example does not ignore the result of the operation. That's the purpose of the [join] keyword in Hyperlambda. It waits for the [fork] invocations to finish, and returns the result of the invocations to the caller. To access the content of the first for instance would be as easy as follows.

get-value:x:@join/0/**/content
Enter fullscreen mode Exit fullscreen mode