Archive for the ‘java’ Category

How to write a bug

Tuesday, August 21st, 2007

In order to break my slump I thought I’d give a quick description of a project I recently worked on.  I was helping set up a demo of an application that was moved onto the fabric.  The app was written in C and we didn’t change any of its code.  We ended up running it by shelling out from Java to make it easy for the developers who didn’t know C.  The person asking for the demo wanted to see our reliability feature but didn’t want to see the usual hardware demo we give which involved pulling a power cord or network cable.  So I had to invent a software bug that would illustrate how an application can be made reliable by running it on top of Appistry’s software.

So to make a short story long, here’s what my first try looked like:

Random generator = new Random(System.currentTimeMillis());
if( (generator.nextInt() % 4 ) > 0 )

   doSomething();
}

The basic idea being that by generating a random integer in the code running on the fabric I could then use the modulo operator to inject a bug about 25% of the time.  Because it’s random, it would be unpredictable (the best kind of bug).  The modulo operator would give me values from 0-3 and therefore if I got a 0 I would run the bug:

else
{
   throw new Exception();
}

The error case just throws an Exception because the fabric will attempt to retry the job if an unchecked exception is thrown.  We tested out our new bug and it didn’t work.  It was running the error case way too much.  So basically I had a bug in my bug.  After reading the javadoc on the Random.nextInt() method I figured out that it will generate negative numbers!  So I added the following fix:

if( Math.abs(generator.nextInt() % 4 ) > 0 )

Now I get my 25% failure rate like we wanted.  We show the client running and submitting a handfull of requests to the fabric.  Then, on the log on, the fabric, we show in realtime that the failure randomly occurs.  But when it does, the job is automatically resubmitted on the fabric and the answer is sent back to the client.  The client doesn’t have to be concerned with retry logic and only gets its correct answer.

I thought a cool web demo would be to use Ajax and setup a button for people to cause a software bug to happen while the results are coming back to the browser in realtime.  Maybe I’ll write that in my "spare" time…

-jasen

Barcelona

Friday, July 6th, 2007

Well, I finished the show and made it home.  On the last day, the crowd was mostly into the tech talks and not interested in the vendors so much.  I talked with a few of the people there, like the Azul guys.  I also talked with the IceFaces guys about maybe doing a demo together.  Appistry could be the back end hosting some business logic and they could be the front end gui.  It would be the merger of AJAX and grids.  That could be really cool.  The future of Java looks really fragmented.  There is no denying the influence of the Spring and Ruby communities in the enterprise software world.  SOA looks non-existant.  There are a ton of web frameworks now. I hope that shakes out a little.  Java is starting to show its age a bit.  People have been predicting the death of JEE for some time and judging by the shows I’ve been to I think it’s already happened.  Who’s writing new software for JEE?  Nobody, as far as I can see.  Its all about Spring/Hibernate apps with AJAX front ends.  Some variations exist here and there, but that’s pretty much the de facto.

After the show was over, I managed to hike around Barcelona for a couple of days before coming home.  I saw some great sights but I started wishing I knew more Spanish.  I went to have lunch in a small place that looked tourist-friendly.  They were off the beaten path, but it looked like thier menu was translated into English so I thought I was safe.  But when I sat down and asked the waitress, "Habla Ingles?"  She replied, "No, cero."  Which means, "You stupid American tourist, there’s no way I’m going to make this easy for you."  So I then decided to try to describe a sandwich by miming two pieces of bread with my hands and saying, "Pan con carne?"  She said, "No," and showed me a hand written spanish menu with 5 items on the top and 5 items on the bottom.  I recognized "spaghetti" so I pointed at that.  Then she wanted me to pick something from the bottom list also and said something about "carne" so I figured it was the meat course or something.  I pointed blindly at something on the list and hoped for the best.  She went to the next table and sat down with them, I heard them repeat the two things I ordered and laugh.  That’s always a good sign when you’re in a foreign country.  But it turned out I just ordered a sausage. It was pretty good.

All in all, I’d say Barcelona is a great place to visit.  I’d highly recommend it.  It was no coincidence though that the first night I was back home we went to CheeburgerCheeburger and I ordered a quarter pound burger with a milkshake.

-jasen

All about Generics

Wednesday, June 20th, 2007

I ran across this cool post on a Natural Language Processing blog.  The site distributes a tool that I’m using for an NLP project as part of my masters degree.  The post discusses how they refactored to use generics and has some great discussion and recources on the topic.

