Archive for the ‘DIY’ Category

OpenJDK for Darwin

Friday, August 22nd, 2008

Landon Fuller has OpenJDK 7 binaries available for testing on Leopard.

Currently it only works for i386 boxes ( and possibly 64 bit machines also, ) at least until Zero works.

You will need to have freetype installed via MacPorts, and have X11.app installed and running if you are running any GUI apps.

Please report all bugs to the BSD porters mailing list.

So far, with the exception of a few GUI bits not drawing properly, it has worked really well.

Well done Landon ( and Kurt and all those other guys who have put in so much time into getting it to run on BSD. )

How to dance … Acid House edition

Monday, August 18th, 2008


http://www.next2friends.com/video/acid-house-dances-/MjhhZTczNTM0ZmRkNGY2YW

Mac OSCON

Tuesday, August 12th, 2008

I was about to write about this myself, but I punched the words into Google first and out popped someone else who had noticed what I noticed, Apple’s presence at OSCON 2008 ….

How’s this for ironic: Microsoft is actually spending some sponsorship dollars here at OSCON (Open Source Conference) 2008, but Apple is stealing the show — without spending a dime. Here’s how.

when our resident blogger checked in with the OSCON registration desk today, he immediately noticed Microsoft’s logo on the conference bag. Lovely. It was right next to the Intel logo. Is this a “Wintel” event? Are we back in 1998? Somebody press Control+Alt+Delete

Yes, thats right, Micro$oft and Intel were the “Diamond Sponsors”, that mean they chipped in the most money, but neither of these companies are known as friends of open source, no matter how much they try to convince us otherwise, and they do. Both companies are blowing the open source trumpet, but intellectual property and lock in are still clubs that they wield against open source projects.

The “Platinum Sponsors” were Google and Sun, both of which have made great contributions to open source in their time, though Sun have been a little stingy with their documentation, I get the feeling that situation has changed, and they are no Intel by any means. Google, well you are completely dependent on them, so who cares, right ?

“Gold Sponsors” were BT, IBM, Yahoo and Zimbra, of note amongst them are IBM who used to be the old Micro$oft before they opened up their hardware specs for the IBM PC and got their arses kicked by the proprietary operating system that ran on it written by …. Micro$oft.

Meanwhile, Apple Corporate is nowhere to be seen at OSCON. Steve Jobs must be locked away, designing the next proprietary software platform tied to proprietary hardware and proprietary online Apple services.

Semi-proprietary operating system, you may well remember my dealings with Apple’s open source initiatives in the past, I still think I’m one of the few people who ever built Darwin from source back in the days of OpenDarwin, so I think I am more bitter, yet more realistic in my expectations of Apple, they have a fine OS, and do a fine job of it, but don’t expect them to not be a computer company rather than a software company ( and these days a music company. )

I also was a Mac user prior to MacOS X, and remember the transition period where Apple looked at every OS going, BeOS was a strong contender, Linux also was a strong contender, you guys remember MkLinux, right ? In the end they opted for Darwin, which was derived from NeXT’s NeXTSTEP OS, which in turn was derived from FreeBSD 3 and the Mach micro kernel.

Still, Apple is EVERYWHERE here at OSCON. The VAR Guy estimates that 20 percent to 35 percent of the crowd is carrying MacBooks or MacBook Pros. This strong connection between the open source industry and Apple is hardly surprising.

It seemed quite a bit more than 20 - 35 percent in reality, it was shocking just how many there were, everyone seemed to have one, it definitely seemed like the majority, Thinkpad users second and then a few micro laptops.

So here we are, at a big event where Microsoft is spending big marketing dollars — and Apple won the hearts and minds of attendees before they even arrived at OSCON.

Blasting from the past

Tuesday, August 5th, 2008

Someone with far too much time on their hands has ported the original BASIC version of StarTrek to C#

May God have mercy on us all.

Ah, good old line-numbered BASIC. It’s all coming back to me now. Those line numbers were there to provide targets for GOTO and GOSUB statements. But, line numbers made editing a tad difficult. It was convention to enter in line numbers that were multiples of 10. That way, as you developed the program, you could go back and insert up to 9 additional statements in between existing lines without reworking all the GOTO/GOSUB references.

Oh bloody hell, I remember that, in fact I was thinking about it the other day, and not in a nostalgic way. Now machine code, thats nostalgia, though I guess line numbers were a natural successor in a way, like flexible addressing, hmmmm … I better stop or I’ll make it sound good.

due to the caps, I feel like the code is screaming at me

Ha ha, yeah …. things sure have changed …

Next, I had to decide what language to port it to. Staring at that BASIC code reminded me that C# brought goto back into the mainstream.

So it’s C#’s fault, eh ? I better move swiftly on before I start quoting Dijkstra, may God have mercy on us all.

Would it be possible to do an exact line-by-line port from BASIC to C#? Apparently so… and the result is some of the sickest code I’ve ever keyed into a computer. Want a comparison? Here’s a segment of BASIC code:


2950 PRINT "TORPEDO TRACK:"
2960 LET X=X+X[1]
2970 LET Y=Y+X[2]
2980 IF X<.5 OR X >= 8.5 OR Y<.5 OR Y >= 8.5 THEN 3420
2990 LET V[4]=X
2991 LET V[5]=Y
2992 GOSUB 9000
2993 PRINT
3020 IF A[INT(X+.5),INT(Y+.5)]#0 THEN 3080
3060 GOTO 2960
3080 IF A[INT(X+.5),INT(Y+.5)]#2 THEN 3230
3120 PRINT “*** KLINGON DESTROYED ***”
3130 LET P[1]=P[1]-1
3140 LET P[3]=P[3]-1
3150 IF P[3] <= 0 THEN 4040
3160 FOR I=1 TO 3
3170 IF INT(X+.5)#K[I,1] THEN 3190
3180 IF INT(Y+.5)=K[I,2] THEN 3200
3190 NEXT I
3200 LET K[I,3]=0
3210 GOTO 3370
3230 IF A[INT(X+.5),INT(Y+.5)]#4 THEN 3290
3270 PRINT "YOU CAN'T DESTROY STARS SILLY"
3280 GOTO 3420

And the C# version:


_2950: Console.WriteLine("TORPEDO TRACK:");
_2960: X = X + _X[1];
_2970: Y = Y + _X[2];
_2980: if (X < .5 || X >= 8.5 || Y < .5 || Y >= 8.5) goto _3420;
_2990: _V[4] = X;
_2991: _V[5] = Y;
_2992: _9000();
_2993: Console.WriteLine();
_3020: if (_A[(int)(X + .5), (int)(Y + .5)] != 0) goto _3080;
_3060: goto _2960;
_3080: if (_A[(int)(X + .5), (int)(Y + .5)] != 2) goto _3230;
_3120: Console.WriteLine(”*** KLINGON DESTROYED ***”);
_3130: _P[1] = _P[1] - 1;
_3140: _P[3] = _P[3] - 1;
_3150: if (_P[3] <= 0) goto _4040;
_3160: for(I = 1; I <= 3; I += 1) {
_3170: if ((int)(X + .5) != _K[(int)I, 1]) goto _3190;
_3180: if ((int)(Y + .5) == _K[(int)I, 2]) goto _3200;
_3190: ;} I = 3;
_3200: _K[(int)I, 3] = 0;
_3210: goto _3370;
_3230: if (_A[(int)(X + .5), (int)(Y + .5)] != 4) goto _3290;
_3270: Console.WriteLine("YOU CAN'T DESTROY STARS SILLY");
_3280: goto _3420;

To simulate line numbers, each line starts with a label consisting of an underscore followed by a number. That works fine for GOTO, but what about GOSUB? Examine line 2992. Subroutines were replaced with methods. That almost worked. In BASIC, you’re not forced to RETURN from subroutines. You can leave them via GOTO. That was used only in the case that the player is destroyed to send them back to the beginning of the program to start over. I replaced that GOTO with a return statement that passes a flag back to the caller. The caller inspects the flag and jumps back to the program start if need be. I also discovered that at one point, there is a GOTO that jumps into a FOR loop. C# won’t let you jump to a label in a sub-block of code. I transformed the FOR loop into a GOTO loop to make C# happy.

