Pony Lang

The other day, I watched Mark Allen‘s talk comparing Erlang and Go Concurrency and I really enjoyed it. Near the end, he mentioned a new programming language called Pony which uses the Actor Model.

What? I’ve never heard of this! So I did a search on “pony lang” and got a bunch of pictures of glamorous women. At first, I thought maybe there was an actress or model named Pony Lang. Then I realized they weren’t all pictures of the same person, though they did have similar hairstyles. It turns out “pony lang” is Dutch for “long bangs”.

Anyway, ponylang.org is where to start if you want to learn more about the Pony programming language. I installed it

sudo add-apt-repository "deb http://releases.ponylang.org/apt ponyc main"
sudo apt-get update
sudo apt-get install ponyc

added the Emacs mode for it

(use-package ponylang-mode
  :ensure t
     (lambda ()
       (set-variable 'indent-tabs-mode nil)
       (set-variable 'tab-width 2)))))

and dashed off hello world.

actor Main
  new create(env: Env) =>
  env.out.print("Hello, World!")

Now compile and run it!

$ cd ~/pony/helloworld
$ ponyc
Building . -> /home/tim/pony/helloworld
Building builtin -> /usr/lib/pony/0.1.7/packages/builtin
Writing ./helloworld.o
Linking ./helloworld
$ ./helloworld 
Hello, World!

Looks great! Another new language to learn! What fun!

Pony Lang

How to measure your CPU time: clock_gettime!

I loved reading How to measure your CPU time: clock_gettime! by Julia Evans.

In Perl, we can access clock_gettime throught the Time::HiRes module.

#!/usr/bin/env perl

# http://jvns.ca/blog/2016/02/20/measuring-cpu-time-with-clock-gettime/

use v5.22;
use warnings;
use Time::HiRes qw(clock_gettime CLOCK_PROCESS_CPUTIME_ID);

my $start_time = clock_gettime(CLOCK_PROCESS_CPUTIME_ID);
my $end_time = clock_gettime(CLOCK_PROCESS_CPUTIME_ID);
say "elapsed CPU time: ", $end_time - $start_time;

sub do_maybe_expensive_thing {
    my $j = 1;
    for my $i (1..int rand 100_000_000) {
        $j *= $i;

If we change do_maybe_expensive_thing to just a sleep, we’ll see that it takes up time without using CPU time.


How to measure your CPU time: clock_gettime!