Monday, June 21, 2010
The power of the power of the power...
Of course those problems have been entirely solved quite soon. I suppose that by the end of the year they were no more and the faster intel chips were just the right choice for everyone. A couple of years after those events I bought a MacBook Pro 15” laptop and that became my main work machine. Among the things I really liked best about the intel processor (and all the lovely virtualization software packets out there) was that I could run Linux in a virtual machine. Since I did not stop working on a certain “almost-linux-only” project, that was really good (and saved me from ugly partitioning). Although I had a Parallels license (which I used on the iMac), I preferred to use the simpler VirtualBox. Back in the day, Parallels did not support Linux exceptionally well and I could just live with the free VB. And that is the machine I used (along with the iMac) for my M.Sc. dissertation.
4 years after i first turned it on, my iMac blew off. Well, not literally. I suppose I can fix it, however, I chose to buy a new Mac. This time it is a MacPro. Essentially, I hated that if I thrashed my iMac (because of other damages) I could not save the monitor. So I chose a monitor-less computer. Essentially the thing is powerful. It is extremely evident when encoding my CDs into mp3’s. I don’t do much video editing.
Nonetheless, Parallels is completely capable of sucking all the resources. I had to stop using it, since the MP became useless. I suppose it may be related to having only 3 GB, even though the iMac had only 2. If I will need a virtualization software, I suppose I’ll go with VMWare or VirtualBox. But… that is not the last machine I bought.
Glad I chose Blogger
Probably I would have regretted if I chose another blog service.
This also makes me think writing the crappy little blogging application for Linux should be pretty easy. :)
Sunday, June 13, 2010
Prolog Homoiconicity
read_all([Predicate|T]) :- read(Predicate), Predicate \== end_of_file, !, read_all(T). read_all([]). read_file(File, L) :- see(File), read_all(L), seen.If we call read_file to read "read_file.pl" (spaces added by me):
?- read_file('read_all.pl', L).
L = [(read_all([_A|_B]):-read(_A),_A\==end_of_file,!,read_all(_B)),
read_all([]),
(read_file(_C,_D):-see(_C),read_all(_D),seen)] ? y
The display predicate some prolog interpreters provide gives us more insight on internal representation of terms. We call it on just one rule in order not to clutter the output with list representations:
?- read_file('read_all.pl', [H|_]), display(H).
:-(read_all(.(_932,_952)),,(read(_932),,(\==(_932,end_of_file),,(!,read_all(_952)))))
And here on the full program (notice... lists are "consed" with the '.' functor):
?- read_file('read_all.pl', L), display(L).
.(:-(read_all(.(_900,_920)),,(read(_900),,(\==(_900,end_of_file),,(!,read_all(_920))))),.(read_all([]),.(:-(read_file(_1410,_1430),,(see(_1410),,(read_all(_1430),seen))),[])))
Indeed, infix operators have been placed in prefix form like every other predicate (indeed, they are not special, just a parsing trick). Another "useful" predicate (not standard) is portray_clause/1, in order to do some "pretty-printing":
?- read_file('read_all.pl', [H|_]), portray_clause(H).
read_all([A|B]) :-
read(A),
A\==end_of_file, !,
read_all(B).
The assert family of predicates can “store” into the Prolog database facts (this is very common, in fact, memoization is often implemented this way) and rules (this is done less frequently – and there may be a slight efficiency penality [CHECK]). Thus we can manipulate terms (indeed that is what Prolog is about) and load them as programs. Notice that I showed the read predicate only to show that “standard” Prolog programs are represented that way, but it is not necessary at all to use programs saved in files.
4 ?- assert((foo(X) :- bar(X), \+ baz(X))). true. 5 ?- assert(bar(1)), assert(bar(2)), assert(baz(2)). true. 6 ?- foo(X). X = 1 .
Monday, June 7, 2010
PDF and other tragicomical histories
In fact, I did not think the thing would have gotten tricky (ah, how naive!). Word 2007 has a nice "save to PDF" menu item and I thought I could use that to solve my problem. Luckily enough, I double checked the generated PDF on the Mac. And, apparently, all the bold fonts were substituted with another font. I already mentioned this in a post earlier today.
This is completely illogical since the font was Times New Roman and I have Word on the Mac as well, which would install a lot of additional fonts, even if TNR was not that standard. So I searched for a Windows PDF creator (which, by the way both OS X and Linux-based desktop programs have). I found a bunch of them, some commercial, some free, some open source. My choice was PDFCreator.
Some reasons are: i) it is free as in free beer, ii) it is free as in free speech, iii) had no ads, iv) is based on the same softwares I happily used with Linux. Of course, reason i) was paramount: I had no intention to buy a stinking PDF creator for Windows unless it is absolutely necessary (which may be). The other three reasons have to be considered together: I searched google for suggestions, but I had no clue on which one was supposed to be better.
Usually the only problem with open source software is lack of support/user friendliness. However, that was not the case of PDFCreator. Unfortunately, for reasons beyond my comprehension, the generated pdf completely screws[0] a TIFF picture I put in the document. The same picture is perfectly fine in the PDF generated with word built-in generator. I tried to include in word a PDF, but that did not work either (the PDF was linked, but not visible -- nor printable --). Amazingly, Word for Mac is capable of using PDF image files, IIRC.
Perhaps, I should have tried more generators. I went home, opened Word for Mac, double checked that the formatting was fine (which was not, but I could fix it in little time) and simply printed to PDF. The PDF is perfect. This goes under: how to completely waste a Monday morning.
Footnotes
[0] This is a technical term, essentially it looked like it had low resolutionA matter of homoiconicity
References
- McIlroy, M. D. 1960. Macro instruction extensions of compiler languages. Commun. ACM 3, 4 (Apr. 1960), 214-220. DOI
- MOOERS, C.N. TRAC, a text handling language. Proc. ACM 20th Nat. Conf. Cleveland, Aug. 1965, pp. 229-246.
- Not meant to be offensive… perhaps old could be replaced with ancient?
Using word to write...
Why is the bibliographic tools such a joke that almost everybody does it by hand (and, moreover, many conferences explicitly tell you to do it by hand? and the W2007 implementation is not compatible with W2003 – at least that is the opinion of W2007 on that matter)
And using images is a PITA. But that is a PITA with Latex as well. Last but not least, I have yet to understand why a PDF created with word for windows visualize bold characters (I'm following the IEEE template, so changing the font is not an option... besides, it's times new roman) with a *different* non-bold font when opened on the Mac. If it were not such a standard font I would have said it's a matter of not including the font.
Thursday, June 3, 2010
Yet another C++ unit-testing library (nano-unit++)
Goals: be easy to use, be easy to install
Right now, it does less than needed. However, I plan to add features as I need them. Besides, I want to make it as DRY as C++ allows, even at the cost of fighting with template metaprogramming.
However, I hope I won't need boost, as it would be a rather important and expensive dependency.
Friday, May 28, 2010
Dropping Perforce
Essentially, there are no faults in Perforce I was not aware of or some other problem inherent with Perforce. I just found out I’m far more productive with other tools.
The first problem is typical of my setup and has nothing to do with Perforce: my home server connection is faulty. Sometimes there is no way to access the server from outside and sometimes the 1666 port is not reachable because of firewalls. Of course, it is not Perforce fault: in this situations it is often the case I could not reach 22 as well (that is the port I use mainly with both git and mercurial through ssh). However, I’ve been able to place the repositories on an external server (where I can’t just install the Perforce server) and I could always use github.
The main advantage with both Mercurial and Git is that if I have connection problems, I can just go on and work locally. Perforce simply sucks in this situation. By the way, when I’m travelling it is quite frequent I’m offline. Both git and mercurial allow me to work with no burden added.
Perforce uses a model different from other modern Source Control Management Systems (SCMSs) which somewhat resembles old locking SCMSs. Essentially, if you have to edit a file you have to mark it for editing. This can have several advantages, however, I never got used to it. Moreover, since I used it to manage .configuration files in my home directory as well, to change a single bloody line of code I had to:
- cd to the Perforce workspace directory
- mark the file for editing
- edit the file
- commit
Moreover, with my desktop computer, my apple laptop, my netbook (dualboot win+lin) and a workstation I had to test some software I already used all the workspaces the free version of Perforce allows me to have. This is rather unfortunate, as I often use virtual machines as well. Of course paying the bloody perforce license to do this kind of things is just stupid.
In the meantime, I found that distributed SCMs had none of those problems. Backup is regularly performed by Time Machine, so that was not an issue either, as long as I keep a clone of each repository on my MacPro. Moreover, the remote server where I keep some projects is very well managed and thoroughly backed-up.
I like the branching/cloning strategy superior (according to my needs) than the integrate stuff Perforce uses. I suppose we can prove them equivalent, however, I like git/mercurial better. I also changed my view on rebase and other commit editing stuff. Sometimes, I find them useful. After all it is my repository: I’m free to screw it up. This does not mean I will or should.
So I stopped moving projects from Mercurial to Perfoce. On the other hand I’m using git to extract projects from Perforce (git-p4, in fact). Well, it works nice. I will keep my Perforce server only for historical purposes, as imported git-p4 project may lose some branching information.
[0] Actually you can manually set an option in order to override the thing
Sunday, May 23, 2010
Back in Black 2
I completed a M.Sc. in Computer Science (in 2 years and 2 months, research dissertation included, which is something rare in my former). Two days after I graduated, I won a scholarship to attend a Ph.D. Course in Information Technology here in Parma, in the Dipartment of Computer Engineering.
This blog "re-edition" is kind of an experiment. Don't know if I have the time to write regularly here, nor if I like this platform. Essentially, I would have preferred a least web oriented platform (that is to say, writing posts offline). Blogspot should support this (I did import some of my old posts this way). Howerver, it seems that all of them can be imported. I don't really know why.
I also tried to write my own blog platform. Lack of motivation doomed this projects to failure. Moreover, I would need a rather costly high quality hosting which, by now, is an overkill as I can place massive amounts of data both on mobile me (public.me.com/enricofranchi) and on Dropbox.
I considered mobileme as a host, however, I would have limited choices on the platform (static HTML only). Rapidweaver/iWeb are not my cup of tea, either.
Thus, I chose an online blogging platform. As I already have lots of stuff with Google and I severly dislike Wordpress, I moved the whole thing here.
Thursday, April 9, 2009
Perforce Conversion?
I’ve always been critical on user interfaces. In two different senses.
Bad user interfaces drive me crazy: I think designing crappy user interfaces should be a criminal offence.
On the other hand, I’ve always been on the “command line side” when speaking about development tools.
Of course I use graphical editor (gvim is a graphical editor, and Emacs as well). But the center of my development is the shell. From the shell I call the editor, from the shell I run the build tools, etc etc etc. That’s to say I’m pretty “against” bloated IDE’s, even though recently I started some serious experimentation with Emacs, but that’s wholly another story.
Back to SCM I recently took some SCM classes (a whole course on source configuration management, indeed). And during the course, we had some lab exercises with Perforce. I never used Perforce before that: I knew there was this Perforce thing which was better than CVS but costed lots of $$$ and was closed source and if you used that you were almost as evil as if you used Windows.
In the meantime I got bore with the free software movement, started using the Mac (which is almost as evil as Microsoft) and lots of proprietary software which makes my life far easier. However, many teams switched to subversion (which is far better than CVS as well) and some times later I experienced the distributed SCM revolution. I started with git which I rapidly dropped favouring Mercurial.
Using Perforce seemed to me quite anti-climatic, in this sense. But Perforce had something I always desired in SCM tools. That is to say a very good graphical interface. Especially for version graphs. And a graphical merge tool. An integrated graphical merge tool, so that you don’t have to find one when on Windows, for example.
Moreover, branching is a breeze. The integrate command is something wonderful. Indeed I never used that much branching in my home projects. Now I just can’t thing how could I do without it. In this sense, the GUI is rather didactical: I just can explore menus and commands and learn new functions of my tool.
Moreover, installing the server is really easy (differently from subversion). And my dyndns powered machine can host all my work. Very interesting indeed.
I forgot to mention: as long as I use less than 2 users, I can use the Perforce server for free. Since they are my own projects...