« October 2002 | Main | December 2002 »

November 28, 2002

Going retro

Blocks in Java and C#

James talks about some syntactical sugar enhancements that can be made to Java borrowed from C#. Although it sounds petty, this stuff really makes a difference when you're staring at code all day. Clean and readable code makes for relaxation which makes for smarter thinking. Syntax is closely related to karma.

The foreach and using operators are particularly nice as it provides a cleaner sequence for commonly executed sequences of events. But why stop there?

One of the features that made Smalltalk and Ruby so popular was the use of blocks. These allow you to create your own constructs.

Having (finally) twisted my brain far enough to start to understand Perl, I'm actually starting to appreciate it. This alone should probably scare me. It is (proudly, deliberately) a derivative language. Perl shamelessly borrows paradigms from C, C++, Lisp and a few Unix tools. I'm still learning, but it looks like a lot of the AOP, block/closure & attribute stuff could easily be (or has already been) implemented in Perl, and has been available for years. I sometimes wonder if language designers are doomed to reinvent things that some guys over the road already implemented a decade ago. Take this:

my $block =
sub {
my ($target) = (@_);
print "Hello, $target!\n";
}
Dangerous Perl Oversimplification 101:
my is like 'private'.
$ means 'scalar' - essentially a single variable.
my ($target) = (@_) means (roughly) 'take a copy of the first argument and assign it to $target in list context'.
$block now holds a reference to a function that will print a greeting every time it gets called. You can treat it like any other kind of variable, including sticking it in an array, or indeed a hash. Dynamic dispatch becomes a simple matter of using your arguments as the key to a hashmap. Yes it can be done in strongly typed languages with some creative use of interfaces and the Command pattern. The point is, its built-in, and has been for some time. Why is Perl hard?
  • Well for a start, it has no grammar. You can't generate a parser for Perl, its too irregular.
  • It is contextual. Like English, meaning can vary depending on the topic of conversation. For example, if I ask you "where are you going?", and you replied, "to the shops", we would both know that it was you we were talking about, and that you were going to the shops. Perl is a bit like that. A lot of those evil looking magic variables are to do with this. $_ is essentially the 'topic' under discussion. Unless told otherwise, most Perl operators assume $_ which is one of the biggest hurdles to overcome when learning Perl.
  • Perl is laid-back. So lines like 'unless ($flag) {return 0};' can also be written 'return 0 unless $flag;'.
XP in Perl? Can be done, of course. In a language as powerful and undisciplined as Perl, the discipline of XP is more important than ever. Refactoring will be harder than in other languages, possibly so much so that the (heretofore undiscovered) 'refactor to other language' may need to be applied. Test first is more rapid than in languages with a compilation step as you might expect. One of the most compelling reasons to use Perl? CPAN. As has been said elsewhere, the true strength of many modern languages lies in the extent of their libraries. Chances are, if you need to do something in Perl, someone else has already done it and put it in CPAN. Something that made me laugh today is the Date::Manip module, which can parse strings like "second wednesday in 1996" to date values. Take a walk on the wild side.

November 27, 2002

java.blogs

Just added myself to the java.blogs site. Looks great so far. And powered by WebWork, judging by the link urls. Great showcase for all the excellent OpenSymphony stuff (as is Jira, of course!)

November 26, 2002

Further bookishness

Received Kent Beck's 'Test Driven Development' book today. Turned to page xv. Read the acknowledgments list. Grinned inanely and basked in the vicarious fame. My name mentioned in a book by Kent Beck! Cool. Despite my help, the book's excellent as well :)

Book buying bonanza

The GoF Design Patterns of enterpise application development.. I just got my copy of Martin Fowler's Patterns of Enterprise Application Architecture. I can best describe this as the GoF Design Patterns of enterprise application development. Beautiful book. I followed the public review process on his web site very closely. Martin's style makes for such an easy read. I see this being a staple of any serious developer's bookshelf.

