Java Philosophy

  • Thread starter Wildemar Wildenburger
  • Start date
R

Richard Reynolds

Wildemar Wildenburger said:
Hi Folks,

I have now played with java for a while and I can't get very comfortable
with it. I don't really /dis/like, but it just hasn't "clicked" yet.

Maybe that is because I come from the Python world, which is (almost)
completely different in approach. Specifically I find Java to be overly
paranoid sometimes (what with interfaces, typing declarations, etc ...). I
see their value for optimization, but they hurt my brain because I'm just
used to the freedom. I'm not writing this as a flame; maybe some
Python-folks here can understand me.

What I'd like now is some sort of "Java Philosophy" text. Something like a
"spiritual guide" to Java, that would convey the right mindset for it. A
quick googling found me nothing that seemed consentient, most was rather
personal views. I've read the Java-is-not-Python thing, but that didn't
cut it (felt lame).

Any ideas? I'd love to hear them.
thx
/W

Blimey, I wouldn't want to be maintaining anything you've written! or, by
the sounds of it, anything written in Python, though that's speculation on
my part. I do hate maintaining perl though, in my opinion it's just not
suitable for large scale development.
 
W

Wildemar Wildenburger

Roedy said:
I hate relaxed type languages. Yes strict typing takes more type to
type, but it saves time in the long run. It is much easier to
understand what the code is doing when you have the types clearly laid
out. Compile time checking excludes many errors.
I know I shouldn't do this but ...

It's all a matter of what you're used to. I usually don't care for the
type of a variable, for the very reason that Python is designed around
just that notion. I don't need to know what type a variable has, just
what can be done with it, and that is usually obvious from the code.

I don't really see the benefit of writing

Thing foo = new Thing();

instead of just

foo = Thing()

OK, it might make more sense when it comes to interfaces, but here I
don't see any benefit.

I can better understand the strict typing in method signatures. But
again, Python does "duck typing", so usually the docstring right below
the function definition is all you need, most if the time. This of
course, depends heavily on programmers writing descent documentation,
which is not to be expected.

So I agree and disagree.

It comes down to what you are doing. If you are whipping out little
one shot programs that you run once, then discard, and you are a slow
typist, then relaxed typing is the way to fly.

If you write systems that you keep coming back to for maintenance over
the years, approaching each time cold, largely forgetting how the
program works, with only your notes and the code to get up to speed,
then you appreciate the tight typing.
Reading that just breaks my little pythonic heart. :( (;))
Python was designed with the idea that code is usually read more often
than it is written. So it is actually very easy to go (back) to a python
program that you haven't seen in a long time if at all. Again, it is
what you are used to reading and thinking that makes a particular type
of program hard or easy to understand. If you expect to see type
definitions everywhere, then of course you're going to miss them. If
you're not used to them, they will bug the hell out of you. But I
wouldn't claim that any aproach is generally worse than the other.


Learning to type quickly, using a high quality keyboard such as the
kinesis or Maltron, and an optimised layout such as DSK, can take much
of the pain out of the verbosity. A smart IDE helps too.
see http://mindprod.com/bgloss/keyboard.html
My problem is not really the typing (though I *am* slow at that), but
the fixture. My mind just isn't used to deciding on the datatype of a
variable. I'm used to trying one an then changing it if my initial
descision was bad. That is of course possible in any language, but in
Java you have to make changes in much more places.

I don't know, I'll get used to it sooner or later.

/W
PS. Thanks for the keyboard tips; I'm looking into touch typing but I've
used my idiosyncratic method for years so that is hard to learn touch.
 
W

Wildemar Wildenburger

Richard said:
Blimey, I wouldn't want to be maintaining anything you've written! or, by
the sounds of it, anything written in Python, though that's speculation on
my part.
I'm not following you. Can you elaborate?

BTW, I cartainly am not a great programmer; I'm an enthusiast, not a
programmer by trade. But assuming difficult maintainability for Python
is doing the language unjustice, because it was (as I said elsewhere)
designed with that goal in mind (readability).

I feared I might hit a hornets nest when asking that question. But
please folks, try to not let this slip into one of those "mine is better
than yours" discussions.

> I do hate maintaining perl though, in my opinion it's just not
> suitable for large scale development.
>
It wasn't designed for that, so what do you expect? It was designed for
wrangling text. I'm not a fan of abusing tools for tasks they weren't
meant to be used on.