"My major complaint about Java when I first saw it was the lack of parametric typing. Many, if not most, of my programming errors are from assigning something to the wrong argument. I’m hopeless in Perl, for instance. As always, be careful what you wish for. Little prepared me for the complexity of Java 1.5 generics."  Read the entire post here.

 

JavaOne ‘07 - Day 4

Saturday, May 12th, 2007

I’m a little behind schedule on this post. We found a piano bar and didn’t get back to the hotel until early in the morning.  I can still hear the chorus to Tiny Dancer ringing in my ears.

The last day of the booths being open at JavaOne was awesome.  We had a lot of people wanting to talk about how to solve problems.  It’s great to see people really resonate with our solution.  I was in one discussion with a guy named Mike Moleschi from the University of Oxford who presented an x86 emulator that ran on a Java VM.  It sounded really awesome.  He is also part of the group working on the Nereus Project which is a "Massively Parallel Computing" platform.  I am definitely going to have to play with the x86 emulator. I have some old DOS games that I’d love to play again.  I told my wife that saving those boxes of old software would come in handy someday.

All in all, JavaOne has been a perfect show for Appistry.  The attendees that come to the show are thinking about issues they need to solve and are looking for ideas.  I really enjoyed engaging with so many developers and architects.  The domains were diverse and interesting and the people were friendly.

I ended my San Francisco trip by shopping a little in Chinatown before catching a shuttle back to SFO.  Downtown San Francisco is an awesome place.  I hope to see you next year. Maybe the slinkys will make a come back.

-j

JavaOne ‘07 - Day 3

Wednesday, May 9th, 2007

Today started with a keynote talk by the Oracle guys. Cameron Purdy, previously the CEO of Tangosol which is now owned by Oracle, stood up and showed a neat data grid demo.  Interestingly, his main points about reliability and scalability all sounded exactly like what I have been telling people at our booth.  The only difference is he’s talking about data reliability and I’m talking about processing reliability.  I’m still unsure about the Tangosol/GigaSpaces/TerraCotta data grid concept.  It sounds so much like EJB CMP to me.  The problem with CMP wasn’t that it was inside J2EE or on a cluster.  It was that the bigger you scaled, it the more problems you had with either stale data or performance.   If you try to fix the stale data problem by locking data instances on the cache, you now have scalability problems.  I don’t see how the data grid solutions address this.  I think what’s really happening in that space is specific domains are able to use optimistic locking, and therefore the ability to virtualize commodity hardware as a large memory cache works for them.  Maybe I’ll go lurk around their booths tomorrow and see if I can get one of them to explain to me how they address the stale data issue differently than CMP.

I had several good conversations with show attendees today. We didn’t give out as many slinkys as the first day, but they were still popular.  I think we have about 1 or 2 boxes left, so they should be gone tomorrow.  I do end up describing our product to people a lot.  Our concept isn’t an easy one to label.  We call ourselves an Application Fabric, but sometimes we say "virtualized grid", "next generation application server", or "execution platform".  Our VP of sales and I were having lunch and talking about different names we could use that would resonate with developers and architects.  I proposed Application Grid, so maybe we’ll try that out.  I had a booth visitor come up and ask straight out if we were a compute grid or a data grid.  He obviously understood the grid space, but I think compute grid wouldn’t explain what we do to most people.

Tomorrow I’m going to try to find some leftover t-shirts.  I have been so busy at the booth that all I have so far is a couple of pens from the Interface 21 booth.  They hinted at some upcoming ultra cool schwag.  I think we may have to turn this into a competition.  I’ll keep the updates on the blog.  Maybe we can get a bet going and an online poll or something.  I noticed we got a mention on Java the Hutt’s blog today which was cool.

I’m going to go get some food.

later,

-j

JavaOne ‘07 - Day 2

Wednesday, May 9th, 2007

Well I survived the first day of working the booth.  Our signs all showed up and everything looked great.  We had 1000 slinkys to give away with our logo on one side and the phrase "Scale for Spring" on the other.  I predicted we’d only give away 300 and our VP of sales predicted 500.  I thought slinkys were a little passe, but I was completely wrong.  Those things were flying off our table.  I couldn’t unpack boxes fast enough.  Apparently, programmers love slinkys- like, really really love them.  We got a lot of foot traffic from people who heard our booth had slinkys, so the marketing guys were right about that, and I was not.

One interesting issue we dealt with was the contact reader.  It’s a little handheld PDA that has an RFID reader in it.  Everyone’s show pass has a smart card in it so as they talk to us we can scan it and get contact info.  Well, our reader crashed.  It was provided by the show and was running Windows.  I found that odd at a JavaOne show, especially when they’re making big Java ME announcements.  You’d think they’d want all their handheld devices running their own platform.  We probably lost 30 or so contacts because of that.  We were given a replacement and made do, but it was kind of lame.

Other than that, I’ve learned to never work a booth unless it has the extra carpet padding in your booth area.  My feet and back are sore.  It’s hard work to stand and talk to people all day, but I did get into some interesting discussions about the difference between Appistry and other solutions like TerraCotta.  That was fun.  We definitely have some distinguishing features besides slinkys.  At the end of the day, Rod Johnson came by to take a look at our Spring integration code.  I opened eclipse and showed him the project we were running and he was impressively good with the hotkeys.  He knew things I didn’t and was flying around pretty fast.

All in all, it was a good day.  I wish I could have made it to a couple of sessions, but I was so busy talking about our software with people, I didn’t have time.  Maybe tomorrow I’ll make it to a couple.  There are a lot of interesting topics at the show.  They do a great job of getting a diverse group of speakers.  I would definitely recommend this show to anyone looking to see what the latest java related technologies are in any area.

Now I’m going to get some sleep,

-j

JavaOne ‘07 - Day 1

Tuesday, May 8th, 2007

So I’m at JavaOne, the Disneyland of Java.  We arrived a day early to setup our booth today.  There are a few shipping issues, some missing signs, etc.  but that is par for the course at shows, as far as I can tell.  I haven’t seen one without some type of last minute issue that resolves itself the next day.  But the tech part of the demo is working.  The development team, whom I have high respect for, delivered our most common demo with Spring integrated into it to correspond to our announcement for the show.  We have the ability to take a normal Spring application and deploy it on our fabric with no changes to the underlying code, which is consistent with the Spring philosophy (and Appistry’s as it turns out).  So we have this cool Swing app that sends a bunch of transactions into a fabric of machines that we truck around to these shows.  The development team took that app and converted it to a Spring app, and then put that on top of our fabric so that we can demonstrate code running on Spring with our dependability and scale it out on commodity hardware.

So yesterday I started debating as to what the dress code should be at JavaOne. I said jeans and t-shirts, the Sales and Marketing guys said khakis and dress shirts.  Today as I was walking around the floor with our VP of sales I pointed out the preponderance of people wearing jeans and t-shirts or jeans and whatever.  He pointed to one group of five people and said there were two wearing khakis.  I said one of those was wearing cargo pants so it counts for me, not him.  Tomorrow I’m going to wear jeans and a dress shirt in a blatant compromise.  If the majority of people walking up to our booth are dressed down in the standard programmer uniform, then I’m breaking out my OpenBSD t-shirt.  Remember the days when wearing ultra casual clothes meant you were so good at coding that you could wear whatever you wanted?  I had a boss once that accepted an interview as a favor when he was younger.  He didn’t want the job so he showed up in shorts and a tank top.  They thought he must have been so freakin smart that they fell all over him and did everything they could to hire him.  Man, I wish those days would come back.

I read in the paper this weekend (yes the paper, it comes to your house and is made from trees) that the telecom market is growing again based on high bandwidth applications.  I’m going to call this the "YouTube Effect" and hope that I’m the first one to say that.  Maybe we’re around the corner from actual sustainable technology growth?  That would be awesome, engineers being highly prized but without the bubble this time.  Just smack anyone that starts day trading tech IPOs at outrageously inflated values.

So anyway, day 1 at JavaOne was all about getting my cool "Java" backpack and a tshirt that won’t fit me.  But my stuff works, so I’m good to go.  Tomorrow we’ll take the nice JavaOne shuttle to the Moscone Center for our complimentary exhibitor breakfast and work the booth.  There are a couple of cool sessions that I want to find time for; they actually are scheduled all day until after 10:00pm.  My wife thought they’d end early so people could go see the sights.  I was like, "No these are uber-geeks and we want 12 hours of tech sessions all week because that’s how we roll."  Actually I said nothing like that, but I like to pretend how cool I sound retroactively.

See you tomorrow.

-j