Coconuts
An ocean liner goes down, leaving only five sailors who swim desperately in search of land. Spotting what appears to be a small island on the horizon, the sailors make a dash for it. [*] The basic riddle without embellishment:
There's a pile of coconuts owned by five men. One man divides the pile into five equal parts, giving the one left over coconut to a passing monkey, and takes away his own share. The second man then repeats the procedure, dividing the remaining pile into five and taking away his share, as do the third, fourth, and fifth, each of them finding one coconut left over when dividing the pile by five, and giving it to a monkey. Finally, the group divide the remaining coconuts into five equal piles, but this time no coconuts are left over.
So how many coconuts were there in the original pile?
The riddle (see link above) was first published in recent times in the Saturday Evening Post almost 100 years ago. Readers, in a panic, demanded the answer, but none was forthcoming. In the 1950s the magazine was accused of fraud.
A solution can be found without use of any tools whatsoever.
Don’t use the link until you’ve found the solution. Good luck.
Changelog
ACP Changelog 2023-06-25 'Scarlet Sails'
A C P C H A N G E L O G
25 June 2023
'Scarlet Sails'
===============
Looks like once per month now. The 25th is Sweden's national payday. Gives people enough time to pay their bills before the 1st. Contrary to practices in the US, rent, for example, is not due on the 1st day of the new rental month but on the day before.
And do tell your friends about us! Send them here:
https://rixstep.com/acp
https://rixstep.com/buy
Anyway.
Herewith the updates since last. Be is a powerhouse for our uses, mostly as a log file. Very convenient that on startup it always scrolls to where you left it last time.
Fortune gets lip gloss. Note it doesn't connect to its help file - yet. See the notes for info on where that help file is.
Take care, be well.
**
2023-03-29
Be. Code clean.
2023-03-29
Be. Code clean.
2023-03-29
Be. New templates.
2023-03-29
Be. Replace colour defaults.
2023-04-05
Be. Restore I/O dir after im/exports.
2023-04-14
Selected ranges. Days of gruel, finally works.
2023-05-02
PlistEdit. Add extension 'pe'.
2023-05-09
Be. Alternate mirrored icons.
2023-05-09
CLIX. Docu update.
2023-05-27
Fortune. Add font, colour via Info.plist.
2023-05-28
Fortune. Add cmd-C copy.
2023-06-24
Fortune. Add random colours as opt-in. Check /Library/Frameworks/ACP.framework/Versions/2.4/Resources/Fortune.html for details.
Preface
IBM own Red Hat. Own it. Like for 34 big billions own it. It's theirs. But will they do anything to improve things? Do they need to improve anything, you may ask. When Red Hat is sooo lucrative that IBM fork over 34 billion? Yes, we say. Yes they do.
And why IBM? Why not Red Hat? Red Hat won't do it because they still haven't seen it after all these years. IBM might - a slim chance but still the same. IBM had a massive deep dive into fake OO a while back. It must have been total misery. Now all you have to do is yank Objective-C away from Lady Tim (yes the language is patented unfortunately) and then you can recreate the NeXT classes like GNUstep and go to town.
Why do it? Why hasn't it been done already?
It's actually easier to answer the second question first.
It hasn't been done because most IT people have NFC. Seriously. They have no fucking clue. They've never seen real OO. They think C++ is OO when it is not. They think all windows have to have menus. They think files like WIN.INI are cool. They think doing things like KDE with class constructors is space age.
Objective-C speeds things up, makes software more reliable and more consistent, less buggy. Works with C, not against it. Work times are about one fifth of what they are otherwise.
[One-fifth, 1/5 - need to read that again?]
So that essentially answers the first question too. Let's get on with it.
Code in Search M-R
Preface
Not mentioned in Part I was how Apple took NeXT's original (and pristine) services design and completely corrupted it, introducing failing APIs - but oh so pretty icons, typical Apple mindset - and trashing the former very helpful hierarchy. Yes, typical Apple behaviour witnessed time and again (and again). They're not capable of treating NeXT code intelligently and with due respect.
macTag
It took a while to come up with a name for this one. And we're allergic against anything with 'mac' in it. But the name is the most accurate, as the app’s only applicable with systems with XA capabilities, and Apple's OS is the only one out there ATM.
Why the need? It's gotta come, it does. The day when you're dealing with an immense hierarchy of files, where the hierarchy itself helps you keep things organised, and suddenly you realise you need to reorganise your hierarchy.
That can take a lot of work. So you either do that or...
Google did something like this with Gmail. You don't want to custom Gmail but it's not a Google product originally. The key that's interesting here is how it uses labels (tags) to keep things organised. You do not use directories. You actually don't want them.
A structural snag appeared when we realised that the array of tags applied to a file must be unlimited in number and in length. How to do that? I know we did it, but frankly can't remember how and am too lazy at the moment to look it up. It wasn't easy!
[The tags field is represented by a pointer to an array. The array is freed when the record is removed. Something like that IIRC. Ed.]
YES APPLE USE TAGS TOO. COLOURS. OH WHOOPEE. Yes they allow text tags too, but how do you organise any of Apple's tags? And we're not going to use their Finder. [And contrary to what Cocoatech believed, yes you can completely disable that beast. And yes it's worth it. Ed.]
So ergo macTag. (Perhaps it should be called 'Rixtag'? Oh whatever.)
On the left: a hierarchy of limited depth showing you what tags have been found in a scan of a directory hive. Note the root '/' at the top, always present. (That's not your file system root.)
On the right: the files found with whatever tag you've selected on the left. [Selecting '/' on the left lists all files.]
There's a special sheet you use to add tags to a file. It's designed so it's easy to use in stenographic situations. Paste in something, hit Enter, you're ready for the next one, etc.
There are also ways to in bulk add tags to files and remove tags completely. You might not often need to do things like this, but the idea is you need as little as possible anyway.
The future? It depends on XA capabilities in the coming platform. And on the exigencies. A company like Google can see a need for this type of data reorganisation now. For individual users it can still be a ways off - people are required to think differently.
But the possibility is there, which is what we deigned to demonstrate.
MC
Mode Calculator. Yes, why not? Some of this is specific to Apple. Perhaps with a simpler Unix the need isn't as pressing. 0644 should be a mystery to no one. The system and user flags - their use - is determinant.
MD
'MD' stands for 'MD', but 'MD' is short for 'message digest'. So yes, this can and perhaps should be ported. Depends on what MDs are resident.
NSURL
Ah. If only. NSURL is the name of a NeXT class. The NeXT peeps brilliantly plucked apart the components of a URL, and here is where you see the results. But does any other platform sport the NeXT classes or even a rough equivalent? No they do not.
Sucks.
Othello
Certainly the Othello engine is portable. So 'yes'.
That engine's been around for a long time. Used under MS-DOS when it was called 'Pokey' and used the 'semi-graphics' system. That version was quite brilliant, getting our resident 'Gandalf' to utter 'beautiful' when seeing it.
This Othello engine consistently beats Microsoft's Reversi. FWIW.
Outbox
A great idea today under wraps. Send out letters individually on the To: field without going bulk (spam). The sender can be anything you want but the headers reveal too much, so scrapped.
PlistEdit & PlistTool
An interesting anecdote about this one. PlistEdit made binary property lists accessible for Joe Blogs. Binary property lists hadn't been the norm originally. Seeing what was in them otherwise required downloading the massive developer tools.
So we simultaneously saw that the W3C had begun propagating for binary XML, and we wrote a piece about it, encouraging readers to contact Sir Tim and complain.
We got a letter from Sir Tim. (Yes the one who invented the WWW.) He explained that he wasn't in charge of W3C decisions like that, and if anyone wanted to join the discussion, they had forums, and please tell your people to stop bombing my mailbox!
So we wrote a followup, mentioning that we'd been contacted by someone close to Sir Tim. It was indeed someone close to Sir Tim - it was Sir Tim himself.
His email headers also revealed what computer he'd used to send off his letters to us. An Apple laptop.
Pwgen
Yes, why not? The paranoid approach: perhaps all those 'random' passwords offered up by your browser are actually easy to crack or have back doors? Or perhaps our code does too?
Rixcomp
This was a big unexpected surprise: 2600 Magazine voted the Windows version the essential hacker tool. This one? The Apple version adds use of an Apple enhancement to Doug McIlroy's diff so you can compare directory hives as well.
Things move on in IT, so by the time we get to a new platform we might find some good functionality waiting.
Rixedit, Be
Two things you need to do when coming to a new platform. Write your own text editor and write or mod your own file manager. Have now done this with 4 or 5 platforms. It's essential. You need to learn to code on the new platform and you need to have tools that work the way you want them to work.
Our test Unix was called Onyx. It had elements from Interactive Systems from Santa Monica and a text editor called ined that was simply brilliant. If you invoked ined from the command line with no file specified, it took you back to the last file you'd edited, with the scroll and the caret exactly as you'd left them. We later discovered this was done via a dot file in the same directory. I incorporated this into our editor for MS-DOS by using a free paragraph in the upper echelons of 'page zero'. We had the same system for all our most used editors. The same idea is in use today on the editor used to write this piece - Be - with the added gem that Be can retain not one but multiple text selections. Which is perhaps not that useful but oh so cool.
IBM later bought Interactive's system and made their own version called PC/IX. One review wrote that it was the first system that didn't need a user manual, as everything was exactly where you'd expect to find it and worked exactly how you'd expect. That's the IBM SAA/CUA Recognition Principle taken to its logical and extreme conclusion and that's always been our goal as well.
Rixicons
Digs into NeXT's ICNS icon directories. Several things to say here.
You don't need images larger than 128x128. FFS.
Icon Composer was fine. Handled up to 512x512.
Apple go berserk over graphics, lose all sense of reality.
If they wanted even bigger icons, they should have enhanced Icon Composer instead of suggesting the silly system they have today.
SVG should replace those old formats anyway. SVG for all sizes.
Rixstamp
An essential tool. Really. The idea may have begun when we saw Microsoft doing this on their OS releases - they put the version number into the time stamp. 'Oh can't we do that too' etc. Then Sydney found out that search engines prioritised files with more recent time stamps. Then we realised that web browsers hate you for having image files with all too recent file dates. And so forth. A utility like this should be essential on all platforms.
Note that leap years are calculated with the greatest of ease, and errors should be highlighted.
Apple's had fun with time stamps. Their useless HFS used time stamps which are good to no one. They did this simultaneously with supporting Unix stamps. But the overlap meant that hackerdom could play extraordinary tricks on witless users. This anomaly (!) was finally remedied in a later version but it took a long time.
Unix now has four official stamps, can be interpreted by different flavours.
atime file last accessed
ctime inode data last changed
mtime file last modified
Now the FreeBSD people added to this. For ctime was often used as 'create time'. But Apple didn't see it that way, and Apple bought over the head of FreeBSD and shut him up, so they standardised a new stamp unequivocally for when a file's created. But instead of calling it 'btime', they name it 'birthtime'. We obviously need to get Apple out of the Unix community.
Rixtime
In honour of Toggle Booleans, a great company producing excellent completely useless software. Was it them who came out with Elvis Detector? The lyrics to 'Are You Lonesome Tonight' would appear on your screen. And other stuff.
https://archive.org/details/win3_elvisd
http://annex.retroarchive.org/cdrom/smsw-win-os2-1/WDESKTOP/ELVIS/ELVIS.TXT
https://runme.org/project/+elvisdetector/index.html
https://runme.org/feature/read/+elvisdetector/+84/index.html
Elvis Detector Version 1.0
(C) Copyright 1992 TOGGLE BOOLEANS
All rights reserved.
The TOGGLE BOOLEANS Elvis detector is designed to sense the
presence of Elvis or his spirit in your vicinity. It includes
some of the most reliable Elvis detection methods gathered from
supermarket tabloids over the last several years.
If you are running Windows 3.1 then it is best to put the
Elvis Detector in your StartUp program manager group. This way
the Elvis Detector will run as soon as you start Windows,
thereby maximizing your chances of detecting Elvis.
If the Elvis detector goes off, perform the following steps
in order:
1 - Look behind you and under your desk. Elvis almost
always catches people by surprise.
2 - If no one around you looks like Elvis, look a little
closer. Many tabloids have reported that Elvis has
the ability to disguise himself at will.
3 - If you still have not found any concrete signs of
Elvis in the people near you, then look outside and
down the street in both directions.
If there is a discernible trail of fainted middle-
aged women then quickly follow it as far as you can.
If the trail becomes difficult to follow then look
around for the glint of sequins.
4 - If after trying all of the above, you still can't find
Elvis then there's not much more you can do. Elvis
works in mysterious ways. Perhaps the Detector sensed
the spirit of Elvis passing by on his way to visit
one of his most loyal fans.
If you find the Elvis Detector to be useful product, you may be
interested in purchasing the Elvis Detector Version 2.0.
Version 2.0 contains a more sophisticated Elvis Detection algorithm
and has been expanded to also detect the spirits of Roy Orbison,
Rocket Robin Hood, and MC Hammer.
Custom detectors are also available. When ordering custom
detectors please include at least three phrases that the object
of the detector tends to say to enable the detector to make positive
identification.
To order the Elvis Detector Version 2.0 please send a cheque
or money order for $8.00 (Canadian funds) to the address below.
Royale
Inspired by Ian Lancaster Fleming. First version was an adventure game! Fleming claimed Baccarat had a 'sound barrier': if you won twice in a row you could go on winning forever. The fairest casino game with odds at only 50.5/49.5 in favour of the dealer. Thereby the 'cagnotte' is set at 1%, or something. Assumes card shoes of six decks. And so forth.
Runner
Based on openFile:withApplication. Someone noted in our forum that Tracker, which used similar code, was acting up on a new version of Apple's 'stellar' OS. The API is also supposed to reveal the default app to open a specified file. Suddenly it wasn't. We wrote to Apple about it and yes got a response.
The programmers at NeXT were intelligent, as opposed to those at Apple. What happens if you ask the API how to open an application file? Well gosh, the API is supposed to return the application file itself!
Put it like this. Pose the question 'who opens this program file?' Well the answer has to be 'why the program file itself!'
This was at the time, we learned later, when Scott Forstall took people away to start the iPhone project. Scott detailed how he went about culling the (ahem) 'better' programmers at Apple.
Those who weren't amongst the 'better' got to remain and now review ordinary OS code, and one of them happened by the openFile: code and felt stymied by the logic which he obviously did not understand.
'So the program file to open a program file is the program file itself? That makes no sense!'
So the DWEEB (what other word is there) DISALLOWED IT.
We got Apple to recant and admit their mistake and promise the code would be restored - BUT ONLY FOR THE NEXT VERSION.
So, what I know, our workaround code is still in place. This is yet another reason why you can never trust Apple. Their programmers suck and their management can suck too.
RxDefaults
An app for one of our inventions. Yes an invention. We have a workhorse framework class never mentioned. It's automatically run when apps launch and exit. The exit part is very detailed and takes care of a lot of the cleanup you don't have to worry about with our software (which other apps from other companies will leave behind for you to worry about). The launch part takes care of initialisation. It looks for the key RxDefaults in Info.plist and registers the settings found there.
The RxDefaults app lists all ACP apps found anywhere and singles out those with RxDefaults keys in their Info.plist, shows you what's been found and offers ways to edit. Something happened under the bonnet at Apple and this app suddenly got very fast.
Appendix: Some Philosophy of File Management
Our maid warned us. It's going to rain for a while. Only one minute ago the birds were chirping, Now they're silent. Now it's raining.
But it's a gentle rain. So that's OK.
It takes a lot of deep thought to understand what makes Windows so weak, so irretrievably weak. It comes down to what we call the 'security model'. This is a bit of a detour in an introduction to file management, but here goes.
To be secure, operating systems must be built with security in mind. Security doesn't have to be uppermost in mind, but it has to be in mind. That's the case with Unix. Certainly the fathers of Unix had no idea how our world would look today, but they kept security in mind. So Unix is a system that can be made secure.
Windows cannot be made secure. Security there is an afterthought. The people at Microsoft work very hard at security because they have to - they're being attacked all the time. They try to spin this to impress you with how much experience they have dealing in security, but this only means they're stuck with an impossible system.
Understanding file management is infinitely easier. Yet to understand file management one must understand application architecture, and system architecture, and the role played by open source (FOSS). And that takes some doing.
A comment on FOSS found the other day.
'One thing I love about open source software is that they're always really small downloads, like 200Kb for a program to do CD and DVD burning in Ubuntu.'
Ahem. 200 KB?
https://radsoft.net/gallery/x-disc/
7 KB.
We built another fancier one for 9.5 KB.
https://radsoft.net/gallery/epx/
There's yet another that runs a scripting language to control media. Can't find it now.
The point is that 200 KB can still be extreme.
There are myriad tips and tricks to write your code properly. They're learned over time. When we first thought we'd go open source, we got shot down immediately. You'll be giving the secrets away.
We once dabbled in open source. Plucked a module of the Mozilla browser at random, pulled it down to look at it. Found 'colour by numbers' programming, brain-dead coding. We fixed it and reduced the number of lines from 300 to 19 and submitted it. We didn't expect a reaction, and certainly not the reaction we got, when both the head of the archive and the big honcho at Mozilla contacted us. They'd never seen anything like it, and immediately asked if we'd be interested in rewriting their entire back end to replace their shaky MFC layer. Getting compensation was out of the question, the task could take up to one year, were we interested?
But we still get named in the credits to Firefox to this day,
The point is they'd never seen anything like that. They should have. That's the way good code is written.
OK, let's get on topic and stop mucking about. Let's start by first delineating what a system is and what an application is. Let's keep in mind that application software is often the 'face' on system features. 'Keep your hands off the drivers', Ken Thompson famously said. What did he mean by that?
Software occurs in hierarchies. Deepest down you have the drivers that run the devices. Then you have the kernel that interfaces with the drivers. Then you have the applications that interface with the kernel. Then you have the user - you - that interfaces with the applications.
You should never jump over the chain of command.
You can put shared libraries (DLLs, frameworks) in there between kernel and applications if you want.
Internet Explorer is but a pretty face on underlying technology found in MSHTML.DLL. David Cutler's version of Explorer is but a pretty face on his own underlying technologies.
Cutler took a chance by moving his 'user' module to kernel mode. And sure enough, the people behind IE took advantage. There was a time when ending a URL in the location bar with a '.' at the end caused a BSOD. And why? Because the IE dorks jumped the chain of command. Actually that possibility shouldn't even be available to them. But Dave took a chance.
Apple tried the same thing round about when OS X Leopard came out. Suddenly users didn't have to authenticate system updates, even though system areas were protected. Cute. What did Apple do? They ran the update off a kernel thread. Can it be done? It shouldn't be possible, that's for sure. If you're not king of your castle...
This happened in the 'Internet era', not back in the day when updates came via CD. Somehow one can hear the voice of David Maynor there in the background.
Acknowledgements: You might find this file on OS X.
/Library/Documentation/Acknowledgements.rtf
That's a list of all the FOSS components in use on your system.
That list implies that today's systems are a collaborative effort. And how does that work? It works with every development team doing their thing to build their component. Then the final product can be assembled. Just as with devices and drivers, Just as with mobos. Everybody does their thing and stays away from other people's things. And everyone keeps their hands off the drivers.
It's collaborative. Collaboration works. If everybody plays by the rules. Get one bugger out of line, trampling on someone else's territory, and confusion sets in. Bite off too big a chunk and you break the rules, mess things up.
Shell
Windows used to define 'shell' in WIN.INI. So the advanced user could actually configure how the system booted. Default was PROGMAN.EXE - Program Manager, the Microsoft equivalent to Apple's Finder. Pretty anaemic. (Except PROGMAN didn't crash.) A better alternative was WINFILE.EXE - File Manager. That gave the user more control. Control is good to have. Start Windows and your shell appeared on screen. Exit your shell and you'd be told you're ending your Windows session. The shell is your be-all and end-all.
NeXT's equivalent was Workspace Manager. Represented by the AppKit class NSWorkspace. NeXT's file manager File Viewer worked within this workspace. Workspace Manager was very visible.
Don't you find it just a bit funny that, in Apple's version of the NeXT OS, the eminently visible class NSWorkspace is never seen on screen? Do the pirates at Apple have any clue when they go into that legacy code and start plundering? Evidently not.
Apple's version of the 'shell' is the Finder desktop and the Dock with Finder.app glued to the one end. The Finder desktop is a special instance of a Finder document window. Contrary to what Steve Gehrman and others think, it's not impervious, but can be neutralised and rendered inoperable with the greatest of ease.
[Worrying about that 'Happy Mac' icon in the Dock is another matter that's best to just ignore. Apple's desktop OS is a wobbly system - deal with it.]
Apple's OS has always been a mess. When first inspecting the damage, Avie seriously proposed writing a new OS instead. NeXT was fine but...
Early versions of OS X included full documentation of Apple's 'old' OS APIs. Many of those APIs included dire warnings in red text. 'Please be careful: incorrect use can hose your system.' No self-respecting system would ever allow such a thing. Yet Apple did that for years. Apple's old 'MacOS', the system that, according to the embalmed Siracusa and others including Steve G, would crash all by its lonesome just sitting there doing nothing if left to its own devices, for example overnight. People who vend systems like that do not take things seriously. They certainly do not take file management seriously. For their own good, users shouldn’t take them seriously either.
Just as a web browser is a pretty face on an underlying technology, a file manager must be the face on a counterpart technology. Apple have never known, used, or created such a technology. NeXT had such a technology in the form of the NSWorkspace class. NSWorkspace was the visible counterpart to the abstract 'Foundation' class NSFileManager. (Sounds like it makes sense, doesn't it.)
**
A file manager - any shell - must be as sturdy and durable as possible. A file manager is not just another application.
A file manager should be single-threaded. Additional threads created by the system itself are unavoidable and normally undergo vetting on a level not possible for ISVs. The code of a file manager should be inspected as meticulously as a device driver.
Even more than other third-party, a file manager must stick to published interfaces. No matter how tempting, a file manager must cooperate with the OS vendor in that regard.
As such, a file manager must be simple. There is of course elegance in simplicity, but more: there is strength. One of the classic cautions comes to mind: always sleep on your darlings.
Stick to the basics. Never endanger your shell. You come upon a great idea? Do as Doug told you: start a new program. Always remember the IBM maxim: 'If it works, don't fix it'.
Small applications are inherently more stable than large ones. Bloat is not just an aesthetic eyesore - it's an operational one. There's a reason Path Finder used to have forums with bundles of crash reports. There's a reason no bug in Xfile has been reported since 2006.
Critical apps like your shell, your file manager, must have a minimal memory footprint. If the going gets tough, you have to be able to operate your most crucial tool. You can't be loading 30 frameworks just to manage files, especially in an emergency.
Certain NeXT widgets are inappropriate for file management. Unfortunately, both Finder and Path Finder use them, leading to disastrous results that can't be avoided.
Afterword
GBP 70,000, 75,000 OFFERS, TERMS BASICALLY AGREED ON - WHAT SHOULD WE DO? ANYONE?
New Postscript
For an entertaining coconut, click here.
Code in Search IV
The fun’s begun, folks!