POV-Ray : Newsgroups : povray.general : POV-CSDL (or Java Binding?) : Re: POV-CSDL (or Java Binding?) Server Time
10 Aug 2024 13:17:01 EDT (-0400)
  Re: POV-CSDL (or Java Binding?)  
From: Jon A  Cruz
Date: 12 Mar 2000 20:57:09
Message: <38CC4C80.5374C28E@geocities.com>
Nieminen Juha wrote:

> Jon A. Cruz <jon### [at] geocitiescom> wrote:
> : Well, it seems you have been misinformed. C++ has some horribly ugly things
> : that are intentionally kept out of Java, while C++ had to keep back-wards
> : compatibility with C and also add new OO support.
>
>   The fact that it has ugly things doesn't mean you have to use them.
>
>   When I try to code with Java I feel more like I am being limited and that
> handy features that I would like to use to make my work easier have been
> taken out, thus making my life harder. Many times some handy shortcuts in C++
> (like typedef, enum, etc) have been left out of Java, and altough you can
> do the same thing with other ways, it's usually a lot of extra work (for
> example defining lots of const variables with their initial values instead
> of just typing their names into an enum). They are often little things, but
> annoying nevertheless.
>
>   Here are some annoyances about Java I have found that usually forces you
> to make _BAD_ code:

Guess what? Those are many things that I specifically like about Java, and think
they help you to write good code:


>   - The enum type has been left out:
>     This means that you have to define a series of values by declaring constant
>     variables with their respective initial values. If you want to add a new
>     name in the middle, you have to change the numeration of the rest of the
>     names.
>     The order of the numeration can be important, for example when sorting or
>     if the names are someway hierarchically defined.

This one is maybe so-so. I've seen it used well, but then again I've seen it
abused. From a C++ viewpoint it's a minus, but from different design views you
don't miss it. But it is maybe a point of style.


>   - The typedef declaration has been left out:
>     Which means that you must use the specific data type when making the code,
>     instead of using an 'alias' type. This means that if you want to _change_
>     that data type later, you have to do it in _tons_ of places instead of
>     just in one place.
>     Of course the most correct way is to use only class-types, which can be
>     modified later without needing to modify the code. However, since there's
>     no operator overloading, you will need to make a lot extra work to make
>     your code if you just want to use integers or similar. See also:

Well, if you know your C++ spec well ('you' in general, not 'you Warp', you'll
remember that a typedef in C++ is just a class with no methods (or something close
to that). So Java pretty much has it the same. It boils down to just missing a
macro processor.

Also, in Java you can specify an Interface or an abstract base class instead of a
typedef.


>   - No operator overloading:

Good if used by a very decent expert programmer. Otherwise I've seen far more evil
done with operator overloading. Especially if someone comes in to do maintenance
on a large project later on. Overloaded operators make things a lot harder to read
if any of the original coders overloaded something that someone didn't expect.


>   - There is multiple inheritance of interfaces, but not multiple inheritance
>     of classes:

Bad. Can be very powerfull in the hands of an expert, but then far more damage can
be done by it's use.


>   - Pointers has been removed.

>     void F(int x)
>     { x = 5;
>     }
>
>     void F(complex x)
>     { x.set(5);
>     }
>
>     The syntax of the function definitions are quite the same. There's nothing
>     that indicates that the first function DOES NOT modify the original
>     variable given as parameter to the function, while the second function
>     DOES modify the original value.

Actually, it's quite clear. In Java all primitives are passed by value. Thus, the
first example is quite clear that it can't change the thing that came in. From a
Java programming mindset, it's very simple. As opposed to C++ where these would do
two different things:

    void F(int x)
    { x = 5;
    }

    void F(int &x)
    { x = 5;
    }

    void F(int *x)
    { *x = 5;
    }

In that case the first should work just like in Java. Of course in C++  the first
two are both called the same, so then it gets a little harder to keep track of.


>   - No templates:

Again, a very good thing.

Probably boils down to that you have to think in Java to use Java well, and think
in C++ to use C++ well.

Also, giving up some of that complex flexibility to get a thirty second compile
instead of a fifty minute compile is another thing I like. But to be fair that
fifty minute C++ compile was for MSVC COM stuff using ATL. Not all C++ is that
hard or inneficient to build.

--
"My new computer's got the clocks, it rocks
But it was obsolete before I opened the box" - W.A.Y.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.