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

Advertisements

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

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

Overloading vs Variable Arguments !!!

In a statically typed (object oriented?) language, function overloading offers the facility of organizing your code into two or more functions with different types and/or number of arguments. This is highly useful when the functionality offered by the function can be invoked in different scenarios. For instance, let us consider the function(s) below:

Continue reading Overloading vs Variable Arguments !!!

jqGrid: Handling array data !!!

This post is primarily a personal reference. I also consider this a tribute to Oleg, who played a big role in improving my understanding of the jqGrid internals – the way it handles source data types, which, if I may say, led him in discovering a bug in jqGrid.

Continue reading jqGrid: Handling array data !!!