Archive for the 'C' Category

02/03 The force is with me little one…

I have written over the last two days RB bindings for libgd, in the continous search for a replacement to the Picture object, which is missing in console apps. As long as the promised-and-long-forgotten SwordFish project won’t be released, there’ll be little need, I think, or more accurately little clamoring for a Picture object – but once people start writing web apps in RB, you bet your ass they’ll want to produce images on the fly, like everybody else…

So. GD’s one option I had been thinking about – while still thinking I could build my own. And fPic works well enough, albeit with quirks. And it covers lots of ground – including PDFs, thanks to CoreGraphics. But it’s not very portable – my attempts to make it work on Linux, sans PDF and vImage.framework, failed so far. Since gd works on all platforms, I thought I could try it out. And sure enough it was easy to write bindings to the library, with very few quirks – I am having problems with saving to wbmp format, but who cares about that format anyway? :-)

One format that’s missing in GD is TIFF – which fPic handles very well, na na na – so I re-read fPics Tiff code [a wrapper to libtiff really] and converted that to RB. Which means I ended up writing bindings to libgd *and* libtiff, oh so much fun! It only reads TIFF files for the moment, as I haven’t worked out how to get access to the int **tpixels array from RB, in order to save as Tiff. Might have to write a small dylib to go with it – or use fPic’s very own manip.dylib! :-)

Like in fPic, when using freetype2 to draw text, one has to pass the path to a .ttf font file. It’s not exactly user-friendly, so I am trying to find a way to provide for a better interface into that. Maybe a Font class that’ll take care of the nitty gritty work. I found a good code sample to retrieve the name of a ttf font. Could be useful…

03/09 Programming, 빨리빨리, and Translation

Appart from a couple of inaccuracies, this is a good translation of Teach Yourself Programming in Ten Years by Peter Norvig. That a document which starts with the question Why is everyone in such a rush? was translated into Korean – and the link to that translation is at the top of the list… – is definitely amusing, since we know the maladive penchant our [ex-]hosts have for speed over accuracy. If you’re learning Korean, it’s a good sample to work from.

Learn at least a half dozen programming languages. Include one language that supports class abstractions (like Java or C++), one that supports functional abstraction (like Lisp or ML), one that supports syntactic abstraction (like Lisp), one that supports declarative specifications (like Prolog or C++ templates), one that supports coroutines (like Icon or Scheme), and one that supports parallelism (like Sisal).

Hmmph. I guess that list could use some upgrading, since the hype languages of the 21st Century are mostly not in there, and at least one language quoted here [Icon] is not developed any longer – which is a shame, I like Icon… As for Prolog, was it ever alive? ;-)

Python will match a few categories here, my favorite, RB, too, Erlang will cover a lot of ground for you here – not that I am conversant [yet!] in Erlang, but I’m learning! – and while C may come up short, most of these languages were/are written in C. Of course, if you aim to achieve stable and well-performing concurrent programming in C, you’ll end up with Erlang, as they say… :D I don’t think I’ll ever wrap my head around Lisp/Scheme – not that I didn’t try… – and I find Java and C++ repulsive and offending, but it’s probably just a matter of taste and education [or lack thereof…?].

But in the end, be it computer languages or human ones, 10 years is a minimum. Practice makes good, and education alone won’t take you very far [case in point: the profs I had at the Uni. You could tell those who had practiced their language skills and those who had kept their knowledge at the academic level…].

Anyway, this is an attempt at tagging

12/22 Updated curllib4RB

From its home page:

Features:
There are three methods available:

  • getFTP(URL As String, targetFolderItem As FolderItem, isSSL As Integer)
  • putFTP(file2upload As FolderItem, Login As String, Pwd As String, URL As String, isSSL As Integer)
  • curllib.getHTTP(URL As String) As String

isSSL can be set with: curllib.SSL_TRANSFER and curllib.NO_SSL

This little dylib was meant to be used mainly for [S]FTP transfers, but since it’s all there, I added the HTTP[S] get, and could possibly add more. Useful for quick jobbies, I guess…

12/01 curllib For RB

I have posted here a preliminary version of curllib For RB, a dylib + RB Module that makes [S]FTP transfers in RB easy; lemme rephrase that: possible and easy… It is based on libcurl and works well enough. There are some rough edges left, but for a first draft, it is quite good, if I may say so myself… :-)

10/23 fPic news

I have fixed a couple of bugs, and added one interesting feature: fPic.displayImage(). It uses GLUT to open a window and OpenGL to draw the fPic. The code is crude in the sense that it’s mono-image only [create two fPic, display both and watch my code make a pig’s breakfast of your efforts], and doesn’t care much about checking your screen bounds vs the image’s. That’ll come in time. But it’s freaking fast. Like, very. Even on my tired TiBook, the most time-consuming task is creating the window. Copying bits to the buffer is something C code and PowerPC do well and fast.

I am not sure whether a command-line application [the intended target of fPic] is really in need of a GUI solution, even a limited one, but it sure comes in handy for me when checking the execution of new functions in fPic.