Regarding Java

Pages: 1... 3456
But what I liked most was garbage collection.


Come on, garbage collection is not that hard to realize in C++.
closed account (1yR4jE8b)

I didn't know that Netbeans had an IDE for C++ until reading this thread. I'll have to try it out.

By the way, do you know of any decent tutorials for plugging in Microsoft's VS2010 compiler into it? I simply couldn't figure out how to make it work for code::blocks when I tried it.


You can install the C++ plugin from the plugin manager or you just download the C++ distribution from the download page on Netbeans.org

I've never tried (or wanted) to use the Microsoft compiler with Netbeans, I believe that they expressly do not support it (open source hippies).
(open source hippies)

Hey! What do you have against open source software? >_>

That aside, I would think that if you can use custom makefiles with Netbeans (which I know you can), you can use any compiler that has a console interface (doesn't Microsoft's compiler have one?).

-Albatross
Last edited on
I don't think he has anything against F/OSS, I call proponents of free software hippies or freetards from time to time, and I'm one of them...
I know, I know. I just don't like being called a hippie... *sits down on a bench in Berkley and proceeds to smoke some currently illegal leaves*

-Albatross
closed account (1yR4jE8b)
I didn't mean to generalize, but some FOSS proponents are more extreme than others (Richard Stallman being one of them IMO)

Yes you can write your own Makefiles with Netbeans, so you should be able to use
cl.exe
and
link.exe
with it. I don't know if Netbeans will be able to parse the errors, but it's a start.
Last edited on
hanst99 wrote:
Come on, garbage collection is not that hard to realize in C++.
There are a lot of look-alikes, with smart pointers and stuff. But 1st - you have to enforce the memory management policy manually. You can not say - configure garbage collection for all GUI code - you have to put smart pointers all over the place. And the other party may use different type of solution - lifetime associations with owner objects like Qt. How do we keep together?

Second, circular references are a problem. I mean, what if two objects communicate with each other in a duplex. Say, the mediator and observer patterns. The subscribers are holding reference of the mediator (to unsubscribe if they have to), and the mediator keeps track of all subscribers. All of those are connected to the remaining system through the mediator, and the mediator is let go. The reference counts can not reach zero. Say you fix that with weak pointers. But the architecture could be very complex. The relationships could be constructed with dependency injection and result in arbitrary graphs. If I am forced to invent some form of specialized garbage collection of my own, this will first burden my design and second cause other delayed effects later. Not to mention that I may have to replicate some standard garbage collection algorithm in the end.

I really wished to try and create smart pointers for precise gc in C++. But it is currently not possible due to lack of portability. Pointer comparison is not portable and I do not care much about non-portable stuff at the moment.

Btw, this garbage collection business is very good illustration of the problems in aspect-oriented programming. You have some aspect that obscures and burdens the implementation and you wont to control it globally and to keep it consistent in the entire subsystem. This is what I need in memory management.
Last edited on

I really wished to try and create smart pointers for precise gc in C++. But it is currently not possible due to lack of portability. Pointer comparison is not portable and I do not care much about non-portable stuff at the moment.


Another problem is that you cannot move objects in memory and you cannot find all pointers pointing to the given block of memory. And another problem is that you can have pointers pointing to the inside of the allocated block, not only to its beginning (because of multiple inheritance and pointer arithmetic). And another problem are destructors - you have to call them, and C++ code is usually littered with destructors everywhere. All of this is a reason why precise GC in C++ would be extremely costly compared to GC in systems designed from ground up for it - you just lose most of benefits given by modern generational GCs: fast allocation of small objects, 0-cost deallocation, lack of heap fragmentation and good memory reference locality, transparency and ease of use for programmer.
Last edited on
rapidcoder wrote:
Another problem is that you cannot move objects in memory and you cannot find all pointers pointing to the given block of memory.
I am not expert on gc-s, but AFAIK even built-in gc will have to work for that. It is a processing intensive graph algorithm no matter how you look at it. Even if you write it in assembler.

And another problem is that you can have pointers pointing to the inside of the allocated block, not only to its beginning (because of multiple inheritance and pointer arithmetic).
This is a problem particularly in C++ due to lack of any portable way to test whether a pointer is directed inside a given range. I think I did mention that in the previous post. Also, only POD types have layout specification in the standard. For me this is just plain lacking, because some constraints are natural, such as laying out all sub-objects inside the memory range of the outer object.

