Stoppt die Vorratsdatenspeicherung! Jetzt klicken &handeln! Willst du auch an der Aktion teilnehmen? Hier findest du alle relevanten Infos
  und Materialien:

Skip to content


Screencast: Debugging with Emacs & GDB

Hey there.
I wish I’d be posting more recently, but haven’t really had the time to do so.
I just wanted to share with you a small screencast I created today on debugging with emacs and gdb, since I think it might be of interest to someone else as well.

You can check out the video at my blip.tv channel: http://bakkdoor.blip.tv/
Currently the video is being converted to flash video (.flv), so you might want to check out the .ogv video file here, if it’s not done yet: http://blip.tv/file/2804484

[Update:]
Video is available now. You can also watch it here:

Anyhow, I hope you like it and I’d like to hear some feedback.

Btw, the programm I’m debugging in the video is stupidvm, a small & stupid virtual machine I’ve started working on 2 weeks ago, written in C.
You can check out the code either on gitorious or github.

Feedback is, as always, welcome :)
I hope you like it.

Posted in General. Tagged with , , , , , , , , , , , .

Small update & Introduction of ‘Stackd’

Oh wow. 3 months have passed – how time flys by!

So, what have I been up to in the past quarter year (doesn’t it sound like a lot more like this?!) ?

First of all, I did some stuff for university, as the summer semerster came to an end. I will upload a homework I wrote in computer science shortly. The topic is “software architectures” – it’s in german of course, but I suppose that some day some one speaking german might find this interesting – isn’t this what the internet is for? ;)

Also, I’ve had a visit from my grand parents from California over in July. And then, I’ve been working at Intevation GmbH as an intern for the last month. Intevation is a very nice company to work at. All employees are very friendly and what I think is great as well, is that they only do free software (as in free speach).
Since I’m a big fan of free software and its movement, I applied for an internship earlier this year and, well, they’ve accepted my application :)

So currently, I’ve been working on some packaging related stuff for Ubuntu and Debian. I’ll probably talk more about that in another upcoming post soon.

Alright, let’s get to the next topic I wanted to adress here:
I’ve started to work on a(nother) interpreter for a stack-based programming language I’ve called “Stackd”. It’s basically a poor & small reimplementation of the Factor programming language, but still missing many features of course.
If you’re interested in how it works and what it’s all about to programm in a concatinative programming language, as stack-based languages are often called, take a look here: http://concatenative.org. There you’ll find plenty of information, most of which will also apply for Stackd.

You can follow the current development progress at my git repositories here:

I’ve started to use Gitorious next to GitHub because I like the fact that it’s free software and I want to support it in a way. Besides, it’s well thought out and I guess more people should take a look at it instead of just choosing GitHub without checking out what else is left. Of course, GitHub does have some nice features, which Gitorious is still missing – but that might change in the future.

I’ll probably make another post soon explaining a little more my new language. If there are any questions, feel free to contact me either on GitHub, Gitorious or via email (see ‘About me’ page).

Posted in General.

Blocktalk Rubygem

Blocktalk can now be easily installed via Rubygems:

gem sources -a http://gems.github.com (if not done yet)
sudo gem install bakkdoor-blocktalk

You can then simply run blocktalk from the shell via

blocktalk sourcefile.bt

To look at some debug information (e.g. the AST, the generated ruby code etc.) type:

blocktalk sourcefile.bt –debug
or
blocktalk sourcefile.bt –ruby (to only show the generated ruby code)

Feel free to play around with it, check out the examples in the examples folder, if you want to get a start.
Would love to hear some feedback from anyone who’s interested, since this is my first attempt to language design :)

Posted in General. Tagged with , , , , , , , .

Blocktalk version 0.1 released

I just released version 0.1 of Blocktalk at Github.
I’ve added quite some features in the past few days and got all of my main problems fixed and the most important features working.
One thing that was on that list until today was chained method calls.
Up to this point, the only way to chain method calls was to surround each method call with parentheses, like this:

?Download parens.bt
str = ("Hello, world!" upcase) gsub: "," with: ":"

Now you can do something like this:

?Download no-parens.bt
str = "Hello, world!" upcase gsub: "," with: ":"

Which is equivalent to this ruby code:

?Download no-parens.rb
str = "Hello, world!".upcase.gsub(",", ":")

