I had a Java dream last night

I had a dream that Jonathan Schwartz has called me on the phone and asked for an advice on Java future. This is what I remember hellip;

Jonathan. Hey Yakov, I “m sure you “ve heard about our great results in the hardware arena. But I “d like to hear your opinion on how to proceed with Java.

Yakov. Jonathan, it “s an honor. How can I help you?

J. We are planning lots of new language features to be introduced in Java 7 (closures, data binding in Swing and more)…

Y. I’ll tell you what I think. But please answer my question first, what “s this thing with outsourcing Java? Why? Do you really believe that it “s the right thing to do?

J. To put it simple: peer pressure. Everything is open sourced these days, you have to go with the flow hellip;

Y. IMHO, this is a mistake. I do not think Sun needs to go through this pain of certification of plethora of future forked products just to call them Java. Unless you are planning to make a couple of bucks by charging vendors for being certified. Java source code is available already, and it “s free. Even now there are several implementations of JRE (Sun, IBM, BEA and more). Isn “t it enough?

J. OK, OK. Please answer my question now: how about adding new features to the language?

Y. To put it simple, leave the Java language alone. Create and market a brand new language that can be used with or without Java. Do not forget that Java is already more than ten years old. Sun “s engineers did a great job by mid-nineties standards. Sun Microsystems did a superb job in marketing Java. JVM rocks, Java memory model shines, multi-threading is great. But, do not forget that Java was originally created a s a simpler alternative to C++. But all these new features made this languages at least as complex as C++.

J. But what “s wrong with closures?

Y. Nothing. Closures are an equivalent of function pointers in C++.

J. But according to Java online forums people vote for closures.

Y. The problem is that people who post in all these forums represent a really small group of Java developers. Vast majority of Java programmers just write if-statements, loops, execute database queries and display results on the screens. So do not make Java overly complex. Do not scare people away from Java. Besides, it “s hard to teach an old dog new tricks. It “s not natural. It “s like a cosmetic surgery. The face looks a bit younger, but the body is still old.

J. It “s easy to critique. What do you suggest?

Y. Sun needs to create a new language. And most importantly, Sun needs to start heavy marketing campaign as soon as this new language is created leveraging existing Java echo-system. You may not even need to build this new language from scratch. Just take a stripped out version of Java and start adding new feature to it the right way. CLDC (not CDC) that is used for Java 2 ME, can be a good starting point. I was reading a white paper on CLDC, and if you forget for a minute that it was written about a language requirement to be used with mobile devices, this is exactly what “s needed by any programming language:

“provide cutting edge performance, deliver fats application start-up time, require minimum footprint hellip; rdquo; Aren “t all these features required in a non-mobile environment? Put CLDC on a real computer with lots of memory and it “ll fly there. Add full-fledged multi-threading support there. Restrict the size of the runtime to 1MB. Do not port Swing there. Come up with a new simple way of declarative creation of GUI (take a look a MXML and XAML). Add to this new language closures, continuations, mixins, and whatever else your talented engineers can come up with. Seriously invest into multimedia features of this new language.

Set up a lab where this new language will be tested on the same computers that were used back in 1995 with Java 1.0. No T1 or cable modems are allowed there: 56-bod modems. Yes dial up. Try to imagine that memory is expensive again, and some people still have only 512Kb of free RAM. Make this language perform well on slow machines.

J. Let me think about it. But what would you recommend to improve the Java quality now?

Y. Your question contains the answer. Just fix the bugs. Open the bug parade, and ask your engineers to fix all of them regardless of how many people voted for these bugs. Some of these bugs are almost as old as Java. Decrease the size of the JRE. What is it now, 16-18Mb?

J. OK, Yakov. Thank you for your input. I “m glad I called you.

Y. My pleasure, Jonathan!

Even though this conversation have never happened, I decided to write it down. Who knows, may be one day I “ll be giving advices to Jonathan Schwartz (and he’d listen to them). It “s A-M-E-R-I-C-A.

