You are currently browsing the category archive for the 'Mac' category.
I’ve always been one of the (not so) few geeks who run Linux on PowerPC.
Sometime ago, Linus himself was one of us, however, it appears that now
he uses a different machine.
Since Apple dropped PPC, the Linux PPC world is quite in turmoil. The architecture is perceived as almost dead. However, new interest comes from the Linux on PS3 projects.
In any case Ubuntu dropped official support for PPC. That was a sad piece of new, since I was quite satisfied with it. I had to recompile the kernel in order to fully support my machine (but this would have been solved in successive releases).
I got back to Debian. I’ve been a Debian user since Woody, and I liked it ever since. I was a Debian unstable user, and I have always been satisfied with it. However, this time it was different. I’ve had many more troubles: each upgrade broke something I needed.
I don’t know if it’s a matter of developers paying more attention to Ubuntu or whatever: the point is that using Debian unstable as a ‘reliable’ desktop system on power pc seemed quite hard. I don’t want to blame Debian developers: it’s unstable. No warranties. I used it at my own risk.
Since Debian is unsuitable for my present needs (no hassle, no config, no time), I considered switching Yellow Dog. I know that these days a PPC community mantained version of Ubuntu has been released.

I bought a Yellow Dog Enhanced account, since I did want to support their work and I was interested in support, if something was not perferct in the first place. Remember, no time.
I installed the distribution from the DVD. My hardware was entirely recognized correctly. From the soundcard to the backlit keyboard. My video card should also work with dual head, though I haven’t tried it yet. YD comes with a nice GUI to do this.
The only thing that was not working was the airport card. I just had to get the fwcutter and extract the firmware. Then it worked. Moreover, the network applet that stays in the notification area works great. I don’t know why, but in Debian and Ubuntu for some reasons it did not work properly (in Ubuntu from a certain moment the whole network-manager stopped working). I did not investigate as I needed less time to write a couple of shell scripts to configure the network interfaces when I needed to switch.
I have always been skeptical about rpm-based distros. Once I used SuSE, but after using Debian I got somewhat convinced of the superiority of the Debian packages. More accurate studies on rpm done recently seem to go in another direction: it was not that deb is better than rpm. It is just that deb repositories were maintained more carefully.
YellowDog repositories are maintained quite carefully. However, there is not a lot of software. I suppose something like 1000 packages (Debian has got ten times that). So I had to learn how to cook my own rpms or simply build software from sources and install it with make install. This is probably the major drawback. However, I’m pretty satisfied with Yellow Dog.
Although some tips are clearly wrong (e.g. having wrong permissions causes problems, it may even prevent some applications from working, but clearly has no impact on performance), most of them are useful and interesting.
After such a long title (mainly for tagging reasons) I suppose I have to write a long article.
One of the things I didn’t really like about Ubuntu standard configuration, was the track-pad.
In fact, although correctly recognized (using the synaptics Xorg driver) default was really poor: the mouse moved so slowly it was unusable. For the first hours you can use an external three button mouse and live happily. However, I wanted to fix my track-pad. I found some articles on the net.
There are plenty of blog posts on this subject and if you use synaptics as a key you find even more. This is a good starting point. However, I strongly advise to read synaptics manual (man synaptics). It is synaptics with a trailing s, not synaptic, the package manager.
If you read the manual, you get a lot of informations about how to configure your trackpad. You also have some GUI configurators (gsynaptics, ksynaptics, qsynaptics). They offer less
Options (but are easier to use).
While I was able to set tracking speed and acceleration correctly (mainly using the link I posted) I’m still somewhat unsatisfied with scrolling facilities. Two finger scroll does not seem to work, and edge scrolling (using the edges of the trackpad to scroll) is far from perfect.
The best thing is that I can use tapping to emulate buttons. Tapping in the right upper corner is a middle click and right lower a right click. Now I can use the powerbook without an external mouse.
I’m to post my xorg.conf. And remember… using ‘radeon’ codecs instead of ‘ati’ should be a good thing (I’ve not investigated, I only read it somewhere)
My XOrg:
# /etc/X11/xorg.conf (xorg X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the /etc/X11/xorg.conf manual page.
# (Type "man /etc/X11/xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
# sudo dpkg-reconfigure -phigh xserver-xorg
Section "Files"
FontPath "/usr/share/X11/fonts/misc"
FontPath "/usr/share/X11/fonts/cyrillic"
FontPath "/usr/share/X11/fonts/100dpi/:unscaled"
FontPath "/usr/share/X11/fonts/75dpi/:unscaled"
FontPath "/usr/share/X11/fonts/Type1"
FontPath "/usr/share/X11/fonts/100dpi"
FontPath "/usr/share/X11/fonts/75dpi"
FontPath "/usr/share/fonts/X11/misc" # path to defoma fonts
FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
End
Section "Module"
Load "i2c"
Load "bitmap"
Load "ddc"
Load "dri" #
Load "dbe"
Load "extmod"
Load "freetype"
Load "glx"
Load "int10" #
Load "record" #
Load "v4l"
Load "type1"
Load "vbe"
End
Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "it"
Option "Xkb
Options" "lv3:ralt_switch"
Option "XkbVariant" "nodeadkeys"
End
Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "Device" "/dev/input/mice"
Option "Protocol" "ExplorerPS/2"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "true"
End
Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "CorePointer"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "SHMConfig" "true"
Option "MinSpeed" "0.30"
Option "MaxSpeed" "1.10"
Option "EdgeMotionMinSpeed" "200"
Option "EdgeMotionMaxSpeed" "200"
Option "FastTaps" "1"
Option "MaxTapTime" "100"
Option "AccelFactor" "0.030"
Option "HorizScrollDelta" "0"
Option "VertTwoFingerScroll" "1"
Option "HorizTwoFingerScroll" "1"
Option "CircularScrolling" "1"
Option "CircScrollTrigger" "0"
Option "FingerLow" "1"
Option "FingerHigh" "3"
Option "LeftEdge" "80"
Option "TopEdge" "80"
Option "RightEdge" "850"
Option "BottomEdge" "560"
Option "TapButton1" "1"
End
Section "Device"
Identifier "ATI Technologies, Inc. RV350 NP [Mobility Radeon 9600/9700 M10/M11]”
Driver “radeon”
BusID “PCI:0:16:0″
Option “UseFBDev” “true”
End
Section “Monitor” Identifier “Generic Monitor”
Option “DPMS”
End
Section “Screen”
Identifier “Default Screen”
Device “ATI Technologies, Inc. RV350 NP [Mobility Radeon 9600/9700 M10/M11]”
Monitor “Generic Monitor”
Default
Depth 24 Sub
Section “Display”
Depth 1
Modes “1280×786″
End
Subsection “Display”
Depth 4
Modes “1280×786″
End
Subsection “Display”
Depth 8
Modes “1280×786″
End
Subsection “Display”
Depth 15
Modes “1280×786″
End
Subsection “Display”
Depth 16
Modes “1280×786″
End
Subsection “Display”
Depth 24
Modes “1280×786″
End
End
Section “ServerLayout”
Identifier “Default Layout”
Screen “Default Screen”
InputDevice “Generic Keyboard”
InputDevice “Synaptics Touchpad”
InputDevice “Configured Mouse”
End
Section “DRI”
Mode 0666
End
Recently I had to install a GNU/Linux system on my notebook. My
work-group is heavily Linux-based and the software which I’m going to
use/extend for my thesis at the moment compiles only on Linux (and
probably on BSD, however, not on MacOS X).
Although it’s a Prolog
software some parts are written in C++ and I haven’t had time to make
it work on MacOS X. Modifications are quite trivial (it’s a matter of
building a dylib). However, I should port the build system to libtool
to make it work on both platforms.
So I decided to install a GNU/Linux distribution. My first choice was Fedora. I’m not particularly fond of RH little sister, but that is the first choice in my team. The PPC version quite sucks. It’s not that things do not work: simply it seems just a bit more than a recompilation of the x86 version. For example package pbbuttons (that makes multimedia keys of my pb work, wasn’t even on the repositories).
It’s not that I particularly want to have the buttons working: it is like those who built it never used it. I mean no one ever tried to use it on a notebook? Moreover, it’s painfully slow. Six minutes to boot. To start some applications (Emacs, the gnome ‘quick’ disc burner, etc) it takes minutes. This does not happen on the x86 version.
Partitioning
So I tried Ubuntu 6.10. It’s heaven. Everything worked without my intervention. Well, almost everything.
The live CD did not recognize properly my screen. It thought it was a 20000×30000 pixel screen (and of course that was *wrong*): I just had to fix that manually. After booting the live CD, I started the installation. Everything went quite smoothly. Details in next posts
Very nice Halloween icon…

This screensaver is simply black.
(… following text is my answer to a usenet post ..)
I wrote a test function that makes various speed-checks. The number I
report are in Rosetta emulation, but it does not matter, since they are
“good enough” and the point is not to bench RB against other “native”
languages, but to test RB against itself.
However, running in Windows gaves about a 2x improvement respect to
Rosetta code.
All loops involve 1000000(10e6) iterations (double loop make 1000 * 1000
iterations). I also tried with 10000000 (10e7) iterations and it took
about 10 times more than the 1000000(10e6) iteration. That is to say
bechmarks are linear with number of elements (as expected). I didn’t try
bigger values as it involved paging, thus making quite useless the test.
The first one is a void loop. It takes 0.09 seconds on my MacIntel.
Then I made a double void loop. It takes the same time. That is to say
using two nested for does not take more time.
Then I made a simple loop that copies a variable into another variable.
This runs in 0.17 seconds. Good.
The third loop puts in the variable array elements. 0.17 seconds. The
same. So arrays are well optimized: accessing an element of an array
takes the very same time than accessing a single variable.
I then tried using two dimensional arrays: we get to 0.22 seconds. So
this is slower, but not a *lot* slower (even if for large objects this
+33% can make the difference).
And then memory blocks. I was surprised: 0.3 seconds. It seems that
using memory blocks is slower than using arrays (and in fact there is a
rationale behind this: a lot of people use arrays to store large amounts
of data, they *must* be ultra optimized. I think that MemoryBlocks are
used more often in a different fashion).
#pragma DisableBackgroundTasks
#pragma DisableBoundsChecking
Const LoopSize = 1000000
Const SmallerLoop = 1000
Dim void_start, void_end, arr_start, arr_end As Double
Dim var_start, var_end, mat_start, mat_end As Double
Dim block_start, block_end, dvoid_start, dvoid_end As Double
Dim var As Double
Dim value As Double = 1.0
Dim arr(LoopSize) As Double
Dim mat(SmallerLoop, SmallerLoop) As Double
Dim block As MemoryBlock
for i As Integer = 0 to UBound(arr)
arr(i) = value
next
for i As Integer = 0 to SmallerLoop
for j As Integer = 0 to SmallerLoop
mat(i, j) = 1.0
next
next
block = NewMemoryBlock(LoopSize *
for i As Integer = 0 To (LoopSize-1) * 8 Step 8
block.DoubleValue(i) = 1.0
next
void_start = Microseconds()
for i As Integer = 0 to LoopSize
next
void_end = Microseconds()
MsgBox "Void loop(" + Str(LoopSize) + "): " + Str((void_end - void_start)/1000000)
dvoid_start = Microseconds()
for i As Integer = 0 to SmallerLoop
for j As Integer = 0 to SmallerLoop
next
next
dvoid_end = Microseconds()
MsgBox "Double void loop(" + Str(LoopSize) + "): " + Str((dvoid_end - dvoid_start)/1000000)
var_start = Microseconds()
for i As Integer = 0 to LoopSize
var = value
next
var_end = Microseconds()
MsgBox "Var loop(" + Str(LoopSize) + "): " + Str((var_end - var_start)/1000000)
arr_start = Microseconds()
for i As Integer = 0 to LoopSize
var = value
next
arr_end = Microseconds()
MsgBox "Arr loop(" + Str(LoopSize) + "): " + Str((arr_end - arr_start)/1000000)
mat_start = Microseconds()
for i As Integer = 0 to SmallerLoop
for j As Integer = 0 to SmallerLoop
var = mat(i, j)
next
next
mat_end = Microseconds()
MsgBox "Mat loop(" + Str(LoopSize) + "): " + Str((mat_end - mat_start)/1000000)
block_start = Microseconds()
for i As Integer = 0 To (LoopSize-1) * 8 Step 8
var = block.DoubleValue(i)
next
block_end = Microseconds()
MsgBox "Block loop(" + Str(LoopSize) + "): " + Str((block_end - block_start)/1000000)
block_start = Microseconds()
for i As Integer = 0 To (LoopSize-1)
var = block.DoubleValue(i*8)
next
block_end = Microseconds()
MsgBox "Block loop(" + Str(LoopSize) + "): " + Str((block_end - block_start)/1000000)
Since I’ve been asked to do it, I wrote the “Open in iTerm” app, that does the very same thing than “Open in Terminal” (except that it uses iTerm instead of Terminal.app)
Actually there could be bugs, but at least on my system I suppose it’s not my fault, but rather it is iTerm that crashes a lot (maybe the AppleScript part has not been tested extensively on intel macs).
If you experience problems, let me know.
The script part that accesses iTerm is
tell application "iTerm" activate set myTerm to (make new terminal) tell myTerm set mySession to (make new session at the end of sessions) tell mySession exec command "/bin/bash" write text "cd \""& myPath &"\"" end tell end tell end tell
I bundled both apps in the very same package, and you can download it here.
I upgraded this script too with Marco’s help.
on run tell application "Finder" to try set myPath to quoted form of ¬ POSIX path of ((target of window 1) as string) on error set myPath to "~" end try tell application "iTerm" activate set myTerm to (make new terminal) tell myTerm set mySession to (make new session at the end of sessions) tell mySession exec command "/bin/bash" write text "cd "& myPath end tell end tell end tell end run
Definitive?
After some discussion on icm and the help of tv and Marco (thank you guys) we came to this
on run
tell app "Finder"
try
set myPath to quoted form of ¬
POSIX path of ((target of window 1) as string)
on error
set myPath to "~"
end
set esiste to ((count (get ¬
name of every application process ¬
whose creator type is "ITRM")) is not 0)
end
tell app "iTerm"
activate
if esiste then
set myTerm to (make new terminal)
else
set myTerm to the first terminal
end if
tell myTerm
make new session at the end of sessions
tell the last session
exec command "/bin/bash"
write text "cd " & myPath
end
end
end
end
This is a trivial AppleScript
tell application "Finder"
set targ to target of Finder window 1
set myPath to POSIX path of (targ as string)
end tell
tell application "Terminal" to do script "cd \""& myPath & "\""
Here you can see a couple of screenshots.
If you want to download the application (with pretty icon) that uses it, you can download it from here.
Edit: Thanks to Marco Balestra for showing me his own script (that does the same thing, but is much cleaner). Now I included his script instead of mine.
on run tell application "Finder" to try set myPath to quoted form of ¬ POSIX path of ((target of window 1) as string) on error set myPath to "~" end try tell application "Terminal" do script "cd " & myPath activate end tell end run
This is a tiny Automator Workflow that opens the current Safari document with BBEdit.
Previously I wrote an AppleScript that did the very same job, however the new document was marked as “new”, thus when one tried to close it, BBEdit would complain and ask if we wanted to save
tell application "Safari"
set cur to document 1
set mySource to source of cur
set myName to name of cur
end tell
tell application "BBEdit"
set x to make new text document with properties ¬
{contents:mySource, name:myName}
activate
end tell
However if we use the automator action “New BBEdit Document”, it offers the possibility to “Set unmodified” (that is to say the new document won’t ask if it has to be saved before closing).
I created a two step Automator workflow. The first step is a slightly modified version of the first part of the script. It is a “Run AppleScript action” containing
on run {input, parameters}
tell application "Safari"
set cur to document 1
set mySource to source of cur
set myName to name of cur
end tell
return mySource
end run
The second step is the “New BBEdit Document” action.
You can download the workflow here. I sugest to put it in the script menu.
I have just compiled a Texniscope version for Intel.
It works for me, tell me if it works for you too.
I have just finished my first autotools project on the MacOS. Until today I deployed software only in Python or Java. I already worked on C and C++ projects that used libtool and automake and autoconf, but I had not to write the configure scripts myself or I developed them on GNU/Linux.
In fact I’m afraid most of the problems I encountered was MacOS X fault + my ignorance. That is to say libtoolize does not exist: it is called glibtoolize. So if I do not rename it, autoreconf simply does not work.
Probably I just had to set the LIBTOOLIZE environment variable to glibtoolize. However my solution works. The error I got was
Can't exec "libtoolize": No such file or directory at /opt/local/share/autoconf/Autom4te/FileUtils.pm line 288, <GEN3> line 3.
autoreconf: failed to run libtoolize: No such file or directory
Well… I’ve to fine tune it. I go.
Some time ago I stated multitasking of Mac OS X Intel was bugged. Under some conditions (which at the time I hadn’t discovered) the GUI hung (something I never saw on tre MacOS before) and all the system slowed down terribly.
Computations
I anticipate here: the problem I found is real. MacIntel seem to have problems when large quantities of RAM are allocated. It is not a problem with the scheduler. In fact the system simply slows down as a whole.
The fist thing I did was to write a simple program trat stressed CPU and made a lot of I/O and at tre same time allocated and deallocated small quantities of memory in a quite inefficient way. However tre system was not slowed in any perceptible manner.
this is tre post where I spoke about trat program.
Here I add some benchmarking. Now I have to describe tre machines involved. Of course tris not a PPC vs. Intel bench. Unfortunately tre most powerful PPC machine is a notebook, and we can’t expect to compete with the iMac. What I want to show are tre relative values between them.
Machines
| Model | CPU | Clock | RAM | Bus | Hard Disk |
|---|---|---|---|---|---|
| PowerBook G4 | G4 (Single Core) | 1.5 GHz | 512 MB | 167 MHz | 5400 rpm |
| iMac CoreDuo | Intel CoreDuo | 2.0 GHz | 1.5 GB | 667 MHz | 7200 rpm |
big_matrix
This the test I described here
I compiled the test with no optimizations. This is probably a mistake.
The full test on the iMac took more than twenty minutes (matrix 500×500). The Mac was usable and had no slowdowns:
time ./big_matrix
real 20m39.110s
user 12m10.943s
sys 7m46.112s
Reducing the matrix size to 100×100 with no optimization the result is
time ./big_matrix
real 0m9.683s
user 0m5.805s
sys 0m3.688s
Compiling with the -fast option did not change things much, nor did -O3 or -Os (as I said the code was intended to be quite inefficient, I’m not surprised compilers weren’t really able to optimize). However explicitly activating -mmmx -msse -msse2 -msse3 gave a little improvement (about 5%, that could even be a statistical variation).
As I said before the most important thing is however achieved: the mac remains perfectly usable.
For those who are interested in this sort of things, the powerbook took about an hour and an half. However optimizations improved speed by a full 10% (which is quite acceptable, indeed). However I’m sad it performed so badly. I should investigate why altivec did not work properly (If it did, I suppose it should do something more that 4 times and more slower than the Intel).
Keep in mind that my software wasn’t designed to work on multiple threads (This could be an interesting addition, thought). However the system kept on swapping it between the two cores, avoiding many possible optimizations.
Wonderings…
Now only very large allocations remained to do. So I wrote this small (idiotic) software.
Basically it takes a filename as a command line argument, finds out the dimension of the file with a stat syscall, allocates enough space to hold it and then fills the buffer. If the file is big enough this (a part from being terribly inefficient) allocates a lot of RAM.
I called it on a 985 MB file (that means the software allocated 900 MB of real memory, since it is not only allocated, but filled too).
$ ls -lh ../../Desktop/Ubuntu_510.vpc7.sit -rw-r--r-- 1 riko staff 985M 12 Feb 03:13 ../../Desktop/Ubuntu_510.vpc7.sit
The file is loaded correctly and this is the time bench.
$ time ./load_file ../../Desktop/Ubuntu_510.vpc7.sit
real 3m31.010s
user 0m0.001s
sys 0m4.062s
This value is really variable. Another time it took only 1m42s.
And… the Mac slowed down. I know that such a program is idiotic. However it was one of the quickest way to understand how behaves the iMac when someone needs a lot of RAM (this could be a memory leak, for example).
In fact in some cases the mac remains slowed down for a while, until RAM is truly released and other processes are paged in.
#include#include #include #include #include #include #define BUFFER 2<<22 int main(int argc, char *argv[]){ char *mem; int fd; size_t pos = 0, res=0; off_t sz; struct stat st; stat(argv[1], &st); sz = st.st_size; mem = (char*)malloc(sz); fd = open(argv[1], O_RDONLY, 0); while( (res = read(fd, mem + pos, BUFFER) ) != 0){ pos+=res; } close(fd); free(mem); return 0; }
As you may notice, this makes no check on sanity of the buffer allocated by malloc. Don’t use it on a 4 GB file, it will probably crash.
When I run this very test on the Powerbook I was prepared that the results would have been terrible. In fact the powerbook does not have 1 GB free ram. It does not even have 1 GB RAM. It has only 512 MB. That means that allocating and filling 1 GB relies heavily on paging (and makes a lot of disk accesses to swap in and out pages of memory).
Keeping this in mind, the results have been quite good (and more stable, in fact sometimes the iMac performs worse than the pb, that has 1/3 the RAM.). I would like that someone with 1.5 GB or 2 of RAM would try this.
$ time ./load_file ../aks_old/nr.bkp
real 3m31.526s
user 0m0.002s
sys 0m7.728s
Moreover the file used was slightly bigger. So it took about the double of the time (keeping the best iMac performance) or quite the same time (keeping the worst), but with a very big hardware handicap. Astonishing. This can also be interpreted saying that something slowed down the iMac considerably.
I didn’t mention it before. Although slightly slowed, the PowerBook was quite responsive and usable during the test, while the iMac was not.
I/O Only
I rewrote the software above to read the file in a smaller buffer of memory instead of keeping it all in memory. This is the source code:
#include#include #include #include #include #include #define BUFFER 2<<22 int main(int argc, char *argv[]){ char *mem; int fd; size_t pos = 0, res=0; off_t sz; struct stat st; stat(argv[1], &st); sz = st.st_size; mem = (char*)malloc(BUFFER); fd = open(argv[1], O_RDONLY, 0); while( (res = read(fd, mem, BUFFER) ) != 0); close(fd); free(mem); return 0; }
The speedup is amazing.
$ time ./read_file ../../Desktop/Ubuntu_510.vpc7.sit
real 0m28.007s
user 0m0.001s
sys 0m1.472s
Some other times I got about 17s. I should investigate this variance. However, the system did not slow down at all and remained perfectly usable. That makes me thing the problem does not concern I/O, but memory.
The powerbook performed like this:
$ time ./read_file ../aks_old/nr.bkp
real 0m47.194s
user 0m0.002s
sys 0m3.833s
Memory only…
The last step is writing a stupid software that only allocates large chunks of memory. I made it allocate (and release) progressively larger chunks. First of all this demonstrates the issue does not regard memory leaks only.
Applications that allocate big quantities of RAM in large chunks are slowed. You can also see that the mac slows down (and the allocation time increases) the more the block gets bigger.
#include#include #include int main (int argc, const char * argv[]) { unsigned long size = 2; unsigned long i; int *mem; while(size * sizeof(int) 0){ mem = (int*) malloc(size * sizeof(int)); if (mem==NULL) break; printf(”Allocated %u bytes\n”, size * sizeof(int)); for(i=0; i I also wrote a version that only cycles through variables without allocating. It took less than half second to run, so it’s not cycling that
affects performance in the software. The first time I run it with not so
large chunks. The computer remained quite responsive. Then I run it with full chunks. And it was a hell. In the 1 GB allocation the computer was plainly unusable, not to speak about the 2 GB.However the machine was much more usable than in the I/O + memory test.
time ./memory_allocator Allocated 2 bytes Deallocated 2 bytes [SNIP] Allocated 536870912 bytes Deallocated 536870912 bytes real 0m43.940s user 0m9.196s sys 0m9.137stime ./memory_allocator Allocated 8 bytes Deallocated 8 bytes [SNIP] Allocated 1073741824 bytes Deallocated 1073741824 bytes Allocated 2147483648 bytes Deallocated 2147483648 bytes real 0m36.538s user 0m9.181s sys 0m8.851sSmall allocations
At this point I wrote a program that did smaller allocations. You can see that what matters is the quantity of ram allocated. The very same task, when the process has allocated more than 1 GB is significantly slower.
[Starting software] utime: 566 stime: 4198 [Allocated first chunk] utime: 20 stime: 30 [Populated first chunk] utime: 117010 stime: 558634 [Allocated second chunk] utime: 27 stime: 50 [Populated second chunk] utime: 132365 stime: 12 [Allocated third chunk] utime: 38 stime: 487 [Populated third chunk] utime: 229719 stime: 10 [Allocated fourth chunk] utime: 22 stime: 41 [Populated fourth chunk] utime: 228182 stime: 880172 * Freed first chunk. * Freed second chunk. * Freed third chunk. * Freed fourth chunk. utime: 79 stime: 2and the software was
#include#include #include #include #include #include void puts_rusage(){ struct rusage ru; static struct timeval slast = {0, 0}; struct timeval scurrent; static struct timeval ulast = {0, 0}; struct timeval ucurrent; getrusage(RUSAGE_SELF, &ru); ucurrent = ru.ru_utime; scurrent = ru.ru_stime; printf(”utime: %ld\t\tstime: %ld\n”, ucurrent.tv_sec - ulast.tv_sec, scurrent.tv_sec - slast.tv_sec ); ulast = ucurrent; slast = scurrent; } int main (int argc, const char * argv[]) { unsigned long size = 2<<26; unsigned long i; int *mem1; int *mem2; int *mem3; int *mem4; puts("[Starting software]"); puts_rusage(); mem1 = (int*) malloc(size*sizeof(int)); puts("\n[Allocated first chunk]"); puts_rusage(); for(i=0; i The last test should be throwing different processes that allocate a quite large chunk of memory and see how they slow the system (if they do — I suppose if you don’t keep them doing something, they will be paged out).
Conclusion
Definitely I think there is something is not in order with the memory management.
The scheduler seems ok. The same tests left the PowerBook usable, while the iMac wasn’t (however it took significantly less time in almost every task).
Those who do not like seeing high their CPU usage stats when doing things like networking, should consider buying a Mac Intel. However I think this is due to the tremendous raw power of these machines than to changes in how MacOS X deals with networking.
I’ve always said that to me it is OK if CPU monitoring tools tell that the CPU is doing heavy work even if the system is only downloading something from the net. In fact although CPU values are high, the system is fast as ever, so I wasn’t concerned.
Well, on MacIntel you don’t even see high CPU usage stats.
This is the first test to understand what makes my MacIntel GUI terribly slow when some software run.
I wrote a small C++ program on that purpose. It makes some operations on matrices, but it does them in a quite inefficient way. When we multiply two matrices, it creates two vector objects, allocates memory for them, multiplies them, stores the result, and destroys them.
Of course this is not what you would be doing when implementing a matrix library, but we are trying to understand which software bugs are more problematic on the MacIntel and aren’t on the PPC (in my previous post I told running some buggy sw on the Powerbook wasn’t an issue, but made the MacIntel almost unusable).
This software does a lot of computations (it multiplies two quite large matrices of “points” — structures of three doubles). Points use vectorial product. It does a lot of allocation and deallocation of small area of memory and I added I/O making it log the result each time it multiplies two points (that is a lot of I/O, since when we multiply two 500 element matrices it makes 500*500*500 point multiplications).
The verdict is positive. It is running right now (it hasn’t yet finished) but the computer is perfectly usable.
Now I’m going to write a software that allocates and deallocates large areas of memory and then one that leaks a lot of memory. I do think, memory leaks are the cause of the “GUI slowness”. However I still don’t understand why the powerbook (that has 1/3 the RAM my iMac has) had no troubles.
Here I post the source of this simple software. Keep in mind that this was designed to be inefficient (don’t use it, it sucks).
#include <cstdlib>
#include <iostream>
#include <ostream>
#include <fstream>
std::ofstream LOG;
struct Point{
double x;
double y;
double z;
Point() :
x(0.0),
y(0.0),
z(0.0)
{}
Point(double l_x, double l_y, double l_z) :
x(l_x),
y(l_y),
z(l_z)
{}
static Point random(){
Point p(
rand()/(double)RAND_MAX,
rand()/(double)RAND_MAX,
rand()/(double)RAND_MAX
);
return p;
}
};
std::ostream& operator<<(std::ostream& out, const Point& p){
out << "(" << p.x << "," << p.y << "," << p.z << ")" ;
return out;
}
Point operator*(const Point& op1, const Point& op2){
Point res(
op1.y * op2.z - op1.z * op2.y,
op1.z * op2.x - op1.x * op2.z,
op1.x * op2.y - op1.y * op2.x
);
LOG << res << std::endl;
return res;
}
Point operator+(const Point& op1, const Point& op2){
Point res(
op1.x + op2.x,
op1.y + op2.y,
op1.z + op2.z
);
return res;
}
template<typename T, size_t size>
class Vector{
public:
Vector(){
mem_ = new T[size];
}
Vector(const Vector<T, size>& o){
mem_ = new T[size];
for(size_t i=0; i<size; ++i){
mem_[i]=o.mem_[i];
}
}
~Vector(){
delete [] mem_;
}
T& operator[](size_t i){
return mem_[i];
}
const T& operator[](size_t i) const{
return mem_[i];
}
private:
T* mem_;
Vector<T, size>& operator=(const Vector<T, size>&);
};
template<typename T, size_t size>
T operator*(const Vector<T, size>& op1, const Vector<T, size> &op2){
T acc;
for(size_t i=0; i<size; ++i){
acc = acc + op1[i]*op2[i];
}
return acc;
}
template<typename T, size_t size>
class Matrix{
public:
Matrix(){
mem_ = new T[size*size];
for(size_t i=0; i<size; ++i){
for(size_t j=0; j<size; ++j){
get(i,j)=T::random();
}
}
}
Matrix(const Matrix<T, size>& o){
mem_ = new T[size*size];
for(size_t i=0; i<size*size; ++i){
mem_[i] = o.mem_[i];
}
}
~Matrix(){
delete [] mem_;
}
Matrix<T, size>& operator=(const Matrix<T, size>& o){
for(size_t i=0; i<size*size; ++i){
mem_[i] = o.mem_[i];
}
return (*this);
}
T& get(size_t i, size_t j){
return mem_[j*size + i];
}
const T& get(size_t i, size_t j) const{
return mem_[j*size + i];
}
Vector<T, size> col(size_t j) const{
Vector<T, size> v;
for(size_t i=0; i<size; ++i){
v[i] = get(i,j);
}
return v;
}
Vector<T, size> row(size_t i) const{
Vector<T, size> v;
for(size_t j=0; j<size; ++j){
v[j] = get(i,j);
}
return v;
}
private:
T* mem_;
};
template<typename T, size_t size>
Matrix<T, size> operator*(Matrix<T, size>& op1,
Matrix<T, size>& op2)
{
Matrix<T, size> res;
for(size_t i=0; i<size; ++i){
for(size_t j=0; j<size; ++j){
res.get(i,j) = op1.row(i) * op2.col(j);
}
}
return res;
}
int main(){
const size_t SIZE = 500;
LOG.open("log.txt");
Matrix<Point, SIZE> m1;
Matrix<Point, SIZE> m2;
Matrix<Point, SIZE> res;
res= m1*m2;
LOG.close();
}
Right at the moment (as you may have learnt from some of my previous posts) I’m working on numerical libraries. I’m developing a (hopefully) efficient version of the aks algorithm to test primality.
I’m not here to describe AKS, nor to describe multitasking or any particular algorithm. It is sufficient to say that they are programs that make extensive use of the CPU.
On my old Powerbook G4 when I run a CPU expensive task the GUI keeps responding. Of course the task uses a lot of CPU: opening a new application takes more time, and so other tasks do. However applications respond as usual. The computer is noy “hung”.
This is one of the things I love more of MacOS. The system remains usable even if under heavy stress. This is no longer true. My brand new iMac Core Duo simply becomes unusable. Applications do not respond (they reaction time can be counted in tens of seconds). This is plainly unacceptable. Of course this does not happen normally: it happens only with some software (and buggy software). However the very same program does not create problems on my Powerbook (the machine slows but remains usable).
This makes me think there is something in the scheduler that just does not work as expected and is fooled by some bugs in the software.
I want to make clear that well written software has’t this problem. I can run heavy compilations and have the CPU (both cores) 100% and the system is responsive as usual. It gets stuck when something goes wrong.
The software that hung the mac had bugs (it’s iper-alpha and I’m still working on it). But while the old MacOS X PPC responded to me relatively quickly (allowing me for example to kill the bugged software), the new MacOS X Intel seems to prefer letting the bugged software finish. The point is that those bug should not slow the system to that point (and in fact the PowerBook wasn’t slowed): they were just a couple of memory leaks.
Now I’m trying to develop a software that has the similar behaviour to the one I’m writing (that is to say uses lots of memory, lots of computation and lots of logging -> I/O), to see what of the three things that stresses more the system. Appearently it is memory.
edit: I just wrote a heavy computation/loging software. This has no troubles at all. You can read what does it do here
Anyway sorry for being allarmistic. I’m trying to figure out what the problem is.
A PPC Application

A Universal App

I have not yet found an Intel only Mac application.
Now we show some unix executables. The first one is a script.

This one is universal

and this is Intel Only

Of course you can build universal unix executables, as you’ve seen.
Good news. With gmp 4.2 assembly optimization works. That means that you can get decent performances. For values of decent that are *below* those of an old Prescott and just a bit better than those of a plain Pentium M with the same clock.
The problem is that (for example) you can’t run make check. This makes me thing something is broken. However, I can’t understand what. However I’ve been told that “MacIntels” are not supported by gmp-4.2 . So consider twice before buying a MacIntel if you need to work with gmp.
And you can’t use c++ too. For some reason there is an error with the generation of an assembly optimization. The answer from the developers has been “gmp-4.2 is not supported on MacIntels” (however I am not really able to consider this a solution to the problem, but unfortunately I’m not skilled enought to fix things by myself).
In fact the second core is not used at all, so this result is quite predictable. Moreover I used shared libraries instead of static ones (for the very good reasons that the guys at apple don’t ship the gcc with the static version of libgcc and of crt0.o, so there is no easy way to do it).
In the end I assume MacOS X on Intel is young and probably not as optimized as a FreeBSD (just to name one). These are the results:
iMac 2 GHz 2 GB
***** GMPbench version 0.1 ***** Using default CFLAGS = "-O3 -fomit-frame-pointer -I../gmp-4.2" Using default CC = "gcc" Using default LIBS = "-lgmp -L../gmp-4.2/.libs" Using compilation command: gcc -O3 -fomit-frame-pointer -I../gmp-4.2 foo.c -o foo -lgmp -L../gmp-4.2/.libs You may want to override CC, CFLAGS, and LIBS Using gmp version: 4.2 Compiling benchmarks Running benchmarks Category base Program multiply multiply 128 128 GMPbench.base.multiply.128,128 result: 9530908 multiply 512 512 GMPbench.base.multiply.512,512 result: 1150785 multiply 8192 8192 GMPbench.base.multiply.8192,8192 result: 12500 multiply 131072 131072 GMPbench.base.multiply.131072,131072 result: 228 multiply 2097152 2097152 GMPbench.base.multiply.2097152,2097152 result: 9.62 GMPbench.base.multiply result: 12463 Program divide divide 8192 32 GMPbench.base.divide.8192,32 result: 306090 divide 8192 64 GMPbench.base.divide.8192,64 result: 104119 divide 8192 128 GMPbench.base.divide.8192,128 result: 66800 divide 8192 4096 GMPbench.base.divide.8192,4096 result: 20668 divide 8192 8064 GMPbench.base.divide.8192,8064 result: 268859 divide 131072 8192 GMPbench.base.divide.131072,8192 result: 435 divide 131072 65536 GMPbench.base.divide.131072,65536 result: 242 divide 8388608 4194304 GMPbench.base.divide.8388608,4194304 result: 0.796 GMPbench.base.divide result: 5617.3 GMPbench.base result: 8367.1 Category app Program rsa rsa 512 GMPbench.app.rsa.512 result: 2755 rsa 1024 GMPbench.app.rsa.1024 result: 478 rsa 2048 GMPbench.app.rsa.2048 result: 72.6 GMPbench.app.rsa result: 457.26 GMPbench.app result: 457.26 GMPbench result: 1956
I had problems with almost all scientific libraries I tried.
gmp builds only if you use –host=none-apple-darwin. That means you are disabling assembly optimizations (and you probably wouldn’t want to . And that option was correctly set for plain gmp, but not for gmp-cxx-wrappers (Gregory Wrigh has no access to a Mac intel, now he should have fixed it).
cln is plainly broken. That means you can’t use GiNaC too. I think someone should buy cln’s developers a MacMini Intel.
If you want to use OCaml, you have to use a cvs special version, since the stable does not yet compile. The solution is here.
In fact I had lots of problems. The guys at darwin ports have been really nice (using dp is just the quickest way to install this kind of software), but there are *lots* of troubles. The same installation on my powerbook G4 went just fine (of course the took a lot to finish, but they did finish).
Portfile for ntl on MacIntel was broken too (now it’s fixed).
I have to admit I’m a libtool noob. However I know gcc and g++ 4.0.1 available with MacOS Tiger are able to compile c++ dynamic libraries. In fact this is done with flag -dynamiclib
However, gmp if configured with –enable-cxx and without disabling dyamic libraries fails. In fact it passes g++ the -shared option (that works for linux). If you compile plain gmp with no C++ support, the problem does not exist. I’m afraid it’s a bug with gmp libtool (I suppose you could fix it with autoreconf, but I did not try it).
Unfortunately I need c++ support since I have to work with ppl. The solution is to modify all occurrences of “-shared” in the configure file with “-dynamiclib“. And appears not to work.
The same hack worked with readline (but I’m afraid that’s because readline was written in C and somehow support for C dynamic libraries seems better on mac os x: I’d say “older”, so it’s more likely developers made it work.
However darwin ports is able to build it the correct way. You only have to specify somewhere that gmp-cxx-wrappers should build with –host=none-apple-darwin
Well… on my PB I recently installed Fink. It run smoothly. Fine. Here on my MacIntel I installed Darwin ports, since Fink is alpha on MacIntel.
DP is amazing. Works with no hassle and all. It’s main disadvantage is that it compiles everything (and that is not quite a problem, since I have a 2 GHz DC processor). Well, I have always been a DP fan (being a BSD fan)… and I have to say they have improved.
Of course (as soon and it becomes more mature) some may prefer to use fink. Not having to deal with compiling issues (that are really rare on DP indeed) can be an advantage (or at least a speed up). Moreover DP lacks a decent UI.
For a cl geek like me this is not an issue (I tended to use fink that way too). But if yoou are used to sparkling icons, it may not be for you.
Until now I almost never spoke about Intel Macs here. My feelings were twofold. The long time Mac user in me told me that using Intel processors was no good. The unix geek told me that many benefits could come.
Of course we know that IBM was not going to invest on G5 anymore. Apple had to switch. And I bought my first MacIntel. Good.
Fast is fast. The perceived speed against my Powebook G4 is astonishing. Applications load instantaneously: compilation is much faster (unfortunately I can’t compare this against a G5 iMac, so this is pointless).
Rosetta is fast enought to run Neverwinter Nights smoothly. Of course the game is quite old, but it’s a full 3d game. In fact I didn’t expect this to work. Moreover it means that NWN wasn’t G4 optimized…
Still I miss some utilities. I’m lost without WindowShade X. About the rest this is a wonderful machine. Go on with more tests.
I kind have to tell something about me, since it better helps understanding my position.
I chose MacOS X as my main developing platform. Of course it happens to write software meant to run on GNU/Linux (or other *nix flavours) or even on Win. Usually when this happens I’m using a cross platoform technology. I never wrote something longer than 100 lines with the WinAPI, for example.
Before I used GNU/Linux, fBSD and even before other unices (OSF1) and MacOS “Classic”. This is my background. I never quite got exposed to windows. So my point is unusual: most people come from windows to other platforms. To me is quite the contrary (a part that I don’t “go” to windows, I just happen to use it from time to time).
About programming environments, I’ve done (and do) lots of things. I like high level languages, such as Python or Ruby. I like ObjectiveC and Cocoa (of course this won’t be in our comparison…). But also do a lot of low level C coding with the POSIX api (well I did… right now I prefer to do it in Python), develope some software in C++, I’m going to graduate with a project in Prolog. I quite like XML and CSS and I also have to use some Java and some calculus (both Matlab and C — no, I don’t quite master Fortran)
So my skills are not particulary vertical (for example someone who does all his job in the XML processing fields, or numeric calculus). They range in many different fields (this does not mean I’m really “guru” in each of them, on the contrary I’ve got much to learn).
Editors
Basically those who work in the Linux community used to share in equal parts between Emacs and vim. There used to be some other editors (nedit), but that was the story. Recently I’ve seen a lot interest around IDEs (kdevelop, anjuta) and some “lesser” editors have reached the status of full programmer’s editors. Among these Scite and Kate, for example. Moreover HTML/web centric editors have also increased their popularity.
On the other side the Windows community has always been more IDE oriented. There were the Borland products, Microsoft Visual Studio, Wacom. The most used web environments were Dreameaver and Homesite (now builtin in dw).
Of course there were also a bunch of editors.
Linux pt. 1
If I have to work on Linux, I’ve got no problems of any sort. I’m average skilled both in vim and in Emacs and I can make it. I do use Aquamacs (an Emacs version) even on the MacOS: once I preferred vim, but right now I need some things Emacs has and vi hasn’t (a decent Prolog mode, for example).
Windows
About an year and an half/two years ago I had to develop an application with Twisted. For a 0-based array of reasons I used Windows as my main developement environment. I installed entought python (and in those times there was no Python 2.4, so no problem), I put Twisted 1.3 on the top of it and chose gvim. Gvim is beautifully integrated with windows. Of course it acts quite much like vim does (i don’t like the evim variant). I did it. Still I wasn’t using windows. I cloned my linux environment on Windows. And it is what I made when I had to code some C++ with mingw and so on.
I chose to use gvim not because I really wanted to, but because other editors were really priced or poor. Yes I tried scintilla too. Not particulary poor, of course not priced… but in fact too simple.
Windows and MacOS
If you compare the situation with the MacOS it’s tragic. MacOS has many “simple” editors that I do not really like (but some love SubEthaEdit or Smultron), but it has also BBEdit (the best web editing environment I’ve seen, much better than dreamweaver and priced 199$ - 129$ for TextWrangler users — TW is a free editor everybody can download and use ). And it has TextMate: the best general programmer editor a part from Emacs.
UltraEdit (Windows)
Recently I had to do some more work: I tried UltraEdit, priced 39 $. The same as TextMate. A couple of users said it is a wonderful editor and I gave it a try. Out of the box it did not support nor Python nor Ruby. Quite annoying in fact.
I googled the solution and I find I had to copy some strings in a file. The format is awful. Where TM has a lot of small bundles, BBEdit has plugins, UltraEdit has only this big flatfile. Ok. What matters is functionality.
But functionality is missing. For example Python or Ruby indenting is really disappointing. TextMate indents code back and forth to match the syntax of the code. It takes less time to try than to read. If you haven’t a Mac, Emacs does it.
TextMate also has lots of ways (and easy one) for saving me from typing lots of code. Snippets are poweful, and I also have commands (snippets are short words or commands that are expandend to full constructs with placeholders to fill in).
I find nothing like this (nothing that simple) in UltraEdit or in Scintilla. Not that Scintilla is not a bad editor. It correctly deals with a lot of languages, the syntax theme is clear and easily readable (I think I should do a “Scintilla Theme” for TextMate one day). With Python/Ruby it lets you run or check syntax directly from editor.
And UltraEdit (in the Studio Version) is a very good “tiny ide”-”enhanced editor” for Java, for example (but we are at 99$). Much better than BBEdit or TextMate in Java editing. It’s fast and has some useful basical functions. Of course Eclipse or NetBeans do a lot more stuff, but UltraEdit Studio takes a couple on microseconds to load.
I’ve not tried it with PHP and HTML (have I already said I don’t use PHP?), but it appears to be really good. I just can’t stand feature bloated IDEs like DreamWeaver. They tend to make the programmer not to think… but that’s another story.
The many windows editors
It could be a matter of taste. Another friend of mine who did a lot of coding in Windows suggested another text editor (I don’t even remember the name of the editor — I still remember my friend’s name of course). Probably among all editors out there (more or less shareware) there is the one that suits my taste (a part from the Emacs/gvim variants). Still everybody knows a good way to fuck up a windows installation is to install and try software (I know ghost, but it looks like I’ve no time to waste to play with software).
GNU/Linux pt. 2
Again… GNU/Linux is quite convenient in this sense. Emacs and vim are wonderful editors (and they are both free and free). They can be extended to do almost everything (think about Emacs mode to make it a Java IDE or the Auctex package).
They are both available for Windows and Mac, but additional packages are not as easy to install (on Debian is a matter of aptgetting…)
About the IDEs… well, KDevelop is told to be really good. Probably For sure it outperforms XCode, but should be not as good as MS Vistal Studio, even if it should support more languages (so if you need one of those…). So depends on what you have to do… anyway it’s a really good IDE, nothing to say… but
Windows pt 2
I tried some more editors. Notepad++ is nice (but not really suited for Python or Ruby: in this sense Scite is much better).
I tried Komodo, and it’s wonderful (and also cross-platform). The best thing it does are easy debugging and intellisense like for dynamic languages (tried with python and ruby, it should work with PHP and Perl too). Unfortunately the full version costs almost 300 bucks. If you don’t develop professionally you can buy the “personal or educational” version, that at 29$ is quite affordable.
Anyway some things in Komodo to me look quite akward, while TextMate is as easy as poweful. Of course comparing Komodo to TM in Rails editing is playing dirty. TM is the editor of choice of Rails developers. And Komode has that intellisense… well, I think it should be great (even if I didn’t really use it, so I think I’m not really gonna miss it).
I’ve seen there are a lot of targetted small IDEs that are worth trying, but I’m not gonna spend all my time this way.
Next time I’m gonna talk about databases
Stattoo è una piccola utility fatta da Panic. Uno dei più celebri prodotti di Panic è Transmit, a detta di molti il miglior client FTP per Mac (io personalmente sono affezionato a Fetch, che come studente posso avere in licenza gratuita e che ho usato fin dalla versione 1.x nei primi anni ‘90, ma i meriti di Transmit sono indubbi).
Un’altra applicazione di Panic è Unison, ottimo newsreader per gruppi binari (per i le discussioni francamente lo trovo abbastanza povero, ma si stanno attrezzando). Ad ogni modo, ora è il turno di “Stattoo”. Il prezzo è 12.9 $. L’applicativo stampa sul desktop alcune informazioni con una bella veste grafica.

Per ora sono disponibili:
- Ora
- Data
- Appuntamenti di iCal
- Ultime Mail di Mail o di un qualunque account pop/imap anche non specificato in Mail
- Lo stato di iTunes
- Lista degli ultimi software arrivati su VersionTracker
- Spazio occupato sui vari dischi
- Temperatura locale
- Stato della batteria
La maggior parte di queste features sono ottenibili in altro modo. Spesso con dei widget o dei programmi. Tuttavia Stattoo è molto più veloce di Dashboard e cerco di tenerci quanta più roba possibile.
Varrebbe la pena di comprarlo anche solo per i punti 3 e 4. E anche la batteria è comodissima. Inoltre si può “sollevare” Statoo in trasparenza sopra le altre finestre schiacciando un tasto.
La cosa che però mi ha fatto decidere definitivamente per l’acquisto è stata la professionalità. Ho inviato una email facendo presente che per la mia città (Parma) non era disponibile un codice areoportuale ICAO (per le città non-USA viene usato questo per identificarle) e quindi non potevo usare il modulo “Weather”.
In effetti non è che la mia città non avesse un codice ICAO, solo il sito da Panic consigliato per scoprire tali codici presentava solo il codice IATA (un’altra sigla, poco importa cosa siano effettivamente). Ho mandato una email per chiedere consigli, dicevo.
Un gentilissimo dipendente (o forse proprietario o programmatore) mi ha risposto dicendomi il codice ICAO della mia città. Ovviamente funziona tutto. Immagino che in caso di problemi (all’epoca non ero ancora registrato) siano altrettanto celeri. E questo deve essere il valore aggiunto delle piccole case software: idee, ben realizzate e rapporto “umano” con il cliente.
Credo di non avere mai decantato pubblicamente questo piccolo software. Lo registrai per la modica cifra di 10 $ (molto moderate. Quando un programma è buono e mi piace, lo compro, anche se è commerciale [ posto che me lo possa permettere ]. Questo è ancora più valido se si tratta di software di piccole case o singoli sviluppatori che mettono passione nel loro lavoro.
È il caso di TextMate di Allan Odgaard e di BBEdit (questa per esempio è una media software house che si dedica da anni a sviluppare ottimo software per Mac). È il caso di Yojimbo, sempre di BareBones (questo lo sto ancora valutando nei 30 giorni di prova). È il caso di GraphicConverter, che ho usato a sorti alterne credo fin dalla versione 1 sui miei vecchissimi Mac (e adesso uso in quanto la licenza viene pagata da Apple se acquisto un Mac di fascia “pro”). È il caso di MacSOUP (anche se ultimamente mi sto stancando di quanto poco sia “aquoso“, d’altra parte è uno di quei programmi che la licenza la paghi una volta e poi lo usi sempre).
Beh… fra questi ottimi software ci sono anche un paio di utility di Unsanity. Mi riferisco in particolar modo a FruitMenu e a WindowShade X. Dei due quello che uso più di frequente è senza dubbio il secondo. Altre utility interessanti di Unsanity sono ShapeShifter per cambiare il tema al MacOS e MenuMaster che sto valutando.
Window Shade X
Una delle cose che meno tollero di MacOS X è il dock. Lo trovo una brillante idea terribilmente sprecata. Al di la di ovvi problemi di coerenza di interfaccia (ad esempio al di la del separatore ci stanno finestre minimizzate, documenti, cartelle e cestino, mentre a mio avviso almeno le finestre dovrebbero essere da un’altra parte). Dicevo, le finestre da un’altra parte anche per ragioni di spazio.
Se si minimizzano molte finestre il dock si allunga e diviene quasi ingestibile. Questo problema viene risolto brillantemente da WindowShade X. Infatti permette di “minimizzare le finestre sul desktop: cosa intendo? Guardate l’immagine.
In questo modo posso facilmente minimizzare le finestre (posso anche spostarle sul desktop come fossero icone). Per esempio posso “rebindare” il pulsantino giallo per fare questo e continuare a minimizzare sul dock con Mela-M.
Per chi se lo stesse chiedendo… si, la minimizzazione sul desktop è simile a quello che fanno alcuni window manger sotto X11, per esempio twm [ ovviamente in modo oltremodo più raffinato, come si può vedere dall'immagine ] oppure il mio amatissimo WindowMaker. Triste che oggi ci si sia tutti o quasi omologati su sistemi molto più pesanti anche su GNU/Linux (senza nulla togliere a GNOME e KDE, solo meno “originali”, per come la vedo io).
Un’altra funzione davvero comoda (la maggior parte delle volte uso questa) è minimizzare una finestra alla sua barra del titolo facendo doppioclick sulla stessa. Questo c’era in MacOS 9 e Apple lo ha (stupidamente?) tolto in MacOS X. È qualcosa presente anche su molti wmanager per X11, metacity per citarne uno.
Il tutto coopera perfettamente con Exposè e rende lavorare con molte finestre davvero comodo.
Altre funzioni sono quelle di fare diventare trasparente una finestra oppure di renderla “floating” sopra tutto il resto (per esempio una chat, un player audio minimizzato, boh). Insomma… davvero geniale WindowShade X.
I first learnt about ObjectiveC and Open/GNUStep when I was basically a Linux user. That was quite a lot of time ago. I was a WindowMaker fan, and that was the way I learnt about GNUStep. However, I did not learn ObjectiveC nor GNUStep programming. In fact there was plenty of “wonderful” languages out there and I felt no need for another one. The few GUI applications I did were made with GTK1 and C (yes, GTK 2 did not exist yet and wx was not really widespread; the first time I installed Audacity on Slackware 8.1 I had to google for them) or Qt with C++.
I was quite skeptical with interpreted languages too: I knew a bit of Lisp (more for academic reasons than for “real programming” — that is to say I would not be able to write a piece of useful software; well, this isn’t changed, anyway) and quite a lot of Perl (still I did not use to do what I considered “serious work”: a few cgi and some system scripting). But I’m going off topic.
One day one of my friends showed me the Powerbook G4 and MacOS X (it was Jaguar, for those who care). After some time I bought my first Mac with MacOS X. Before being a Linux user I was a big fan of MacOS Classic (and the first machine I installed GNU/Linux on was an iMac), so I was really happy with the “new deal” of Apple. Still I planned to “install GNU/Linux as soon as possible”. In fact this never happened (but one of this days when I have time and airport support is stable enough…).
The first thing I did was to learn Objective C. I took a look at Carbon, but I wasn’t amazed. I read Apple’s guides about the language. They were clear and well done. Still to code GUI applications I needed a more detailed book (I’m kind of a perfectionist) since the Tutorial, although well done, is designed for absolute beginners. Anyway the Apple guide for the language ObjectiveC is here.
I still have no idea why I chose to learn it. In fact I was a “cross-platform gui”. I still thought I would use both systems, so having my own applications on both of them was probably quite desirable. Moreover the QT MacOS port was young (it was released a couple of months after I bought the Mac, IIRC).
In the same period I was learning Python too, and almost everything else (system tools, web sites, cross platform gui applications with awful Tk) was made with it. I found some similarities between the two languages (in fact I think they were more similarities between Python and Smalltalk, and only indirectly between Python and ObjectiveC). Still one thing was different. Python is a very high level language, but does not force you in anyway into some kind of framework.
In fact you can perfectly “translate” command line from C using the same POSIX APIs or, for example, “convert” a Qt + C++ program. The language Objective C in fact has the same properties. In fact I wrote a few command line utilities and found that the Foundation kit was a well designed environment that abstracted some POSIX interfaces. I quite liked it. And quite liked ObjectiveC.
The only thing I truly missed were namespaces (or analogue things). I spend a couple of days understanding the memory model and that was everything. I bought two books, “Cocoa in a Nutshell” (today I would not buy this) and “Cocoa Programming” by Anguish Buck and Yacktman. They were both good books. I do not use the Nutshell because Apple documentation is more recent today, not because it’s not well done.
“Cocoa Programming” is a “big” book. There are lots of infos. Some of them are advanced topics (for example there are Chapters about optimizations — you know, optimization hinders evolutions, but we want to run our software on something more portable than a mainframe).
The book focuses on how Cocoa was thought with Design Patterns (expecially those from the famous book), even if they change their name (and Anguish/Buck/Yacktman show which Cocoa pattern corresponds to a GOF pattern). I was already acquainted with DP, I read the “Design Patterns: EORSD” some time ago (and recently I bought the book and I’m reading it again). In fact Cocoa developing needs understanding of design patterns, but you can have a less theoretical approach to Cocoa.
I recently read Hillegass’s “Cocoa Programming for MacOS X” and that is what I mean. It’s more like a tutorial, but not as elementar as Apple one. It shows you some “real life” small applications that use key tecnologies. It shows Cocoa structure, main “patterns” (for example how to deal with a NSTableView — and introduces the concept of delegation).
While “Cocoa Programming” shows how much Cocoa can be powerful, Hillegass shows how much Cocoa is easy. There are many things that are not explained in the latter (even if it covers some topics I didn’t find in the other book).
You may need (you probably need) a book like Anguish/Buck/Yacktman’s “Cocoa Programming“, but I strongly advise to start with “Cocoa Programming for MacOS X“. It’s not recent, but it’s well done and complete. You can build a whole lot of applications reading it, and for example explains the Document Based Applications in a very simple yet complete way (for example in “Cocoa Programming” the authors implement classes that act quite like the NSDocument and friends to show you in details how it works, still I was not really able to understand how easy it is programming Doc-based apps with Cocoa; in fact I thought it was hard, since many explanation about how the “true” class works are embedded in the explanation of how to rewrite a subset of it.
Another reason for reading “Cocoa Programming for MacOS X” is its length. Much shorter than the other one, you can read it in less than a week, and dive into programming with more skills. Some useful subjects in “Cocoa Programming” are not at the beginning and you must already know you have to skip chapters and go and read them.
In fact I find the two books complement each other well. I’ve got a third book (well a fourth), but I’m not gonna speak about it this time.
- “Cocoa Programming” - Anguish/Buck/Yacktman
- “Cocoa Programming” for MacOS X” - Hillegass
La prima cosa che salta all’occhio è la nuova interfaccia. Più browser e meno “pacchetto integrato”. Di default ci viene mostrato solo il minimo indispensabile come si vede nello screen

Le classiche toolbar sono comunque tutte accessibili attraverso il solito Menu.
La prima cosa che faremo sarà caricare una pagina. Qui rimarremo sorpresi. La velocità è impressionante (sicuramente la velocità percepita). Anche il resto del programma rimane decisamente reattivo.
Alcuni binding sono cambiati (per esempio adesso per aprire un nuovo tab possiamo usare Mela-T/Ctrl-T come su Firefox e Safari, mentre prima, se la memoria non mi inganna, era Mela-Option-N, con eventualmente sostituito Mela da Ctrl se sotto X11 o Windows).
I bookmark sono stati importati in un batter d’occhio. Bene. Per posta e altro non mi esprimo, non sono funzioni che uso, preferendo di gran lunga programmi apposta, come Apple Mail e NetNewswire — newsfeed –).
Il problema più grosso temo sia *esportare* i bookmark. Passare da un altro browser ad Opera è facile, non altrettanto facile il contrario, purtroppo. L’ultima volta lo feci attraverso un servizio web esterno (questo) . Tale sito fra le varie cose offre un convertitore di file di bookmarks da e per moltissimi programmi diversi.
AJAX pare funzionare bene (a parte un problemuccio su Wordpress, qui, sulle immagini, ma cose “complesse” come per esempio l’editor di post WYSIWYG in javascript avanzato funziona decisamente bene).
Ribadisco… veloce, interessante. Vediamo Google cosa inventerà, perchè per adesso Opera 9 sembra una versione riveduta e corretta di Opera 8, ma non offre davvero quanto Firefox, ne è integrato come Safari.
Comunque da tenere sott’occhio senza dubbio.
The small script below uses PyObjC (it was born as a snippet in ipython to have a quick check to a pair of variables). Of course you can write the very same thing in ObjectiveC.
I strongly encourage to install PyObjC and ipython even if you do work with Cocoa and ObjectiveC, since you can use that to prototype your application and to test snippets of code.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import Foundation
ud = Foundation.NSUserDefaults.standardUserDefaults()
d = ud.dictionaryRepresentation()
for k in d:
sys.stdout.write(k)
sys.stdout.write(":\t")
try:
print d[k]
except UnicodeEncodeError, e:
print d[k].encode(’utf-8′)
To have more information on PyObjC (that is to say Cocoa bindings for Python), go here.
You can find ipythonhere. ipython in an improved interactive shell, with powerful introspection capabilities.
Since MacOS X Python by default comes with no support for readline, I advise to install the missing module for Python 2.3 (search google, I don’t remember right now where to find it) or better install this version of Python 2.4, complete with the patch (on the same page).
Of course you must set your path so that the “first” python is the new one (if you set PYTHON_ROOT and such, you must also fix them).
Remember when you “python setup.py install” a module (that is the typical command line to install a python package), it is installed for the python version called by default (find it out with which pyhon)
I just love it. Yeah… an old screen on my Mac.
| Key | Meaning |
|---|---|
| ctrl-q | Beeps. If pressed twice deletes selection. |
| ctrl-w | Cuts text |
| ctrl-e | Moves to end of line |
| ctrl-r | Beeps?? |
| ctrl-t | Swaps near characters |
| ctrl-y | Pastes text |
| ctrl-u | Beeps?? |
| ctrl-i | Beeps?? |
| ctrl-o | Insert new line after current |
| ctrl-p | Moves cursor to previous line |
| ctrl-a | Moves to beginning of line |
| ctrl-s | Beeps?? |
| ctrl-d | Deletes character on the right |
| ctrl-f | Moves forward one character |
| ctrl-g | Beeps?? |
| ctrl-h | Deletes character on the left |
| ctrl-j | Beeps?? |
| ctrl-k | Cuts line from cursor to the end |
| ctrl-l | Does nothing? |
| ctrl-z | Beeps?? |
| ctrl-x | Beeps?? |
| ctrl-c | Beeps?? |
| ctrl-v | Moves half screen down |
| ctrl-b | Moves backward one character |
| ctrl-n | Moves cursor to next line |
| ctrl-m | Beeps?? |
Unfortunately it appears I’ve no time to talk about programming. It takes lot of time to think about something useful, to write examples and such. However, I promise I will doing it soon.
And yet I’m again talking about a text editor. In fact since most of my computer time is spent on an editor, this makes sense. It’s the most crucial application to me (and the one I spend most time to learn using its full power).
I already said I discovered TextMate. The more I study the more I’m amazed. In fact it did substitute Aquamacs even for latex editing. The new bundle is perfectly integrated with Texniscope and “Command-B” opens in TextMate the pdf document compiled from the document I’m editing. That makes environment such that TexShop almost useless to me.
Emacs is more powerful. But most of the times I’m not using that power. It’s my fault, of course. Still TextMate is always open on my Mac, and I started using it even for latex. That’s the main reason. If I have to do a very long latex editing session I still do prefer Aquamacs.
The Python mode is now wonderful. It lets me check my sources with pychecker or with pyflakes. It allows me to run them from inside TextMate, lets me run unit-tests with one command. And even more. Right at the moment it’s the best python programming environment I’ve ever met (a part from WingIDE).
The only thing I’m missing right now is a “prolog mode”. And probably I have to work on TextMate/Xcode integration (it has been done, but I haven’t done it yet). Oh, and I’m looking forward to see TextMate 2, that should have massive improvements on the “project management” side. And probably I’d like some more refined auto-completion with static languages. This could have somehow been added (TextMate can be extended and customized a lot, still in a really simple way), but I’ve not yet discovered if and how.
But the reason I wrote this is another. For years the “Text editors” with capital T have been Emacs and vim. BBEdit was a beautiful Mac editor, but first it is very web-oriented, second it is somehow less powerful in the way it deals with text.
On the windows platform I have not found really impressive text editors. There are a bunch that are powerful and easy to use. But in fact I installed vim (gvim) and I was happy with that. Most such editors were more concerned in “integrating” command line utilities (compilers, latex, interpreters) with the editor not to have the “programmer” opening the “DOS console” than pure text editing.
Newer editor for Linux (Kate for example) also paled in comparison with Emacs or vim. Now I’m wondering:
- Was I superficial? It is possible that no one did something that could be compared with vim or Emacs before TextMate? This seems really unlikely.
- Why haven’t I spotted such editors? They exist? Let me know. I’m talking about “pure text editors”, not about “IDEs”.



