PngOptimizer on github

I finally put PngOptimizer source code on an online repository (github) instead of using a zip/tar.gz archive.

What motivated me is that today I have finally been able to upgrade my Windows 7 to Windows 10. My previous attempts were always leading to errors, and none of the solution I could gather would work. What I did was wiping my Windows hard drive partition, reinstall a fresh Windows 7, avoid installing any software or tweaking the hard drive (for example by installing grub). And voilą, the Windows 10 update procedure worked.

So what is the relationship between Windows 10 and PngOptimizer? Well, PngOptimizer is built with Visual Studio, and using Visual Studio build files have always been a painful experience. One of the problems being that the file format keeps changing with mostly each new version of Visual Studio.

I already ported PngOptimizer build files from Visual Studio 6.0 to Visual Studio 2005, then to Visual Studio 2010, then to Visual Studio 2012 and then I was blocked because Windows 8 was required. So now I will be able to... sigh... port them again to the latest version of Visual Studio (I guess it is 2015).

Meanwhile on Linux I use Makefiles. Makefiles are painful to work with too but at least the file format is quite stable.

I had to prepare the source code for online access so the contents are not exactly what is currently proposed on the download page:

  • I updated the distribution scripts to avoid creating the source code archive as it makes no sense anymore.
  • I removed some Windows-only or experimental projects. I just kept PngOptimizer (the graphics tool) and PngOptimizerCL (the command line tool).
  • I updated several files and directory casing. Maybe it is because I spend most of my time on Linux now, I foster lower case. I used to use PascalCase a lot when I was mostly using Windows.
  • PngOptimizerCL executable file is now all lower case on Linux. I found that it is some kind of convention on Linux.
  • I build the Linux version with std=c++0x instead of std=c++11 for older compilers.

Unfortunately I could not save the commit history because PngOptimizer was using Mercurial. It was just easier to create a new git repository from scratch.

I used a new version number (2.4.3) to identify those small changes. The download page still propose an older version. I will probably update it after I convert the build files for the latest Visual Studio and be sure everything is all right.



From time to time, I write small programs to fulfill a need, or just because I have some ideas I want to experiment with. I used to fire my text editor and my C++ compiler to code such programs. But lately, I've been playing with the Rust programming language, and I think it became my favorite language at home.

Of course, the main list of features found on Rust's home page is a source of motivation when you are looking at programming languages that fall in the same category than C and C++: memory safety, explicit ownership... including some radical features like the move semantic, i.e. a variable is moved by default instead of being copied, or the fact variables are read-only by default. I would love having "const" by default in C++.

But lately, what made me reconsider my default programming language at home was the Rust ecosystem, something I feel is lacking with C++. With Rust, you don't only get a compiler, you also get:

  • a good and quite complete standard library. I started with C++98 and in that era everybody were rewriting their standard framework. Fortunately that's now better since C++11 and other recent iterations of C++.
  • a build system. This have been a major issue of time loss for me on both Windows (tweaking Visual Studio project files, which format tends to change from one version to another) or on Linux, where I sometimes default to GNU Make (but creating a full build system with GNU Make is painful) or QBS, provided with QtCreator. With Rust, you get a full build system (called Cargo), and that really saves time, for you own code and when you try to build someone else's code.
  • an infrastructure for third-party libraries. Integrating a library in my C++ projects has always been painful. With Rust you just go to crates.io, check the dependency you would like to add, and then add a line in your Cargo build file. That line will lead to the automatic download, build and integration of the third party library. That too is really time saving and makes code reuse easy.

I wanted to run on Linux an old program I wrote on Windows in C++ with my own framework. But instead of adapting the existing C++ code, the reasons I just listed made me decide to rewrite the program from scratch. The program is a tool to fix subtitle files. Sometimes subtitle files are not well formatted, or some small mistakes can be found that would easily be fixed automatically.

In addition, I found other several design decisions that pleased me: easy and incentive unit testing, low dependency (you can in fact write an OS with Rust), or some syntactic sugar. For example, I've always been bothered by nearly-useless parenthesis around some C++ statements:

if( value == 42 ) { plop(); } // That's C++, {} are optional for single line operations
if value == 42 { plop(); } // That's Rust, {} are mandatory, but you don't need parenthesis

I could go on about that language. I am still learning and there are still plenty of features I need to play with. Do I sound enthusiastic ? ;) I have to find some counter points:

  • the entry ticket can be high. C++ requires discipline to avoid mistakes, but it does not enforce any good practice rules. The Rust compiler will enforce them. I love that, but it can feel like you are fighting with the compiler.
  • contrary to a lot of recent languages that focus on productivity but with a compromise on performances, Rust follows the same tracks than C++ in that regard. The cost can be a higher complexity. For example, you have const char* and std::string in C++; in Rust you have str and String. Rust will hardly replace languages in domains where C and C++ are already not suitable.
  • the language is only one year old. Well, it started several years ago, but version 1.0 came last year. It means there are still libraries and tools to be built around it. In other mature languages, you get a lot of out of the box facilities. The lack of maturity and advertisement may also frighten people that are not closely following the tech industry.

One last word. You want to try Rust without installing anything? You can write Rust online! Go to the Rust Playground were you are greeted with a "hello world" program. Click Run to build and run the porgram. That's a fantastic initiative to learn and to exchange code snippets.