Flex 2: Development on a budget

My primary clients are Java shops. When I suggest using Adobe Flex 2 as a rich client tool for their Web applications, they typically ask about the cost on the server side. Expected answer: free. When I start telling them about really powerful features of Flex Data Services, they like it. They just do not like the licensing cost,which is very reasonable. But Flex 2 it’s too young, and some people are still in denial phase. It’ll change soon, but there got to be a free solution. Just to get the foot in the door. And there is one.

I’ll be using a JavaServer page (JSP) here, but you can replace a JSP with any technology you’re comfortable with: servlets, Active Server Pages, Python, PHP et al. Whatever can spit out an XML to a Web browser should work the same way.

I’ll show you a really simple application written in Flex 2 that talks to the XML producing JavaServer page. Just to make it simple, let’s take an XML with the information about employees:

lt;people gt;

lt;person gt;

lt;name gt;Alex Olson lt;/name gt;

lt;age gt;22 lt;/age gt; lt;skills gt;java, HTML, SQL lt;/skills gt;

lt;/person gt;

lt;/people gt;

Now, let’s hardcode this (I’ve got three persons) into a super simple JSP that consists of one out.println() call, where the xml should go between the double quotes:

lt;%out.println( “… “); % gt;

The complete JSP looks like this (just put your XML in one line so you won’t bother with string concatenations):

lt;%

out.println( ” lt;?xml version=\ “1.0\ ” encoding=\ “UTF-8\ “? gt; lt;people gt; lt;person gt; lt;name gt;Alex Olson lt;/name gt; lt;age gt;22 lt;/age gt; lt;skills gt;java, HTML, SQL lt;/skills gt; lt;/person gt; lt;person gt; lt;name gt;Brandon Smith lt;/name gt; lt;age gt;21 lt;/age gt; lt;skills gt;PowerScript, JavaScript, ActionScript lt;/skills gt; lt;/person gt; lt;person gt; lt;name gt;Jeremy Plant lt;/name gt; lt;age gt;20 lt;/age gt; lt;skills gt;SQL, C++, Java lt;/skills gt; lt;/person gt; lt;/people gt; “);

% gt;

Deploy this JSP under some servlet container. I have Tomcat, so I just saved it as employees.jsp under my webapp\test directory. Do a sanity check to make sure that you’ve deployed this JSP correctly: entering http://localhost:8080/test/employees.jsp in your Web browser has to return the employee data.

Now comes the client part. If you have extra $500 laying around, purchase a license of Flex Builder from Adobe and enter the code below code in its editor. If you do not want to spend any money, just type this code in any text editor and use free command line mxmlc compiler that comes with Flex 2.

lt;?xml version= “1.0 ” encoding= “utf-8 “? gt;

lt;mx:Application xmlns:mx= “http://www.adobe.com/2006/mxml

applicationComplete= “employees.send() ” gt;

lt;mx:HTTPService id= “employees ” useProxy= “false ” method= “POST ”

url= “http://localhost:8080/test/employees.jsp ” / gt;

lt;mx:DataGrid dataProvider= “{employees.lastResult.people.person} ” width= “60% ” gt;

lt;mx:columns gt;

lt;mx:DataGridColumn dataField= “name ” headerText= “Name “/ gt;

lt;mx:DataGridColumn dataField= “age ” headerText= “Age “/ gt;

lt;mx:DataGridColumn dataField= “skills ” headerText= “Skills “/ gt;

lt;/mx:columns gt;

lt;/mx:DataGrid gt;

lt;/mx:Application gt;

Not too much typing, isn’t it?

This code uses the lt;mx:HTTPService gt; component that allows you to connect to a specified URL either directly or through a proxy. In my example I just specify the URL of my JSP. The data provider of my data grid uses binding (see the curly braces) and E4X syntax to parse the XML and populate this table with the elements located under the lt;person gt; XML tag that is coming from our employees.jsp. Next month, I’ll write a piece explaining Flex data binding in more details. On the applicationComplete event, we send a request to the HTTPService object known under id employees, and our JSP readily returns the XML, which is bound to the data grid.

Compile and run this program, and it’ll show you the following:

Not a bad result for a dozen lines of code.

Of course, it’s better to be rich and healthy than poor and ill. But my point is that even poor (or pretending to be poor) people can use Flex 2 with their existing server side Web tools for free.

Top ten ways to screw up an enterprise Java application

Tonight, I “ve attended Java SIG meeting in New York. CameronPurdy of Tangosol was presenting on ten thing that will help you to screw your enterprise Java application. This was a re-run of his JavaOne talk.

#10 To specify your data access model before you understand the granularity

#9 Assuming that container will take care of transactions

#8 Using a stateless architecture

#7 Design the application for deployment on a single server and assume that that server will handle reliability and scalability for you

#6 Using popular technologies such as WebServices for component integration and remoting

#5 Rolling your own frameworks

#4 Distributing of synchronous objects across the network

#3 Design logic and data flow assuming that this is a single user system

#2 Compensate for lack of knowledge of the application domain by maintaining flexibility

#1 Put off the system testing until the application is ready to deploy

It “s always fun to listen to Cameron.

How I improved my Java skills over the weekend

I spent last weekend in the classroom studying Java and popular frameworks. Actually, I was moving from one classroom to another trying to absorb as much information as possible while attending a traveling Java symposium called Non Fluff Just Stuff. For busy Java professionals who can not attend training during business hours this seminar is a steal. Even though all speakers are published authors and well known in the industry Java experts, the tuition is very modest. This seminar does not include any sales pitches: there is no vendors there. Just the training.

I started with the session on Spring Framework delivered by Stuart Halloway. His message was clear: programming has to be simple. Spring is a well crafted framework, that can be used in a variety of ways: entire Spring framework, some of its components, with or instead of Java EE.

Since the sessions run in four parallel tracks, you often have to make a tough decision: which one to attend. What really helps is that the CD will all presentations is given to attendees as soon as they are registered. Let me repeat, not soon after the seminar, not we “ll let you know when the slides are published, but b-e-f-o-r-e. I was browsing the slides to pick up the next session .

This is very informal gathering. Attendees casually talk with each presenter in the classrooms, during the breaks, and they eat together. For example, over the breakfast after my prediction that AJAX will be gone from the business applications landscape in three years, Stuart Halloway has immediately bet a beer that this was wrong and AJAX will become even stronger. What “s your take, who “s gonna pay for the beer? By the way, Stuart, I drink Leffe beer.

Here “s another important observation: to be a cool presenter at Java conferences, you need to purchase an Apple notebook and use IntelliJIDEA IDE for the live demos. Most of the presenters used this combo. I am using IntelliJ already, but I “m still working on the slide show for my wife that would give her a reason to let me spend another $2K for an Apple notebook (we already have three iPods in the house to support Steve Jobs lifestyle ).

Neal Ford delivered an interesting talk on how to become more productive at work. This talk is about making a comfy environment for a programmer. Programmers are weird creatures, and for them a comfy environment means to have proper code editors, the version control system and the like. Neal is the guy who actually spent time studying all these little shortcuts, utilities and tricks that various OS “s have but we do not know about. Knowing these things can substantially improve your productivity.

I “m not going to list all the sessions here: all presenters were top notch! OK, just one more: Brian Goetz. Yes, the author of the excellent book on threads. We “ve discussed several subjects with Brian, but let me just give you a couple of Q and A “s.

At some point, there was a discussion about Hibernate, and I “ve asked him, “What is your personal preference, using Hibernate or SQL for data persistence? rdquo;. Brian said, that every time he uses on of these, he thinks that he should have been using the other one.

Here “s my next question, rdquo;A requirement to write the GUI-related operations in the event-dispatching thread complicates Swing programming a lot. If you had a chance to redesign Swing, would you implement it differently so the life of the Java programmers would have been easier? rdquo;.

Brian said, “No. So far any GUI toolkit that tried to support multithreaded GUI failed. There are two reason that can lead to the GUI update: the user interaction and the application itself, and unless you have a single dedicated thread that updates the GUI, it “s very difficult to avoid lock-ordering inconsistencies, which leads to deadlock “.

Brian “s presentation about Java memory model was a heavy duty stuff. I felt as if a Thai-style massage was being applied to my brain. Luckily, there was a lunch break after this talk where Jay Zimmerman, the man behind this event raffled off several books and iPods. Jay has managed to build an all-stars team that travels around the country for years. Think of it this way: JavaOne speakers are coming to your town, to share with you the latest trends, tricks and techniques that are important for any professional Java programmer (the emphasis is on the word professional). To put it simple, you can “t go wrong with NFJS.

Java does not need Botox

During my 25 years in software development, I lived through different trends in programming and usually changed my primary programming language every five years or so. While teaching students to program in whatever language was hot at the time, I kept warning them, “Do not fall in love with any programming language as it “s just a tool rdquo;. But here I am, living with Java for eight years. Isn “t it time for a divorce? The short answer is no. As of today, there is nowhere to go. Java was a really well crafted and MARKETED language. I do not know how Sun Microsystems was able to pull it off, but it just happened.

Most importantly, Java puts bread on my table. I am a professional programmer, and can not just jump up when I see a group of kids praising a new programming language. This might sound rude, but show me the money. If the language XYZ is the best thing that happened to the world, why dice.com does not list jobs asking for the XYZ skills?

The market is not there yet? See you in a year or two.

When people discuss programming languages, they often fight over specific features that this particular language has while Java does not . So? Java does not allow for dynamic objects, closures and continuations. So? Who cares? Just go to dice.com and type the word Java. You “ll get 15 thousand jobs.

Is Java the primary language that pays my bills today? Hell, yes. Are there other languages/technologies I work with? Hell, yes. Am I happy that Java is trying to add new features to the language? Hell, no. Someone proposes adding closures to the language. There are some attempts to introduce data binding to Java Beans. Get real guys, you can “t teach an old dog new tricks. When I hear about all these additions to Java, I see an aging woman that keep coming to her doctor for another Botox injection. These doll-looking faces do not trick men anymore. The same applies to Silicon (not as in Silicon Valley). Are these boobs real? Keep Java simple, let it age gracefully! It “s a very robust platform for enterprise and mobile applications and let “s leave it right there. Fine-tuning of the JVM is fine, but I do not need new language features. Id ” rather use some other modern language that can be easily integrated with Java EE.

Sun Microsystems has excellent engineers who can craft a brand new language in a year or so. May be creating a new language is better than trying to add patches to Java here, there and everywhere? Just come up with some cool language, while Java is still strong.

If James Gosling will get together with Guy Steele, they can come up with a new practical language for enterprise software developers, and I “m sure that this new language will beat crap out of other languages/tools/technologies that became popular by coining a catchy acronym or were born on the railroad.

Java is here to stay for another ten years, at least on the server side. But I do not wish Java to be around for the same reason as Cobol, which is still with us because there is no money for the funeral: too many Cobol applications were written and deployed in production.

I’ll keep looking around and use other languages or technologies that can compliment Java EE applications, but I “ll remain loyal to Java for another three years or so with a hope that something “s gotta give.

A quote of the day

I’ve got an email that contained a quote describing the way we live:

“Normal Life is getting dressed in clothes that you buy on credit for work, driving through traffic in a car that you are still paying for, in order to get to a job that you need so badly so you can pay for the clothes, car and the house that you leave empty all day in order to afford to live in it. ”

I do not know who’s the author of this quote, but it’s well said.

