Java is written in C, but so is GCC. I could write a C compiler in Java too, and that wouldn't necessarily make C run slower than Java.
Java is nowadays typically compiled.
As for buffer overflows, consider this code in C.
char x[100];
char inTrustMode = isInTrustMode();
//...
gets(x);
//...
if (inTrustMode) {
//Do trusted(unsafe) operation
}
In this example, what happens if you input a 100th character. This is a typical C security vulnerability. I believe GCC even outputs a warning for using gets. Maybe it's just gets that's badly designed, but the fact is even strcpy has an associated security vulnerability.
Now, C++ might have improved the situation for strings, but the remaining types of arrays are still unsafe.
In Java, this is a Out of bounds exception and that's the end of it. So, you get a nasty exception(that can be caught) instead of having malware installed in your computer.
Last time I tried, I could use try/catch in C++ without the double underscore prefix. It still can't catch out of bounds.
they probably just had written it better in Java than in C
Then you're saying the application code matters more than the language. And, in that case, I'd rather be solving problems(and coding better) than being stuck with C.
GTK, Qt, and wxwidgets are in that category. So are WinAPI and XLib.
Of all your examples, only wxWidgets(and possibly Qt) are worth discussing. XLib was a particularly miserable example.
However, I'll grant that Swing is less than optimal, and C# GUI is not-so-brilliant if you need cross-platform.
However, Java+Swing coding is simpler than C+wxWidgets. With the time I get left, I can actually figure out where/why my code is being slow and optimize the parts that matter, instead of trying to reinvent the wheel or recompile some C++ library, so the end user gets an application that's safer, faster and - most important of all - is actually released!
Regarding IDE writing, Java code is more predictable than C++ code.
For instance, consider the following pseudo-code(translate it to Java and C++ in your mind):
class Foo{
Content goes here
}
what is that? A Java IDE would correctly assume it is a class. A C++ IDE *could* try to assume it is a class. However, the C++ IDE first needs to be sure(in order to be accurate) that this particular piece of code does not appear:
#define class enum
Which, guess what, is valid C++.
Also, the above code could be in a header file of its own, so I could have:
#define class enum
#include "Foo_definition.h"
So when editing Foo_definition, there'd be absolutely no reference to the class definition as enum.
The C++ IDEs can, therefore:
- Incorrectly assume that all classes are classes. I believe most IDEs do this.
- Check for #defines in the same file. As I showed earlier, this is not always correct behavior.
- Infer usage based on previous compilations. This does not work on the first time and works badly when headers are used in multiple contexts.
- Implement some fancy system that's not intuitive(hence nobody will use your IDE), takes 3 years to theorize, 5 years to understand and another 4 years to implement, and takes O(n^n) time to run, making even IE6's JScript look fast.
Besides, Pinta, Tomboy and F-Spot aren't very good, nor are they fast.
I provided examples, which was what I was asked to do.
Some citations:
http://en.wikipedia.org/wiki/Buffer_overflow :
Programming languages commonly associated with buffer overflows include C and C++, which provide no built-in protection against accessing or overwriting data in any part of memory and do not automatically check that data written to an array (the built-in buffer type) is within the boundaries of that array.
The Java and .NET bytecode environments also require bounds checking on all arrays. Nearly every interpreted language will protect against buffer overflows, signalling a well-defined error condition.
http://golang.org/doc/go_faq.htmlGo features fast compilation (as opposed to C) as a language feature. So it obviously isn't just for me that it matters.