Much nicer, if you ask me. Of course you can chain as many methods as you want, even with each method taking a codeblock, if you want to (as it is possible in ruby as well).
So now that I’ve got the most important things done, I’ll try to focus a little more on refactoring, working on the standard library (adding more classes & methods) and thinking about some more unique, new features for the language :)

Posted in General. Tagged with , , , , , , , , .

Blocktalk code available @ Github

I just released the code for my Blocktalk interpreter at Github.
Feel free to clone my repository, create patches or file in some bugs, if you dare to ;)

Posted in General. Tagged with , , , , , , , , .

Blocktalk: A simple portscanner

Here’s a little blocktalk script, that shows the latest working feature I’ve added to my Blocktalk interpreter: Exception handling :)

Basically, it’s just a simple portscanner.

?Download portscan.bt
System require: "socket"
 
host = "localhost"
 
(ARGV at: 0) if {
  host = (ARGV at: 0)
}
 
open_ports = []
 
1 upto: 1024 do |port|
  Thread new {
    try{
      t = TCPSocket new: host port: port
      open_ports << port
 
      s = Socket getnameinfo: ["AF_INET", port, host]
      Console puts: ("\nPort #{port} (#{s[1]})" + " is open.")
 
      catch{
        Console print: "."
      }
 
      ensure{
        t if { t close }
      }
    }
  }
end
 
Console puts
Console puts: "Open ports on #{host} are:"
Console puts: (open_ports join: ", ")

So yeah, this is actually working. Now I’ve basically have most of the language features done that I had in mind first. Next to come are probably some performance optimizations as well as some more unique features, I still have to come up with. We’ll see :)

Update:
I’ve added Threading to the code, this speeds up the process a little ;)

Posted in General. Tagged with , , , , , , , , .

Blocktalk: Dealing with classes & modules

Alright. I’ve renamed my language again: Blocktalk is what I’ve settled on (finally I hope).
I think it resembles a little more the Smalltalk heritage, although most implementation related concepts come from Ruby though. Oh well, I like the name better, so that’s why i chose to name it that way.

Current progress:
Class & module definitions work correctly now, meaning that it now fully supports nearly all concepts that you find in Ruby. The main difference is, that in contrast to Ruby, Blocktalk does not have any real Keywords predefined, except for just a few including:

  • def (for indicating method definitions)
  • do & end (for codeblocks)
  • self (the same as in Ruby & Smalltalk: reference to the current object)
  • return (explicitly returning from withing the middle of a method)
  • yield (same as in ruby: yielding to a given implicit block)
  • Some literal syntax (not real Keywords, but somehow belongs into this category) for Arrays, Hashes, Codeblocks, Integers, Floats, Strings, Symbols, Characters and of course Assignment

That’s pretty much it, regarding predefined keywords in the language itself. Everything else relies on expressions like message passing (a.k.a. method calling) to objects, assignments and arithmetic. Even defining new modules or classes is done by sending a message to the Class or Module class-object (very similar to how it’s done in Smalltalk and how you can also do it in Ruby).

Here’s a small example of defining a class and a module:

Module >> :ModuleA do
  def method_a = do
    Console puts: "in ModuleA#method_a!"
  end
end
 
 
Module >> :ModuleB do
  def method_b = do
    Console puts: "in ModuleB#method_b!"
  end
end
 
Class >> :Place do
  def 1/>self from_city = do |city_name|
    # should do something useful here ...
    Place new
  end
 
  def coordinates = do
    # do some calculation here...
    return (Kernel rand)
  end
end
 
Class >> :Person do
  1/>self mixin: [ModuleA, ModuleB]
 
  # constructor with named params
  def initialize = do |name age: age city: city|
    @name = name
    @age = age
    @city = city
  end
 
  def go_to = do |place with: vehicle|
    ((place is_a?: Place) and: ((1/>self distance_to: place) < 10.5)) if_true {
      vehicle take: 1/>self to: place
    }
  end
 
  def place = do
    Place from_city: @city
  end
 
  def distance_to = do |place|
    (place is_a?: Place) if_true: {
      dist = ((1/>self place) coordinates) - (place coordinates)
      dist abs
    } if_false: {
      0.0
    }
  end
end
 
chris = Person new: "Christopher Bertels" age: 22 city: "Osnabrück"
city = Place from_city: "Berlin"
 
Console puts: "Distance from chris to city:"
Console puts: (chris distance_to: city)
 
# Person mixed in ModuleA & ModuleB:
chris method_a
chris method_b