All the variables in the BASIC program, including the arrays, are real number type. However, in BASIC, an array and a scalar can share the same name; the interpreter is able to sort it all out. But, C# is less kind. To solve the problem, I prefixed array names with underscores. Also, arrays in BASIC are indexed from 1 instead of 0. To compensate, I increased the length of all arrays by 1. Index 0 is never used.

Well, BASIC to C# using labels is a fairly neat hack, but …. it is still painful. Notice the use of reals to compensate for the typing conversion. Whenever anyone goes on about the superiority of dynamic typing I always think of them as BASIC programmers.

Anyway pain aside, here comes the real gem and the reason for posting the article ….

Rewriting the game brought up an interesting aspect of the BASIC version. Targeting is done using polar coordinates, but you won’t find any trigonometric functions in the BASIC code. I assume the functions were unavailable. Instead, the angle is converted into a direction vector using different ratios that approximate the trigonometric functions. That means even if you worked out perfect targeting using trigonometry, when you entered in the angle, the actual trajectory will be slightly off. Nonetheless, it’s a pretty clever math trick. As for me, I took advantage of Math.Sin() and Math.Cos().

Now that is nostalgia, using math hacks because there wasn’t any support for things like trigonometry, not that from time to time in certain situations these old hacks don’t resurface, for example I remember coming across a pretty slick circle drawing algorythm a few years ago using ints and no trig at all, or having to provide your own divide route for chips without a divide instruction.

Three from the killer

Monday, August 4th, 2008

doG bless uTyoube, not that I quite understand the play-a-whole-track-with minimal-gfx thing that much, ( at which point I have to point you to pzar’s videos, interesting hobby you got there pzar ;) and the sound quality just bottoms out, but it is nice to listen to the occasional classic regardless, and I grew up up with cassettes, which had the most appalling sound quality, especially if they had been copied, especially if they were copies of copies … and so on. In this day and age you cannot always get everything you want via some legit download or some illicit P2P network, so if anyone has a copy of this, let me know.

Oh, and if you are going to listen to these, at least make sure you have an audio output that can reproduce the bass properly, for example, built in speakers on a MacBook == FAIL.


http://www.youtube.com/watch?v=wcCmqkWhRMU

(more…)

{My,Postgre}SQL smackdown

Sunday, July 27th, 2008

http://www.youtube.com/watch?v=AAGgUCDiRlQ

Monty Widenius of MySQL and Josh Berkus of PostgreSQL scrap it out sumo style at the Sun party. Chris has also got footage of this fight, but it does not have me in it, yup thats right, if you look at the beginning of this video, myself, Brad, Josh and probably Chris ( I haven’t spotted him yet, ) are there in the background. I don’t have Chris’ footage, but I’ll link it when I do.

I think it’s fair to say Monty won the bout, I am half tempted to say it was rigged, it was a Sun party after all, and they were handing out Sun / MySQL stuffed toy dolphins that I picked up a couple of, and MySQL boxer shorts which I didn’t … for ( hopefully ) obvious reasons.

For the record, I stayed for the first two falls and then I went back to the hotel, so that bit at the beginning is all I would have been there for. The Sun party wasn’t that much fun, or maybe it just felt as if everyone was trying to hard to have fun, I don’t know.

Onions will bring a tear to your eye

Sunday, July 27th, 2008

The annual Perl State of the Onion Address was delivered as always by Larry Wall, this one ( 2008 ) the 12th state of the onion Larry has done.

This is actually my second attempt to write about this, the first attempt was done as it was being given, but due to WordPress being a web application and networks being so reliable, while trying to save an update I lost all my text, wether this is a WordPress bug, or a PHP bug ( forget the language, the guts of the system is horrible, ) or it’s just the pain of people believing web applications work like applications, but whatever happened I deleted the post out of disgust. I am very tempted to write my own blog software again, but I have just increased my code workload considerably so we shall see.

Tim Bunce was saying in the Perl Myths talk that civilisations come and go, and languages are very like that, we still have FORTRAN in wide use in the scientific community, but on the whole languages come and go. Tim says that Larry is trying to draw out the lifespan of Perl 6, and from what I can see the way Larry knows best, by creating a language that can twist itself into weird positions that are more perverse than the karma sutra ( a great piece of bed time reading BTW. )

At the start of the address, Mr.Wall says when people ask him what he would change he says he has two answers …

Nothing

… and then he says …

Everything

Maybe the jeopardy question to the first answer is “what do you regret ?”

The second answer is most revealing, previous onion addresses I have read the transcripts from, I get the impression that Larry has come to dislike many of the things about Perl I dislike. What Perl 6 has that it doesn’t have in previous incarnations is maturity, Perl normally reads like the mad ramblings of a paranoid psychopath, Perl 6 has a spec and by all accounts, in it’s raw state, is a lot cleaner.

Perl 6 code looks a lot like a Yacc / Flex hybrid with this cleaner Perl syntax embedded in. Larry has obviously spent too many years using them all and thinking “why not ?”, however I don’t think he has managed to unify all these different aspects together as he had expected to in previous addresses, but maybe he has come to understand how these tools were designed in a way he hadn’t before. He has taken it in a new direction adding in sub-languages and polymorphism.

“Son, you use that regex prettier than a thirty dollar whore.”

I don’t know where that came from, but now I’ve typed it I don’t want to delete it.

Not just yet anyway, maybe it will take on some profound meaning later on.

The raw state of Perl 6 is … Perl 6, and apparently it is written in Perl 6, but these new features give you enough control to make the syntax you want easily and efficiently. This will mean, lots of local little languages, domain specific if you like, with Perl 6 being the stuff from which it’s made. In this scenario I think people will quite possibly stop discussing the pros and cons of Perl and instead go on about the pros and cons of what they are doing with Perl.

Like making the jump from newtonian physics to quantum physics, I think Perl hackers are going to find the leap to Perl 6 the hardest. Tim Bunce quoted Larry Wall as saying that Perl 6 saved Perl 5, because everyone who had opinions and objections to Perl 5 stopped complaining to the Perl 5 developers and went and complained to the Perl 6 developers instead, leaving the Perl 5 developers to get on with working on Perl 5. It was at this point I started to wonder if Perl 6 is not just a clever ruse, and that Perl 6 may never see the light of day, just to keep naysayers away from Perl 5.

Which brings us to the big question, “I want my MTV !” which does not seem to be the classic form of a question, but it makes a refreshing change from the chortles that occur when we ask where the fuck is Perl 6 and where can I get my greasy mitts on a release date ?

Christmas, or so the murmur from the corner was, which was paraphrased through the microphone onstage. Santa may be committing the branch, with the Easter Bunny riding shotgun and providing the 6.1 patch. I don’t know, but as I don’t think anyone actually heard what Larry said, he can deny everything, and we all know the rules …

Rule 2. Larry is allowed to change his mind about any matter at a later date, regardless of whether he previously invoked Rule 1.

.. and in this instance I believe we have a special case of rule one, what is rule one ?

Rule 1. Larry is always by definition right about how Perl should behave. This means he has final veto power on the core functionality.

… or in this case, Larry is always correct about the release date of Perl 6, he has final veto power and commit bits, and to be quite honest we have been waiting for Perl 6 almost as long as I have been exposed to Perl, so we can wait until our children have graduated from collage with Ruby and Python skills before we can truly claim he was yanking out chain with vapourware.

I think thats about it, if I remember anything else I’ll add it here, I still have … four Perl talks to type up from my notes, so I’m not done yet.

I am looking forward to Perl 6, it is a markedly different beast, but I don’t think I’ll be riding the Perl 5 camel with pleasure any time soon.

0xDEADB(R)EAD