I'm off to Ireland to drink my Thanksgiving dinner. Bet your ass that this book will be in my carry-on. [crazybob.org - web log]

Just placed the order for my copy. I've been following its evolution on Martin's site for over year, so it seemed only fair.

November 22, 2002

Written any good books lately?

Michael Feathers of Object Mentor has started writing a book (currently) called Working Effectively with Legacy Code. Everything you need to know about tackling that aspect of software development that most of us spend a large chunk of our time on, and would probably rather we didn't have to. Excellent stuff. Follow its development, and discuss refactoring in general at the 'refactoring' yahoo group here.

November 20, 2002

What's up with Roller and Radio?

I don't know if its a problem with Roller, Radio, or an unfortunate conglomeration of both, but every time a Roller-using blogger adds an item I get their entire feed duplicated in my Radio news page. Its getting so I have to hit the 'delete' button 4 or 5 times to clear the backlog. Is it just me?

November 19, 2002

XP Misconceptions

This article makes for an interesting read, but it suffers from a common misconception about agile methods and planning. Namely that Agile doesn't do planning. I'm more familiar with XP than the other agile methods, but as far as I know, none of them claim that 'planning doesn't work so lets throw it out', as the article states. There's even a book called "Planning Extreme Programming", by Kent Beck and Martin Fowler. What XP does recommend is that you should have just enough planning/design/whatever for your specific needs. Its about removing anything that doesn't add value to your process.

November 18, 2002

The shroud of the dark side is falling

I like Perl. I feel like I should go to a meeting or start a 12 point plan or something. I've volunteered to work on a project at work that is using Perl, as I've wanted to see it in action for a while, and I have to say that it is scarily seductive. It just does what you want and gets out of the way. Provided you know how to tell it what you want. One thing in my defense: I am entirely unconvinced that there should be 'More Than One Way To Do It'. I got terribly confused with some date manipulations due to the 'localtime' function returning zero-indexed (0-11) months, and the Date::Calc module expecting 1-indexed (1-12) months. Sometimes its just easier to have Only One Way To Do It. The OO stuff also looks like a dodgy aftermarket bolt-on...

Language Loss

Books and Words

Learning another language is tough. Amazingly tough. Cedric is going to post about accents some other day, which should be interesting. My accent in Spanish is horrible... I feel for the people who have to try to have conversations with me every day. I need another 3 years here at least.

-Russ [Russell Beattie Notebook]
Learning another language is certainly tough. Knowing that you used to speak one and can no longer is also a bummer. Its hardly my fault - I was 5 when we left Brazil. But when my parents recount stories of how my mother used to get me to translate for her, I feel gutted that I have (apparently) utterly lost all my Portugese. I would love to go to Brazil or Portugal to work just to see if I could regain my childhood facility with the language, but unfortunately its hard enough to maintain a software career in your native country currently, let alone try to make a go of it overseas. Darn.

November 16, 2002

Nullify Nasty Negotiators

Kept Waiting. Karen wants to know how to handle being persistently kept waiting by lawyers and accountants. [read more] [Tony Bowden: Understanding Nothing]
I hate negotiations, mostly because I'm not very good at it. Or perhaps its because the majority of my experience has been with people who do it for a living (car salesmen, estate agents etc.) and are therefore a lot more experienced at it than I am. Either way this link makes for an interesting read. The best way to prepare for a negotiation is to understand what tactics might be employed against you and how to deflect them, while resisting the temptation to try and be underhanded yourself. About the only thing I hate more than negotiation is dealing with a dishonest negotiator.

November 15, 2002

Someone's melted my keyboard!

Got a Maltron keyboard on hire for the next few weeks. Its very strange. People also think I am for using it. I've just about gotten used to the fact that all the keys are at different heights and angles, but its all the control keys that are giving me real difficulty. Several times I've gone to hit alt-tab and got \' instead. Most of the non-letter keys are in different positions, and muscle memory is working against me. My mind thinks alt-tab, but my body is doing 'left arm over, thumb back, second finger up' before I can catch it. Its an oddly jarring sensation. I know what I want to do, but my fingers defy me.

