From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-08 23:46:31 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: 18k11tm001@sneakemail.com (Russ) Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? Date: 8 Sep 2003 23:46:30 -0700 Organization: http://groups.google.com/ Message-ID: References: NNTP-Posting-Host: 63.194.87.148 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1063089991 22548 127.0.0.1 (9 Sep 2003 06:46:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 9 Sep 2003 06:46:31 GMT Xref: archiver1.google.com comp.lang.ada:42302 Date: 2003-09-09T06:46:31+00:00 List-Id: Hyman Rosen wrote in message news:... > Russ wrote: > > Suppose I want to take the sine of an angle in Java. Can I somehow set > > things up so that I can simply write "sin(x)", or must I write > > something like "math.sin(x)"? The former is acceptable to me, but the > > latter is not. > > The latter generally. Also for cases like this, 'math' would be a class, > not an object, and 'sin' would be a static method. If that's too odious, > you can always do this: > > class MotherOfAnythingIWouldEverCall > { > double sin(double x) { return math.sin(x); } > // etc. > } > > class MyClass extends MotherOfAnythingIWouldEverCall > { > double f(double x) { return sin(sin(x)); } > } > > But no one would do that. Just pretend you're using Ada in a shop > that has forbidden use clauses. Then Java was certainly not designed for elegant implementation of algorithms. Let me give you a brief example of some basic greatcircle calculations based on a spherical model of the earth. The great circle distance d between two points with coordinates {lat1,lon1} and {lat2,lon2} is given by: d = 2 * asin(sqrt((sin((lat1-lat2)/2))^2 + cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2)) We obtain the initial course, tc1, (at point 1) from point 1 to point 2 by the following. The formula fails if the initial point is a pole. tc1 = mod(atan2(sin(lon1-lon2)*cos(lat2), cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon1-lon2)), 2*pi) The corresponding equations for the ellipsoidal model of the earth are far more complicated, but even these relatively simple equations demonstrate the awkwardness of using Java for algorithms. The latter expression has no less than 9 math functions plus a constant (pi), and you're telling me I must precede each one with "math." (or do some other nonstandard trick). You can have it.