I’m still tweaking a little here and there, but I think most of the standard language features are working now. Now I’ll try to come up with some more unique things. I do have a few ideas already, but I still need to see, if they really work out nice. Let’s see ;)

Posted in General. Tagged with , , , , , , , .

Blockd: Mixing Ruby & Smalltalk

My new simple language, blockd, that I’ve mentioned in my last blog post is progressing quite nicely.
Since my last post a few days ago, I’ve worked on it quite a bit and I’ve got a first simple interpreter for it working.

For now, the interpreter is able to understand & execute methodcalls on objects, anonymous methods (blocks & procs in ruby) and some other minor stuff.

Heres a small example, that actually works now:

y = { |x|
  Console puts: x
  Console puts: (x * x)
}
y call: 10
 
m = { |x y|
  Console puts: ((x upcase) * y)
}
m call: "cool " y: 10
 
square = { |y|
  y * y
}
cubic = {|x| (x * x) * x}
 
3 times do |i|
  Console puts: i
end
 
foo = {
  3 times { |i| Console puts: (square call: i) }
}
 
Console puts: "--"
 
foo call
 
10 times &foo

This basically is equivalent to the following ruby code:

y = Proc.new{|x| Console.puts(x);Console.puts(x.*(x))}
y.call(10)
 
m = Proc.new{|x,y| Console.puts(x.upcase().*(y))}
m.call("cool ", 10)
 
square = Proc.new{|y| y.*(y)}
cubic = Proc.new{|x| x.*(x).*(x)}
 
3.times(&Proc.new{|i| Console.puts(i)})
 
foo = Proc.new{3.times(&Proc.new{|i| Console.puts(square.call(i))})}
 
Console.puts("--")
 
foo.call()
 
10.times(&foo)

Now, to make this clear: The ruby code above is what the current interpreter actually executes. The way I’ve implemented it for now (and for simplicity only – just to get something working first) is, that it simply parses the blockd code and translates it into equivalent ruby code, which then gets executed via eval in ruby.
Now I know, this isn’t the best way to do it, for several reasons:
Normally, an interpreter executes the code it gets fed directly, expression for expression, as this is also the case for ruby. If you have an syntax error within the code that is evaluated, the interpreter usually notices this only at the moment it reaches that part of the code and tries to evaluate it. This isn’t the case for the current interpreter I wrote here. The reason I chose to do it this way, was that I wanted to get something working as possible. I do want to change it though later on, so that each expression gets executed on the fly, once it is parsed.

So for now, i evaluate the parsetree, and each expression node gets turned into a string of equivalent ruby code, that then gets saved in a global list (within a class called Evaluator). When the parser has done it’s job and all the values (strings of ruby code) of all expression nodes have been accumulated, i simply run ruby’s eval on it and at that point do the actual evaluation (and possibly get semantic errors here – like missing variables etc.).

I still need to implement some stuff regarding classes & modules, but I’m quite happy for now, since it wasn’t so hard as I had expected before. Once I have everything working, I’ll start to actually rewrite the parser in a way, that it evaluates & executes code on the fly, expression per expression and not all of them at once at the end. This should also improve performance, which is obviously another downside of my current approach, since I have to wait for all expressions being parsed & evaluated to appropriate ruby code first, before even beginning the actual evaluation process…

For anyone, who is interested, here is a simple benchmark of the code above:

The blockd version (executed with my current interpreter):

real 0m0.264s
user 0m0.184s
sys 0m0.072s

The ruby version of the equivalent code (generated by my parser):

real 0m0.021s
user 0m0.008s
sys 0m0.008s

As you can see, there’s quite a performance overhead. Although not really noticeable by a viewer, the numbers tell the story. So I expect quite an improvement in performance, once I’ll start rewriting the interpreter in the way I’ve mentioned above. Still cool though, if you ask me :)

Posted in General. Tagged with , , , , , , , , .

Parser generation with Ruby

I’ve started to play a little with Treetop, a parser generator library for Ruby.
Why? you might ask. While I’ve been dreaming of my own programming languages and designing them for quite some time now, I never really managed to actually get beyond the design-phase. I’ve come up with several language designs in the past, each time getting closer to something that I think really could work (which doesn’t mean, that it actually could be useful or ‘good’ – if that even makes sense).
While I’ve been looking at many different languages in the past, I’ve found the dynamic, object-oriented and functional high-level languages to be most interesting & fun to work with. Naturally, after working with Ruby alot, I’ve started looking a little bit at Smalltalk and how it differs to Ruby.

