Monday, September 29, 2008

comparing class syntax in C++, Java, PHP, Perl and Python

As I recently started learning Python one of the things I noticed which I didn't like is the class syntax. So I wrote some minimal hello world programs in the languages I recently used to show the difference:

C++ hello.cc

#include <iostream>

class Hello {

private: char *value;

public: Hello(char *newvalue) {
value = newvalue;
}

public: void hello() {
std::cout << this->value;
}
};

int main() {
Hello hello("hello\n");
hello.hello();
}
I like the C++ syntax, it is the language which introduced me to OOP and it it clearly states what bits are what without too wordy syntax.

Java: hello.java

class Hello {
private String value;

public Hello (String newvalue) {
this.value = newvalue;
}

public void hello(){
System.out.println(this.value);
}
}

class main {
public static void main(String args[]){
Hello hello = new Hello ("hello");
hello.hello ();
}
}
Also very nice, a bit clearer than C++.

PHP: hello.php

<?php

class Hello {
private $value;

function __construct($newvalue) {
$this->value = $newvalue;
}

function hello() {
echo $this->value;
}
}

$hello = new Hello("hello\n");
$hello->hello();
From the dynamic languages this one is the clearest. Except of the __construct() constructor, where I prefer the ClassName() syntax (which still works in PHP5)

Perl: hello.pl

package Hello;

sub new {
my ($class,$newvalue) = @_;
bless { newvalue => $newvalue }, $class;
}

sub hello {
my $this = shift;
print $this->{newvalue};
}

package main;

$main::hello = new Hello("hello\n");
$main::hello->hello();
I always hated objects (and functions) in Perl, there is no parameter syntax for functions or methods. Most of it is not enforced and you can use functions in objects in thousands different ways.

Python: hello.py

class Hello:
_value = ""

def __init__(self,newvalue):
self._value = newvalue

def hello(self):
print self._value;


hello = Hello("hello")
hello.hello()
A lot clearer than Perl, but also a lot of convention instead of forced syntax. I got used to the indention by now. But I hate that I have to specify "self" as the first parameters, the __init__ syntax and the underscore prefixing of private or protected variables. At least it has proper function parameters.

Saturday, September 27, 2008

phpconference.es

I just returned from the Barcelona phpconference.es . It was a small on day conference, with just a few talks and not many big names. It was also really cheap at 20€. The organization was very good, especially for Spain. It was held at citilab in Cornell√† Centre, which is at the very end of one of the metro lines. There were two rooms with parallel talks. The talks were all in english, which was a change from the last PHP conference. Wifi was available everywhere and there were free drinks and food.

In the morning I got hassled a bit by companies looking for developers, though nothing which convinced me to quit my job yet. I am glad that there are companies like this available in Barcelona though, as they seem to be interested in improving the communitiy through supporting events like this instead of seeing PHP or open source just as the “free beer” option.

I enjoyed the talk about PEAR and the one about xdebug. But none of the talks was really advanced and each one was more or less just an introduction to the topic.

One thing I noticed was the number of netbooks in use by the attendees. I would say the distribution was 30% netbooks, 40% mac and 30% for the rest. I just bought a Asus Eee PC, which is my first portable computer – but more about this another time.

Overall I must say that I am probably not a conference person. I enjoy the talks, but I am not so much av crowd person and probably could get the same information spending a day in front of firefox and youtube. But I will give it a another try next time.

Tuesday, September 23, 2008

My music podcast selection

This are the music podcasts I am listening too at the moment. It is mostly techno, but also house and some dub. And whatever last.fm thinks I would enjoy.


