Hi everyone. I really like Nim and I want more people to use it. Right now Nim 
is a niche language but I want to help change that by making Nim more popular.

I think making it easy for devs working in other languages to use Nim code is a 
good way to get Nim used in more places and broaden Nim's appeal.

If developers start using Nim libraries from other more popular languages, Nim 
can work its way into more developers' sphere of awareness and maybe into more 
companies. I hope after more developers see they already use Nim code, they 
will start experimenting with it themselves.

This is why @guzba and I are working on `genny`.

## genny

With `genny` you can generate a shared library (.dll, .so and .dylib) with a 
simple C API and quality bindings for other languages.

Currently we have Python working pretty well with C and Node.js pretty far 
along too. We plan to and more languages. What languages would you like to see?

## pixie-python

For our pilot `genny` project we have created `pixie-python`, bindings for 
Python programmers to use [Pixie](https://github.com/treeform/pixie). You can 
simply install it with `pip install pixie-python` (just `pixie` was already 
taken). See: <https://github.com/treeform/pixie-python> and 
<https://pypi.org/project/pixie-python/>.

The Python code that binding users will write should feel "Pythonic" and pretty 
close to Nim:

Python:
    
    
    paint = pixie.Paint(pixie.PK_SOLID)
    paint.color = pixie.Color(1, 0, 0, 1)
    ctx.fill_style = paint
    ctx.fill_rect(50, 50, 100, 100)
    
    
    Run

Nim:
    
    
    let paint = newPaint(pkSolid)
    paint.color = color(1, 0, 0, 1)
    ctx.fillStyle = paint
    ctx.fillRect(50, 50, 100, 100)
    
    
    Run

## A bindings interface DSL

We provide a DSL that you can use to define how things need to be exported. The 
DSL is pretty simple to follow:
    
    
    import genny, pixie
    
    exportConsts:
      defaultMiterLimit
      autoLineHeight
    
    exportEnums:
      FileFormat
      BlendMode
    
    exportProcs:
      readImage
      readmask
      readTypeface
    
    exportObject Matrix3:
      constructor:
        matrix3
      procs:
        mul(Matrix3, Matrix3)
    
    exportRefObject Image:
      fields:
        width
        height
      constructor:
        newMask(int, int)
      procs:
        writeFile(Image, string)
        copy(Image)
        getColor
        setColor
    
    
    Run

Genny is very new and experimental, don't expect it to work perfectly for 
everything just yet. Genny is working though and we think it is possible to use 
`genny` for more projects at this point.

Consider trying `genny` or `pixie-python` for your next project and let us know 
what goes well and what we can improve! 

Reply via email to