slembcke / Chipmunk2D

A fast and lightweight 2D game physics library.
http://chipmunk2d.net
MIT License
2.18k stars 346 forks source link

Chipmunk and Rust #156

Open iago-lito opened 6 years ago

iago-lito commented 6 years ago

Hey, and forever cheers for this wonderful Chipmunk project, which I keep sticking to over the years :')

I also recently dove into Rust, which is, I think, a very promising low-level language, both modern and efficient.

Wondering how Rust and Chipmunk could interact, I came accross this page listing known Chipmunk binding and ports, which does not include Rust yet.
On the Rust side I found two crates: the first, chipmunk-sys, claims it only wraps sys-level calls for the second, chipmunk, claiming it's work in progress but seems abandonned since 2015.

Did you know about them? Is a port to Rust or a neat binding already on the roadmap somewhere? Has anybody else started anything in this direction?

slembcke commented 6 years ago

Hi!

I'm no stranger to Rust actually, though I've never used it for a serious project yet. I have too much C code I would want to use for a game project, and bindgen didn't really seem up to the task yet last time I looked a few months ago. The bindings were too low level, and wrapping them with idiomatic Rust seemed like too much work. I guess that's where I found myself stuck anyway. My impression of the GL libs available were that they were all trying to "improve" GL, in ways that were counterproductive, and I didn't want to rewrite my rendering code... yet. I think I did come across the two Chipmunk wrappers you mentioned 6 months ago or more, sounds like they haven't changed too much in that time.

Anyway, I don't think I really answered your question in a way that is satisfying... I am highly interested in rewriting Chipmunk from scratch to use data oriented techniques someday, and I'm really tempted to do it in Rust. I think I could make it considerably faster than it is now, and it would be much easier to multi-thread properly. The problem is time... That sounds like a lot of work, and I don't know when I'll have the time for it.

On Oct 27, 2017, at 06:18, Iago-lito notifications@github.com wrote:

Hey, and forever cheers for this wonderful Chipmunk project, which I keep sticking to over the years :')

I also recently dove into Rust, which is, I think, a very promising low-level language, both modern and efficient.

Wondering how Rust and Chipmunk could interact, I came accross this page listing known Chipmunk binding and ports, which does not include Rust yet. On the Rust side I found two crates: the first, chipmunk-sys, claims it only wraps sys-level calls for the second, chipmunk, claiming it's work in progress but seems abandonned since 2015.

Did you know about them? Is a port to Rust or a neat binding already on the roadmap somewhere? Has anybody else started anything in this direction?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

data-man commented 6 years ago

@iago-lito You can try the Nim language. Chipmunk bindings for Nim. Planets example. Nim bindings to Chipmunk v7

slembcke commented 6 years ago

Kind of off topic, but it does seem like a neat language. I think the biggest problem for me personally to jump ship from C-ish languages is that the FFI's always require respecifying the symbols in a new syntax. That usually ends up being annoyingly laborious to declare things twice (in a .h, and for the FFI) for "live" code. By that I mean I'm likely to have a small amount of C code for rendering or somesuch in my project that is constantly changing. LuaJIT had a really neat feature where it could directly read .h files and generate native symbols for them. I sort of gave up on LuaJIT a while back though. Neat language, unpredictable performance.

ghost commented 6 years ago

@slembcke Nim has c2nim, which automates most of the work (e.g. respecifying the symbols in a new syntax)

iago-lito commented 6 years ago

@slembcke Thank you for this picture. My questions weren't really meant to be very precise. And so you did answer them in a way ;) Now I'm mostly glad this thread is open.

Rewriting Chipmunk from scratch with data oriented techniques and deep multithreading opportunities like the ones Rust offers sounds like a wonderful project indeed. And I agree it is dreadful how much time it'd take. Btw, do you have any kind of wild estimate on that?

I'd be happy to help if anything started in this direction. First I need to get familiar with this language : I'll maybe use it at work for a few months and get a grip on it with smaller projects. But then who knows? Maybe I'll have spare time next summer or in another life. I'll keep an eye on #156 ;)

For now, keep up with the good work :)