Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What if pngquant was written in Rust? #161

Closed
kornelski opened this issue Jun 26, 2015 · 12 comments
Closed

What if pngquant was written in Rust? #161

kornelski opened this issue Jun 26, 2015 · 12 comments

Comments

@kornelski
Copy link
Owner

I'm seeking feedback on moving parts of pngquant from C99 to Rust. At first I'd only move pngquant CLI executable to Rust, but leave libimagequant as a pure C library.

It would build as a statically linked binary on OS X, Linux and Windows, x86 and x86_64. Rust's support for other architectures exists, but AFAIK is still immature.

How does this impact you?

@quiret
Copy link

quiret commented Jun 26, 2015

I do not know. Just recently learned about Rust. I like the good performance of the libimagequant library, and as long as that stays, I guess it will be okay?

Make sure you do not change the API. Btw, still waiting on that custom palette setting function. :-)

@sergiomb2
Copy link
Contributor

Hi, is Rust OS independent ?
Rust does not exist in the Linux Fedora yet , still in review [1]

[1] https://bugzilla.redhat.com/show_bug.cgi?id=915043

@kornelski
Copy link
Owner Author

Rust certainly supports Linux, although it may take some time before distros create packages for it:
http://www.rust-lang.org/install.html

It also getting musl support, which as far as I understand, allows it to create static binaries that work without glibc, so are compatible with any Linux distro (on x86/x64)

@rcanavan
Copy link

While support for Linux may just be a question of time, older and/or more exotic platforms such as IRIX will probably never get a functioning rust compiler. Currently, pngquant can be compiled basically everywhere even with ancient C compilers. I'd prefer if you'd stick with C and not use features from standards newer than C99.

@kornelski
Copy link
Owner Author

Rust is on its way to Fedora and Debian. For platforms without packages it's easy to install and keep up to update via rustup. It can target iOS, Android, *BSD, PPC and MIPS Linux. Not IRIX though.

Currently pngquant is annoying on Windows due to poor C support in Visual Studio, POSIX-isms in the code, and need for bash-based configure script. OTOH Rust has very good support for Windows, and Cargo build scripts can be used to hide the pains of C integration.

For a while now I've stopped using C for and have been using Rust instead for all new projects, and I'm quite happy with it.

For now pngquant works well enough, so I don't feel pressure rewriting it immediately. But if I decide to add any major functionality, I'll probably split libimagequant and pngquant, and rewrite pngquant.c in Rust.

@sergiomb2
Copy link
Contributor

Found this today: https://fedoramagazine.org/rust-meets-fedora/

@pickhardt
Copy link

I'd also recommend considering Go. It could be great for what you're trying to accomplish.

@kornelski
Copy link
Owner Author

kornelski commented Feb 9, 2017

I'm already having great results in Rust. Since pngquant and libimagequant are C projects, I think Rust, which does not have GC runtime and can produce pure "C" libraries, is a much better fit for this project.

@ex
Copy link

ex commented Jun 7, 2017

Rust is fine, please not Go.

@kornelski
Copy link
Owner Author

Now cargo run runs pngquant :)

It's still all 100% C, but everything is in Cargo packages. Almost builds on Windows, too.

https://crates.io/crates/imagequant-sys
https://github.com/pornel/pngquant/blob/master/Cargo.toml

@kornelski
Copy link
Owner Author

First Rust code has landed!

The good news is the whole program builds on Windows out of the box!

@kornelski
Copy link
Owner Author

See #252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants