Potjeh wrote:I've only learned C(++) and Java, so I don't understand how it could be made any more intuitive without sacrificing versatility.
If you know C++, then you should be able to see the contrast, because it exists between C++ and Java as well. I just don't want to use C++ as an example, since I hate that language for reasons outside the scope of this thread. :)
The main difference is that you don't
need to use classes in C++, unlike Java. Python can still be argued to be simpler for the same reason, however, since C++ still requires you do grok its concepts of header files, namespaces and functions, but C++ is still simpler than Java. The difference is clear from a simple Hello World program.
Python:
- Code: Select all
print "Hello World!"
C++:
- Code: Select all
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
Java:
- Code: Select all
public class MeaninglessSymbol {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
In the C++ example, you need to understand what "#include", "int main()" and "std::" means. In Java, in addition to having to understand what "void main(String[] args)" means, you need to understand the significance of the "class" concept, the meaning of the Meaningless Symbol, which happens to have to be the same as the name of the file you put the code in, and the meaning of "public" and "static" and why the "void main" has to be scoped inside the "class" block. I'd argue that "#include" and "std::" are far simpler concepts to grok than all that; in particular, Java's distinction of static/non-static members can be quite difficult to understand before one has a
quite clear grasp of what classes* and objects even are and how they encapsulate their members. In C++, you don't need to grok classes until you actually need them.
Note, also, that I don't argue that you have to learn what "cout", "System.out.println" or Python's "print" mean. That is the core part of what one actually wants the Hello World program to
do, so it's only reasonable that one would have to learn that. My argument is that Java and, to a lesser extent, C++ (and C, mind you) force you to learn a lot of superfluous concepts in order to even
begin to write actual, meaningful code.
*
I write "classes" instead of "object orientation", since I don't really subscribe to the idea that "object orientation" necessarily must mean "Simula-style object orientation". This is also closely related to the reason why I dislike C++.