opensubscriber
   Find in this group all groups
 
Unknown more information…

C : CTJUG-Forum@googlegroups.com 9 June 2009 • 6:16AM -0400

[CTJUG Forum] Re: To use, or not to use Java
by Dr Heinz M. Kabutz

REPLY TO AUTHOR
 
REPLY TO GROUP




Hi Johan and other CTJUGers,

first off, I am not flirting with any young beautiful language at the
moment, though I will be looking at some new languages in my summer
holiday, just out of academic interest (a good thing to do anyway).

When we get pushed into a discussion of what is better, Java or C# (for
example), I think it is a mistake to even look at the language itself.  
It might seem elegant to someone coming from a C/C++ background, but
that is because we are used to the Java syntax and way of thinking
necessary for programming in such a language.  The surrounding
infrastructure / buzz / JVM / community is what make Java so powerful,
which is why other languages would not even be an option for me.  I want
to build systems that work, reusing existing technology, hiring good
programmers, etc.  I don't think that .NET is even a contender anymore,
remember that 99% of my business is in the USA, Canada and Europe.  Most
serious business is using Java.

And that is exactly where the problem comes in (ok, I'll tone down my
language a bit - that is where the issue lies).  A "normal" person has a
disconnect with the Java language.  I have taught thousands of people
Java and only a very small minority come from the C/C++ background.  
Most of them come from something else and for them it is really hard to
understand how to do things.  Even experienced Java programmers get
surprised sometimes by the behaviour, which might be standardized, but
it's still weird.  For example, what does this do?

public void f() {
  {
    byte[] data = new byte[40 * 1024 * 1024];
  }
  byte[] data2 = new byte[40 * 1024 * 1042];
}

And then next, what are the possible values for local variables a and b
at the end of methods f() and g(), assuming that they may be called by
two separate threads?

public class Foo {
  private int x,y;
  public void f() {
    int a = x;
    y = 3;
  }
  public void g() {
    int b = y;
    x = 4;
  }
}

Any guesses?

So Java's behaviour is not that well defined, the output to the first
f() that I showed is system dependent.  The Foo class may in some
circumstances give rather strange results, such as a=4 AND b=3.

What happens when stop() is called on a Thread - I know it's deprecated,
but what happens?  Probably everyone on this forum would be able to
answer these questions correctly, but we represent a tiny minority of
Java programmers that think a bit further than the ends of our noses
(which would be a significant distance for me, ...)  A lot of Java
programmers have been brought over from other languages and are now,
whether they like it or NOT, programming for a living in Java.

I also think that Java is becoming the language of choice for the
enterprise, just like COBOL did.  I regularly do code reviews as an
independent consultant.  Very seldom do I see Java code that makes me
particularly happy.  Most of it is in-elegant (better choice of words?),
written just so it can compile, not for clarity.  You can write neat
clean code in Java, but very few actually do.

Here is an interesting article, though I don't agree with everything he
writes, there are some ideas to make us think a bit:
http://www.defmacro.org/ramblings/fp.html

Regards

Heinz
--
Dr Heinz M. Kabutz (PhD CompSci)
Author of "The Java(tm) Specialists' Newsletter"
Sun Java Champion
http://www.javaspecialists.eu
Tel: +30 69 72 850 460
Skype: kabutz



Johan Steyn wrote:
> Simplicity and Elegance versus Marketing and Hype...
>
> Java got my attention in 1995 precisely because I liked its'
> simplicity and elegance, which *does* count a lot in my book. I care
> more for a well thought out and engineered language than the marketing
> hype, which usually has the opposite effect of irritating me. The
> problem (benefit? depending on point of view) of marketing is that it  
> *is* powerful in getting a language/platform adopted by the masses and
> businesses. That helps build momentum, making it ubiquitous (look at
> Windows, which I haven't used for more than 8 years...). In the early
> days I was trying to convince skeptics at the company I worked for to
> go down the Java route. Nowadays there is seldom such a need (unless
> you work for a Microsoft-only shop).
>
> When Java came along in the mid-nineties, it was a godsend for me.
> Having programmed in C for a few years, on a product that needed to
> run on various OS's (DOS, Windows 3.1, Windows NT, OS/2, various
> UNIX's, even Mainframes) and interface with various databases and
> transport networks, I started looking at alternative languages.
>
> I took a long, hard look at C++ and didn't like what I saw. I spent
> more brain CPU cycles learning and remembering language syntax than
> solving the problem at hand.
>
> Then I looked at Objective C, liked it a lot, and joined the sole
> distributor of NeXTSTEP in South Africa in 1994. I loved the
> simplicity of Objective C with its smalltalk-like additions and
> dynamic nature compared to C++.
>
> Then Java came along, and I took an instant liking to it - especially
> grateful that I was able to wave goodbye to pointers and subsequent
> memory leaks while concentrating on actually getting the job done -
> with the added benefit of portability.
>
> If Java had never been invented, then Sun might have continued down
> the path of using Objective C, as they had intended to do during their
> collaboration with Steve Jobs' NeXTSTEP (opened up as OPENSTEP). If it
> weren't for the merger (acquisition) between Apple and NeXT, then
> Objective C would probably have died along with NeXTSTEP. Fortunately,
> it lives on in the MacOS X Aqua desktop, proving that the combination
> of native C with a thin, simple OO layer is a better tool for building
> a modern desktop than Java ever was.
>
> However, Objective C was a well-kept "secret" compared to the
> marketing tsunami that swept Java onto our shores. Still, Java wasn't
> all hype and marketing - behind the dancing dukes was a simple, clean
> language that appealed to me, plus some core API libraries, which were
> mostly fine (the AWT libraries were rushed to market).
>
> I cut my teeth on JDK1.1, witnessing the addition (hack?) of inner
> classes (so that the limit of one public class per file would not lead
> to a proliferation of files for listener interface implementations,
> while mangling class file names so that classloaders would still work
> without change). I liked the scope and size of the language, and the
> API class libraries were small enough for a beginner to get familiar with.
>
> But with JDK1.2 it started down a slippery slope of API bloat. While
> the language itself was kept pretty much the same, Swing was tacked
> onto AWT, and then a humongous stack of enterprise API's, many of
> which I stayed well clear of (I never bothered with EJB's and hope
> never to need to look at them).
>
> And then with Java 5 came the addition of new language syntax
> features, many of which I don't care for, and some of which have
> subtle "gotchas" you have to look out for. The Java that we have today
> is far removed from the Java that grabbed my attention back in 1995.
> If I were to learn it from scratch today, I would probably be wasting
> brain CPU cycles similar to the way I was with C++ years ago. It is no
> longer a simple, elegant language.
>
> When I started looking at Python, I liked it and was drawn to it in
> the same way I was attracted to Objective C and Java years earlier.
> For example: everything in Python is an object. There is no such thing
> as a primitive type (eg: int) and the subsequent need for a
> corresponding "wrapper" class (eg: Integer), and hence no need for
> autoboxing to be tacked on later to "simplify" things. And that's just
> one small example of the simplicity and elegance that appeals to me.
> There are many other things I like about Python. I don't intend
> discussing them all here now - especially since I don't use Python in
> my day job, and I haven't even looked at the new features in 3.0.
>
> Fritz mentioned Java's backward compatibility, and asked "Are there
> other languages where the compromises have been better made?". That is
> a good and relevant question. From what I've seen with Python, they
> aren't afraid to introduce changes that introduce backwards
> incompatibility, but they do it in a seemingly well-managed manner
> where you can import features from "future" versions in advance so
> that you can start porting your applications before the new features
> replace the old way of doing things. Since I don't use Python in my
> day job, I cannot comment on how well it works in practice, But I like
> the fact that they are prepared to cut out past mistakes and fix
> things properly rather than introduce new features in order to work
> around legacy warts.
>
> Still, I think we all agree that for in-house enterprise applications,
> nothing beats Java. I would not call Java terrible, ugly, or a
> "rubbish" language, that succeeded only due to successful marketing.
> There is (actually, was) a good language behind all the hype. If it
> were terrible/ugly/rubbish it would not have succeeded. It has it's
> warts, and I think it has grown too large - partly to maintain
> backward compatibility.
>
> And I certainly would not label it along the same lines as COBOL,
> which I was fortunate to never have needed to use in my day job, as I
> suspect I would have found it mind-numbingly stultifying. Whereas
> COBOL is often associated with stale, bureaucratic organizations, Java
> reaches beyond the enterprise into more youthful, dynamic
> organzations. I'd bet you both Java and Python are widely used in
> Google...
>
> For building my career while using an acceptable language (in the
> sense that I would want to use it daily), Java is a good choice. If I
> had financial freedom, I would use Python more, and explore more
> esoteric languages out of pure academic interest.
>
> So, do developers ultimately choose elegance and simplicity over
> marketing and hype? I hope so. As powerful as marketing is, the noise
> eventually settles down and then the survival of a language comes down
> to it's technical merits. I don't think Java will suffer the same
> demise that COBOL has, and I hope that Python will triumph over the
> hype surrounding Ruby in the long run...
>
> Heinz is very knowledgeable about Java. I just think he is being
> critical of his "old faithfull" while flirting with a younger model...
> Ruby perhaps?  ;)
>
> And that is not a bad thing - being critical is healthy - especially
> if you have the knowledge and experience to back it up, which I
> believe Heinz has. I just think using terms like terrible/rubbish/ugly
> is easy and cheap. What would be more interesting, and useful, is a
> technical critique of Java, listing some of the warts and gotchas.
>
> Meanwhile, I will carry on using Java, while I feel motivated to delve
> in a bit more Python again, and perhaps look at Ruby just to see what
> the hype is all about (in case I'm missing out on something).
>
> Perhaps all languages seem simple and elegant during their early
> years, and before they become mainstream, or during the early stages
> of learning it? Maybe the act of becoming ubiquitous forges and shapes
> a language into a larger beast then the original? Or perhaps one just
> becomes bored with the same old, while being attracted to a new kid on
> the block... which Java was in the mid-nineties.
>
> I'm just glad that I learned Java while it was evolving. If I had to
> learn it from scratch today I think it would be far more difficult.
> But don't let that put you off, Johan (Mynhardt). You are very welcome
> in the Java community, and, as you can see, you will likely hear both
> praise and critique - but hopefully not slavish following by
> non-questioning sheep ;) Religious fervor and ideology are dangerous
> and damaging to any language.
>
> Johan.
>
> On Mon, Jun 8, 2009 at 6:27 AM, Dr Heinz M. Kabutz
> <heinz@java...> wrote:
>
>     Exactly, you don't choose Java because of its simplicity,
>     elegance, nice style, etc. You choose it because of other things.
>     As a language, it's ugly, but I would not choose anything else for
>     an enterprise app.  Obviously.
>
>     Regards
>
>     Heinz
>     --
>     Dr Heinz M. Kabutz (PhD CompSci)
>     Author of "The Java(tm) Specialists' Newsletter"
>     Sun Java Champion
>     http://www.javaspecialists.eu
>     Tel: +30 69 72 850 460
>     Skype: kabutz
>        
>
>
>
>     Johan Steyn wrote:
>>     I wouldn't use Python if I required calculations at hardware
>>     speed. I'd do it in C myself.
>>
>>     That's why my "toolbox" contains 3 languages:
>>
>>     1. C (not C++) for low-level, native stuff.
>>     2. Java for enterprise applications.
>>     3. Python for scripting (and to stimulate and soothe the mind).
>>
>>     Anything else holds purely academic interest for me - a luxury I
>>     can seldom afford as much as I would love to re-discover some
>>     Lisp and explore Erlang.
>>
>>     If I were to judge a language purely on the merits of the
>>     language itself, Python is just so damn elegant... I miss it's
>>     terseness and simplicity when I code in Java.
>>
>>     But in terms of "getting the job done", my current toolbox
>>     suffices. I happen to spend most of my time doing enterprise
>>     applications, and for that nothing comes close to Java. I just
>>     don't care too much for the Java 5 syntactic "features" - I can
>>     do without them and have been made aware of some nasty pitfalls
>>     that they have introduced.
>>
>>     Yet, if someone asked me now to develop an application that needs
>>     to interface with a database, parse some XML files, read-write
>>     data over a socket and present a user interface in either a
>>     standalone GUI or web application, and have it run on various
>>     Os's, then I wouldn't dream of doing it in anything other than Java.
>>
>>     So, when someone states that Java is a "terrible" language - take
>>     the comment with a condiment of your own choosing. I suspect that
>>     if presented with the task of completing an enterprise
>>     application in time and budget using language "X", then you'd
>>     likely hear cries of just how terrible language "X" is now that
>>     they are forced to use it, and how much they fondly miss their
>>     cup o' Java ;)
>>
>>     Johan.
>>
>>     On Sat, Jun 6, 2009 at 11:28 PM, Noel Grandin
>>     <noelgrandin@gmai... <mailto:noelgrandin@gmai...>> wrote:
>>
>>
>>         Python?
>>
>>         That would the language that makes a hard requirement that
>>         you have a
>>         C programmer on your team, because it can't do calculations at
>>         anywhere close to hardware speeds.
>>         The language run-time that requires manual interventions to
>>         prevent
>>         memory leaks because it uses reference-counted GC?
>>
>>
>>         On Sat, Jun 6, 2009 at 17:07, Johan
>>         Steyn<johan.steyn@gmai... <mailto:johan.steyn@gmai...>>
>>         wrote:
>>         >>
>>         >> Fritz Meissner wrote:
>>         >> > In that case I'd be fascinated to hear what isn't a
>>         terrible language ?
>>         >
>>         > Python.
>>         > I wouldn't say Java is terrible. It avoids many errors that
>>         are common in
>>         > C/C++ (where I started), but introduced other pitfalls - of
>>         which Heinz
>>         > mentioned some.
>>         > I wouldn't ever consider using .Net, and in my free time I
>>         (used to) dabble
>>         > in a bit of Python, which to my senses is just plain
>>         no-nonsense
>>         > straightforward done right. I have no interest in Perl
>>         anymore, and I
>>         > haven't looked at Ruby, which I think gained popularity on
>>         the back of Rails
>>         > rather than the language itself in it's own right.
>>         > IMO, if you know some C for low-level, fast native apps,
>>         Java for enterprise
>>         > apps, and Python for scripting - with obviously some
>>         intersection among
>>         > them, then you are pretty much sorted to tackle any
>>         programming task without
>>         > needing to know any other language.
>>         > That said, I haven't looked at Lisp since 1992, but I don't
>>         see a need for
>>         > it other than stretching my mind - which is a good thing in
>>         it's own right
>>         > ;)
>>         > Johan.
>>         > >
>>         >
>>
>>
>>
>>
>>
>
>
>
>
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to CTJUG-Forum@goog...
To unsubscribe from this group, send email to CTJUG-Forum-unsubscribe@goog...
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
For jobs see http://gamatamjobs.appspot.com/
-~----------~----~----~----~------~----~------~--~---


Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.