[ajug-members] Clojure-Conj and the State of Java
Chris Fowler
cfowler at outpostsentinel.com
Fri Nov 18 13:26:08 EST 2011
Now that we are bashing Java I'll join the fray.
I like Java, but some of the programmers upset me.
There was a truthful comment about a web app 10 years ago vs today
requiring 10x the resources for similar functionality. I have an
experience that backs this up.
I started writing an app about 7 years ago. I had a friend that
programmed in Java provide me some guidance. I used tomcat and
servlets. This was a simple create HTML output.
I got very busy and hired a contractor to take this development off my
hands. He converted all the work I did to to create XML then pipe
through XSLT and then generate HTML. At the time I thought this was
cool. Today, I'm still paying for that decision. They way we used
XSLT to create HTML made out app un-scalable. Even today, during this
thread, I get an email from a customer where Apache is giving him a 500
error because our app crashed and I need to go delete 8000 rows from his
database. I've converted many of out web pages to include pagination in
its lists. This has alleviated some of the problems. Removing DB ->
XML -> XSLT -> HTML weighs on my mind, but would be time consuming to
execute it.
I'm a lazy programmer. Anytime I see myself writing the same code over
and over I'll create an abstraction. I'm a believer of them. I'm also
a believer that there is a time and place for them. Dependency hell is
a real problem here. So many times will a Java programmer not think
about the code of a project before they think about what cool API
they'll use to create it. This creates layers of dependencies. The
programmer fails to fix problems that occur from within the API because
it some of them are huge and the programmer has written so little of
their own code they don't know how.
Take a config file example. How many times would a simply name/value
pair format work, but XML is chosen because it is cool? We can all
write a N/V pair class with ease. However we choose XML and bring in
dependency.
SOAP was mentioned. Another royal PITA :). Years back I needed an RPC
system written in Perl, C, and Java. I looked at SOAP for about 5
seconds. I went with XML-RPC. I implemented my own APIs for it for C.
Perl had Frontier and Java had some stuff. I fixed the lack of
authentication specification by modifying Frontier and the Java APIs.
To this day I still use it and will use it in a new project. It meets
my needs.
Many times abstractions are used because some folks can't program.
There are those out there that would write a whole web app like this if
they could.
Web app = new Web();
app.start();
I had once instance where in Linux Java IO could not figure out a read
of 0 bytes is equal to EOF. To this day I've not figured out if it was
a programmer issue or a Java one. Imagine what a select() loop will do
to a CPU if the program can't figure out that read() = 0 = EOF!. We
would have TCP clients disconnect ungracefully from some code proxy code
for real-time communications then the load on the box would shoot up.
To stop it I had to restart tomcat. I fired that code and implemented
the same code under a day in Perl.
Imitation is the sincerest form of flattery. I've copied Java classes I
liked and implemented them in C to use on the embedded device I
program.
I like the language. It is just that some of the programs written in it
truly suck.
Chris
More information about the ajug-members
mailing list