On 18/04/2024 8:29 pm, Rony G. Flatscher wrote:
The mileage of people here vary including the Java people themselves
who have started to reduce the need of explicit declarations like the
new "var" (imitating JavaScript) instead of strict types or foregoing
the static main method such that one can at least code the main method
without the explicit declarations. The motivation about these changes
is to make Java easier, reduce typing needs and the like.
The Java var keyword is more like C# than Javascript. The variable still
has a strict type - you can only use var if the compiler can figure out
the type from other information e.g.
var start = ZonedDateTime.now();
start is a ZonedDateTime. You can't use it before it is defined, you
can't assign anything other than a ZoneDateTime to it, you can't create
a new variable called start in the same scope, whether or not it is a
ZoneDateTime. You can't e.g compare it to a LocalDateTime without
specifying a timezone for theĀ LocalDateTime - that is one of those
things that helps avoid errors.
var just reduces redundant code, e.g. specifying the type twice in the
same statement.
Of course a static and statically typed languages with a compiler must
define as much rules as possible, such that the compiler can check for
them all. The more rules the more time consuming and the more
difficult to learn a language.
I think the syntax rules for Rexx are actually more complex than Java,
because it is less likely to flag an error if you do something that's
not actually what you want. E.g. string concatenation where variables
are expected to be strings but maybe not, might not be initialized,
sometimes you need vertical bars but not always etc. If you're used to
the language you write it without thinking and avoid the traps, but the
rules are there nonetheless.
Java is relatively straightforward, and shares many rules with other
languages - C++, C# etc. I'm not saying Java is perfect - it has its own
traps (int vs Integer etc) but I find it a much easier language to work
with.
--
Andrew Rowley
Black Hill Software
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN