May 16th, 2008

Database land - postgres scales nicely.2

There are plenty of choices, but as a rule I advise Postgresql. It supports a lot of fancy SQL, it has all the transactional goods you need to make sure the app keeps working even after deployment (yes, I mean you, PHP kids!) and it’s really, no strings, free.

I’m also aware, largely by way of the experience of my roommate with it, that oracle is a giant steaming turd that exists today only because ‘no one got fired for using oracle’.

One thing I have been wondering, though, is how well postgres scales for the really huge projects. Turns out postgres scales nicely in a real-world scenario. Though I wonder if those hacks they speak of have been contributed back.

So, just FYI, if you need a quick database solution, give postgres a try. There’s a particularly convenient mac os x installer for postgresql here thrown together by a company that uses it a lot. Even gives you some (admittedly crude) GUI tools to toy with the DB. So far I’m a happy camper using it.

FOLLOWUP: Benchmark: Postgresql beats the stuffing out of mysql, speedwise - that really nails it.

FOLLOWUP #2: Postgres wins, big, again - If you have a database independent implementation, try it yourself. Switch to postgres (or if you’re already there, mysql) and do a comparison to the raw number that is most important to your app (e.g. for webapps, page load times).

Het immigratieprobleem van Nederland1

A dutch post about internal politics. I’ll return to the normally scheduled visionary revelations on programming in the next one!

More after the jump.

Hier een artikel van Management Pro over de (gesuggereerde) negatieve smaak in ’s werelds hoogopgeleide vluchtelingen.

Dit is een heel zwaar probleem. Nederland heeft relatief weinig resources en is toch een zeer hoog luxe niveau gewend, en dus moet er quantitatief veel and qualitatief hoge kennis ‘gexporteerd’ worden. Een stapel hoogopgeleide allochtonen met entrepreneur trekjes helpt daar heel goed bij, en ik zie ze graag.

Toch stem ik VVD. Ik stem zelfs Rita Verdonk. Want: Dit is geen simpel probleem.

Het management pro artikel maakt een aantal assumpties die ik in twijfel trek:

Ten eerste: de HUIDIGE politiek is niet verantwoordelijk voor dit probleem. Voor dezelfde redenen dat miljoenen nederlanders nog steeds stelselmatig te hard rijden ondanks dat ze boetes krijgen aan de lopende band, kun je niet zomaar even een wet aanmaken met ‘alle buitenlanders zijn lief en dienen fijn geaccepteerd te worden!’ - dat heb je gewoon niet in de hand. Een nederlander (onafhankelijk van cultuur achtergrond) kijkt graag naar iemand’s abilities en potentieel, of ze kijken graag naar iemands huidskleur. Daar gaat een wet helemaal niets aan veranderen.

Het is dan ook mijn opinie dat een eventuele teneergang van nederland als plaats om neer te strijken als vluchteling-met-pit niet zoveel te maken heeft met het immigratie beleid van nu. Het zal veel meer te maken hebben met verhalen dat de gemiddelde nederlander je zo de straat uitkijkt.

DAT probleem oplossen is andere koek, en grapjes als het vrijstellen van de 26,000 gezichten lui maakt dat alleen maar erger. Ik wil hier niet mee zeggen dat je dus vooral groffer moet optreden omdat er wat mutsen in nederland rondwandelen met KKK-aspiraties; ik wil alleen maar stellen dat een land waar X% lichtelijk discrimineert een land is waar een gewilde vluchteling echt niet heen gaat, boeien wetgeving.

Volgend probleem: Volgens het artikel:

Vluchtelingen krijgen tegenwoordig namelijk onvoldoende kans om aan werk te komen, want werkgevers zijn - niet door de minste politici - bang gemaakt voor allochtonen en hun problemen.

Daar heeft de politiek toch geen ene snars mee te maken? Zit de politiek reclamefilmpjes uit te zenden met: Pas op jongens, want die marokaan daar op de hoek, die weet waar je huis woont, jongen! Wegwezen!? Tuurlijk niet. Je kan hoog of laag gaan staan, maar de statistiek liegt er niet om, en het is zeer zeer lastig om de mens’ natuurlijk drang om patronen te zien tegengaan.

Er is een soortement van ‘economische sweetspot’ voor een gegeven immigrant: Een bepaalde hoeveelheid productiviteit. Daarop of daarboven wil je hem of haar graag het land in hebben. Echter, een immigrant die voor wat voor reden dan ook aan het jatten slaat of gezellig van een uitkerinkje gaat genieten terwijl hij een hele uitgebreide familie overhaalt, is funest voor het hele systeem. Niet zozeer voor de duidelijke reden, maar vooral ook omdat het een wrange nasmaak achterlaat bij diegenen die het zien gebeuren. De hardwerkende middenstander die de helft van het zuurverdiende geld waar ze 12 uur per dag voor hebben gezwoegd met de noorderzon ziet vertrekken en vervolgens een uurtje gaan vloeken jegens het hoofd van een Bos of een Marijnissen die insinueert dat ze kil en harteloos zijn. Het gaat er niet zo zeer om dat algehele overheidsverspilling bij verre de grootste factor is en niet zozeer uitkeringen voor asielzoekers. De mens is de mens, en ik zou het graag veranderen, maar zo is het nou eenmaal.

