See the RSS feed in CodeProject
Over the years, now almost a decade with bits and bytes (at an abstract level), I have had to come to terms with some (not many) strange programming language constructs in a variety of programming languages. On second thought, not so much the constructs, rather some of the features provided by these languages I found un-intuitive and unnecessary in some ways.
On the weight(!) of my experience, I would like to list down the strange phenomenons and unintuitiveness I encountered in these languages.
Let me start with my very favorite C.
And obviously, the first thing that springs to mind is pointers. Could I do away with pointers? no. Pointers are a must when you are dealing with low level programming languages such as C. But the syntax, it might have been better.
int *pAddr = &p, *qAddr = &q; -> This as a syntax is damaging, arising a lot of confusions.
Why associate the * with the pointer variable name? Rather, int* pAddr = &p, qAddr=&q would sound a little easier. The variable's data type, in this case, int* is a data of pointer type.
in C++, they came up with a better solution for pointers with reference concept. Alas, it would have been very helpful if I could declare a reference inside a class and instead of constructor I could assign the reference at a later time.
later, in some place other than the constructor I could assign as follows:
wrapper.dc = & (new DeviceContext());
And while talking about difficult syntax and phenomenons, let me conclude for this section of C and C++ by saying template syntax can create one of the most unreadable piece of code in history.
Coming to Java, they have made everything a little too complex for my liking by deriving everything from JObject.
I wonder if an Integer has enough properties or necessities for it to become a class. Probably I have been influenced by the great Bjarne Stroustrup in this regard who said:
"They believe that you should do everything by creating a class as part of a class hierarchy with lots of virtual functions. This is the kind of thinking that's reflected in a language like Java for instance, but a lot of things don't fit into class hierarchies. An integer shouldn't be part of a class hierarchy. It doesn't need to. It costs you to put it there. And it's very hard to do elegantly.
You can program with a lot of free-standing classes. If I want a complex number, I write a complex number. It doesn't have any virtual functions. It's not meant for derivation. You should use inheritance only when a class hierarchy makes sense from the point of view of your application, from your requirements"
And as I move on to complexities, java's over usage of design patterns has taken the simplicity out it. For example, usage of decorator pattern to read a simple user input from the console. I even forgot how you write this.. inputstreamreader(new buffered reader..).. whatever. And I am sure they have to go to through hell to introduce generics and templates in java.
C#, more or less exists with limited flaws. I may blame the overuse of interfaces as something that gives pain to my eyes.
Implement an interface ISortable to sort items in a list.. Here we are shooting cannons to gun down a fly I believe (This made up proverb sounds more nice in Bengali though :) ).
JQuery syntax, I need to grasp it more to understand if it really makes sense or not. Usually, I don't face too much readability problems with languages. But this JQuery thing, and the way programmers are implementing over the world looks very unreadable to me.
PHP: The reason I believe I have started written this post. It was the === operator that I commented about which created a discussion in my friend group (who are in programming side of things of-course). To quote a highly talented friend of mine,
"I have no idea how php works, but it will take highly trained eyes to see == and === differently in a sea of code. I dont quite see the benefit".
In my humble view, putting different types intentionally in two variables and using a comparator operator for type comparison purpose is a strange way of doing things.. and whenever you are doing something unusual you should use a syntax that's easily identifiable, such as is_identical($p, $q).
Another unintuitive syntax I have observed is the usuage of array of arrays in php.
The assigning sign means actually appending
$col = array();
$col["title"] = "Id"; // caption of column
$col["name"] = "id"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["width"] = "10";
$cols = $col;
$col = array();
$col["title"] = "Date";
$col["name"] = "invdate";
$col["width"] = "50";
$cols = $col;
Believe it or not, the $col array is being appended to $cols. In my view, even a new comer in php without any documentations should be able to understand the workings of an operator. It shouldn't bypass normal conventions.
The thing that really got into my nerves in php is the usage of dot (.) as a string append operation. It makes no sense at all. It is highly counter intuitive and a very unusual notion, that a dot should be an append operator. I do admit, it makes the writing of the codes a little easier some of the time, but the trade off between un-intuitiveness and ease of writing is way too too much. This one heads the top of my list when it comes to strange syntax. The intuitive syntax for string operations should always be +; the reason being + stands for addition. Therefore, it is intuitive that + as an operator can add any type of variables together. So, it can add string as well. You may make a case about what about * as an operator for multiplication? I would defend my case with the following argument :
It is well established that * is an operator for multiplication in programming languages, so it would be silly to come up with a new notion for that.
My point is, You have to show inventiveness with new features in a new language, not change the well established and readable syntax that exists for basic operations.
A little off topic, I am seeing an over-reliance on frameworks such as code-igniter which abstracts stuff too much for my liking. However, I haven't spent that much time with php to comment in more details.
I have some obeservations about how the web programming is evolving and where it is leading to and what are the lags - I plan to write about it someday. But till then,
Astana vista comrades...
signing off - mukit
Google says it won’t approve any Glass apps with facial recognition until it has protections in place
Read more on TNW ...
New lithium-ion battery design that’s 2,000 times more powerful, recharges 1,000 times faster
Read more on extremetech.com ..
Big data: The next frontier for innovation, competition, and productivity
Read more on mckinsey.com ..
Microsoft Seeks Windows 8 App Wave
Read more on informationweek.com ..