Oddest things so far:

  • Return is under the left thumb
  • ...as is backspace
  • ...and tab

Coolest things so far:

  • Opening brackets, braces, angle brackets etc. is done with the left hand, closing them with the right. Appeals to my logical programmer nature.
  • Angle brackets are unshifted, which makes typing markup a lot easier.
  • The shift-lock key (as distinct from caps-lock).
  • ctrl-alt-del are next to each other and can be activated by drumming one hand over them.

November 14, 2002

Internet not obsolete yet

The Top Seven Things Wrong with the Internet. The Internet is in serious need of an upgrade in a number of areas. Some of these problems already have fixes, they're just not being rolled out because it's considered too hard, or there are large vested interests in maintaining the status quo. (This was originally going to be a top ten, but I ran out of writing time during my lunch hour. I may amend the list later.) (1003 Words) [The Fishbowl]
To address some of your points: 1. DDOS attacks. ISP's already have the ability to contain some of these and make them less damaging. Its called something like 'Packet Egress Filtering'. One of the ways that DDOS attacks like SYN floods and the 'ping of death' work is that they get lots of machines to send packets with spoofed IP addresses. In the example of SYN floods (as I understand it - I may be wrong) zombie machines are instructed to send out TCP SYN requests (the initial 'handshake' request for opening a connection to another machine), with the source IP spoofed to be that of the machine being targeted for the denial-of-service. A server receiving a SYN request will send an ACK response to the source IP to acknowledge the connection. If sufficient zombies are all sending spoofed SYN packets, the target is buried under a flood of ACK packets all coming from well-meaning servers that are under the impression it tried to initiate a connection with them. The really sneaky part is that each individual middle-man machine would only see a very minor increase in traffic, as its the aggregated total of all the middle-men sending ACK's that swamps the target system. A variation of this (I'm more fuzzy on this one so I may be even more wrong) is sending SYN packets directly to the victim system, with source IP's spoofed to be non-existant. The victim will try and send an ACK response, which will go nowhere, so it will try again, several times before giving up. Given enough SYN packets, it will eventually be spending its entire time trying to send ACK's and not servicing genuine requests. How does egress filtering address these issues? An ISP knows which IP address ranges belong to it, and could put this data into their routers, such that any packet that arrives at the inside edge of their network that claims to be from an IP that is NOT within the ISP's allocated range could simply be dropped. This would prevent packets with spoofed source IP addresses ever getting out of the originating network. This is about the limits of my knowledge on this. More info: here, and here 3. IP numbers. IPv6 is on its way, with mind-boggling numbers of er, numbers, unfortunately inertia (and upgrade cost) is against us on this one. It will get here eventually (I hope). 7. Amero-centricity. Agreed. :)

Refuse Collection Engineering

Turbo-charging Java HotSpot Virtual Machine, v1.4.x to Improve the Performance and Scalability of Application Servers. This paper describes the requirements of a Telecommunication (Telco) application server written in Java, and how those requirements might influence Java virtual machine design. Most of the discussion is not limited to Telco alone, but applies to the enterprise as well. [Java-Channel]
Some serious detail on java garbage collection here. Tweaking GC can have major impacts on application performance. I've obtained speed-ups of up to 500% on batch operations (turning a 1-hour task into a 12 minute one) by doing this. For almost all server-side or long-running batch applications, the default young generation size is way, way too small, and should be increased to a significant proportion of the JVM's maximum memory.
-verbose:gc
is your friend.

Healthy Competition

Aspects and Attributes are both Big News in java blog land currently. I'll say this about MS: one positive thing .net has done is kicked us all in our complacency, and inspired a whole raft of really excellent projects. Its great to see the number of committed java people who are out there learning from .net and adding the good bits to java.

