Friday, May 02, 2008

Idle thoughts of a idle coder

Brian Tkatch has launched a thread on the PL/SQL forum about enhancements to SQL which would just basically save some typing: Things i wish SQL supported. The lazy man's list. This is quite a revealing thread, because it is always interesting to see what shortcuts people would like to take. It's a bit like peeking inside the medicine cabinet in other people's bathrooms (not that I would ever do that).

My personal wish is for:
select * {-empno} from emp;

That is, select all columns from the EMP table except EMPNO. This would be particularly useful for querying tables with BLOB columns in SQL*Plus.

As the thread as grown it has turned into a discussion of SQL theory ("conceptually, (using Venn diagrams) the tables/views are the circles, and the predicates define in what way the circles overlap") which requires too much concentration. The thread was supposed to be about laziness!

The patron saint of programmer laziness is Larry Wall, the inventor of Perl:
"The virtues extolled for Perl programmers are laziness, impatience, and hubris. Together, these admirable characteristics have led to the creation and use of many publicly accessible Perl modules. Because of laziness, programmers would rather write modules than repeat a procedure over and over (and would rather use modules written by other people than write new code from scratch). Because of impatience, programmers write consolidated code that is flexible enough to anticipate their future needs. And because of hubris, programmers share their triumphs with the rest of the Perl community and continually tweak their modules until they're the best they can be."


The problem with proactive laziness is that it can be hard to estimate how much effort will be saved later by putting in some extra effort now. Plus, writing automating utilities and code generators can just be a seductive form of procrastination. It feels like work but we aren't moving forwards. In the end we spend so much time sharpening the axe that we never get around to cutting down the tree. So the trick is to only automate the things we know it will be worth automating. This means doing something the plain way at first. Only when we get to the second or third cut'n'paste should we consider whether we need a parameterised module instead. The important thing is to automate early, in order to derive the maximum return on the work.

I am currently practicing cut'n'paste programming in a test data generator. I could refactor my code to drive off an array but re-editing my package to populate a collection will be a PITA. I should have done it some time ago, but I failed to realise just how many additional datasets I was going to need. At this point the ROI on the automation is quite small. So I have chosen to continue paying the find/copy/edit tax rather than spending half a day to figure out a better way of doing things. In the long run I will have expended more effort but in the meantime I keep making progress towards the main goal.

Labels: , ,

Wednesday, April 30, 2008

Esprit de cores

Oracle-L has been hosting an interesting thread on migrating to another (cheaper) DBMS. It seems like the company in question has not targeted a specific product yet, they just want a cheaper one. The entire thread has much to recommend it but I would like to highlight Mark Brinsmead's analysis of the definition of 'processor' in the Oracle License and Services Agreement, because it complements my post on licensing multi-core servers.
"[The OLSA] certainly adds a new wrinkle to SE licensing that I had not noticed until just now. Probably a lot of IT professionals, few IT managers, and even fewer lawyers, know the difference between a 'chip' and a 'carrier'. What's more, how many people *know* when they are purchasing a system with quad-core X86 'CPUs' whether the carriers in that system contain a single chip with 4 cores, 2 chips with two cores each, or four single-core chips. It makes little difference when purchasing the hardware (well, okay, it might make more than you think), but it can make a *huge* difference to your license costs and compliance."

Labels: , ,

Tuesday, April 29, 2008

Core blimey!

The Register reports on the latest developments in Oracle's multi-core licensing policy:
"Oracle, we hear, is charging a factor of .75 for Sun's T2 and T2+ systems even though they're running at about the same speed as the T1s. The major difference with the new chips is their support for more threads and the fact that the T2+s can go into multi-socket servers making them more useful for, er, databases. And by 'more useful' here we mean 'useful at all' since no one in their right mind would have thrown the older T1 systems at Oracle.

The .75 T2 factor comes as quite a shock to Sun customers who have upgraded their hardware only to have the Oracle tax man come along and tell them that the solid price/performance they were expecting via the hardware will be eroded via the software."
Of course Oracle is entitled to price its licences however it wants. But trebling the fees for customers who move to a different server with the same number of cores as their old kit doesn't seem like the best way to maintain loyalty. It also alienates Sun, who have previously used the favourable licensing terms to sell T1 boxes.

