Sunday, November 08, 2009

Why to Learn Programming Languages


This post is part of my ongoing effort to familiarize the readers with the commonalities & variabilities of C++/Java/C# programming languages. A tentative outline of this series can be found at Contents.

Why Programming Language:
My first programming experience was a shock for me. On the same day when our first programming lecture in Pascal took place, we had to write a pascal program in the lab. I had no idea why I was doing what I was doing. My first tutorial was more shocking. Let's skip this now :)

We use natural language to communicate with each other. A letter is a written form to carry information to others which, if asked properly, may bring some responses back from the receiver. The language has some defined syntax (Grammar) which must be interpreted to some Semantics (meaning) by the receiver. So a common syntax and semantic pair is necessary to successfully establish the communication. The principle also holds for programming languages.

Machines are piece of hardware which understand only 0 and 1, called bits1. Sequences of bit combination form the byte code instruction and data which are encoded and decoded to perform the intended information. Now how can a human communicate with a machine? Programming language comes in action. Like natural language, a programming language defines some syntax with some intended semantics which is converted to machine readable format by the compiler.
A programming language defines syntax and semantics to instruct the computer to do some defined tasks.
Why C++:
C and C++ are definitely the most widely used programming languages on the Earth. If you are a computer science student whether you want or not, you will come across one or both of them in your career. So a fair knowledge of C/C++ is a prerequisite for a good software engineer. Since C++ is an extension to C, they are very often refer as a single language and called C/C++ (see-see-plus-plus)

With C/C++ you can control the system thanks to its support for low level capabilities even with inline assembly language 2 compiler. So for system level programming C/C++ is important. For driver and kernel development C/C++ are ubiquitous. Both Java and C# need a lot of resources to run the virtual machine on top of which your program will run. It is very frequent in the embedded system domain that you have insufficient resources to load Java or C# VM and you will prefer C/C++ for those systems. There are even special C/C++ compilers for those resource critical systems.

You need cross OS development in the Windows and *nix worlds. In addition, you want to perform system level operations. C/C++ can support you the best. There are various libraries available which let you build your program on multiple OS platforms. For Graphical User Interface (GUI), you can use QT (http://qt.nokia.com/) or GTK+ (http://www.gtk.org/) that enable you a consistent view of the user interfaces on many systems.

If you want your application to run super fast, you need C/C++. They are still the dominating languages in the game programming and 3D-Visualization domains. Though now-a-days, many popular games are coming out in other languages. I myself is currently working with 3D visualization in .Net platform using DirectX technology.

C++ is very frequently called a federation of languages rather than a single language. It supports various programming paradigms. It is a natural extension to C and Assembly. You can code procedural, functional, object oriented programs. Template Meta Programming (TMP) is a new programming paradigm that is made popular by its support for templates. C++ is undoubtedly harder than Java and C#. It has a high learning curve. You need many years of die-hard efforts to become expert in this language. Therefore, think first whether you really need C++ before you start learning it. But if you can reach at that level, you are a master of your systems.
For system programming you can hardly ignore C/C++.
Why Java:
Java is the most widely used language for cross platform development. "Write Once, Run Everywhere" is the motto of Java from the beginning. Though there are controversies how far it achieved that, nobody can ignore that Java's stronghold for the multi-platform development.

Java is a pure object oriented language. Every data entity and function belong to a specific class. There is no direct notion for scattered global data which has reduced complexity of procedural programming a lot. Garbage collector reduces the overhead of maintaining the program resources. The language defines a lot of standards and reference implementation which cover almost all aspects of programming concerns from simple desktop applications to large enterprise development. Since Java programs run on top of Java Virtual Machine (JVM), programmer has less control to manipulate the hardware directly which, in turn, provides a much higher security model for a system. Sun has, in addition, released the source code of complete Java stack as open source software under GNU public license reducing fear for vendor lock-in thus increasing its acceptability to the enterprises and open source enthusiasts.
Java is very strong in cross platform middleware development.
Why C#:
You are a Microsoft enthusiastic. You have almost no chance to program on other platforms. You are not forced to program in C++ by your employer. You don't need to control your system. You like pure OO programming language. Speed in development is important for you. Collaborative development of expertise on multiple languages is necessary for your team.You should use C#.

Microsoft has invested its large workforce for .Net development. C# is the main language for this framework. It is a very neat language. MS has tried heart and soul to reduce programmatic complexity in C#. Those who are disappointed with Java's lack of high performance visualization support, can effectively program in C# while equally enjoying advantages of managed environment. There is an easy migration path to transfer existing code base to the .Net platform. You can even run your code in dual (parts in managed and parts in unmanaged) environment facilitating gradual migration to the .Net platform.

Microsoft developed a version of C++ for .Net platform known as C++/CLI. It has simplified the execution of existing C++ components on .Net runtime. It is a combination of C++ and new constructs for .Net which has again steep learning curve. So for new .Net development, I discourage use of C++/CLI and rather recommend C#. Microsoft Visual J# is a Java compiler which compiles Java code for .Net runtime. But MS has suspended support of J# language in the future release of Microsoft Visual Studio. So it is not safe right now to start a new project in J#.

Though theoretically .Net is platform independent, MS released version 1.0 of the Shared Source Common Language Infrastructure, also called RotorVM which can be built only on FreeBSD (version 4.7 or newer), and Mac OS X 10.2. Commercial use of it is prohibited. Mono (http://www.mono-project.com/) is an open source implementation of .Net framework on Linux, Windows and Mac OX platforms. It currently supports C# 3.0, Visual Basic 8, and several other programming languages. Similar to J#, IKVM is a Java implementation built around Mono which compiles Java code to .Net platform.
C# is the premium language for the future application development on Windows
If you are a new leaner, you may start with a managed platform like Java or .Net. In this way, you can restrict yourself from learning unnecessary staff. Management of resources is a big headache for programmers. In Java and C#, this responsibility is left to the garbage collector. With standardized attribute (annotation in Java) support, the program can be made highly configurable. Both platforms has brought a large set of standardized classes to ease the development, deployment, and maintenance of software systems.
C++ is more widespread. But C# and Java are easier than C++. Java is open sourced and has implementation for virtually all platforms. C# has addressed GUI programming in managed environment better than Java but full implementation only on MS platforms.

For the hobby programmer, I recommend the following-
C# programming with Visual C# Expression Edition on Windows is fun.


References

  1. John B. Anderson, Rolf Johnnesson (2006): Understanding Information Transmission
  2. The Art of Assembly Language

6 comments:

  1. Great article. Very comprehensive.

    ReplyDelete
  2. Thanks for the post. Your explanation for the necessities of programming language is really different. The correlation between natural language and programming language is very interesting. I think in natural language you have lot more freedom.

    ReplyDelete
  3. Very nice description of why we need programming languages to communicate with the computers. I think you can do system programming with C# at least on Windows. If productivity is important for your company, which is the case in most companies, you can develop your program in C# and either use InterOp or a separate C++ project for the system level programming

    ReplyDelete
  4. Nice series of posts. It is difficult to describe three languages in blogs. It is a life time work. But I appreciate your effort.

    ReplyDelete
  5. nice post-test

    ReplyDelete
  6. i am learning from you
    quader

    ReplyDelete