/W
 
R

Richard Reynolds

Wildemar Wildenburger said:
I'm not following you. Can you elaborate?

you wrote:
Specifically I find Java to be overly
paranoid sometimes (what with interfaces, typing declarations, etc ...).

these are the tools for producing well designed maintainable and robust OO
code in Java.
BTW, I cartainly am not a great programmer; I'm an enthusiast, not a
programmer by trade. But assuming difficult maintainability for Python is
doing the language unjustice, because it was (as I said elsewhere)
designed with that goal in mind (readability).

I feared I might hit a hornets nest when asking that question. But please
folks, try to not let this slip into one of those "mine is better than
yours" discussions.


It wasn't designed for that, so what do you expect? It was designed for
wrangling text. I'm not a fan of abusing tools for tasks they weren't
meant to be used on.

/W
As I said, my statements on Python were pure speculation, was it designed
for large scale development? I had thought it was a derivative of perl, am I
wrong?
 
W

Wildemar Wildenburger

Richard said:
you wrote:
Specifically I find Java to be overly
paranoid sometimes (what with interfaces, typing declarations, etc ...).

these are the tools for producing well designed maintainable and robust OO
code in Java.
You could have just said that. Thanks for doing so now.

My wording may have been a bit offensive to Java folks, but I tried to
make clear (and understandable) the subjectiveness of this impression.
Sorry if I irritated you.

As I said, my statements on Python were pure speculation, was it designed
for large scale development?
No, not really I guess. Then again, it *was* designed to be read a lot.
There are also quite a few relatively big projects based on or at least
using python. Chandler and Google come to mind.

I had thought it was a derivative of perl, am I wrong?
Try telling that to the folks at comp.lang.python and see what happens. ;)

/W
 
L

Lew

Joe said:
Bummer. I just bought the older version at Barnes & Noble last week! I
guess it will still be a good read, though. Not everything is specific
to the platform version, I guess.

Seriously, it's worth it not to wait seven or eight months. Just buy
/Effective Java/ again when the 2nd edition arrives. You won't regret having
it early.
 
L

Lew

Roedy said:
Learning to type quickly, using a high quality keyboard such as the
kinesis or Maltron, and an optimised layout such as DSK, can take much
of the pain out of the verbosity. A smart IDE helps too.
see http://mindprod.com/bgloss/keyboard.html

I have used both the Kinesis and the Maltron keyboards. The Kinesis has these
tiny little function keys that annoyed me the entire five years I used it.
The Maltron was great, although it frightened my friends, but very fragile for
a $300 keyboard. Both completely cured any tendency I had to wrist or arm
pain. Neither really has a perfect layout for common PC key chords, but the
Maltron is much better than the Kinesis for that. (I used the QWERTY layout,
not the Maltron layout.)

Now I just use a Microsoft wireless keyboard (Wireless Comfort Keyboard 1.0A)
at home. It's only slightly ergonomic by comparison, but it seems to be
enough to avoid pain. I just have to get my employer to let me use a more
ergonomic keyboard at work.

It's very important that the keyboard be low, your chair properly set, and the
mouse be on the left due to the asymmetry of PC keyboard layouts.

Touch typing really helps. I type roughly 50 wpm with reasonable accuracy, so
a lot of the "it's too long to type" issues don't arise for me, even when I
don't use copy-and-paste.
 
L

Lew

Wildemar said:
You could have just said that. Thanks for doing so now.

My wording may have been a bit offensive to Java folks, but I tried to
make clear (and understandable) the subjectiveness of this impression.
Sorry if I irritated you.


No, not really I guess. Then again, it *was* designed to be read a lot.
There are also quite a few relatively big projects based on or at least
using python. Chandler and Google come to mind.


Try telling that to the folks at comp.lang.python and see what happens. ;)

Readability of source code is one element of maintainability, but not the only
one.

Frankly, I think bad code can be written in any language, likewise good code.
Some languages support certain coding idioms better, others support
different ones better. The trick is to think in the language that you're
using and play to its strengths. Use good coding discipline appropriate to
the language and you will write better code.