I disagree with Ashlee Vance's conclusion that Oracle's licensing policy will drive customers into the arms of IBM. If you're going to take the pain of moving to a new DBMS and if licensing costs are the main driver then free is a lot more attractive than DB2, no matter how sane IBM's fee structure. In his blog Sun CEO Jonathan Schwartz recounts a pertinent story from a recent visit to a large commercial institution:
"We had just closed the acquisition of MySQL, so before I wrapped up, I asked, 'And would you like a quick update on the newest addition to our family, MySQL?'

The CIO responded categorically with 'we don't run MySQL, we run [name withheld to protect the proprietary].' The CISO said, 'We can't just let developers download software off the net, you know, we've got regulation and security to worry about.' The CTO smiled. Everyone else appeared to be sitting on their hands. I was going to leave it at that. Thanks for the business.

Until a (diplomatically) assertive Sun sales rep piped up, 'Um... no, I connected with a buddy of mine over at MySQL, and had him check - you've downloaded MySQL more than 1,300 times in the last twelve months.'

After a profoundly awkward silence, one of the individuals from their internal development team piped up, 'Actually, everybody uses it. Why bother hassling with license agreements when MySQL's got you covered. We're stoked you bought them.'"
As we all know, purchasing decisions are frequently made on the basis of which product is the most cost-effective rather than which product is the best. The danger for Oracle is that Sun's purchase of MySQL lends the free database a lot more credibility than it had before. If Oracle won't give Sun any more sweetheart deals then Sun has more reason to start trumpeting the price-performance advantages of running MySQL on their new multi-core boxes. Oracle has made a lot of play about the benefits of free when it adopted Linux as its OS of choice. So it's not like it doesn't understand the allure. Which is probably why Oracle has restricted the price gouging to the Enterprise Edition licences whilst the Standard Edition is charged per socket. The jump from the SE feature set to MySQL is probably a lot less daunting than the equivalent jump from EE.

Footnote


Over at the Service Architecture - SOA blog Steve Jones considers the implications of the Register article for Software licensing in a virtual world.

Footnote #2


At the time of writing, the Multi-Core Processors - Impact on Oracle Processor Licensing document hurls an 404 error. This may indicate that Oracle are updating it to reflect the new chip sets.

Footnote #3


Also worth a read is the Register's recent interview with Mark Shuttleworth, Ubuntu's rentaquote-in-chief. Amongst other things he makes this prediction about Oracle's Unbreakable Linux strategy:
"Oracle will find themselves in a position where, if this business is successful or strategically important to them, they will need to fork or buy Red Hat. They will do one of those things within three to five years."
.

Labels: , , ,

Monday, April 14, 2008

Jean Prouvé: The poetics of the technical object

I confess I had never heard of Prouvé before I came across this exhibition at London's Design Museum but the title grabbed me. If I had have known how interesting and relevant Prouvé was I would not have left it to the last minute to go. I think he's not better known outside of France because he mainly worked on municipal projects.

He never formally trained as an architect; so although he did work on the design of buildings, his is not the name which tends to be associated with them. His most iconic designs are chairs. But these are chairs for university halls of residence, works canteens and classrooms, not the sort of chairs which grace Notting Hill living rooms.

Although he came from an artistic background Prouvé started out as an artisanal blacksmith in 1919. He quickly moved from wrought ironwork into steel and aluminium, but he always remained rooted in the practice of working with materials. He designed through trials and testing of concepts.
"...one should not sketch out utopian projects, because evolution can only result from practical experience."
This commitment to evolution is demonstrated by a display of Standard Chairs, variations on a theme produced by Prouvé's workshop over the course of two decades. The basic shape and configuration of Chair No.305 is not markedly different from Chair No.4. There are minor tweaks, and there are variations in material: wood, steel or aluminium, plain or lacquered. The biggest adaptation was the collapsible Standard Chair.