November 12, 2002

Christmas comes early

Just released 3.0.

Whoof, we got it finally!

[Begblog]
Groovy new monitor, and groovy new IDEA to play with on it!

Open (Source) Government

Australian government backs open source. According to this articlethe Australian government is backing the use of open source software for it's e-government platform. The Federal... [<big>kev's</big> catalogue of this and that.]
Yet another government threatens to slip out from under the fist of Microsoft. Don't they know that's not allowed? Hope rises every time I read another story like this. The 'TCPA plan' (aka. all your [apps/music/data/anything else we think of] are belong to us) will only gain ground if there is sufficient passive acceptance. If enough major governments and large institutions start using open source, TCPA / Palladium might actually be killed before it ever gets going. My computer is mine. For better or worse. Nobody gets to choose what I run except me. Why is this such a hard concept for organisations like MS and the RIAA to grasp? How would consumers react if their cars only allowed them to drive on approved roads? Or only accepted fuel at filling stations operated by 'trusted' oil companies?

LCD Lust

We just got a shipment of gorgeous 18" LCD screens at work. They are fantastic, and much, much easier on the eyes than CRT screens. I was amazed. I have a dual-head graphics card so I stuck my new screen next to my old one, and the difference is huge. Although before I saw the new screen, I would have said the old one was excellent. If you can swing it, get one, your eyes will thank you.

November 10, 2002

Any port in a storm, as long as its 80

OpenSymphony Wiki online. OpenSymphony has a new Wiki online, powered by SnipSnap. It should be useful for on-the-fly documentation writing and tip sharing. Already the WebWork Cookbook has moved there and got some extra contributions! [rebelutionary]
Looks great, but for as long as its on any port other than 80, I won't be able to see it from work. :( Trying to get ports opened in our corporate firewall tends to generate a reaction similar to saying "Hi, mind if hack the network, install packet sniffers on all the servers, set fire to the office and sell all our data to the competition?".

Development Dichotomies

Don't get me wrong, I love XP and Agile, and Test-First is a better object designer than I am. Unit tests have also saved my bacon on more than one occasion. Its just that sometimes, its strangely liberating to throw caution to the wind and code like crazy without a safety net. Some of the most fun (and technically cool) things I've done have been hacked together in an afternoon, with no regard to anything other than the single idea that I'm trying to express. My JMock-alike fake servlet framework (have to discuss getting that open-sourced with the PTB's) is one example. I've tweaked bits and pieces since, but the core took shape in a single afternoon of manic coding. Odd. PS. The 'just do it' technique only works (for me) when coding something truly engaging. Most production code isn't on the cutting edge of cool, and thats when test-first helps me to stay focussed and catches my silly mistakes.

November 09, 2002

Internet 2

Internet 2. Interesting, although merely a continuation of the internet of today. Still waiting for the (next) new paradigm...

November 08, 2002

Physical key cryptography