And another problem are destructors - you have to call them, and C++ code is usually littered with destructors everywhere.
Destructors or finalization, you've got to have something. The problem is that there is fundamental difference between memory management and resource management in general. When I say fundamentally, I don't mean in particular design, I mean in its very nature. If I understand correctly, clean-up in systems where the references create graphs with cycles is generally something complex. But this is not problem particularly for C++.

And fall back to semi-manual management is not entirely satisfactory. Say object X keeps a socket open, and object Y owns object X. Then I have to say to the users of object X, and of object Y, that both require their clean-up ASAP. My designs will not be very transparent to the users of those types. What if I start using some pooling method in the future, and the clean-up is not anymore so critical. Will anyone modify their code to reflect the change and to tidy their functions.

All of this is a reason why precise GC in C++ would be extremely costly compared to GC in systems designed from ground up for it
They will be a bit costlier for sure. Like matrix computations compared to Matlab. Or regular expressions compared to Python and Perl. But does this mean that we will never build libraries - we will just wait for compiler developers to integrate every feature we need in the language. And I don't like vendor lock-in. Also, I admit that without compile time type introspection, the presence of several pointers in a single object would be handled sub-optimally in C++, but who knows - this may change.

you just lose most of benefits given by modern generational GCs: fast allocation of small objects, 0-cost deallocation, lack of heap fragmentation and good memory reference locality
I see what you mean. You mean compacting gc. Compacting gc-s have numerous benefits, because they use memory stacks and this makes the allocation rapid. The problem is not that you can not create compacting gc in C++, the problem is that you can not efficiently create growing stack in C++. And the core problem in doing that is the lack of separate reserve and commit operations in the language. You need to be able to reserve big range of memory and commit actual resource for it only when it is later needed. This is also omission. One can try to use vector presently, if careful, but it wont be as efficient. On the other hand you may not be comfortable with the objects moving in memory for some reason - like interprocess communication.

transparency and ease of use for programmer.
This is always a problem with extensions implemented by the programmer. But instead of deciding over the need to have more features in the language, I prefer entirely new paradigms - aspect oriented programming, language oriented programming, etc. I know this is day dreaming at the moment, but I look to the future with hope.

As I already said, I really would like to have gc as part of the run-time, not as part of the platform. If the run-time wants to delegate the support to the platform for efficiency, fine. I still want to be able to compile for freestanding environments though.

Regards
Let me point out one *very subjective*, yet very important advantage of C++ over Java - its culture/attitude of its users to the language.

In Java, the programmers somehow accept that some higher authority - in this case a group of ordinary engineers at ex-Sun Microsystems - decides the general guidelines and concepts of how a program should be written.

On the other hand, the spirit of C++ is quite different. The very author of C++ (Bjarne Stroustrup) is extremely critical to the language. He points out that some of the choices made in the language are not the best, and he even admits to have made bad choices (on a google talk video).

The spirit of C++ is that of constant criticism and constructive improvement, following one's own workflow and way of thinking. In the same time, doing C++ means sometimes struggling with poorly chosen language features (which remain only due to backward compatibility), as well as lack of true standard for I/O and parallel processing (which in turn is related to the diversity of hardware, operating systems and amount of companies relying on C++).

On the other hand, the spirit of Java seems to be that of studying the Divine inspiration of the Original Java Developers, reusing their style as much as possible, building on top of it, but never questioning or trying to improve it. Matters such as Garbage Collection, hardware management, networking, etc. have already been decided for us by the Java Higher Authority.

We do not need to worry about such things: we are not as smart as the engineers at Sun.

On the other hand, Java has some clear benefits - its better standardization due to its virtual machine, huge ready made libraries, and the consequent quick development of small to mid-sized projects.
Last edited on
@tition: have you ever heard of OpenJDK or Java Community Process? The community behind Java has a lot to tell about the shape of the language. Java's design is open - everyone can post a JSR, and if it is good and most of the community agrees on it, it enters the platform. Therefore you sometimes get long debates on what should be in the language and what not, e.g. see the latest long debate on clojures and three competiting (working) proposals. Also, not only Oracle (former Sun) develops Java, there are some other big companies involved e.g. IBM, Apache Foundation, Azul Systems and also Google (although they don't play to the rules, so Oracle sued them).

Java community is not critical-less about the language or the platform and they don't take anything as granted. For example in the recent releases they added a brand new low-pause GC algorithm, because some Java apps want to use heaps of size >64 GB - for such large heaps the current available solutions were inacceptible.


On the other hand, Java has some clear benefits - (...) the consequent quick development of small to mid-sized projects


Actually Java was designed and successfully used for very large projects (like several millions lines of code), and IMHO it beats most of other languages in this regard. Common convention, rich standard libraries yet quite simple language core, documentation standards are very important things for big projects - things I wish were prersent in C++.
Last edited on
@rapidcoder
Seriously though. The scope of the Java solution is limited:

1 No ability to run the code separately on environments with no OS. Why not? I know that you can install some minimal Linux for this purpose, but why is this necessary? What would be the cost of injecting the run-time support that will be needed directly in the code, when you will not be running other applications. Licensing issue?

2 No ability to create unmanaged code in Java like in .Net. You have to use another language and JNI. I would choose .Net, but it is not portable, and I doubt it will ever be.

The way I see it, I have to learn three languages to perform the same task - C++, Java, some .Net language. That's like learning Python and Perl.
closed account (z05DSL3A)
Java's design is open...Google (although they don't play to the rules, so Oracle sued them).
Not really open then is it?
It's amazing how this thread descended into a language debate (although I expect that was fated from the very beginning). I'll try to stay away from this debate, but there is something I'd like to ask. Is it really that important for a language to be superior to another overall?

The way I see it, each language has its advantages and disadvantages, owing to each language's different purpose, and while it's neat to uncover them I wouldn't debate about which language is better based on those.

...unless I clearly defined a problem to solve and had a choice of language.

-Albatross
The overlap in problem domain between languages is close enough to make comparisions inevitable.
I'm with Albatross on this.
I would venture to say that D is superior to them all ::cough:: ehem...

The way I see it, I have to learn three languages to perform the same task - C++, Java, some .Net language. That's like learning Python and Perl.


Yes, of course. No language is perfect for all the tasks, so if you know more of them, the better for you.


Not really open then is it?


It is open in the way that you can create your own implementation of JVM conforming to the specs, you can create JSRs, you can provide your own implementations of JSRs and contribute to the core JDK thanks to OpenJDK. What you cannot do is create your own Java-like platform using the patented work of Sun/Oracle. Which is exactly what Google did and was sued for. So the only restriction is when you go your own way, you have to use your own ideas, not steal ones from Sun/Oracle. And of course you cannot name it Java then.


I would venture to say that D is superior to them all ::cough:: ehem..


May be, but they seem to have serious social problems with the development process and they are moving too slowly. It was released 5 years before Scala and only one year after Erlang but still there is no serious stuff written in it, and there is even no decent IDE for it. Library support is also not yet there (nothing even remotely comparable to Boost). And its compilers produce code slower than both Java and C++. It won't catch, IMHO.
Last edited on
I would venture to say that D is superior to them all ::cough:: ehem...


When I first heard of D I already had 20k+ lines of C++ code, so I never gave D a try.

However, I have been reading quite some about the language now- I might actually give it a try. I wonder how difficult will it be to convert a C++ program (around 45k lines of code by now) to D.

My favorite programming technique is templates (including inheritance between templated classes and nesting templates), which seem to be central to D (their compile-time "const" keyword). Any comments on your experience in D with similar techniques?

Where should I start if I actually want to try D?

@rapidcoder
It is open in the way that you can create your own implementation of JVM conforming to the specs, you can create JSRs, you can provide your own implementations of JSRs and contribute to the core JDK thanks to OpenJDK.


Here is a joke on freedom:

An american and a russian are arguing whose country is more free (the time is early 1980's).

The american goes:

"My country is *completely free*. You know, I could go in front of the White house and shout:
"President Ronald Reagan is an idiot", and *absolutely nothing* will happen to me! "

The russian retorts:
"My country is just as free: you know, I could go at the Red Square in front of Kremlin, stand in front of Comrade Brezhnev's window and shout:
"President Ronald Reagan is an idiot", and *absolutely nothing* will happen to me! "
Last edited on
@Return 0:
So the two standard libraries, no shared object support, and string handling controversies have been resolved? [/rhetoric] Sorry, but I'm not trying D just yet. :/

-Albatross
Last edited on
Pages: 1... 3456