Comparing C++, Java and C# A Broad Perspective
Why learn a language? A language is not worth knowing unless it teaches you to think differently – Larry wall & Randal Schwartz
What’s in a language? Just like a human being it has its own characteristics way of expression strongholds and weaknesses and more than everything it has a lively spirit
Why do we need it? ‘it provides a vehicle for the programmer to specify actions to be executed and it provides a set of concepts for the programmer to use when thinking about what can be done’ – Bjarne Stroustrup
Why C++, Java and C#? Most prominent languages Very close relationship Object oriented Part of C language family - a common ancestry
Why Comparative Approach? Represent different generations Distinct languages Their own specialties
How to learn a Language? Having a broad picture Syntax, semantics and pragmatics traps and pitfalls Of course, practice/experience
A Broad Picture? The underlying technology Evolution and Design considerations
The Underlying Technology? Approaches in Language Translation Intermediate Languages Where C++, Java and C# fits
Approaches in Language Translation? Compilation Interpretation A mix of both
A mix of both? Intermediate Languages Virtual Machine Portability and Language Interoperability
Intermediate Languages? The Approach: No loss of significant info Don’t keep any other info!
Examples? Three Address Code Object Files Tree Representations Using another high level language!
Stack Based Approach? P-code (UCSD Pascal) Bytecodes (Java) MSIL (.NET)
How to Improve Performance? JIT (Just in Time) Pre-JIT (Ahead of Time) Aggressive optimizations ‘fat’ class files and Hardware chips
A Retrospect – C! B language - threaded code! ‘virtual B’ ! (Ken Thompson) C - drastic change in the translation approach – native code!
Evolution? Language is the archives of history - Ralph Waldo Emerson
Why C++?
Why Java?
Why C#?
Design Overview
Design? ‘As I write a program, I should use a language that minimizes the distance between the problem solving strategies that I have in my head and the program text I eventually write on paper’ - Jon Bentley (Programming Pearls)
Why Language Design is Challenging? Because design itself is all about aspiring for the best solution, yet striking a balance and making compromises!
Example? Language Features As simple as possible but no simpler! (Albert Einstein) Neither can you have lots of features nor less features
Why Conceptual simplicity ? Essential feature of any software Many technically superior produces fail as they lack this
Evolve or BuildFrom-the-Scratch? Pros and Cons Conclusion? Neither Ideally a mix-of-both
Is a ‘Revolutionary’ Language Possible? No. Because there can be ‘No Silver Bullets’ – Fredrick P Brooks
‘No Silver Bullets’? ‘There is no single development, in either technology or management technique, which by itself promises even one order-of-magnitude improvement within a decade in productivity, in reliability and simplicity’ - Fredrick P Brooks (The Mythical Man Month)
Design of C++, Java and C# ? syntactically similar but differ considerably in their design approach Examples? Portability, ‘trust the programmer’ and library support
How approach to portability differs? C++ - as efficient as possible even at the cost of portability Java - as portable as possible even at the cost of efficiency C# - follow Java’s approach and still support C++ philosophy!
Which extent to ‘trust the programmer’ ? C++ - just ‘trust the programmer’ Java - don’t trust him! C# - don’t trust and help him avoid getting into trouble!
Part of the Language or not? Library Support Pros and cons C philosophy – ‘keep it in the library’ - reputation of being the most reused library in the programming language history
All three - extensive library support
Why C as Base Language? ‘C is clearly not the cleanest language ever designed nor the easiest to use, so why do many people use it?’ - Bjarne Stroustrup
How C is Base Language? ‘Pragmatic’ family of languages General purpose, free-formatted and strongly typed Efficiency and portability Library support and Curt code
An Example? Floating Points No floats in switch Maps to the underlying support ‘keep the built-in operations close to the machine (and efficient)’ - C philosophy
All floating point arithmetic in double precision
How C++ is Designed? multi-paradigm language designed for implementing class libraries and frameworks evolutionary design for large-scale programming
How Java is Designed? If a feature can be done by a class, don’t support it in the language Make the life of programmer easier Keep the language simple
How C# is Designed? Primarily to get maximum out of .NET combines best features of languages plus its own new features component programming
Which Language is THE Best? Misleading question No language is perfect or ideal Influence other languages
Conclusion? No language is the best History has shown - every language has its place in the world of programming!