Tuesday, July 31, 2012

C++: Why or why not?

These days, I'm most integrating with native libraries, although web browsers are interesting, too. (See perhaps NaCl and Emscripten on the latter.) Some of those libraries export C APIs. That's nice for reuse across languages. Some (Bullet, Skia, ...) do best with the raw C++. This makes interfacing more difficult. One of the best ways to use C++ libraries is to code in C++.

And truth told, especially with C++11, I don't mind coding in C++ myself these days. I like type inference and closures. Bothering with shared_ptr, weak_ptr, and unique_ptr isn't the end of the world, and it gets most resource management done. Eclipse CDT has passable (although quirky and not always reliable) support. On a fast CPU, I can almost survive compile times.

On the down side, C++ is still a complicated beast. I'm not sure I'd like to see results of newbie code in C++ as they try out fancy features (which sometimes really are needed for clean code, too). I also don't understand everything myself. I get the point of C++11 move semantics, for example, but I don't really understand how to use it. I'm sure I could, if I spent time on it, but I sort of hover around "I need to get to that someday" mode. And it's such a bother to have to understand such details. Many other such examples exist in the beast.

Also, there's the issue that I'm really tired of needing to declare functions before defining them and the whole header vs. source files. It seems a small thing, and I could argue their virtues, but it's one of the things I'm most tired of.

In the end, for just getting a job done when I need to integrate, I think C++ is the easiest way to go, and it really is possible to write clean and portable code. However, the warts and slow compiles really grind on me. I'd also like a good implementation I could use everywhere, open standards not withstanding. Maybe that'll be Clang someday, if Windows coding support goes up. Maybe.

I wish the language in my head would fly out automatically with amazing C++ integration support included.

Saturday, July 28, 2012

How to be a polite helper

I love to see polite responses like this on help groups. So often I see complaints about people being incompetent or not reading manuals or whatnot. Being polite is wonderful and what's needed if you care about having a good relationship with folks out there. People aren't morons just because they make mistakes. Everyone makes mistakes.

Maybe rude responses are more likely for projects that feel they already have all the attention they want and just can't keep up?

Sorry for not spending the time to look up a counter-example on rudeness, but the polite example is nicer to read anyway. And I guess finger pointing isn't nice either, so maybe it's just as well I haven't looked one up. I guess I could anonymously quote or something.

Tuesday, July 17, 2012

A closer language: Julia

Well, I can't seem to get language design out of my mind, but someone got really close to what I've been planning: a human-friendly, math-friendly, high speed, scripting-feel, typing-allowed programming language with multiple dispatch and whatnot. The one I found today is called Julia.

It has been well known for the past few months, but I managed to miss it until today.

My (mostly vapor) language is called Rio, and here's some sloppy "brainstorm about the language" demo code.

Some similarities between Rio and Julia are almost uncanny, but there are strong differences, too. Julia has no namespacing (but maybe they'll fix that), emphasizes fully dynamic typing, has too many keywords, doesn't let you really be a peer to core control constructs, has syntactic macros (which I dislike -- but they at least need special syntax and maybe are hygienic?), has batteries included (vs. immediate emphasis on package management), and so on.

But given they already have the buzz, are way ahead of me, and have people paid to work on it, maybe I should throw in the towel and get my own work done, knowing that Julia does a lot of what I wanted.

Some additional differences arise between Julia and Rio, by the way, like how they've gone reference-based and I was leaning value-based, but there are so many pros and cons on such things. That I can follow them down to various subtleties and think about how they've chosen where to go vs. where I have been headed with Rio just lets me know that we've thought about a lot of similar things. Julia just might be my language in the future. Argh. If only for infinite time and money, eh?