Away for a week

by Zef Hemel

My grandparents are married 50 years so we’ll be spending the coming week on Terschelling (one of our country’s islands).

Moved to a VPS

by Zef Hemel

I’ve moved again! This time to my very own VPS (Virtual Private Server). A host offering VPSes has a server with a load of memory in which it runs multiple virtual machines, each VM has it’s own memory, CPU power, partitions and files. That means that from the user perspective it seems like you’re hiring a dedicated server. You get root access and can install any software you like. Of course, that’s very cool. I can now install mod_python, java, mono, CVS, Subversion and any other application I like. I just moved ZefHemel.com to the new server and my mail is hosted there too.

Drawback is that you have to install everything yourself, I started with a clean Debian install and had to get apache, ftp and the mail servers to work myself (which wasn’t easy). But I did it :)

I got 3gb of space (but remember I have to store all my system files there too), 128mb of RAM and unmetered traffic (upto 1tb/month I believe). It’s hosted at JVDS which I heard lots of positives stories about (at webhostingtalk.com).

We’ll see how it goes and let’s see what I’ll host here, unmetered traffic, that opens a lot of perspectives. :)

Articles

by Zef Hemel
  • Eclipse Tour
  • Regular Expressions: Automata theory applied
  • Things wrong with PHP (empty)
  • MSDN:

    The Microsoft Visual C++ Toolkit 2003 includes the core tools developers need to compile and link C++-based applications for Windows and the .NET Common Language Runtime:

    • Microsoft C/C++ Optimizing Compiler and Linker. These are the same compiler and linker that ship with Visual Studio .NET 2003 Professional!
    • C Runtime Library and the C++ Standard Library, including the Standard Template Library. These are the same static-link libraries included with Visual Studio.
    • Microsoft .NET Framework Common Language Runtime. Visual C++ can optionally build applications that target the Common Language Runtime (CLR).
    • Sample code. The toolkit includes four samples designed to showcase the powerful new features of the 2003 version, including new optimization capabilities, features to improve code-security and robustness, enhanced ISO C++ standards support, and the ability to use the .NET Framework library and target the CLR.

    For those still programming in C++, now you can get the best C++ compiler for Windows for free.
    Download it now.

    Generics in Java

    by Zef Hemel

    A tutorial (PDF)

    One of the things I liked in C# is its event-system. Although you need quite a lot of code to define an event. When I saw Python supports operator overload, I thought I’d try to implement such an event system in Python, and I did in 12 lines of code:

    class Event:
        def __init__(self):
            self.listeners = []
        def __call__(self, *params):
            for l in self.listeners:
                l(*params)
        def __add__(self, listener):
            self.listeners.append(listener)
            return self
        def __sub__(self, listener):
            self.listeners.remove(listener)
            return self

    This is how you can use it:

    class MyClass:
       def __init__(self):
          self.Clicked = Event()
       def click(self, button):
          self.Clicked(self, button)
    
    def onClick(sender, button):
       print 'Button clicked: %s' % button
    
    o = MyClass()
    o.Clicked += onClick # subscribe to event
    o.click('Right') # Trigger the event from outside

    Cool huh? :)

    Playing with Python

    by Zef Hemel

    A couple of days ago I got Python in a nutshell. I’ve been playing with Python a bit (trying to write a threaded server).

    What I like:

    • Everything is an object, even functions and classes
    • Object oriented in nature, the API is a huge set of modules containing functions and classes
    • Code feels natural. If I want to print all the numbers in a certain range I can simply do that using:
      for n in range(0,10):
         print n
    • Indenting has a purpose, in Python indenting is no longer a convention. The level of indentation determines what block you’re in, there’s no need for braces. For example, this will work:
      for i in range(10):
         for j in range(10):
            print i, j

      And this won’t:

      for i in range(10):
      for j in range(10):
      print i, j
    • Extensive API, you have an amazingly large API to your disposal when using Python. There are full frameworks for easily building a threaded server and even an API that makes it very easy to make a console text-input oriented application (cmd).

    What I don’t like:

    • Naming is inconsistency, always important to me. Some module names are all lowercase, some use CamelCasing. Same goes for classes and functions. Is it o.set_property(), o.SetProperty() or o.setProperty()? It differs from class to class
    • No layered IO, in Java when you want to introduce a new kind of IO class all you have implement is a read() and write() method which read and write a byte. Over those you lay an abstraction layer which can also write lines and read lines (using the read() and write() methods you supplied). No such concept is available in Python. There are ‘file-like’ objects for most streams (files, sockets) but if you want to add your own IO source, you have to code all of the file-like methods yourself.
    • Dynamically, weakly typed. You have to run the program to see if it runs without method not found errors, unknown variable errors and the such. When I compile my code with a Java/C# compiler I know no such errors exist. Another drawback of dynamically and weak typing is that IDE’s can’t supply code completion all the time, some IDE’s can do that is some cases, but never always. This decreases your productivity enormously.
    Next Page »