The "Python is designed for readability" claim doesn't really indicate whether
it's better, worse or the same as Java for writing industrial-strength
applications. I suspect Java is stronger for such applications simply because
of its combination of philosophies: GC, strongly-typed, dynamic,
network-aware, well-defined operations (no endian controversies), built-in
concurrency and the package organization make it suitable for large-scale team
projects. This in no wise denigrates Python or its usefulness. It's just
that Java provides bricks for your walls, which is great when you want to
handle a windstorm of, say, 50-100 million documents entering your system in
one week with no collapses, when those walls were built by dozens of programmers.

Java is pretty readable, too, when written by someone who wants it to be.

If the code we write isn't readable or maintainable, the fault lies not in our
stars, dear Brutus, but in ourselves.
 
J

John W. Kennedy

Wildemar said:
I don't really see the benefit of writing

Thing foo = new Thing();

instead of just

foo = Thing()

OK, it might make more sense when it comes to interfaces,

But that's it. It absolutely, positively guarantees that foo will
/always/ be a Thing. Which means that the compiler can always generate
code based on that certainty, and give you an error message at compile
time if you ask foo to do anything that cannot be done by a Thing -- and
/not/ have to ask, "Is foo a Thing?" every single bloody time -- perhaps
millions or billions of times -- foo is used.

The word "new" could probably have been left out of the language design,
but I think most Java programmers would prefer to retain the clear
distinction between a constructor and a factory method.

--
John W. Kennedy
"The whole modern world has divided itself into Conservatives and
Progressives. The business of Progressives is to go on making mistakes.
The business of the Conservatives is to prevent the mistakes from being
corrected."
-- G. K. Chesterton
 
W

Wildemar Wildenburger

John said:
But that's it. It absolutely, positively guarantees that foo will
/always/ be a Thing.
>
I *kind of* see that. But that can be guaranteed with the second form
just as well; once a var is initialized, it must always be a Thing. This
is nitpicking on my part of course.

/W
 
W

Wildemar Wildenburger

Lew said:
Frankly, I think bad code can be written in any language, likewise good
code. Some languages support certain coding idioms better, others
support different ones better. The trick is to think in the language
that you're using and play to its strengths. Use good coding discipline
appropriate to the language and you will write better code.
Hence my question. :)

The "Python is designed for readability" claim doesn't really indicate
whether it's better, worse or the same as Java for writing
industrial-strength applications.
>
It probably isn't. Most surely.

It'll grow on me, I'm sure.

/W
 
B

Big Jim

You could have just said that. Thanks for doing so now.

My wording may have been a bit offensive to Java folks, but I tried to
make clear (and understandable) the subjectiveness of this impression.
Sorry if I irritated you.

No, no, I wasn't irritated, I apologise if my response sounded brash,
wasn't meant to be, my point was just that you would use the correct
tool for each type of job. Java is a tool suitable for large scale
development and its features are thus what you'd use to do that,
nothing really to do with a philosophy. Similar to how C is a tool
suitable for system development so you'd have a different set of
approaches again when using that.
No, not really I guess. Then again, it *was* designed to be read a lot.
There are also quite a few relatively big projects based on or at least
using python. Chandler and Google come to mind.

Being readable is important but it's not the only important thing, and
Java and C, C++ etc. are readable too. But they provide a model that's
suitable for what they're intended for which you should use to produce
maintainable and robust code.
Try telling that to the folks at comp.lang.python and see what happens. ;)

/W

Think I'll keep my head down then!
 
R

RedGrittyBrick

Wildemar said:
I don't really see the benefit of writing

Thing foo = new Thing();

instead of just

foo = Thing()

I sometimes wish there were a short-cut notation such as
Thing<Whatever> foo = new();
for
Thing<Whatever> foo = new Thing<Whatever>();

and
List<Whatever> foo = new ArrayList<>();
for
List<Whatever> foo = new ArrayList<Whatever>();

but clearly I haven't thought this through :)
 
B

Bent C Dalager

I sometimes wish there were a short-cut notation such as
Thing<Whatever> foo = new();

I'm rather partial to a C++-like
Thing<Whatever> foo(arg1, arg2, etc);
myself.

The only thing you'd be losing is the "new" operator so if you like
searching for those, it might be a problem.
for
Thing<Whatever> foo = new Thing<Whatever>();
(...)

Cheers,
Bent D
 
L

Lew

