|
Re: How do you choose your programming language ?: msg#00081culture.hackers.israel
On Wed, Nov 23, 2005, Zohar Kelrich wrote about "Re: [hackers-il] How do you choose your programming language ?": > Actually, the Java spec says nothing whatsoever about what sort of > implementation the GC should have; its only GC "contract" is, IIRC, > no object gets finalized more than once. > You're free to free (as it were) objects at the end of every method, > if you so choose. Just like understanding human languages requires several levels (syntax, semantics, pragmatics, and world knowledge), so does understanding a programming language. You cannot realisticly seperate a language and its syntax from the language's standard library, and accepted practices. Also, the syntax and semantics it provides, or doesn't provide, implies on the way people use it, and therefore on the way typical programs are written in this language. In this example, one very fundamental point about Java is that there is no free() call and no objects that live only for the duration of a single scoped (such as "automatic" (on-stack) variables in C/C++, or "autoptr" in C++). So generally, a user cannot do what you describe in Java (he has no free() function), and every Java implementation, whether an "interpreter" or "compiler", CANNOT do what you describe in the general case. Because, imagine the following piece: { Thing a = new Thing(17); counter+=someobject.doSomethingWith(a); } Can a be freed automatically right after this block (by an interpreter or a compiler, it doesn't matter)? It's not easy to decide. It depends on what doSomethingWith() does. Typically, what this method does is not known during compilation of the individual classes. Also, someobject might be of different classes (because of inheritence) and each of these classes' method might do something else. But even if you know exactly which method is called, it's still not easy to know if a pointer to a is kept. Perhaps that method calls other methods with a, or with parts of a as parameters, and these methods saves pointers? Don't understand me wrong - the very fact that everything in Java is a reference, and there're no error-prone pointers/autopointers/automatic variables/malloc-free, and no chance to accidentally use an out-of-date pointer or forget to free one - is what makes Java different, and easier to write than languages like C++. It's a deliberate design decision, and not an implementation mistake. But at the same time, it's what makes it a memory hog. -- Nadav Har'El | Wednesday, Nov 23 2005, 22 Heshvan 5766 nyh-TS7m/3hpY0sOpacJJkBjfT4kX+cae0hd@xxxxxxxxxxxxxxxx |----------------------------------------- Phone +972-523-790466, ICQ 13349191 |My password is my dog's name. His name is http://nadav.harel.org.il |a#j!4@h, but I change it every month. ------------------------ Yahoo! Groups Sponsor --------------------~--> 1.2 million kids a year are victims of human trafficking. Stop slavery. http://us.click.yahoo.com/WpTY2A/izNLAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/hackers-il/ <*> To unsubscribe from this group, send an email to: hackers-il-unsubscribe-hHKSG33TihhbjbujkaE4pw@xxxxxxxxxxxxxxxx <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: How do you choose your programming language ?: 00081, Zohar Kelrich |
|---|---|
| Next by Date: | Re: How do you choose your programming language ?: 00081, Gábor Szabó |
| Previous by Thread: | Re: How do you choose your programming language ?i: 00081, Zohar Kelrich |
| Next by Thread: | Re: How do you choose your programming language ?: 00081, Gábor Szabó |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |