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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,52d41ed2965dfc50 X-Google-Attributes: gid103376,public From: stt@henning.camb.inmet.com (Tucker Taft) Subject: Re: Something like "->" in Ada? Date: 1996/04/03 Message-ID: #1/1 X-Deja-AN: 145688246 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: henning.camb.inmet.com references: <31620B5E.FCD@mcs.com> organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-04-03T00:00:00+00:00 List-Id: Mike Young (mikey@mcs.com) wrote: : ... : In playing with Intermetric's adajava package last night, I had : an interesting few minutes translating the following Java statement into : Ada-ish code: : (size().width - g.getFontMetrics().stringWidth(helloStr)) : The Ada equivalents I finally coughed up are: : 1) (size(this).width - stringWidth(getFontMetrics(G), hello_Str)) : ... Of course, given my background, I find this latter form much easier to grok. Perhaps something like the following is going on (speculating on how my perception works here; add big grain of salt... ;-): with the prefix form g.f(a).h(b,c), the name of the thing you are getting ("h") is buried in the middle of the expression, whereas with the "params inside" form, the function name comes at the front, so you know right away that you are getting a stringWidth. With field selection the name at least comes at the very end, rather than buried in the middle. It is interesting that Java code examples often have very short variable names. If your variable names are relative long, such as: currentGraphicsObj.getFontMetrics().stringWidth(stringOfInterest) then it becomes even harder to find the important signal with all the noise. As another example, in using Java, one of the "perceptually" confusing lines I see frequently is: System.out.println(Message); whereas in Ada/Java this becomes (presuming "use" clauses): println(stdout, Message); Again, I find the Ada usage much easier to understand at first glance, given my background. The complete conceptual switches between "System" (a class), "out" (an object), and "println" (a method) in the Java version is particularly unhelpful to my perception. I suppose in Ada, I think of "." as meaning "digging into" the guts of an object or package, and I think of "()" as performing some operation. When "." means both digging in and invoking a method, depending on context, I find it harder to intuit the meaning on a first reading. I suspect it is somewhat the reverse-polish vs. infix issue again. One is easier to write, the other is (at least for some folks!) easier to read. Since on a calculator, noone is generally reading the result of your button pushes, a reverse-polish approach makes good sense. In a programming language, you can argue for the most readable -- which is unfortunately going to vary depending on your background. : But, as you say, it's probably a matter of acclimation. For sure. Vive la difference. : Mike. -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Cambridge, MA USA