January 8th, 2010
UPDATE: I’ve uploaded a preliminary proof-of-concept Rebmu implementation to GitHub. See http://hostilefork.com/rebmu/ for details.
StackOverflow has a tag for so-called “Code Golf”, which has the goal of attempting to perform a programming task with a program that has a minimum number of ASCII characters.
There are several loopholes:
- You can obviously define a language which specifically performs only the one task, and uses a single-character program to do it (e.g. if the task is to print “Hello World”, you can make a fictitious language in which the single character program h will do it)
- You can compress your program into a form where it is no longer the sort of thing a human can reasonably read or write (e.g. the hexadecimal representation of assembled machine code)
But a real Code Golf language needs to be Turing complete. Furthermore, I feel that you should be able to give an arbitrary challenge to a programmer they could write a working program without machine assistance. It should also be feasible to make minor adjustments to the program’s behavior without using some kind of tool. My opinion is that in this respect, Rebol has potential to be the most impressive language for Code Golf ever created.
However, Rebol has striven for a verbose English-like wording scheme. So out of the box, its ability to compete is hampered against less ideal languages that have been purposefully shortened for this purpose (like GolfScript) Yet I began to wonder if the language could be configured in a trivial way that preserved its basic character (so it still passed the language parser) but that made it more terse.
I’ve decided to call my idea “Rebmu” (REBμ) the Microsocopic Rebol Dialect for solving code golf challenges! You can find a proof-of-concept source file on GitHub which has some documentation, but this post goes into some detail as well…
http://github.com/hostilefork/Rebmu/blob/master/rebmu.r
Read the rest of this entry »
Tags: humor, rebol
Posted in Ideas | No Comments »
December 24th, 2009
I came across an article in Wikipedia about Dudeney numbers. These are numbers whose digit sum add up to their cube root:
1 = 1 x 1 x 1 ; 1 = 1
512 = 8 x 8 x 8 ; 8 = 5 + 1 + 2
4913 = 17 x 17 x 17 ; 17 = 4 + 9 + 1 + 3
5832 = 18 x 18 x 18 ; 18 = 5 + 8 + 3 + 2
17576 = 26 x 26 x 26 ; 26 = 1 + 7 + 5 + 7 + 6
19683 = 27 x 27 x 27 ; 27 = 1 + 9 + 6 + 8 + 3
The wiki page went on to proclaim that those are the only six such numbers. Somebody on the talk page asked where the proof was.
I poked on Google and didn’t find anything, so I wondered if I could just prove it myself. Here’s what I came up with off the cuff. Perhaps others would find it interesting.
Read the rest of this entry »
Tags: rebol
Posted in Math, Puzzles | 3 Comments »
December 2nd, 2009
Merely plugging a removable drive into a mac (when it has write access) makes OS/X think it can take the liberty to write a lot of hidden garbage onto that disk. If you want to stop this from happening, you have to put some special files on that disk before you plug it in.
To stop OS/X from doing Spotlight indexing, you need a file called .metadata_never_index in the root directory of the removable drive.
To stop OS/X from making a .Trashes directory, you need to make your own file that *isn’t* a directory and call it .Trashes
To keep it from doing logging of filesystem events on the drive, you need to make a directory called .fseventsd and inside that folder put a single file named no_log
The contents of these files don’t matter, so you can make them empty files using touch. Even better, you could make it a text file with a link to this post, so that you (or someone else) wandering across the files will know what they’re for.
Apple’s choice to do this is incredibly self-serving and shameful. At bare minimum, hidden files and features like these should be off by default for any non-mac-only filesystem formats. They should only be enabled when the user has been made aware of them.
Posted in Uncategorized | 5 Comments »
November 22nd, 2009
Ubuntu has a nice install screen that lets you press F4 for Modes or F6 for Other Options. If you have an older laptop, you may find that you can’t boot unless you turn on “Safe Graphics” or check “acpi=off”.
(Note: In my case, the failure I was experiencing on boot was accompanied by horrible graphic corruption on the LCD. This made me think I’d need safe graphics mode, but that had no effect. It turned out the acpi=off was the setting I needed to get through the boot. YMMV.)
Yet there’s a catch to getting Ubuntu working this way. It may get you through the install, but once you’re finished and try to boot from your hard disk these options aren’t there any more. As of 9.10, it seems that it does not slipstream these settings into the configuration files on your hard disk.
As more of an exercise than anything else, I looked into how to address this after installing Ubuntu onto an old Pentium III laptop. Hopefully it can help someone else. Here goes…
Read the rest of this entry »
Tags: GRUB, Linux, Ubuntu
Posted in Uncategorized | No Comments »
October 26th, 2009
Historically, I have always disliked the idea of using boolean test operations on types that can take a number of values. This deep-seated aesthetic grudge comes from cases like this:
int x = 0;
if (not x)
cout << "X is zero" << endl;
I’m simply bothered by this. Perhaps it’s a cognitive thing where I just don’t feel there’s any “truth” to the idea that every non-zero integer is somehow “true” but zero is somehow “false”. It could just as easily be that negative numbers are false and non-negative numbers are true. Or if you ask a mathematical purist, they might suggest that at a more foundational level it is primes that are true and non-primes are false!
My comfort zone is when I’m only testing for “truth” and “falsehood” those things that can only have the values true and false. If I could, I would enforce this. So in the example above I would always write something more like:
int x = 0;
if (x == 0)
cout << "X is zero" << endl;
That particular example is not very controversial, and I think most programmers would agree with me that’s a better way to test against a literal zero. It’s just better code for capturing the intention.
Yet I have historically considered that a logical extension of “zero is not false” is the premise that “null pointers are not false”. And that belief is contrary to practice:
shared_ptr< foo > fooPointer;
if (not fooPointer)
cout << "fooPointer is null" << endl;
In fact, look what a mouthful you get if you insist on comparing against null literally:
shared_ptr< foo > fooPointer;
if (fooPointer.get() == nullptr)
cout << "fooPointer is null" << endl;
In the past I have tried to work around this by creating inline template wrappers like “isNull()” so that I could stick to my guns and avoid flattening pointers into booleans. It doesn’t cost any more in the runtime, so I figured what’s the harm?
template< class T > inline bool isNull(shared_ptr< T > ptr) {
return !ptr;
}
Yet I’ve decided this is a lost cause and too much of a speed bump in sharing my code with other C++ programmers. They’ve accepted the notion that null pointers are false and non-null pointers are true, and you use boolean logic to test this—not some other operator. It’s not worth it to pick this particular fight.
I’m not happy about it. But I now accept this for pointers only. And I’m going to use “not” instead of “!”… it’s part of the language and a lot more readable.
Posted in C++ | 1 Comment »