Maar ja, waar zit die oplossing nou? Je kan moeilijk alle allochtonen maar buiten het land houden omdat teveel nederlanders racistische trekjes beginnen te vormen, dat is het karretje voor het paard spannen, slaat nergens op.

Rock and a hard place dus, en dat is het grote probleem. Veel van de kleine groep die het verzieken zijn al nederlander dus al die reactionaire regelingetjes treffen niet die lui die je zou willen. Het idee van een sociaal contract (Ja, we geven je onderdak, maar als je je niet gedraagt dan vlieg je er uit, onder het motto: Als het alternatief neergeknalt worden is in het land waar je vandaan komt ga je echt niet een winkel bejatten), even buiten of dat nou gaat werken en/of humaan is, lost niet zo heel veel op, zelfs als je het voordeel van de twijfel geeft aan zoiets - veel probleemgevallen hebben al de status van nederlander verworven. De kop-in-het-zand mentaliteit van kabinetten van vroeger hebben ons dit probleem meegegeven. Geschiedenis kun je niet veranderen.

Nog geen reden om dan maar het handdoekje in de ring te gooien en nu dus maar de grenzen wijd open te gooien.

Het lijkt me bijvoorbeeld een goed idee om een dubbele regeling in te voeren: Je bent vluchteling, of gast. Als een bedrijf je vraagt hier te komen, is het van de pot af gepleurt dat je perse nederlands moet leren. Maar in diezelfde trend is het ook dubieus dat je hier op de knieen komt voor onderdak, je dat dan krijgt, en je vervolgens als een hork gedraagt. De financiele schade valt nog mee te leven, maar die go-getter van next-door is er wel de dupe van op straat, en dat is niet eerlijk.

Het verhaal van Navid Otaredian op Management Pro is aandoenlijk en ik leef met hem mee. Het is dus ook jammer om te zien dat zijn (blijkelijk nogal linkse inslag) om aan dit probleem te werken compleet niet samenvalt met de partijen waarvan ik verwacht dat ze het beter kunnen doen.

De oplossing? Ik weet het gewoonweg niet. Echt niet. Dit is een Probleem met een hoofdletter P en ik zie geen enkele politieke partij die echt met een overweldigend goed idee komt. Ik kan alleen zeggen dat de bleeding heart approach ook slachtoffers maakt, ze zijn alleen wat minder direct gekoppeld. Desalniettemin is Mr. Otaredian mooi de lul en dat is niet fair voor hem, en niet fair voor nederland.

Ik wil wel een ideetje opperen: Welke idioot ooit dacht dat het een goed plan was om wijken op te stellen waar mensen van hoofdzakelijk dezelfde cultuur heen worden gesluist, schande! Laten we in ieder geval dat niet meer doen. Een ding dat ik me kan voorstellen is het nog verder verbeteren (het bestaat nu al, voornamelijk voor hoger opgeleiden) van hulp bij het vinden van een huis voor alle immigranten, en zoveel mogelijk vermijden dat je “X-buurten” krijgt (vul cultuur-scheldwoord-du-jour in voor X). Helaas is de extremistischer wordende houding juist een reden om dan maar veel op te trekken met cultuurgenoten. Dat is jammer, want ‘melting pot’ werkt alleen als er ook echt gemixt wordt.

Nog een laatste gedachtenspinsel voor die lui die me raar aankijken over mijn stem (je weet wie je bent!): Ik vind het bijzonder beledigend dat ik aan word gevallen als harteloos en racistisch, alleen maar omdat ik denk dat de oppervlakkige plannen van de linkse politiek volgens mij niet gaan werken. 1.2 miljoen nederlanders (wilders + verdonk) meteen afdoen als racistische idioten is knap lullig jegens de miljoenen mensen die de dupe zijn van de echte klootzakken (puntmutsen en hakenkruizen), en het lost helemaal niks op - terwijl we juist oplossingen nodig hebben.

Brilliant ad!1

This ad really makes a statement. I rather dislike making droll comparisons to nazis, but at least its creative. For some reason it appears to be allowed, too.

Nifty - java BYREF passing.4

I have to give Roel credit for this one, he built something like this @ his workplace at some point, but it’s still nifty. Also, it crashes about half the javac compilers out there, but at least on my local version of eclipse this runs fine and produces the expected output (10, 11, 12, 13):

public final class Reference<T> {
	public T ref;

	private Reference(T initialVal) {
		ref = initialVal;
	}

	public static <T> Reference<T> reference(T initialVal) {
		return new Reference(initialVal);
	}

