art's abode

Archive for the ‘boo’ Category

boo network code: simple telnet/web server

without comments

Shamelessly modified from the boo example sources, but it’s enough to get you started:

import System.IO
import System.Net
import System.Net.Sockets

server = Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
server.Bind(IPEndPoint(IPAddress.Any, 8200))

while true:
        socket = server.Accept()
        using stream=NetworkStream(socket, true):

                writer.WriteLine(“Ahoy, this server is running: ${shell(‘booc’, ”)}”)
                writer.WriteLine(“${shell(‘cat’, ‘/proc/cpuinfo’)}”)

MSDN’s System.Net Namespace docs might could also be of use. I’ve tested this on sparc and x86 linux variants with mono.

Hope you find this useful, network programming seems to be a relatively familiar experience if you’ve done it before in another modern language, just took a little bit of scrounging to dig up.

Written by art

January 31st, 2008 at 11:16 pm

boo versus ruby

without comments

Here’s a document I ran across today which details some of the specific differences in the two languages. Just one of the many glorious tidbits:

Boo uses CLR threads, which generally map one-to-one to kernel threads and therefore exploit multiple processors and are fully preemptive.

In contrast, Ruby uses lightweight threads – threads implemented within the interpreter. Because of their extremely low switching latency, they can be used in situations where kernel threads impose too much overhead…[b]ut Ruby’s threads are limited to one CPU, and block on OS calls.

Microthreads can be implemented in user libraries, but only cooperative threads (as far as I know). I don’t know how important preemptive (within the hosted language) microthreads are. But the CLI (and therefore, Boo) seem to have no standard library implementation of lightweight threads.

All this is specific to the main Ruby implementation. JRuby, like Boo, relies on the underlying VM’s threading model – the JVM’s, in this case – and so its threads are generally fully preemptive and exploit multiple CPUs.

At the end of the day, I suppose comparing boo with ruby is a bit like comparing dicks to pussies, as ruby is an interpreted language through-and-through, whilst boo can be run, for instance using booi in interpreter mode, or using booc compile CLI bytecode binaries (which are absolutely tiny compared with, for instance, ruby2exe’ing a ruby project) to be run with mono/.NET or other CLR.

Also gotta love the mention of the JRuby: now we’re talking optimized best-of-breed solution. Lulz.

Written by art

January 31st, 2008 at 9:24 pm

Posted in boo,development,ruby