As an artisan and then a factory owner he understood the properties of wood and metal and their appropriate usages. Designers and architects more driven by the need to appear avant garde tended to get carried away with the thrill of new materials and looking modern. Prouvé appreciated that good design had to come from functional success: no matter how striking it looks, a chair is no good if it is not comfortable to sit in. An example is the Solvay table, which is made of wood bolted together with lacquered steel. The engineering of the table is not hidden, it is part of the aesthetic, but neither is it fetishised.

Prouvé was a early adopter of the concept of design patterns. He assembled a dictionary of structures which could be reused in different situations and scales. The crutch - a asymmetric Y shape - which supports the roof of the Pump House at Evian re-appears in the design of an armchair. He devised a roof made of single curved pieces of steel. These shells were light enough for two men to slot them together. At a larger scale this shape could be rested on the ground to form vaulted halls. One favourite shape, a elongated pentagon, appears repeatedly in his work: as the back legs of the Standard Chair, as the legs of various tables, in the cross-section of a table top, even as the handles of a sideboard.

I tend to be wary of attempts to draw parallels between our industry and branches of engineering or architecture, as these strike me as attempts to lend software development a spurious sense of discipline. Just calling it "software engineering" does not make writing a program as rigourous an activity as building a motorway flyover. However, with his commitment to iteration, re-use, modification and adaptation, and his championing of practice over theory it is hard not to regard Jean Prouvé as the Godfather of Extreme Programming.

There's more


The other exhibition at the Design Museum featured lots of modern work. One of the most striking exhibits was a chair "sketched" by a Japanese design house called FRONT. Their designers have developed a mechanism for designing furniture through motion capture and then rendering the designs using extruded plastic. Unlike Prouvé's work you probably wouldn't want to sit on the chair or rest a cup of coffee on the table but the process is fascinating to watch.

Labels: , , ,

Friday, April 04, 2008

Big zips

I have just downloaded the database 10.0.2.4 patch for Windows 32bit. It is a zip file which weighs in at a cool 1,034,080,256 bytes. Opening it up reveals a single directory called Disk1. Well I suppose it's one way of maintaining the fiction that Oracle installs fit on a single disk. This is the first time I have come across a patch which is too big to fit on a CD-R. It's a pain, because DVD burners are not yet standard kit and certainly all our servers still just have CD drives.

Labels: ,

Monday, March 31, 2008

Comparing CHAR values

Here is a table with a single row of data.

SQL> create table my_tab (c2 char(2))
2 /

SQL> insert into my_tab (c2) values ('Y ')
2 /

1 row created.

SQL>

Which of the following queries will match that row?

select * from my_tab where c2 = 'Y'
/

select * from my_tab where c2 = 'Y '
/

select * from my_tab where c2 = 'Y '
/

If you said all three you get a cigar (providing you live in a jurisdiction where such infernal devices are still permitted).

SQL> select * from my_tab where c2 = 'Y';
c2
--
Y

SQL> select * from my_tab where c2 = 'Y ';
c2
--
Y

SQL> select * from my_tab where c2 = 'Y ';
c2
--
Y

The reason is due to Oracle's rules for comparing blank-padded datatypes. If the two values are of differing sizes Oracle pads the smaller variable with the requisite number of blank spaces. Obviously it is documented.

On the whole I think this is a boon - CHAR columns are a pain in the neck at the best of times, without having to worry unnecessarily about additional RPAD calls. This is unfortunate if you are relying on 'Y ' being different to 'Y'; but if your application depends on trailing spaces for data integrity then you probably have bigger problems.

Labels: ,

Friday, March 14, 2008

Hacking a pacemaker

In the last few days I have read a couple of pieces which quote the William Gibson dictum "the future has already arrived, it’s just not distributed evenly". Confirmation that we are indeed living in a science-fiction story arrived today in the shape of a message on the Full Disclosure list: hacking a pacemaker. Security researcher Gadi Evron cites a report in the NYT.
" The threat seems largely theoretical. But a team of computer security researchers plans to report Wednesday that it had been able to gain wireless access to a combination heart defibrillator and pacemaker.

They were able to reprogram it to shut down and to deliver jolts of electricity that would potentially be fatal . if the device had been in a person. In this case, the researcher were hacking into a device in a laboratory. "
What a great way to assassinate somebody....

Labels: ,