While browsing some old pictures on my computer and some old posts on social media, I stumbled upon some used-to-be-funny stuff that I used to say, write and believe. Well, not all of them are true, my opinions about them have changed with the time, and I don't believe or support them anymore. Some of them are n00b thoughts (don't judge, we all start as n00bs). Here I am giving a list of some of them, hopefully any young programmer doesn't make the same mistakes.
C++ is better than Java
First of all, there is no language better than another! Except Visual Basic; all languages are better than Visual Basic. I started programming with C++, and it feelt nice. The way the computer was doing what I wanted it to do was amazing! If it blew up, it was my fault, not the computer’s. I wanted to learn every small component of C++, and I loved every tiny bit of it. But I knew that C++ was really old, most of people didn’t use it on an daily basis. Instead of C++, Java was (and still is) the most used programming language by the developers in the world, with a community of over 10 million of developers. So I took a look at Java (a really fast look, I’d say), trying to find reasons to hate it. I managed to find a couple actually:
- The absence of pointers
- Forcing to use Object Oriented Programming (hence no procedural code)
- Single inheritance (C++ has multiple inheritance: one child class may have more than one parent)
- No inline assembler (C++ inherited this from its old parent: C)
I remember calling JavaFag everyone who loved Java and thought it was better than every other language. Now, I proudly say that I was wrong. Why? Well, there is a reason for each of the “reasons” above.
The absence of pointers
Whoever wrote C code knows the importance of pointers. C++ inherits this importance from the good ol’ C and of course makes it better. So the first thing you think when you learn that Java lacks pointers is “WTF?!” (that stands for Why This Feature). But wait: Java is implemented above a C/C++ layer. This means that, underline, it should use pointers. And it actually does. And also you as a Java developer use pointers almost every line of code you write. How? Every time you use an object, you actually are using a pointer to a class instance. That’s why objects are passed by reference on methods. Also, when you write non-static methods of a class, you use the
this keyword. Yep, another pointer, just like in C++.
OOP - only
Consider C++ as a bridge between C and Java. C is mostly procedural (other paradigms also), while Java is mostly OOP (other paradigms also). C++ is both procedual and Object Oriented. Is this a good thing? It depends on your point of view. But there is a reason why Java supports OOP so much: code modularisation. Good programmers write code that humans can understand, and modular code is better to read and to understand. No more words needed!
There is a reason why a child class shouldn’t have more than one parent. Consider a class called
Child which extends a
Mother class and a
Father class. Now both parents have a method (function) that is called
speak(). If the
Child class implements that method is OK, but what if it doesn’t? Will there be called the
Mother’s method, or the
Father’s one? This is what they call the diamond problem. Java tries to solve this problem by simply not allowing multiple inheritance.
No inline assembler
I have one question: Why do you want to write assembly code in a Java program?! Well, let’s supose you have a strong reason (still, why?!). There is a way to write code in C, C++, Assembly and other native languages by using Java Native Interface. It is not the best thing to do, since it would remove the WORA of Java and make the code platform-dependent.
C# - May the hate be with you
After throwing hate to Java, I’d go on with the sentence: “And there is C#, the closed-source Microsoft copy of Java”. I actually hated C# more than Java. There were reasons after that. Firstly, I don’t like to name my methods using
PascalCase just like my classes (at least Java uses
camelCase). Remove that, and C# looks just like Java (the syntax, at least). Keep in mind that C# was released 5 years later than Java (conspirative programmer is conspirative). Well, I didn’t write too much C# code but I know there are some features of C# that Java doesn’t have, or that are introduced much later. The best feature of C# is LINQ (Language Integrated Queries), a way of executing SQL-like queries for object collections. The closest thing that Java has to that is the Stream API added with Java 8, but that is nowhere close to LINQ (there are some LINQ implementation though).
Another issue, C# is strongly related to Microsoft. Microsoft’s .NET framework exists only for Microsoft products, and this makes C# less cross-platform (0 times more than C++). There was always the Mono Project, but it was really slower than JVM on every machine. But finally, Microsoft decided to open-source it. Later, we probably will see a cross-platform .NET, with a higher performance and usable in Mac OS, iOS, Linux and Android.
- Not standard for all the browsers (don't come up with jQuery yet)
- Braces don't guarantee scope; everything exists in the global scope (WTF - Why This Feature)
- Semicolons are optional (Come on! Use them or don't use them! Make up your mind, woman!)
- Object Oriented (you'd wish!)
- Weak typing (prefix all the variables!)
- Debugging is a nightmare
Let’s be honest, every language has its drawbacks. No programming language is perfect, and it’s their right not to be (Visual Basic is abusing with this right). But thankfully, there isn’t only one programming language. You are free to use the one which has the features you require for the project you have. There are two kind of programming lanugages: the ones you love, and the ones you don’t know. So don’t hate any of them, don’t set high standards for the programming languages. All of them are good for something (except one… but now you know).
How about you? Did you hate any programming language? Write it below on the comment section.