	public static void main(String[] args) {
		Reference r = create(10);
		System.out.println(r.ref);
		r.ref++; //A
		System.out.println(r.ref);
		r.ref += 1; //B
		System.out.println(r.ref);
		r.ref = r.ref + 1; //C
		System.out.println(r.ref);
	}
}

The crazy stunts you can pull with generics. Depending on your compiler, either this works, or line ‘A’ causes javac to crash completely, B produces a compile error, and C compiles on all versions.

This device is actually useful because it can replace, completely, every instance where ordinarily you’d use the ‘array of size 1′ hack. This occurs in two unrelated situations:

Pass-by-reference

Let’s say I have an int variable in a method. Call it ‘foobar’. I want to call some method, and pass it not the VALUE of this int, but the object, so that the method I call can change it. OO code style cries everytime you try this, but let’s say you -really- want to. You can’t use ‘int’, obviously, because primitives always pass by value. You can try ‘Integer’ instead, but those are immutable - still can’t be changed. The usual solution is to use a new int[1].

From now on you can use a Reference<Integer>:

Reference<Integer> r = reference(25);
call(r);
System.out.println(r.ref); //prints 30.

public void call(Reference<Integer> r) {
    r.ref = 30;
}

Modifying parent scope variables from inside an inner class

The following snippet won’t compile, because any variables accessed inside an on-the-fly written class must be ‘final’:

int x = 10;
new Runnable() { public void run() { x = 12;}}

The array-of-size-1 trick works here again, but Reference looks better:

final Reference<Integer> x = reference(10);
new Runnable() { public void run() { x.ref = 12;}}

(Note, with CICE, ‘the final’ would be inferred due to x being used in an inner class).

Some even crazier stuff with this thing after the jump, and a puzzler!

(more…)

Offices? Are you kidding me?2

Spent 2 hours yesterday team-editing a document using google docs with Jeroen, whilst voicechatting by way of skype.

I have no idea why anyone would need an office given these two fantastic tools. Whilst the ‘word’ variant of google docs is a bit sparse on the formatting, editing the text there and taking care of the layout later is all sorts of shiny. Collaboration. Simple. Free.

Apple’s still on the ball…0

3 of the top 10 gadgets are apple products. List composed by a (so he says, I guess it might take a grain of salt) non-apple fanboy. While the superiority of MacBook(pros) vs. PC notebooks is obvious to me, I still don’t entirely get how the hell Apple’s continuing to pull off the iPod business. The shuffles - yes. The bigger ones just got me stumped. Are they -THAT- pretty?

I mean, a friend of mine even bought a 5G iPod together with his MacBook. I don’t get it.

Quick Programming Puzzle3

Using whatever language you like, try this problem.

Including reading the assignment, this took me less than 20 minutes, hence the ‘quick’ in the title of this post :-P .

It’s written in java, generic to a certain extent, and takes (on my macbook CoreDuo 1.8Ghz with a load of apps open) 2.7 milliseconds to reach an answer (calculated by running 10,000 times and taking an average). Not the best of metrics but should be enough to impress that this test is really far too small to make a reasonable timing measurement.

No cheating by peeking at the comments!

IDEs: order-of-magnitude improvement?2

It’s a common claim that the ‘invention’ of programming languages (versus assemblers) amounted to an ‘order of magnitude’ shift in the ease of programming. Most people I talk to agree to this.

From here it gets fishier. Joel claims there are 5 silver bullets and that’s it - and more recently insinuates there are none, except for the invention of programming languages here

I feel for that camp, because the essence of the message: That programming is intractably difficult, is (to me) absolutely true.

There are a number of features which have been claimed to be ’silver bullets’ - in the sense that they provide an order-of-magnitude improvement. And for every claim, there are a lot of detractors.

For example, I’ve asserted that IDEs are a silver bullet before, on a forum that’s known for rabid python and LISP fan-boy-dom due to the history of the site. Whoops.

More interesting, to me, is that ones favourite style of programming more or less dictates what one considers magic bullet versus no magic bullet.

Personally, I think this is all a bunch of bull. So much depends on so many factors that calling any one thing ’silver bullet’y and something else ‘not important’ is fallacious for a very large group of programmers and situations. There is only ‘a good idea’, and ‘general improvement’.

And, of course, programming is intractably difficult. A definition if ’silver bullet’ which means: Solves ALL your problems, is a pipe dream. Most specific problems can be solved, but at some point you bump up against the problem that programming is actually hard.

Relevant links:

IDEs are nice, though (thanks for that link Axel, by the way).

Reg Braithwaite nails this whole silver bullet thing as a storm in a teacup. Good read. He really does the meta-topic of why programming is intractably difficult far more justice than I can.

dansplaat!2

Another article about dutch politics. More (in dutch) after the jump.

If you care about dutch politics but don’t know the language, a number of links to english analyses of the situation follow at the end of the article.

(more…)

Innovative…0

I’m so happy I live in an innovative country!!

Imhotep theme designed by Chris Lin. Proudly powered by Wordpress.
XHTML | CSS | RSS | Comments RSS