This article explains how to develop and implement trees in the Standard Widget Toolkit. Learn how an SWT tree is created and populated with data, how columns can be used to categorize data, how a tree can be extended to support row sorting, and how the tree’s content can be searched.
I opened it because this night I should implement trees.
But seeing that it deal with Java SWT, Beeuuuu :-*
I will implement it in Qt anyway, this night and in C++.
(maybe python who knows !)
So whats wrong with Java according to you?
Or you just want to show off that you can hack something in C++?
show what ?
Anyway, I don’t like Java and its speed disaster.
Some years I heard about an OS written in Java, still alive ? XD
C++ is for robust things, Python is for prototyping this is the best combination !
Look at Jython. They have an excellent tree example. I wrote jython viewer that connects to a database with hierarchical information in like 10 lines (clean and clear) of code. It just showed me the tree structure and printed information when you selected a node.
Speed disaster? Come on, please be correct. Java was slow in the beginning of its release. Current JIT compilers are as fast as C++ / native code or even faster in some cases.
Why do you think NASA is using Java instead of C++? Because of pointer bugs. Its not reliable enough.
[q]show what ?
Speed disaster? Come on, please be correct. Java was slow in the beginning of its release. Current JIT compilers are as fast as C++ / native code or even faster in some cases.[q]
So that’s why OpenOffice is too fast, and Eclipse is too fast, and netbeans is too fast and JavaEE apps are tooooooooo fast
dude, OOo is C++!
You are mentioning HIGHLY complex and dynamic applications. QT Creator doesn’t even skim the surface of the capabilities of Eclipse & Netbeans.
Stop trolling and get back into your cave, you’ve obviously been sleeping in it for the last 5 years.
Except OpenOffice is written in C++ And Eclipse was waaay faster than KDevelop when I last checked it…
Probably your computer is toooooooo fast also
OK OK, Java is Faaaaaasst (Forward)
Why there is no java made OS ?
why they use C ?
come on – read up on things!
There is no pure C/C++ OS either – they all need (some) ASM (I am not aware of register level access from within C – but I could easily be wrong).
Java has no way to execute asm code directly, however it can execute native code via JNI.
Thus you need a VM + JNI to create a Java OS – which is done by the JNode project: http://www.jnode.org/
However, all this aside – creating an OS in a language is not a requirement to prove its performance.
Java IS slower than C/C++ – however, it all depends on the compiler. Java has Hotspot which can do RUNTIME (jit) optimization whereas C/C++ has Ahead of Time compilers/optimizers. This means that c/c++ code will typically be optimized from the beginning whereas java needs some investigations to create the optimum path. This means that during an applications life-span it should (and often do) perform faster in Java.
This is basically what the LLVM project is doing for c/c++ – which means that c/c++ should get much faster, and gain some of the Java-jit benefits.
> Java IS slower than C/C++
Not quite true:
http://stefankrause.net/wp/?p=9
Don’t you think that’s a little petty?
* C is a relatively low-level language, which makes it ideal for OS internals.
* C++ is a middle-level language, but inherits all the low-level bits from C.
* Java is a pure middle-level language that completely abstracts away OS details.
We need to accept that different languages are useful for different things. Personally, I don’t like Java at all, but I must accept that it has its uses!
Edited 2009-05-15 09:11 UTC
Java OS is jNode.
http://jnode.org/
The major problem with Java/.Net (or most VMs for that matter) is not its speed, but rather the high memory requirements for initial JIT compiling of bytcodes whenever they are loaded and the GC tuning that is required to develop performance apps with it. A way around the JIT memory requirement is to do AOT. This would however not solve the GC problem and make your Java app non WORA.
The J2ME JVMs tend to interpret code when there isn’t enough RAM to JIT compile classes. Some J2ME VMs, like the IBM J9, can accept AOT compiled classes that do not have the JIT overheads, but would only run on CPUs they were targeted for.
-Ad
So that’s why I hear chantings and chorus performances and whole concertos about JNI in the back of my head whenever I need to code a cpu-hungry algorithm.
C++ is for robust things in the same way that Windows 95 is the ideal operating system for your heart & lung machine.
Edit: tried to clean up the sentence structure. My grammar parser is broken, must have been written in c++
Edited 2009-05-14 20:18 UTC
What’s the relation between Win95 and C++ ???
Robust app means app that are written after prototyping phase
No, thats not what “robust” means.
http://en.wiktionary.org/wiki/robust
My point is that in the same way you would not want your heart and lung machine to run an operating system known for its crashes and instability. You would not want to write anything you needed to be robust written in c++.
The robust requirement is a large reason why enterprises switched from cobol to java and never considered c++.
FYI, there are still many enterprises using COBOL though the mainstream development has moved on to other languages.
Also, critical embedded applications are mostly written in C, not Java or any VM language for that matter.
-Ad
Edited 2009-05-15 09:56 UTC
Since when? “Robust” means something that does not break easily. Not one of C’s or C++’s strength. When talking about robust, languages like Erlang come into mind…
Let me correct a typo, you meant Ruby there, right ๐
Ruby ?
I don’t know much about it ! sorry !
But I know that google uses alot of Python inside
There’s no point going into a Java vs C++ argument here — the question is one of toolkit design. Qt is an exceptionally well-designed toolkit (and has Java bindings, remember), but not everyone is fortunate enough to be in a position to use it, and in some situations it may not be appropriate.
Personally, I disliked the design of both the SWT and Swing toolkits when we studied them at university, but if I were required to write something using SWT, this article would be useful, so good job!
Now how about a series of articles comparing widget toolkits — Qt, GTK, wxWidgets, FLTK, etc…?
Someone is wrong on the Internet!
Dude, think in terms of Economics – what is the added value of your comments? 0 or less
This article is interesting for Java developers. Not interested, skip it.
I would like to contribute articles on writing Qt apps. How do I that? I don’t see a contribute link anywhere on this site.
-Ad
Click on “Contact”.
Either contact one of the editors as suggested, or you may click “Submit News.” It’s in the top right corner.
C++ is utter crap:
http://www.theregister.co.uk/2009/05/07/verity_stob_cplusplus/.
Every programming language has its warts. None of the them is utter crap.
You might wanna spend some time learning InterCal to appreciate what utter crap would be like!
-Ad
C++ is not for everything, nor is it for everyone– especially with the proliferation of “Java Schools” that pump out graduates who have never heard the word ‘pointer’ and couldn’t write a linked list if their lives depended on it.
But if you take the time and effort required to learn and understand C++, it’s a very powerful tool to have at your disposal for those times when it is the best tool for the job.
I can say C++ is utter crap because I use it and I hate it.
Linked list with pointers? is this 19th century or what?
And there are plenty of us that also use it daily, and don’t find it to be utter crap. Though I am not aware of your situation, so you may have a job that requires you to use C++ in areas where it’s not the best option. In that case, I can understand why it would be painful. I get to decide which tools I use, and lately, I tend to prefer C++ for the low level bits, C# for the application level, and Python/Lua for scripting on top of that. This makes the easy things simple and the hard things possible. Taking C++ out of that mix would only cause me more trouble, so I find it to be a useful tool.
No, but I would expect that anyone graduating with a degree in Computer Science would have some familiarity with the fundamentals of programming, and those would include pointers and basic data structures and algorithms. Unfortunately, this doesn’t seem to be the case for a good portion of graduates anymore.
You’re right. Take into mind the word “algorithm” – it’s much older than the 19th century, but it’s essential to understand what is meant by it when you’re doing serious programming work. As well as concepts – linked list, stacks, trees, enumerations, arrays, even pointers and memory addresses – that are important, it may be possible that a programmer never has to implement something such basic on his own, but it’s neccessary that he understands what’s going on “under the hood”, so if problems occur (and they usually will), he has a clue about how to solve them. Surely, this is often considered “old-fashioned” or “unmodern” by many novice programmers who know how to click in “Visual BASIC” and consider themselves geniuses. But when you need to optimize code, you’re thinking in “old-fashioned” categories like exponential complexity, iteration loops or memory layout.
Furthermore, I agree with your consideration that today’s educational concepts in computer science don’t seem to put much emphasize on teaching basic concepts. But finally, it’s these basics that enable you to understand how things work. But if you’re just keen on a BA, MA, Dipl.-Inf. or some other degree that you can show around, while treating your PC as a worse typewriter, it should be sufficient. ๐
Right. The higher level abstractions provided by languages like Java and C# are useful, but you still need an understanding of what’s going on underneath. Otherwise, how do you choose between structures like HashMap and TreeMap or ArrayList and LinkedList?
Except that today, the “disease” is carried by Java, and it’s even worse because the whole thing has been institutionalized by the educational system. I don’t blame Java itself– it’s a perfectly fine language if that’s your cup of tea, but it is the current tool being used to train an army of programmers who are completely unable to see behind the abstraction.
The only problem with this is that a Computer Science degree has become completely irrelevant as an indicator of someone’s level of knowledge in the subject. Not that it was ever perfect, but it did, at one point, suggest some minimal training and understanding of the basic concepts.
This is complete BS. So Java programmers dont know whats underneath? Come on, the Java API is know by most programmers. Ever thought of Certifications? I’m a Sun Certified Programmer and Web Component Developer. Dont tell me I dont know when I need a HashMap or a TreeMap. I’ve got a Bachelor degree in Software Engineering, but I also do my certifications so what are you talking about? Also 10 years of experience helps to develop yourself as a programmer.
It would be helpful if you were to respond to something that I actually wrote.
The fact that I condemn using Java in an educational setting as a means to avoid the difficulties of teaching low level concepts does not in any way imply that I think all Java programmers are incompetent.
More specifically, if you can look at a piece of Java code and understand what’s going on underneath, then I wasn’t talking about you.
See that’s funny, because if you asked Stroustrup, only using C++ to replace what you’d otherwise be using C for is a huge waste of the immense featureset that C++ provides.
You know what’s worse than a Java programmer who doesn’t know how to program? A C++ programmer who doesn’t know how to program. The usual assumption is that bad programmers won’t cut it in C++, but personal experience has taught me that bad C++ programmers are quite plentiful. The sheer destructive power of the bad C++ programmer is unmatched in the world of software engineering.
The other dirty little secret is that unless you’re a bonafide expert with years of experience, you’re probably a bad C++ programmer.
Indeed, it is. There is no reason not to take advantage of function and operator overloading, classes, templates, RAII, the STL, and even the fantastic Boost libraries. In fact, Stroustrup even suggests that the only reason to use C over C++ is when you’re faced with the lack of a good C++ compiler.
Bad programmers are plentiful in every language. That is unavoidable. What I find disturbing is that universities, due mainly to retention and budget problems, have institutionalized the act of creating bad programmers.
It is a large and complex language. I’d say it takes at least a decade of experience with C++, working with it full time on a variety of different projects at different technical levels before you can call yourself a good C++ programmer. And of course, any good C++ programmer has copies of the Scott Meyers books and D&E on their bookshelf.
Edited 2009-05-18 22:29 UTC
I’d say they’d need to do linked lists with pointers (and somesuch) exactly because it’s not the 19th century. Languages – and teaching of them – drives new coders away from basic knowledge, also de-emphasizing knowledge of basic algorithms. The result is a bit frustrating – for me at least it is – since I feel (I work in a research institute with connections to universities) the handicaps they sometimes have because of this, and they don’t even know the cause.
And FYI, just recently I had to create a tree structure with pointer node interlinks from the ground up, since no preexisting ones I could use would produce the preformance I wanted, it took me a few hours and it works great. It’s not what I do every day, but if the knowledge is there, than it’s no problem. If the knowledge is not there, well let me put it this way, sometimes you can’t tolerate a few hours of work to go on for days and produce inferior results just because the coder doesn’t have the necessary basic algorithmic and coding knowledge.
Problem with java and c++ is that it to complex or the learning curve to steep. Things that are simple in basic
take a long time to implement in java, looked at it for a while to write a little program for my mobile phone, but it is just annoying…
Edited 2009-05-17 07:42 UTC