Wildemar said:
I *kind of* see that. But that can be guaranteed with the second form
just as well; once a var is initialized, it must always be a Thing. This
is nitpicking on my part of course.

"Once a var is initialized" happens on the customer's machine. "During
compilation" happens on the developer's machine, before customer, tester or
manager can see any trouble. The difference is run-time vs. compile-time
validation of the type. Both work, but Java is designed to reveal these
things during development, and that is an advantage.
 
P

Patrick May

Lew said:
"Once a var is initialized" happens on the customer's machine.
"During compilation" happens on the developer's machine, before
customer, tester or manager can see any trouble. The difference is
run-time vs. compile-time validation of the type. Both work, but
Java is designed to reveal these things during development, and that
is an advantage.

There is also a cost associated with it, in terms of development
time and therefore the number of alternatives that can be
investigated. Developers who have used languages with duck or
optional typing are familiar with the very different style of
programming such languages support.

That being said, the typing wars are easily found elsewhere on
Usenet and I have no urge to start that battle here. Suffice to say,
a good developer will consider both the costs and benefits of any
language feature.

Regards,

Patrick
 
S

Stefan Ram

Big Jim said:
tool for each type of job. Java is a tool suitable for large scale
development and its features are thus what you'd use to do that,

I have different priorities. The reasons for Java
that come to my mind now are:

- prevalence

Java is the most common language nowadays.

»With over 6 million developers (according to Sun)
Java clearly dominates the software development industry[.
It is] perhaps the most successful software development
platform in the history of computing«

http://apsblog.burtongroup.com/2007/11/why-microsoft-l.html

»3.3 billion Java devices worldwide«

http://web.archive.org/web/20060615...ssions/general/javacompatibility_thursday.jsp

This means, that the chance that Java will be still
around in the future is large. I am not only thinking
of 2 years, but also of 20 years in the future.

This means a smaller chance that I will be forced to
rewrite into another language.

- A standard GUI

The standard distribution of the language (platform)
contains a GUI library (Swing, AWT).

Therefore the first reason of stability by prevalence
also applies to Swing.

Perl, Python, Ruby, C, C++ do not have a GUI toolkit
as part of the standard library - though several
extensions are available.

- Portability

Java includes a JVM to ensure portability even of
GUI applications. While Python plus a GUI-Toolkit
might also run on several platforms, it is not known
how long such a combination will be available in the
future. A C-program on Win32 surely is not that portable.

- Teaching

I give classes (open to everyone for a certain price)
and only the most common languages will attract enough
students. This includes C++ and Java, but not Perl,
Python or Ruby. So I have to learn Java anyways.

Otherwise, purely from the point of language notation, I might
prefer Ruby. But I even do not dare to use JRuby, because I do
not know how long it will be available and maintained.
 
S

Stefan Ram

John W. Kennedy said:
The word "new" could probably have been left out of the
language design, but I think most Java programmers would prefer
to retain the clear distinction between a constructor and a
factory method.

I am not one of them. »new« just annoys me.

But let's wait. Possibly someone here comes
up with a good reason for it.
 
R

Roedy Green

Thing<Whatever> foo = new Thing<Whatever>();

Beside clutter you introduce the possibility of errors of this form:

Thing<Whatever> foo = new Thang<Whatever>();

Unless you stare carefully you might read that as:

Thing<Whatever> foo = new Thing<Whatever>();

In Bali, I suggested the following shortcut:

BigDate d = new BigDate( 1997, 5 , 6 );
could be written as
BigDate (1997, 5 , 6) d;

It would be an easy extension to Java, requiring no JVM changes.
 
R

Roedy Green

quoted or indirectly quoted someone who said :


I agree about the pathetic Kinesis function keys. Thankfully, modern
programs make very little use of them.

One thing I like about the Kinesis is the lack of separate numeric
keypad. There is a logical embedded one I almost never use. The
advantage is it makes the keyboard narrower. This means the mouse can
be closer.

I have looked all over for cheap keyboards for people with shoulder
mouse pain. I saw a keyboard mouse combo the other day called an "air
mouse". The retailer would not let me open the box to try it out.
(This seems to be the new norm. How can you pick a keyboard without
testing the feel?) Apparently the mouse does not need a surface. It
says it uses a "gyroscope". I suspect they mean an accelerometer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top