Facets of Immutability

Immutability, the cornerstone of functional programming, has many facets.

Not every (mainstream) language supports all the facets; at least not per what each facet stands for. That’s what I will talk about today. The various facets of immutability from a theoretical perspective, and briefly show how some of the mainstream languages have adopted and support these facets in their own way.

Continue reading Facets of Immutability


A Paradox of Braces

A great deal of thought goes into language design. Eric Lippert’s posts is a living testament, at least for C#. Syntax and idioms are also part of the language design. When designing a language, the designers have to also consider its future. For instance, when designing C#, Anders and others should have thought of and planned for what’s coming in then upcoming version(s) of C#. Such level of forethought might be seem daunting for an outsider. But the language designers are good at what they do, and most importantly, they know what they are doing. Well, in most cases!

Continue reading A Paradox of Braces

JS Programming in C# – Local Functions

Functional programs treat functions and data alike. No discrimination, if you will. That means, you can declare and use functions – assign to variables, pass to other functions etc., the same way you would play with variables.

A canonical example of a functional program would show how to pass functions as parameters to other functions (higher order functions). It would also show how one can create functions on the fly (lambdas or anonymous functions) and also assign it to a variable, which is of a predefined function type; either the compiler deduces or aligns to the calling context.

There is one important attribute of data that is mostly forgotten. It can be declared almost anywhere, particularly within functions. Local variables, remember? If we agree to treat data and functions alike then we should be able to declare a function inside another. Errrk! Why would anyone want to do that? Seems like JavaScript.

Continue reading JS Programming in C# – Local Functions

My Take on Picking a Log Level

Logging? What’s there to talk about logging? It’s straightforward. Use the one of the log levels and log it.

The ubiquitous log4j‘s website says …

ERROR level designates error events that might still allow the application to continue running
FATAL level designates very severe error events that will presumably lead the application to abort
INFO level designates informational messages that highlight the progress of the application at coarse-grained level
WARN level designates potentially harmful situations

That is the theory of it. Let me tell you my opinion on a more practical matter.

JS Programming in C# – Objects on the fly

Creating objects without defining types is considered a great flexibility in JavaScript. JavaScript treats objects nothing more than key-value pairs. Yeah, you can declare functions in the object but they are still part of the key-value philosophy. Bottomline: JavaScript did not start out as an object oriented language.

Typically, objects are created on the fly1 using the object literal syntax:

let obj = {
   name: "Will",
   age: 26

There are scenarios when creating objects on the fly is indeed a flexibility.

Continue reading JS Programming in C# – Objects on the fly

Lo and Behold

A few days back, I published an article Lo and Behold here on my blog, and also publicized on Medium and LinkedIn.

The article, inspired by Werner Herzog’s documentary Lo and Behold, is my opinion on one of the anecdotes (Robots that are being designed to beat Messi).

Does the anecdote grab your attention? Then you should find my article interesting.

Let me know what you think.

Writing sonnets in C++

Recently, I came across this post – Write a URL in a C++ program, one of those C’s tricks. If you have not already read the post, I will wait until you read and return …

waitingWaiting …

The crux of the trick is the protocol part of the URL – http:, becomes a goto label and the rest of the URL starting with // becomes a comment. Sweet 🤗

My turn My turn …

Continue reading Writing sonnets in C++