dailysessionhttp://dailysession.com/?feed=podcast
DE:BUG POD - a netaudio podcasthttp://www.de-bug.de/pod/wp-rss2.php
electro house & house & techno mixhttp://djbene.podspot.de/rss
Galaktika Records Podcast: Minimal, Electro and House hottests tunes!http://www.galaktikarecords.com/podcast.xml
Ibiza Voice Music Boxhttp://www.ibiza-voice.com/music/rss_podcast.php
Last.fm free recommended downloads for cdamian'shttp://ws.audioscrobbler.com/2.0/user/cdamian/podcast.xml
Minimal(maximal) Techno DJ mixes by Louis de Bourbonhttp://www.graphicjuice.co.uk/podcast/podcast.xml
MinimalNethttp://www.minimalnet.org/feed
Minus Podcast:http://m-nus.com/podcast.xml
NetAudio Russiahttp://www.netaudio.ru/feed
Resident Advisor podcasthttp://www.residentadvisor.net/xml/podcast.xml
Starfrosch - Free MP3 Download - Acidhttp://starfrosch.ch/download_music/acid/feed
Starfrosch - Free MP3 Download - Breakshttp://starfrosch.ch/download_music/breaks/feed
Starfrosch - Free MP3 Download - DJ-Mixhttp://starfrosch.ch/download_music/dj_mix/feed
Starfrosch - Free MP3 Download - Drum and Basshttp://starfrosch.chdownload_music/drum_and_bass/feed
Starfrosch - Free MP3 Download - Dubhttp://starfrosch.ch/download_music/dub/feed
Starfrosch - Free MP3 Download - Electronichttp://starfrosch.ch/download_music/electronic/feed
Starfrosch - Free MP3 Download - Househttp://starfrosch.ch/download_music/house/feed
Starfrosch - Free MP3 Download - Minimalhttp://starfrosch.ch/download_music/minimal/feed
Starfrosch - Free MP3 Download - Technohttp://starfrosch.ch/download_music/techno/feed
the fabric podcasthttp://feeds.fabriclondon.com/fabricpodcast


I would upload the OPML file, but blogger.com doesn't allow attachments.

Monday, September 22, 2008

Staying with Linux

Recently I was affected by the Steve Job Reality Distortion Field. After watching the demonstration of the iPhone developer kit and the iPhone in general I wanted one too.

I thought I get myself a nice Apple Power Book or maybe an Air plus the iPhone and start developing. As it is also very much UNIX based I could still go to the command line if I want too and most of the tools I use every day are available on Max OS X and work very well.

My girlfriend has been using her PowerBook Titanium since 2002 and it still works well. She now also got the iPhone, which is the best phone you can buy at the moment. For someone who just wants to use computers, these are perfect.

But after seeing the problems software developers have with the AppStore and the sharing of information about iPhone development, I decided that this whole closed source thing is not for me.

I have been using Linux since my Amiga days and Red Hat Linux since 3.0.3 and I just can't imagening using software which doesn't have the source code available for me to learn and thinker with. Most people now will say that you probably are not going to this, but it is not true for me. I fixed, patched and changed Apache, Rhythmbox, PHP and Perl. I build my own RPMs for the changed versions to keep my system clean and I want to have this option in the future.

But it is not only the source. It is also the community and things like open bugtrackers. If I report a bug with some Apple or Microsoft product there is no way of knowing if this was reported before or if someone has a fix already. This just happened to me again with a USB mouse problem on Fedora, I just hat a look at bugzilla and there was already a solution which I was able to apply before the fix goes into the updates.

I still need to upgrade my computer though. My Athon XP 2400 (IIRC) just doesn't do the trick anymore. I also want to switch to an ATI graphics card to use open source drivers. So I decided to spend 1000€ on an upgrade to the machine, which probably consists of:
  • 24" TFT monitor
  • some AMD four core CPU which doesn't use too much power
  • a passive cooled ATI card
  • 4GB of memory
  • ASUS motherboard
  • two 1T hard disks for RAID1
all running the Fedora of course.

I might also get an OpenMoko phone at some point, but I am not really a phone user so it would be just a toy.

The only close source products will be my iPod Classic and iPod shuffle. But they are well supported now in gtkpod and Rhythmbox.

Sunday, September 21, 2008

M_NUS @ BAM

Went to see Magda, Gaiser and Richie Hawtin at the Red Bull Music Academy M_NUS @ BAM.

It started at midnight, which is a more civilised time than the usual 3:00 we get here in Barcelona.

Magda was very good, Gaiser was ok and Hawtin had his good moments. I think Hawtin now has the same problem as Sven Vaeth, he is just too popular and his productions and studio mix sessions are way better than his live sets. It is a pity, because I remember a lot of good parties with him a few years ago.

The visuals were also especially good, I have to find out who created them. Also very minimal, abstract and like a good screensaver. It wasn't a projection, but a enormous LED display wall with one part below the DJ desk.

Very good times, can we have more of this please? 



  

Saturday, September 13, 2008

moving wikicalendar

I haven't updated it for ages. To prepare for some small changes I moved it to google code.  This also gives me subversion, which takes another bit of work of me.

The sandbox on krass.com will still serve as a testing area.