Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Eccentricity in programming languages

, 21 Feb 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
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

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.

The languages I personally worked with are mainly C/C++, Java, C# and more recently php and javascript.
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.

example:

class DeviceContextWrapper
{
.....
public:
DeviceContext& dc;
.......
};

later, in some place other than the constructor I could assign as follows:
DeviceContextWrapper wrapper;
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 Smile | <img src= " /> ).

Javascript - to me a heavenly language for basic client side operations. But it is difficult to really come up with a solid flawless architecture for bigger programs containing several modules with the prototypical hierarchy it offers. I have seen people trying to fit javascript into classical hierarchy model a notion itself I believe is flawed. I plan to write on this later, some other time maybe.

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

Example:

$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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mukit, Ataul
Chief Technology Officer Rational Technologies
Bangladesh Bangladesh
C++ is not C with classes, JQuery is not Javascript, Google Search is not Learning, Design Patterns are not fashion, A code written in 2005 is not backdated just because it's 2015
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 2 PinmemberBartlomiej Filipek27-Feb-13 5:07 
GeneralRe: My vote of 2 PinmemberMukit, Ataul27-Feb-13 6:19 
GeneralRe: My vote of 2 PinmemberBartlomiej Filipek27-Feb-13 6:51 
GeneralRe: My vote of 2 [modified] PinmemberMukit, Ataul27-Feb-13 8:48 
GeneralMessage Automatically Removed Pinmembermrchief_200022-Feb-13 9:34 
GeneralRe: My vote of 1 PinmemberMukit, Ataul22-Feb-13 18:06 
GeneralLink bait Pinmembermrchief_200022-Feb-13 9:34 
QuestionI prefer C but wish it had inline functions like C++ Pinmemberdusty_dex22-Feb-13 9:21 
AnswerRe: I prefer C but wish it had inline functions like C++ PinmemberMukit, Ataul22-Feb-13 18:04 
GeneralRe: I prefer C but wish it had inline functions like C++ Pinmemberdusty_dex23-Feb-13 1:47 
GeneralMy vote of 1 PinmemberMember 327776022-Feb-13 4:25 
GeneralRe: My vote of 1 PinmemberMukit, Ataul22-Feb-13 5:23 
GeneralMy vote of 5 PinmemberMukit, Ataul16-Feb-13 5:20 
GeneralRe: My vote of 5 PinmemberJohn Brett18-Feb-13 5:30 
GeneralRe: My vote of 5 PinmemberMukit, Ataul18-Feb-13 5:35 
GeneralRe: My vote of 5 Pinmembermrchief_200022-Feb-13 9:35 
GeneralRe: My vote of 5 PinmemberMukit, Ataul22-Feb-13 21:40 
You sound too aggressive to be an impartial critic.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 21 Feb 2013
Article Copyright 2013 by Mukit, Ataul
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid