Java networking code


Argh!  Time for another rant, methinks.

I’m trying to write a simple networking library in Java (I have a few projects ongoing that require networking, so I think a library that abstracts some functionality makes sense, especially considering point 1 of my horror story)

Point 1 of my horror story

You’d think that Java would avoid throwing unhandled Exceptions as much as possible, since it can quickly turn neat code into a spaghetti bowl of try/catch blocks and if/else statements.  Nope, apparently they make an Exception to the “handle every Exception” rule for IOException, which it seems they want to use like some sort of high-ROF code munger and to put people off writing network code.

This is annoying, but it’s nothing compared to…

Point 2 of my horror story

Unsigned types.  Anybody familiar with Java will already have facepalmed as they realise they’re about to read yet another furious network coder’s ranting about this problem.  The justification, it appears is that “many C developers are fucking idiots.”  Well, duh.  I guess that’s why you stole my macro preprocessor too, huh?  Thing is, I don’t mind people writing tools for idiots.  I mind them writing tools for idiots and branding them as tools for serious developers.  And I mind serious developers actually using these tools.  I mean, the tool is good.  It abstracts away memory management and other gumph that most developers couldn’t care less about and used to see as a tiring necessary evil (mind you, there are some benefits to managing your own memory).  However, this sort of language feature isn’t idiot-proofing the language, it’s genius-proofing it.  Genius-proofing is good, idiot-proofing is bad.  Genius-proofing means making the language so simple that even a genius can use it (in much the same way that idiot-proofing is making the language so simple that even an idiot can use it).  The difference lies in the fact that geniuses use very different methodologies to idiots.  A genius will not want to have to do mundane tasks like allocating and freeing memory when it can be automated, whereas an idiot wouldn’t want to be able to accidentally refer to an unsigned int in a signed context, or vice-versa.

The biggest problem with this is the fact that it’s inherently the wrong way around.  Treating everything as signed because idiots don’t know how unsigned works is somewhat akin to welding all the knives into sheaths so that the sheaths don’t hurt anyone.  It’s far more sensible to treat everything as unsigned, so that people get used to converting to signed themselves, and write abstraction layers that allow them to use signed stuff where they want to shoot themselves in the foot.  Especially as you then please the networking camp, because everyone will then be using their kind of code!

Just one more reason to write my own language, I think…


Q1.3: Can I download the generator software and run it on my own computer?

No. It’s not just the software you’d need, but also three radios (or one, at any rate), which must be carefully adjusted to pick up atmospheric noise at the right volume. It’s not completely trivial to set up.

What a pompous ass.  It IS completely trivial to obtain random entropy.  Three radios?  Give me a fecking break.  This guy clearly sees himself as some sort of God of Random.  Evidence suggests otherwise.  A pure random distribution of bits can be found in every single computer in the world via simple and indeed TRIVIAL programming.  All you need do is:

Query RTC, or if there is no RTC in hardware ask the software for an RTC.

Dependant on RTC, read a bit of memory.

Truly random.  100% guaranteed to produce a bit that could be either 1 or 0 and is entirely unpredictable.

Sure, it requires kernel-level code, and sure it’s a tiny bit predictable, but if you think that is any less random than using atmospheric noise, you’re in for a shocking treat sonny.  Randomness is EVERYWHERE.  Not just at

Christ, it’s like this guy’s literally walked out of some kind of weird-ass steampunk machine and said “WOW I SEE RANDOM”.


EDIT: In the clear light of day, one obvious flaw is apparent; the procedure for grabbing random entropy I outlined would give a tendency towards zero.  However, it is indeed entirely trivial to program a RNG (not a PRNG) using hardware available to every computer system on the planet.  Even if you don’t have a Real Time Clock in hardware, you can quite easily program a recursive function whose randomness increases with each recursion:

#define RECURSION 1
int current_level = 0;
int randomInt(int seed) {
int n = // use inline assembly to fill n with whatever is currently in an arbitrarily chosen register
if(RECURSION && current_level++ <= RECURSION_LEVEL) randomInt(seed);
return seed;

Sure it’s messy but it’s a 2 minute proof of concept.

Emma the OS

It’s been a while since my rather heartbroken post in August entitled “Long Time No Post” to which my last comment was proven true (no replies…) I’ve since managed to repair my xbox, but it broke again shortly afterwards and this time I shall have to replace it. It is decidedly irreparable (several unsuccessful attempts have been made).

I have not made any progress on the “finishing what I start” quest, but that’s not really the purpose of this post.

I have started an Operating System project called Emma. So far I’ve only written the bootloader, and it’s a very simplistic bootloader at that. It doesn’t even load a kernel yet. It does, however, go over its 512 byte mark, which means I now have to learn how to make a two-stage loader because it don’t fit in the bootsector of a floppy.

The Makefile I’m very impressed with myself at though. I don’t have to type the usual 5 or 6 commands to recompile and test the OS, all I have to do is type “make” and up pops a virtual machine running Emma 0.0.1! woo!

Here’s some sample output:

Welcome to Emma version 0.0.1.
Detecting RAM… 637KB [OK]
Loading Kernel..[ERR]
Error reading floppy:[A]

It should be noted that the Error in this output is because the kernel doesn’t exist (and I’m pretty sure my loader code is fucked anyway) and the A next to floppy doesn’t mean Drive A:, it’s -supposed- to be a hexadecimal representation of the error code (stored in AH, should be TWO hex bits long) but the routine for printing said code appears to be… well, it obviously doesn’t work.

Hooray for it actually outputting anything though! You wouldn’t believe how excited I was just to get the thing booting yesterday, I’m telling ya! ^_^

Long time no post!

Ok so a lot has happened.  Rachael left me for a fella named Tom Coutts.  All the best to them, it was a totally painful experience at the time but I’ve realised that anybody who’s going to leave me for somebody else isn’t worth getting upset about.  No offence, Rachael, and yes I know you said it was for umpteen other reasons but frankly you’re not going to be able to bullshit me with that “it’s your own fault” rubbish if you go out with someone else 2 weeks after we broke up.  Ain’t gonna happen.

Ok so in lighter news, I’ve made some new friends, discovered a love for Bon Jovi and that’s about it.  Still no direction in my life, but I’d like to take an LPI exam so I can become a Linux System Administrator.  That costs money though, and I really don’t know where I can get £120 from.

So yeah, life is still its usual roller coaster.  Everything broke in the last 2 months or so, and I’m gradually fixing what I can – my desktop was the first to officially be labelled “mended”.  My phone, my netbook and my relationship with Rachael have all be written off as irreparable.  Next thing to work on is my ability to finish projects (something I’ve never really had fixed).  Any help with that would be appreciated, but I don’t know who I’m talking to.  I don’t really have a support network.  Oh well.

Servers! Roof!

Yes, my servers are finally in the roof; which means I can relax and wipe everything off my whiteboard.  I’m happy.  I’m also connected through w1zard who is now our network’s personal Proxy server (currently optional, in the long run mandatory).  It caches and filters and makes life more streamlined and safer for the old fogeys in the house who are a little naive to say the least (my mother searched Google for “fisting”, thinking it was the act of shaking one’s fist; which first prompted me to think about setting up a filtering proxy).

Ossum has changed its name to Enosis and still hasn’t been worked on very much; but the infrastructure is now in place so the next step is to write a plan and then a tech demo.  Fun, fun, fun!

I’ve received four 7″x5″ canvases and finally dug out mum’s old acrylics (of which there is a disappointingly small pallet, but it should be significant for the work I have planned); I will be painting four abstract works entitled “Battlefield of the Mind”.  Pictures once I’ve actually done it.

I have also begun thinking about considering contemplating starting to ponder the possibility of organising a “Geeknic” over the summer, so if you’re a geek in the Tewkesbury area (or a geek who can reasonably travel to the Tewkesbury area) then get in touch, the more the merrier!

Very excited about finally having my desktop back…  And my whiteboard, for that matter!

Oh, and started work on a computerised Rubik’s Cube solver with the ultimate goal of making a robot that will solve rubik’s cubes (hopefully to be shown off at the geeknic).


First off, an update on my health situation. Well, it has worsened somewhat. I have developed, as has seemingly become my custom after periods of illness, agoraphobia. I am seeing the doctor about it next monday, hopefully I will get to the bottom of this in due course.

Now on the bright side, I got my netbook from ZaReason! It is everything I expected and about three times faster than I thought it would be. The webcam isn’t quite as high quality as I was expecting, but that’s no big deal really and the battery life is a bit shorter than I would’ve hoped but there’s not much can be done about that now.

There seems to be some minor shipping damage as well, the shift keys are a bit dodgy and the left speaker seems to have a loose connection or some interference or something. Thanks to the open hardware warranty, however, I can fix these myself or get a local shop to do repairs without having to send the thing back halfway across the world, probably picking up more shipping damage along the way.

Speed-wise, I couldn’t be happier, the Intel Atom performs exceptionally and the 2GB of RAM is barely used by Ubuntu Netbook Remix (about 200-300MB in use most of the time).

Also, the ‘book runs almost silent, drowned out by the noise of my typing on a keyboard whose own sound is drowned out by gentle background conversation. Even under heavy usage.

I’ve also set up Citadel groupware on my server to replace the postfix/dovecot solution, making it easier to share calendars and other stuff, and giving a more extensive web interface for local users. I will be looking at bundling Citadel with my SMART system when I get around to it.

Techie stuff again

Dunno why I made that rule, I’ve never been one for following orders.

Anyway, here’s a brief update on the status of sophie.

She has been placed in an SVN repository (read-only anonymous access available), and is stable(ish)!

Ok, so she doesn’t do much more than she used to, but she’s a little more developer-friendly, and on that note the project has gained a developer!  Yes, my good friend Spoon has been recruited into the project and we shall procede forth with vigour and determination!  After a procedural discussion meeting, of course, and several planning council arrangements.  Not to mention the beuracracy enablement committee formation…  But as soon as all of that is out of the way, we can get right to programming.  Well, not -right to- as such, I mean we’ll first have to submit the application to consider beginning, which needs to be approved by the select general committee.  But -then- we’ll get into the nitty gritty business of programming!  After tea, of course, because it’ll be quite late in the day by then.  And then we’ll have to have the post-tea project alignment talk, which is followed by tea and coffee in the foyer.  Once all that is out of the way, we’ll get to programming!  I think…