I did..stuff!

I did..stuff!

by baggers

Hey again, I've been on holiday and I decided that, even though it was a staycation, it would be a holiday from all obligations (and everyweeks fell into that pot it seems).

[EDIT] I tried to keep this kinda short and failed so hard. Sorry :/

Lego!

I had a set of mindstorms that I had only played with a little so I got the IDE set up and got cracking. Got a little arm and controller going. The visual programming language means it's got such low information density though and working via the mouse felt painfully inaccurate.

Good experience but was to dig into the lower level code sometime.

Cells

Got a couple of PRs into this project

Non glitch-free observables seem odd to me now, especially after reading more of the inventors views on what it should be (continuous, denotational), Cells isnt that either, but it doesnt feel like a stream at all, just like a spreadsheet instead.

Wrapping libs

  • Found that autowrap doesn’t support passing structs by value
  • Found that the main ffi CFFI has support for doing this and that it has support for c2ffi (clang->spec generator)
  • experimented further with wrapping nuklear
  • Bugfix for CFFI as c2ffi spec has been updated
  • Added a feature to CFFI for generating symbol exports for generated libraries
  • Added a feature to CFFI for allow the user to generate lisp forms based on the FFI forms emitted from the generator
  • Two small enhancements the latter of which gives a very large perf boost
  • Finished the grovel/wrapper caching feature..Well I thought I had finished it but the tests are failing. But I know why and it's a trivial fix. Will do that asap

With all the above in place I can, in about 30 lines of code, take a single-header library as source and have the lisp build system:

  • compile it
  • generate a full lisp wrapper
  • cache the .so/.dll/.dylib file with enough platform info to know which platforms (and features) are needed to use it

Example project here: https://github.com/cbaggers/raw-bindings-nuklear

UI

After getting the bindings for nuklear generating to my satisfaction it was time to make it nice to use. I had already been hacking around with the basics so it didnt take long to come up with a ok API.

It is very macro based and feels 'heavier' that regular lisp code. This is by design, I wanted the UI to feel more like an artifact, a language of it's own that mixes with regular code, but cant be thrown around as easily as regular functions...hard to explain as it's a feel thing. But it is ok to write and extend at least!

Here it on github and here it is working on OSX and Linux:

osx

linux

In the linux one you can see some of the code that made the bigger of the windows.

Data Oriented Design

Been watching a bunch of talks recently

I'm sure there were some more. Anyhoo I very much like some of the ideas:

  • avoid world modelling. Ask yourself the question is this subclass (whatever) for the datastructure's sake or a story Im telling with the data. It should always be the former. The example I liked was StaticChair, PhysicsChair & BreakableChair shouldnt be in type related as they are entirely different in data & behaviour from each other. What they have in common they had with MANY other game objects.

  • The CPU is spending half it's time idling waiting for cache. Thought in data-structures can help this.

  • Efficiency is about doing less (algorithms), Performance is about doing what you have to do fucking fast (data-structures)

Also the feeling I get is a lot about keeping things flat and simple where possible.

I feel the speakers are naturally biased in favor of these things (Mike Acton can be a real arse on the subject), but there are some good takeaways I can use in my low level stuff to make sure I can piss cycles away in the high-level fun bits.

Other Videos

Tiling Viewport Manager

I live in a tiling window manager and wanted something similar for GL. The idea is to be able to split the screen into any number of frames that you can either render into, or attach textures that it will render for you.

If you have used emacs you know the drill.

So I made that, I have no good screenshots yet as it's very WIP but will do another day

CEPL

Whilst profiling the UI library above I noticed some places I was unnecessarily allocating memory. It's turns out that my compiler doesn’t yet store pointers 'unboxed' in structs so I was hitting a lot of places the pointer was getting type tagged/untagged.

I talked to a couple of guys on the compiler team and they have this on their todo list and in the mean time I can user a machine-word. This will work for all architectures..except Alpha :D so I don't think that is a problem (though the compiler doesn’t support this!).

To aid working with this I made a simple library which uses machine-word on SBCL and pointer everywhere else.

This has helped me chop down large amount of unnecesary garbage for the GC to handle.

One more bit of love for this compiler.. its type system is just so fucking cool, it's a dynamic language with a crazy type inference engine, with some dependent-type magic in there too. So take this case:

I need to call glScissor, it takes floats. Now I have a x position (float) from my UI window and a scale (32bit int). I multiply them, however my compiler (correctly) doesn’t know if this will be a number than can fit in a single precision float. But I can just do this (declare (type (single-float 0s0 #xffff) x) As I know that my window won't on a screen 65000 pixels wide. Now the compiler KNOWS it can safely use a faster multiply

I think that's cool, also this is optional stuff, unless you tell it to, the compiler does the safe thing.

Other code

  • get my stumpwm config cleaned up and online
  • Started collision support for my math library
  • Finished the first full pass at my paths library
  • More work on my event system
  • Found and filled some gaps in the CEPL api docs
  • Made a macro to let you more easily modify local variables from the repl at break-points (no online repo for this yet)

Outdoors?

Been doing some other things I've been putting off

  • swimming
  • kayaking

kayak

I saw King Crimson live the other day, which was mental. 3 drum kits at the front of the stage, truly mindbending noise coming out of that band. Nice to see them before they start dying.

Also went and had 2 sessions in a floatation tank, which is essential sensory deprivation (no light, no sound, floating in body temperature salt water...so no touch). Was very relaxing of course but in the first session at about the 50 minute mark I started thinking on some code and the clarity of the thoughts was alarming to me, 10 seconds and I had the answer to stuff I'd been musing about for ages. Didn’t work as well the second time, but there were a number of variables I had changed so I need to tweak those in future sessions.

Also just been working at coffee shops more. Worked well in 9-10am slot to get a bunch of ideas in place before heading home to really hammer on code. Was nice, must do this more.

Misc Reading

  • Read up on lisp streams: been meaning to do this for a while (as with almost everything in this list)
  • Read up on lisp gensyms and other uninterned symbols
  • reading the static-vectors implementation
  • Learned how to use the lisp step debugger
  • Other stuff I just don't remember

Fuck I gotta stop

I haven’t touched on general RnD stuff I have been doing for upcoming projects yet...but this is toooo damn long

Goodnight all, thanks for wading through this crap :D

Last Edited on Mon Oct 03 2016 18:14:00 GMT-0400 (EDT)


youthlagoon commented

I have always wanted to try a flotation tank! That must have been a great experience! I'm not much of a coder so I really don't have much to comment on for your projects, mostly because I don't understand them :P. I am rather jealous of your kayak adventure tho, I haven't had mine out all year :( ... summer is gone. Hope you had a good vacation!

on Mon Oct 03 2016 20:49:17 GMT-0400 (EDT)