I am new to Java, and cannot find a discussion group for basic Java questions - so perhaps you guys can help with the following, or suggest more appropriate groups:
1) One of Java's major touted features is garbage collection, especially when compared to C++. However, in the 3GL and 4GL Languages [e.g. Pascal, Fortran, Oracle PL/SQL etc] we never had to worry about "cleaning up" memory.
So, what's so different in languages such as C++ and Java that requires memory to be cleaned-up, manually in the case of C++, and automatically within a Java environment - Why doesn't Pascal require this?
2) The concept of the "Stack" in memory is very common - everyone in college learns how variables are pushed and poped off the stack. However, when programming in Pascal/Fortran, there was never any talk of the "heap" memory area! -
a) So, is the concept of heap particular to just these sort of OO languages?
I would appreciate all input.
Thanks in advance
You have some good points , but you're also missing a lot.
1. If you don't have to worry about garbage collection or allocation/freeing you have to worry about wasting space and time.
Older version of Pascal and Fortran didn't have dynamic allocation.
So you couldn't implement dynamic structures such as graphs unless you were using arrays, and indices instead of pointers.
This was a big limitation and one of the reasons why Kernighan and Richie invented C in order to have a 3GL language for programming the Unix OS.
PL/SQL does have some garbage collection behind the scenes.
2. The concept of stack is somehow present in Java but only primitive types variables (int,float,boolean) are allocated on stack. Also pointers to object arguments are passed of stack.
I also wish Java will also implement objects on stack, but this has some technical difficulties related to managing pointers and doing garabage collections, so we'll have to wait or live with it.
3) No, the concept of heap was there for a long, long time. I'm not sure who introduced it in Computer Science but you can read about it in the classical book by D. Knuth which is some 30 years old.
But what exactly is your problem with heap and garbage collection ?
Thanks - I don't have a problem with any of this - I'm just trying to get a good fundamental understanding - It's the sort of stuff that is interesting to know.
My general opinion about Java is that it isn't just a programming language, it a whole (different) concept and not easily understandable.
Even without the complete understanding of a concept you can of course write a simple (or complex) class, but designing a good (maybe even J2EE) system in Java it quite difficult without the understanding of the concept.
I've seen lots of people coming in to our company saying they could program Java or could learn it (when coming from a c++ background for instance). But in fact lots of times the fact was they didn't understand Java yet. In my opinion this will take a while...