logo       

Re: How do you choose your programming language ?: msg#00090

culture.hackers.israel

Subject: Re: How do you choose your programming language ?

On 11/23/05, Nadav Har'El
<nyh-TS7m/3hpY0sOpacJJkBjfT4kX+cae0hd@xxxxxxxxxxxxxxxx> wrote:
> 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?

There are rumours [0],[1] that the next Java version, Mustang, will
include the C++-like behaviour (the proper name for which is RAII).
Most probably the mechanism will be conservative, i.e. it will opt for
false negatives over false positives. So your assertion on the general
case is still valid.

> 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++.

Well, easier for some tasks. Generally speaking, there are a lot of
opportunities to accidentally use an out of date pointer in Java.
This is because there are mechanisms that allow one to escape the GC
model (e.g. weak references), along with mechanisms that allow one to
extned the garbage collection. These techniques are used by developers
of JxEE application servers, which are the reflection of OS
development in the Java universe. Of course, an assumption that a
business logic developer never touches these, so she's free to assume
that the code is executed by scrupulous pixies.

The bottom line is that expert-level development is dangerous even in
Java. On ther other hand, Java universe provides good tools for a
developer that is ready to use these.

> It's a deliberate design decision, and not
> an implementation mistake. But at the same time, it's what makes it a
> memory hog.

A memory hog and a mess to hack on. Try to implement a port scanner in
Java (I did) -chances you'll have to implement your own abstractions
for: sockets, addresses, memory buffers etc. On the other hand, there
are wonderful tools that can help you doing these - I am still to see
a tool that gives me a powerful refactoring browser for C++ that will
be comparable to where Eclipse was 2 years before.[2]

Memory problems are the easiest problems out there. Once the memory
problems are figured out, there are logic errors, type errors, state
errors, concurrency errors, error handling errors and not meeting the
functional requirements. All these are subtler than memory errors and
therefore harder to get right. Java attempts to answer these issues as
well as memory-related issues - an activity that contribute to the
infamous Java performance and run-time requirements.[3]


[0] http://forums.java.net/jive/thread.jspa?messageID=7952&tstart=0
[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6336351
[2] SlickEdit is considerably less powerful. CDT is a joke, just as
KDevelop is. Of course, I can manage with
sed/awk/perl/vi/emacs/python/shell biosphere, but it routinely
requires more effort.
[3] These issues are treated in a compeltely different way in the C++
community. Here, learning curve is completely sacrificed to portable
and productive environment (that is inconsistent to the degree of
hostility and requires YEARS of hands-on experience)[4]. Most people I
know just do not make it to the end of the learning curve (which
includes type theory)
[4] Just as Common Lisp does.

>
> --
> 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.


--
Sincerely Yours,
Omer Shapira





------------------------ Yahoo! Groups Sponsor --------------------~-->
Get fast access to your favorite Yahoo! Groups. Make Yahoo! your home page
http://us.click.yahoo.com/dpRU5A/wUILAA/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>
Google Custom Search

News | FAQ | advertise