People don't choose secure passwords, and they don't generally use different passwords for secure (online banking) vs insecure (mailing lists) authentication. Public-private key cryptography is even more of a hassle for the average person. However, now that 'plug-n-work' connection technologies like USB and FireWire are fairly pervasive, and products like this USB Drive are available, it should be fairly simple to build something that works as a 'data key' much like a car or door key does. A device small enough to fit on a keyring would be unobtrusive enough to take everywhere, and people understand physical keys, so the learning curve would be minimal. Just plug it into your PC to 'unlock' your data. It could work for encrypting your personal data on disk as well as for sending secure messages. Even (by today's standards) moderate storage capacity (say 64 Mb) could store hundreds of contact details, including public keys, so sending encrypted email could become much more transparent.

Just some thoughts that occurred while I was reading 'Java Cryptography'.

Inside the Penumbra

Every day that I use Eclipse I am more a believer in it. I've never used an IDE as much as I've used Eclipse - it just works so great. With more and more plugins coming every day, cool stuff on the way in 2.1, and companies like IBM and Borland steering the project it's going to dominate for sure. I'm totally with you on this one. Sorry all you IDEA guys... enjoy your favorite while it lasts.

-Russ [Russell Beattie Notebook]

Have to disagree with you here, Russ. It would be a real shame if Eclipse killed IDEA. IDEA is one of those things that just continually brings a smile to your face as you discover new things it can do, and new keyboard shortcuts. I can spend hours in IDEA without ever having to touch the mouse. And you haven't lived (IDE-wise) until you've done some major refactorings that would have taken orders of magnitude more time in any other product (Eclipse included). Eclipse is good, but IDEA is like an extension of my hands.

November 06, 2002

Schoolyard Squabbles

This thread at javalobby has to rate as one of the most surreal examples of name-calling and hair-pulling ever seen in a technical forum. I fear for the software industry. Updated: Radio mangled the link originally. I fixed it.

November 05, 2002

Quirky Keyboards

Has anyone used the Maltron keyboard? It looks seriously cool, but appallingly expensive.

XPDay 2

November 15th-16th: XP Day 2. The place to be if you're interested in XP.

Organised by the world-famous eXtreme Tuesday Club.

November 04, 2002

We'll have no casting here...

Spam, Spam, Spam, Spam, Spam, Spam, Spam.. Java's Casts of Thousands More than any other programming language Java forces programmers to embed hard-coded knowledge throughout their code about the types of data items. The numerous explicit cast [Small Values of Cool]
Generally speaking, numerous explicit casts are a sign your design is a bit suspect. Chances are there's some duplication to be removed (so numerous casts become just one), or the design is attempting to be too generic ie. 'built for flexibility', which often (ironically) results in a very brittle and inflexible codebase. I tend to find myself using casts when (a) dealing with the collections framework, and (b) writing framework code. Be suspicious if there are lots in 'normal' code. Added later: having followed the post to its source, here, it looks like the code is suffering from from the 'too generic' problem. The Additive interface appears to be far too general to be useful. This is just my opinion of course, but I find that very specific and well defined interfaces lend themselves to flexible code far more than vague ones do.

J2EE Performance

I just got word from one of our developers, who have been testing our portal/CMS product using WebStress. Turns out that with a combo of Apache/Tomcat/JBoss and 50 concurrent users (i.e. no "think time") we consistently get an average page rendering time of about 30-40ms, and this is on quite moderate hardware. Each page has a bunch of portlets on it which displays texts, forums, images, etc. I.e. a normal portal/website.

This is pretty good, but remember this: while the recent benchmarks of PetStore was done with architectures that were optimized for performance, our architecture is created entirely focusing on good design patterns and maintainability. Plus, everything in our system is an AOP object (e.g. Server,Site,Page,Forum,Message,Thread,Link,etc.etc., even a persistence manager is an AOP object), so it's pretty complex (yet simple). No corners have been cut with regard to the design of our product. [Random Thoughts]

There is no substitute for good design (or excuse not to do it). "We must strive to reach that simplicity that lies beyond sophistication." - John Gardner (courtesy of Russ).

Make it run, make it right, make it fast. I find that the third rule is often not an issue if the first two have been followed.

Great stuff Rickard, now when can we get our hands on this monster you've created? :)

November 03, 2002

Reusable Teams.

One of the arguments against reusable software is that it doesn't come free. [read more] [Tony Bowden: Understanding Nothing]
Isn't this what military organisations have done for years?

November 02, 2002

CookWork WebBook

WebWork Advocacy.

People just don't understand how damn cool WebWork is - so I've started my own mini-webwork-education-crusade.

The WebWork Cookbook  contains useful hints, tips and techniques that you probably didn't know you could do from reading the docs. (Oh - and try to do that in another framework!)

Let's call them 'lessons from the trenches'

Got a use WebWork tip? Email it to me!

[rebelutionary]
Superb! This is just what I need.