Inspired by what Smalltalk and Ruby have to give, I started designing my own language, heavily influenced by those two great, very dynamic, truly object-oriented programming languages and came up with a quite simple language named blockd.

The name is based upon the main principle of the language: Everything is an object, and in the end, all code is defined within blocks – that are ruby / smalltalk like blocks. Naming these blocks is done via simple assignment. So instead of having a huge amount of keywords, the language itself is pretty simple, because all we really need is a way to describe assignments, instantiate objects and easily create blocks to pass to methods or use in an assignment.

So in contrast to Ruby, where there are procs, lambdas and blocks, blockd only knows blocks, which basically behave like Smalltalk like blocks – they simply are anonymous procedures / blocks of code (or functions, if you want to call them that – although not pure as in Haskell).

The syntax is a mix of Ruby’s and Smalltalk’s with some minor tweaks I thought would be cool (or not? I don’t know ;) ).
To give you an example of how the language looks, here is a small snippet of some sample code, that actually doesn’t work yet but might do so in the future :)

?Download sample.blk
# this is just for demonstration
# there probably won't be the need to require the console module from the
# standard library every time you want to print something to the screen ;)
System require: "console"
 
# we support ruby-style blocks with do ... end and curly braces { ... }
File open: "test.txt" mode: "w" do |f|
  f puts: "what's up, dog?!"
  f puts: "crazy shit, yo!"
  f puts: "hahaha!!"
end
 
10 to: 0 do |i|
  Console puts: i
end
 
i = 0
(i < 10) while_true: do |i|
  Console puts: i
  i incr
end
 
numbers = [1,2,3,4,5] select: {|i| i < 3}
numbers each: do |i|
  puts i
end
 
(1 .. 100) each: {|i| Console puts: i}
 
squares = (1 .. 100) collect: {|i| i * i}
 
# define a square method
square = { |x|
  x * x
}
 
# or like this:
abs = { |num|
  (num > 0) if_true {
    return num
  }
 
  num * -1
}

I’m still tweaking the syntax and haven’t decided upon all things completely yet, but I guess I’ve found the pretty basic “feel” of it.

While I haven’t shown you any code that defines a class or modules, it still does show a little of the languages syntax. I’ve started the parser today and it successfully parses the code above, meaning, that since the syntax isn’t too complicated, I expect to be able to parse all the remaining stuff (classes & modules and some minor other things) pretty soon. I then intend to start writing the actual implementation – an interpreter written in Ruby. While I could come up with my own runtime, class library etc, I want to make use of the Ruby infrastructure as much as possible. For one reason, it makes it easier to actually implement something useful, on the other hand, since the language is very close to Ruby’s object model and semantics, I hope I can use most of Ruby’s code directly. This also would mean, that the interpreter could also run on other Ruby implementations like JRuby, IronRuby etc. And maybe, some day, it could also run natively compiled with the Ruby compiler I’ve been working on recently as well – but that’s still far into the future, since the compiler isn’t finished yet.

I guess that’s it for now. More to come soon :)

Posted in General. Tagged with , , , , , , , , , .

Creating a simple game in Ruby – Episode 5

This is the 5th episode on creating a simple game in Ruby. In this episode, we’ll add some automated testing via the BDD framework RSpec. We’ll also start to implement the Character class.

Posted in General, Ruby Screencast. Tagged with , , , , , , , , .


Ihr Browser versucht gerade eine Seite aus dem sogenannten Internet auszudrucken. Das Internet ist ein weltweites Netzwerk von Computern, das den Menschen ganz neue Möglichkeiten der Kommunikation bietet.

Da Politiker im Regelfall von neuen Dingen nichts verstehen, halten wir es für notwendig, sie davor zu schützen. Dies ist im beidseitigen Interesse, da unnötige Angstzustände bei Ihnen verhindert werden, ebenso wie es uns vor profilierungs- und machtsüchtigen Politikern schützt.

Sollten Sie der Meinung sein, dass Sie diese Internetseite dennoch sehen sollten, so können Sie jederzeit durch normalen Gebrauch eines Internetbrowsers darauf zugreifen. Dazu sind aber minimale Computerkenntnisse erforderlich. Sollten Sie diese nicht haben, vergessen Sie einfach dieses Internet und lassen uns in Ruhe.

Die Umgehung dieser Ausdrucksperre ist nach §95a UrhG verboten.

Mehr Informationen unter www.politiker-stopp.de.