JMorse Part 1 – A Crack at the Rules

As mentioned in my previous post, I decided to actually try going down the route of mixing Morse Code and programming. The first step in doing this was coming up with a few rules to write programs in Morse code. The easiest way to get started was to use standard Morse letter sequences, and then fill in any characters that were missing, e.g. ( ) [ ] { } ; ” “. This gave me:

Morse Code

To make parsing easier/possible, I came up with a few spacing rules as well. A single space, ” “, is used between characters in the same “word”. A double space, ”  “, is used to represent the access operator, in Java’s case this would be the period. Finally, a triple space, ”   “, is used to indicate the gap between two words. If any of that is confusing it’ll make sense in a minute with the code snippet.

To start with, I wrote a very simple and cliche “Hello World” in Java, and then encoded it into Morse. The original program looked like this:

Java Hello World

And encoded in Morse I ended up with this abomination:

Java Morse Code

Two things became clear pretty quickly while writing the above program. The first was that as more non-alphanumeric symbols are needed, the more complex the morse equivalents are going to become. I still need =,+,-,/,*,%, the logical and bitwise operators…To fit them all into the Morse code set I’d probably have to extend out to a length of 6 dot/dashes for some cases. This would become very yucky very fast.

The second problem is Morse doesn’t allow for capital and lower case letters. You more or less have to pick one and stick with it. This is a pretty big problem as I’m a strict follower of camelCase-style naming conventions and Java’s standard libraries are loaded with mixes of upper and lower case. The only solution to this that doesn’t require an additional 26 Morse codes adding a “shift” character that has to be prefixed to any character that needs to be in upper case. That would be a bitch.

So where does this leave us? I can’t help but feel that there’s got to be a better way to go about doing this. I know the original intent was to use strict Morse Code compliant characters to write programs, but retrofitting the necessary characters into the existing codeset is brutal. As I see, there are two options left:

1. Use morse of the letters only, and retain existing “punctuation” using Java’s traditional symbols ()[]{}””,;. etc.

or

2. Start from scratch and design a new variant of Morse Code that’s optimized for programming. Rather than having “e” as “.”, maybe “.” could be the period symbol that it appears to be. And curly braces could be “-.” and “.-“, and so on.

I’ll have to think about this some more, but I think number 1 is looking a bit more appealing. The problem with number 2 is that it feels like I’m just rewriting ASCII, albeit a more reduced version of ASCII. Number 1 retains the Morse Code feel and will require far fewer additions to the original codeset.

That’s all for now though.

T

Advertisements

One response to “JMorse Part 1 – A Crack at the Rules

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: