Friday, May 25, 2012

Musings on the Rust language

I've looked over many programming languages. I was a big proponent of Fantom for some time. I still think it is one of the best languages in the Java vs. Ruby space, if you know what I mean.

In recent years, though, I've (1) gotten tired of JVM memory hogging and the need for pure-Java-hood, despite its own practicality, and (2) gotten tired of the Java ecosystem and community, especially with the whole Oracle vs. Google thing. Just tired of it. And while I still like Google, I'm not sure I trust them quite as much as I used to. Oh, and (3) related to pure-Java-hood, I've had a lot more need to interface with native code in recent years.

Anyway, I've coded much more C and C++ in recent years than I had for some time. (I've also done a fare share of MATLAB and Python, among other things, including Java.) I like playing native, but C requires so much overhead to get things right, and C++ is such a mess, despite tools like CDT in Eclipse. (Yes, I still use Eclipse despite its Java core.) I'm also just tired of header vs. source files and bother like that.

I'm also a programming language hungry sort, so I've looked at languages like Go, D, Rust, and Vala that aim to make low-level coding more pleasant and safer. I'm not sure I like D originating from a propriety land, even with open implementations, and Vala is too locked into glib land among other issues. I also buy Rust's arguments against Go's global variables and lack of automatic resource management. I also can't stand being expected to check for error responses every time. That's Go's official way of dealing with errors, although they have a discouraged form of exception handling in the form of panics. Rust also has no exceptions, but you are allowed to crash your task (coroutine) and recover from another. That's acceptable to me. That's what errors are for, really.

I also actually like functional programming despite my complaints at complicated languages like Scala. I'm not sure yet whether Rust is any better, but I think it has enough of the core things right while still being low level.

Anyway, Rust isn't what I'd design by a long shot. (The language Clay is closer in overall feel, but it's not as likely to go mainstream, and I'd actually go higher level than either Rust or Clay myself, although I'd want to retain the ability to call straight into C and maybe even C++ libs.) However, with its momentum, is Rust good enough?

I don't know, but there's a chance that Rust will become my tool of choice in the future.

Sorry no time to go into the particulars of my feelings on all the little issues.

For now, though, realize that Rust is in a heavy state of flux. That much is clear. Before 1.0 comes out, I expect a lot of things will change, and the current latest features (as for any project) risk being buggy. Documentation also lags some. Just a heads up.

Wednesday, May 16, 2012

Piano keyboard & musical staff figure

For three semesters, I've taught a course on programming in C. I like to give a particular application domain for the final exam and let them solve multiple problems in that context. This past semester (and my last for the foreseeable future), I chose sheet music.

Knowing that many people aren't familiar with sheet music but that some are, I gave a quick crash course in the exam itself. Seems crazy, but I simplified things, and I ran it past multiple folks with little to no music experience. Overall, it worked out. However, for my quick summary, I wanted a figure of a piano keyboard in context with a musical staff. I had trouble finding anything else out there that met my needs.

So I made something:

I also have a pure SVG version of that, but Blogger doesn't let me attach SVGs. How modern of them. Maybe I should go to WordPress sometime.

Anyway, I hope some folks find this figure useful. Let me know if you want the SVG. The figure is public domain, so far as I'm concerned.

Credits: LilyPond, Frescobaldi, LibreOffice, and Inkscape.