Back Original

Base Case

I was not entirely sure what to expect when things kicked off here, but I was quickly very impressed by how well the organization inculcates its culture and mores. Right off the bat the environment felt so inviting and pleasant, a really delightful intellectual atmosphere to explore ideas and meet really fascinating people.

The people part is really the best aspect for me – after working with such small groups for the last decade or more, it’s such a treat to meet lots of new people, all the more so when they’ve all been exactly the sort of person I would want to meet! So many great little conversations have been sparking ideas for things to make, I already have so many people I can’t wait to work with again.

I had been thinking of doing something I’d wanted to make for a while during my time here, a sort of “leiningen for Prolog”, tools to manage projects the way modern software developers expect. I still would like that to exist, but…it feels like a matter of writing scripts, gluing things I already know how to do together. Instead, energized by the Recurse self-directives, I decided to push myself to do something I feel much less confident about – write my own SDL bindings for Prolog, with the goal of making a sort of reactive-style framework or perhaps a game in Prolog.

I spent the first few days banging my head against linking in the library & exposing predicates to Prolog but today, in a very fun pairing session with a very cool Recurser, I got my MVP working – I could open a window & fill it with a colour in Prolog!

:- module(logui, []).

:- use_foreign_library(foreign(logui)).

:- multifile user:portray/1.

user:portray(SDLState) :-
    blob(SDLState, logui_sdl_state), !,
    logui_sdl_state_portray(user_error, SDLState).

:- initialization(main, main).

main(_Args) :-
    debug(xxx),
    sdl_start_window(Window),
    sdl_raise_window(Window),
    ( repeat,
      ( sdl_poll_event(Event)
      -> debug(xxx, "GOT EVENT ~q", [Event]),
         fail
      ; debug(xxx, "NO MORE EVENTS", []), ! )
    ),
    sdl_fill_window(Window, 128, 24, 200),
    sleep(10),
    sdl_close_window(Window).
purple_window.png
Figure 1: Gotta start somewhere!

That seems like it would just be a matter of following the most basic SDL tutorial, but it turns out that when you’re trying to not use the normal SDL runtime and instead control everything from a different language, things get weird. I’d spent the last four days seeing all the functions return correctly, but no window appear, before blinry hit upon the idea of trying to drain the SDL events, and voilà! So glad to have gotten over this hump, so grateful to meet new people that are as excited about stuff like this as I am!

I’m not sure where I’ll end up after Recurse, but I’m already so glad I’ve come here, if just for the community making me feel like I’m less of a weirdo ❤️

“Recurse” means to try once more