Saturday, July 26th, 2008

There are few things I enjoy more than returning back to Hilo after being away, even for a short time. It’s easy to lose ones appreciation of it, when it is all you see all the time.

The word on the streets is that O’Keefe and Sons Bakery is shutting up shop on Thursday, the cost of shipping flour from the mainland has become too expensive to make ends meet. I have no real sympathy for Jim O’Keefe, but the bakery is the one thing he seemed to have done right and it will be a real shame to see it go, however it does open up the market for some entrepreneur to overcome the logistical problems. The combined food and oil crises will hopefully provide plenty of motivation and opportunity.

Not sure what we are to do for bread now, make our own I guess.

SRSLY ?

Saturday, July 26th, 2008

OH HAI !

While I wait for my plane, and as I haven’t got round to fleshing out my drafts from OSCON08 yet, I thought I’d share with you a little gem I picked up.

LOLCODE !!1!

First the obligatory, “Hello, World !” example


HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE

OK, so far so good (?!) now how about loops and conditionals …


HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
    UP VAR!!1
    VISIBLE VAR
    IZ VAR BIGGER THAN 10? KTHXBYE
IM OUTTA YR LOOP
KTHXBYE

OK, OK, how ’bout some IO ?


HAI
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
    AWSUM THX
        VISIBLE FILE
    O NOES
        INVISIBLE "ERROR!"
KTHXBYE

SRSLY ?

Yup, and like all serious languages it has even been implemented for Parrot. Give it ten, maybe fifteen years and all code will look this way.

RLY ?

Yup

KTHXBYE !

OSCON 2008 closing keynotes

Friday, July 25th, 2008

As no one else amongst my compatriots will be here to blog this I might as well.

First, there was nudity, lots of nudity, I have to say unfortunatly nothing you wanted to see, some things you cannot unsee if you know what I mean.

Following that diamond sponsors were placed in stocks and pelted with rotten fruit and vegetables left over from the week. It was quite horrible, and yet it was hard to turn away.

Oh the humanity.

Then there was the Open Voices talk featuring Jim Zemlin of The Linux Foundation, Keith Bergelt of Open Invention Network, Karen Sandler of the Software Freedom Law Center and Phil Robb from Hewlett Packard and FOSS bazaar. Basically there are a number of legal organisations here at OSCON, and no one really knows what they do, so this is a chance to tell us all about themselves. The Software Freedom Law Center for example provide advice to non profits about open source licensing. FOSS bazaar is “a community dedicated to improving the governance and adoption of free and open source software within enterprises, institutions, and government,” they dismiss FUD about open source and they leverage HP’s resources for open source software, which are now available as open source software, such as being able to scan code for licenses.

They attempted to start discussion with SFLC of the BusyBox case, that they cannot talk about for legal reasons, but they said what you don’t see is the many cases that don’t make it to court which is the majority of their work.

Companies are used to standard proprietary licensing, where a violation means a trip to court, and are not used to being approached by people saying “how can we help make you become compliant ?”

OIN is concerned about protecting, primarily linux, from intellectual property problems, especially patent infringements, but also companies trying to establish patents that cause problems for linux. I think.

Next up we have Paul Fenwick of Perl Training Australia, to discuss an Illustrated History of Failure, which I believe has already been given as a talk I’m sure.

Paul is a very good and humerous speaker, and his talk has been covered elsewhere.

So there was a quote about causing a failure so catastrophic you invalidate your worth as a human. After a quick calculation we come up with a figure for the average australian, which is $3.17 million USD, we are now to use this metric to gauge the cost of a failure.

Most failures seem to be based on assumption, denial, different units of measurement or poor conversion, el niño ;O) and self diagnosis and correction.

The solutions seem to be based on these cases, test your code, test your spec, test your code before you deploy it, think hard about race conditions, test for race conditions, and as you won’t find them by testing, think really hard about race conditions, and then deploy it in new zealand first.

Oh BTW Alasdair won a prize for his picture from OSCON last year, you’ve won some kind of fancy HP photo printer thing. Nicely.