C++ or Java?

Last week I was talking with a manager on the subject of C++ versus Java. The motivation behind this was if a project needs to be developed in C++ does experience in Java could be useful to quickly learn the specifics of C++ and become proficient in a very short period of time.

I would like to share my thoughts regarding this question. Perhaps it will shed some light into similar discussions that may arise in current or future projects. I would like to state that in my software development career I have learned and used a few procedural and OO programming languages (Assembly Language (multiple processors), BASIC, Bash shell, C shell, C, C++, C#, Fortran, Java, JavaScript, Pascal, Perl, PHP, PL/1, PL/C, Python, Ruby on Rails, SQL, Visual Basic and Visual C++ among others). In some projects I have written several million LOC using a single programming language.

To me the discussion between programming languages is one that has been going on since I learned my first programming language a few decades ago. At the time programming languages were procedural as opposed to object oriented. There is a huge difference between a procedural and an object oriented language. Using good and solid programming software engineering principles should make for a quick transition between procedural and object oriented. That said; such transition should take several months. The ideas behind OO languages and procedural are quite different. That said; there will always be a need for both types of languages until the point is reached when automated mechanisms based on Artificial Intelligence (AI) allow machines to develop their own programs. That is coming. Not sure when it will become a reality.

The data structures encountered in OO programming languages tend to be ported / implemented to others as soon as someone creates a new one. Of course, the names for the same data structure might be somewhat different on another. The same tends to hold for the actual implementation and behavior. As expected, there will be some differences.

The transitional situation may be quite simpler for a developer that has used both languages. The questions at hand was regarding an experience software developer that switched (not for the first time) to Java and is using such language in a project for a few months. If that developer has used C/C++ for long periods of time in multiple projects and now is required to transition to C++ after working on Java for a year or so; would that be considered an immediate transition or would it take months for the developer to switch to C++?

I have written millions or lines of code (LOC) in C/C++. I have also written hundreds of thousands LOCs in Java using multiple toolkits / frameworks and middleware. When I switch from one language to another, it takes me a couple days to adapt to the new language even though I have used it multiple times for long time periods. For example, I may initially make a few mistakes with #include or import, or using statements but just like riding a bicycle or piloting a plane, after a few hours the syntax mistakes start to disappear. You also need to take into account that developers do not write code using Notepad or any other text editor. Developers tend to use Integrated Development Environments (IDE) which provide help resolving syntax issues. Regarding the names of classes you have the Internet. I do not know many (in reality any) developers that do not use the Internet to look up data structures or algorithms on-line.

Of course, a syntax issue or looking for the name of a class is quite simple. Knowing and having experience with algorithms is nothing you can just look up. That takes years of education and experience. The same hold true with software engineering. There are people that look up such items on-line and then without experience apply them to the task at hand. In some few cases, such approach may work, but on most it creates many problems, some very hard to find and correct.

I have always been of the idea to look up and immerse myself on the subject when I start work on a new project. If the programming language is different to the one I was using on the previous project, I like to take a day or two refresh my skills. I am amazed at how I always tend to discover something new or learn to appreciate new uses for an existing feature that I have used many times before.

I am going to try out something different. Starting this week, I will be attempting to solve HackerRank and LeetCode challenges using C++ and Java. I will alternate between both languages (solve in C++ a challenge on HackerRank and LeetCode and then switch languages for the next challenge on both sites). I will report on my findings in the next few weeks.

If you have experiences in switching between programming languages I would like to hear from you. Most projects that I have worked on tend to use one or two programming languages. It is not a good idea form the productivity point of view, to have a dozen languages in use in the same project.

If you have comments or suggestions regarding this post or any other entry in this blog, please I encourage you to send me an email message with your thoughts. I will not use your name unless you explicitly tell me to do so.

John

john.canessa@gmail.com

Follow me on Twitter: @john_canessa

Leave a Reply

Your email address will not be published. Required fields are marked *