Thursday, 21 August 2014

Family Ties

Bonds of Citizenship

There's an argument that occasionally surfaces in the Scottish independence debate which has been annoying me for a while.  Namely that if Scotland was no longer part of the UK, then somehow families would be driven apart.  Nick Clegg touched upon it again today, with this article in (ironically enough) the Independent.

"For centuries we have crossed each other's borders, married each other, raised families together. What Scot doesn't have any English, Welsh or Northern Irish in their family tree?  ...  I believe the bonds that bring us together are stronger than the forces that would tear us apart."

There was also that well-meaning open letter from celebrities earlier this month, which talked about the "Bonds of Citizenship" we'd be breaking, and ultimately served only to illustrate how completely out-of-touch they really are.  Then there's sentimental opinion pieces like this one, again harmless enough, you might think.  I could go on, but I'm sure you all know how Google works.

So, why does it irritate me?

A couple of reasons:

Johnny Foreigner

Firstly, it's the pernicious undercurrent of xenophobia.  The argument is, in essence, that family members might end up a different country (!)

Well, so fucking what?  My sister left Scotland years ago and now she's living in Australia with a New Zealand passport (long story).  None of that diminishes our relationship in any way whatsoever; she will always be my Big Sister, that's how family works.

My wife is Japanese, my two wee boys have dual nationality, and my daughter has British+Japanese+American.  Is anyone seriously suggesting that our family is in any way diminished because we've got a bunch of different passports?


But what really makes my blood boil is this: the coalition government changed the rules about immigration, in a way which actively ripped families apart.  There was no debate in parliament about it, Theresa May just went ahead and changed the rules.

The story of what's happening to Philip Malloy has a particular resonance for me because we're so alike in many ways, but there are countless other examples.

Well, to be fair, there was some debate, but it was after the fact and nothing resulted from it because the Home Secretary can do whatever the hell they like.  Maybe if there was, I dunno, some form of written Constitution which defined the role of government and limited their power, then they might not be able to get away with stuff like this, but that's another blog post.

Better Together

So, do you want to know who'd be Better Together?

How about husbands and wives, parents and children?

Vote for independence and this will stop.

Thursday, 14 August 2014

Even Better Together

The "Better Together" campaign in the Scottish Independence Referendum raise some interesting points.

But surely, taking their argument to its logical conclusion, wouldn't we be even better together with a much more powerful nation?

If we're going to give our country away, let's raise our sights!

Even Better Together with China!


  • They’d totally be up for it.
    • They’re always interested in securing more territory.
    • They’re so desperate for oil that they've been prospecting in Vietnam purely within the scope of China's territorial sovereignty and jurisdiction!
  • We’d be a Super Power again!
  • If it's okay for Britain to take a chunk of China, surely it’s only fair for China to take a chunk of Britain in return.
  • Moar Pandas!
  • In all honesty, their political ideology is a lot closer to ours than England's is.
  • Just think how much more our pensions and investments would be worth in twenty years if they were all in the Yuan instead of the Pound!
  • Moar History!  300 years of Britain?  Pffft!
  • Their trains go at 268 mph - imagine Edinburgh to Inverness in 32 minutes instead of 3½ hours it currently takes!
  • We could re-industrialise and actually start making stuff again!
  • We'd get stars on our flag!
  • We could keep the nukes, but stick them in the middle of the Gobi Desert instead of the Glaswegian suburbs.  So when an accident eventually happens, as accidents are wont to do, it won't wipe out half of Scotland's population.
  • They could build us a massive wall to keep the English out!


    Actually, there's probably enough time left to change the wording on the ballot, just to make things clearer.  I propose something along these lines:

    Do you think Scotland should be given to:
    1. Scotland.
    2. England.
    3. China.

    Please Share!

    You know it makes sense!

    Wednesday, 16 July 2014

    JNI method signatures


    When calling Java functions from C++, you have to use the Java Native Interface. This is a pretty cool piece of software but it can be fiddly to get it working.

    The one thing that seems to trip people up more than anything else is: finding the function that you want to call.

    To do that, you need to know its name (of course) and also its signature.  The signature is the tricky bit.  You have to convert the normal, human readable, sensible version into the considerably more cryptic format that Java uses internally.

    For example:
        long functionName(int n, String s, int[] arr);

    Actually, there's only about a dozen rules and they're not particularly complex, so it's really not that difficult.

    If you're a computer.

    If you're not, then it's very, very easy to get wrong.  And when you do, the error message doesn't help much.  Essentially - "computer says no".

    Fortunately, there's a way to print them out.


    The JDK contains a tool:
        $(JDK)/bin/javap.exe   (I don't know what the "p" stands for, it's a disassembler)

    You can use this to see the function signatures of a class file.
        >javap -s Object.class

        Compiled from ""
        public class java.lang.Object {
          public java.lang.Object();
            Signature: ()V

          protected java.lang.Object clone() throws java.lang.CloneNotSupportedException;
            Signature: ()Ljava/lang/Object;

          public boolean equals(java.lang.Object);
            Signature: (Ljava/lang/Object;)Z

          protected void finalize() throws java.lang.Throwable;
            Signature: ()V

          public final native java.lang.Class<?> getClass();
            Signature: ()Ljava/lang/Class;

          public native int hashCode();
            Signature: ()I

          public final native void notify();
            Signature: ()V

          public final native void notifyAll();
            Signature: ()V

          public java.lang.String toString();
            Signature: ()Ljava/lang/String;

          public final void wait() throws java.lang.InterruptedException;
            Signature: ()V

          public final void wait(long) throws java.lang.InterruptedException;
            Signature: (J)V

          public final native void wait(long, int) throws java.lang.InterruptedException;
            Signature: (JI)V


    If you're working with Android, you can access any of its class files by unzipping the "android.jar" file that you downloaded with the SDK Manager.


    "jar" files can be unzipped with standard archive tools, like 7-zip, or you can use:

        $(JDK)/bin/jar.exe -x

    if you want to do it from the command line.

    Monday, 16 June 2014

    Kanji Tree

    The Japanese writing system is the most complicated one in existence, possibly ever.

    There are two phonetic alphabets.  Hiragana is a nice cursive one which is used for writing particles, conjugated verb endings, and things like that.  Katakana is an angular one which looks a bit like Norse runes and used for writing noises, such as onomatopoeia and foreign people's names.  These two are straightforward enough.

    Then there's an ideographic syllabary called kanji, which is just mental.  No, seriously.

    Readings & Meanings

    Each kanji can have a variety of meanings and pronunciations depending on context.  For example, one of the very first ones you learn is :
    • 日曜日 = Sunday
    The first is pronounced "nichi" and means "sun", the second one is pronounce "bi" and means "day"!

    They can also have multiple pronunciations for the same meaning, take the kanji for "one":
    • 一人 = One person
    • 一羽 = One bird or rabbit
    The first is pronounced "hito" the second one is pronounced "ichi".  It's the exact same character with the exact same meaning!

    And, of course, they can have multiple different meanings with the same pronunciation:
    • 参る = To go (humble)
    • 参る = To come (humble)
    • 参る = To call
    • 参る = To be defeated
    • 参る = To collapse
    • 参る = To die
    • 参る = To be annoyed
    • 参る = To be nonplussed
    • 参る = To be madly in love
    • 参る = To visit a shrine or grave
    These are all pronounced "mairu", you have to figure out which one given the context!


    Kanji are comprised of component parts called "radicals", and some of these radicals are actually other kanji:
    •  =  + 
    If you were learning , then it would be a lot easier if you already knew the other two.
    • 家 = House
    •  = Roof
    •  = Pig, hog.  (archaic term)
    So, a pig under a roof is a house.  Sure, it's a little bit weird, but it's certainly a lot easier to remember than a collection of random scribbles.

    Unfortunately, the order in which kanji are taught understandably pays more attention to the needs of Japanese children than it does to foreign adults.  So kanji for simple words which a five-year-old could understand are taught early on, and more complex words come later.

    Kanji Tree

    Faced with the daunting task of learning a few thousand kanji, I naturally turned to my computer for help.  The result is "Kanji Tree".

    It's an application for mobile devices, being developed primarily on Android but I'll upload for iOS too when I can get the auto-builder outputting IPA files.  It's still a work in progress, but it's usable right now.

    I'm writing it in Unity (of course) and I'll be digging into the problems and solutions I discovered on the way.

    I hope someone finds it useful.

    Thursday, 24 April 2014

    Shiny new blog!

    It's so nice working for a company which actively encourages you to share ideas and code with the wider community.  I'm talking, of course, about Unity Technologies (the engine people) who's attitude contrasts in so many ways from those of my previous employers.

    Until now, the standard position has been "we own everything you write, scribble, say, or even think while you're here", leading to a career of reinventing various wheels over and over again.

    Thankfully, no more.

    Hence this blog.