The person who sent me the quote added a short comment: “Each working day shortens your life by 8 hours “. This is yet another correct assessment of the lifestyle that many of us have in the USA. I’d change 8 to 12 though since many of us leave for work at 7AM and come back home at 7PM or later.

During the last couple of months I’ve heard from more that one programmer a statement like this, “I’d like to relocate to another country…let it pays less, but I’m tired here…I can sell my house here and it’ll get me going for a while… “. I guess, they started to fell like the burning candles that will be replaced by fresh ones soon.

Pretty sad posting for Saturday… Let’s add some postive and happy ending. How about this one:

The life is not easy in the USA, but I’ll stick around…because it’s even more difficult anywhere else.

How to write an RSS reader in AJAX

IBM Developers work has a tutorial on how to build an RSS reader using AJAX. The amount of code you need to write is scary (and this is not the complete code). Adobe Flex 2 plus a simple Java programming to support DB interaction allows you to achive the same functionality using A LOT LESS coding.Just take a look at this screen:

The Flex 2 code below populates the bottom portion of the screen with financial news based on the selected stock on top ( (it does not work with a DB to store the RSS source so it’d add some 50 lines of Java code ). The data come from the Yahoo! Finance RSS feed. The URL looks as follows: http://finance.yahoo.com/rss/headline?s=MSFT

The suffix can be MSFT or whatever is selected on top is being passed to the code below.

Flex lt;mx:HTTPService gt; object is used through a proxy deployed under Tomcat or any other servlet container.

The entire application code and its description can be found in this article.

lt;?xml version= “1.0 ” encoding= “utf-8 “? gt;

lt;mx:Panel xmlns:mx= “http://www.adobe.com/2006/mxml

title= “News ” width= “100% ” height= “100% ” gt;

lt;mx:DataGrid id= “newsGrid ” width= “100% ” height= “100% ”

dataProvider= “{newsFeed.lastResult.channel.item} ” variableRowHeight= “true ” gt;

lt;mx:columns gt;

lt;mx:DataGridColumn headerText= “Date ” dataField= “pubDate ” width= “200 “/ gt;

lt;mx:DataGridColumn headerText= “Title ” dataField= “title ” wordWrap= “true ” / gt;

lt;mx:DataGridColumn headerText= “Description ” dataField= “description ” wordWrap= “true ” / gt;

lt;mx:DataGridColumn headerText= “Link ” width= “130 ” gt;

lt;mx:itemRenderer gt;

lt;mx:Component gt;

lt;mx:LinkButton label= “{data.link} ” click= “navigateToURL(new URLRequest(data.link), ‘_blank’) “/ gt;

lt;/mx:Component gt;

lt;/mx:itemRenderer gt;

lt;/mx:DataGridColumn gt;

lt;/mx:columns gt;

lt;/mx:DataGrid gt;

lt;mx:HTTPService id= “newsFeed ” useProxy= “true ”

destination= “YahooFinancialNews ” concurrency= “last ”

resultFormat= “e4x ” fault= “onFault(event) ” gt;

lt;/mx:HTTPService gt;

lt;mx:Script gt;

lt;![CDATA[

import mx.utils.ObjectProxy;

import mx.rpc.events.*;

public function set security(value:String):void {

this.title = “News: ” + value;

newsFeed.send({s:value});

}

private function onFault(event:FaultEvent):void {

mx.controls.Alert.show

(

“Destination: ” + event.currentTarget.destination + “\n ” +

“Fault code: ” + event.fault.faultCode + “\n ” +

“Detail: ” + event.fault.faultDetail, “News feed failure ”

);

}

]] gt;

lt;/mx:Script gt;

lt;/mx:Panel gt;

Would you hire me?

Recently, I was talking to a couple of Java guys about what to put and what not in the resume (CV). One of them said: “I do not know, because I do not have a resume. I have more work than I can handle, and if I need cash, I just announce that I’m available “.

I was really impressed! Of course, he is not an average Java developer, but a well known person in the industry. But still…

During the last year or so, if I need to interview a job applicant for a senior position, I spend about 30 seconds skimming through his/her resume. Yeah, yeah, yeah…same old, same old: J2EE, Struts, EJB, design patterns… developed, lead, participated. I am not sure though, if knowledge of Struts and design patterns is a plus or a minus, but it’s irrelevant for this discussion. Then, I go to Google and key in the name of the job applicant. If I see some activity there, I consider it a huge plus. If the person blogs, you can get a feeling of the temper and attitude of this person. Knowing Java is good, but if this is a nasty person, would you want to spend eight hours a day with this guy/gal? If s/he participates in the technical forums, you can have an idea about the technical abilities and interests of the candidate.

A couple of days ago, James McGovern blogged about how to hire a consultant, and he thinks the same way. Internet can help you in making this kind of a decision. He talks about consultants only, but I do not see why the same approach would not work for employees?

Hiring is about finding capable people with the personality and attitude that fits your organization. It’s not about people who know a particular API or a framework.

Let’s take J2EE APIs. I did not have a chance to work with Java Connectors (JCA). Would this stop you from hiring me for developing an application that heavily relies on JCA? I know Java and the rest of J2EE. Don’t you think that I can pick it up pretty fast, and can contribute to your project in other ways without being the JCA expert?

So let’s get back to my original question, “Would you hire me without seeing my resume? “. Google my name, and it’ll bring you enough technical and non-technical materials that would give you an idea of my personality and abilities. I’m sure that there are people who do not like me, but there are people who do. The fact that there are people who subscribe to my blog tells me that some people want to hear my opinion (I’ve got plenty of those) on a regular basis. This does not mean that they like me, but they are interested in my opinion.

So here I am again: if you want to hire me, please send me the following: the cIty and the country where you want me work, the project and my role’s description, and how much are you willing to pay. I’m not going to show you my resume, and I’m not going to go through technical interviews.

Are you up to the challenge?

WTFM-2

Last week I’ve written the WTFM blog, and then Sys-Con decided to reprint it. Apparently, Active MQ guys got offended and left angry feedbacks there. They did not get my message. I have nothing against their software, but if they do care or do not know how to write documentation ABOUT THEIR PRODUCT, I will write about it publicly. They teach me how to get help from the open source vendors. Thank you very much. I was just asking for a short writeup describing how to configure Apache Active MQ with Apache Tomcat…

Most people do not know how to document their creation. They describe the details of their software, but they do not write the BEST PRACTICES MANUAL on WHY AND HOW we should use their software. If you turn the key, the engine will start. If you press this pedal, the car will move. Why won’t you start with the statement that this car has been produced to get you from the point A to point B and the most effective speed is from 50 to 70mph? Or this may not be the case, and this car has been created just to improve your social importance, which means that the make and model matters more than efficiency?

Kathy Sierra is an excellent writer. I’m sure you know her Head First books. Yesterday she’s bloged about her photography classes, and she ran into the same issue: lack of best practices manual. This is what she writes about the photography class she’s attended:

“For most of us, the problem was NOT that we couldn’t learn how to use anything but automatic “P ” mode. The problem was that we didn’t know why or when to use anything else.
It wasn’t simply a camera problem–it was a photography problem. The camera manuals describe precisely how to turn the dials and push the buttons, but never tell us why we’d want to. They focus on the tool rather than the thing the tool enables (taking pictures). What good does it do to master a tool if we haven’t understood (let alone mastered) the thing we’re using the tool for? ”

That’s the major problem of most of the open source vendors. They do not bother explaining WHY and HOW should I use their software in the real world, where people are already using someone else’s software (surprise, surprise!). Pleeease, if you are about to make the world a better place by offering us your tool, sit down and desrcibe the best practices of using it with what the most popular products that we already have. Not just how to use it, but the proper way of using it. If you can’t describe it BEFORE your software is ready, do not even start working on it. Most likely this project will fail.