funcjure

funcjureI’ll soon be starting a new permanent job, and in preparation I’m making it clear what is my prior intellectual property. In this case, it’s not so I can make “oodles of money” in the future, but it’s actually so I can release it as Open Source.

So what I’ll be explaining here is not something I’ve finished, but an idea which I’ve actually been playing around with for a year or so, but never gotten around to fully implementing. This will also help bring together my thinking on this and hopefully inspire me to really get going on this project :-)

 

What is funcjure?

funcjure is a “functional syntax wrapper” around Clojure. What do I mean by that? Well, Clojure is a great language, especially if you’re either used to or prepared to adapt to prefix notation. ie instead of typing 1+1, you type (+ 1 1) which although relatively easy to understand, can get a bit harder as things get more complex, like 9+5*7/4+62/6 which would translate as (+ 9 (*5 7) (/ 62 6) etc…

The logical question is Why? (do I have to type prefix notation) The Clojure and Lisp people will say “well, that’s the way it is, so just get used to it”, which I’m fine with as I wrote my first Lisp program over 3 decades go. Even still, I would prefer to use infix notation (which is what we’re taught for maths) and see no reason why we shouldn’t as computers are great at doing the sort of rote translation required to convert infix to prefix notations.

Clojure is a great language, which also has a fantastic ecosystem and community, and is written in Java which has a HUGE ecosystem. Furthermore, Clojure can call Java code, which has helped tremendously by giving Clojure “out of the box” access to so many libraries and products. Finally, because Clojure is a Lisp, its strong point is Symbolic Manipulation which is exactly what is required for translating infix to prefix structures in order to implement funcjure!

What would this look like? Let’s take some typical Clojure and then show what it would look like in funcjure:

"Hello World!"            ; Minimal "Hello World!"
; "Hello World!"

(println "Hello World!" ) ; Standard "Hello World!"
; println("Hello World!)
; Clojure((println "Hello World")) ; Execute some Clojure code
(def a "test")            ; Define a variable
; a="test"

(def mylist '(1 2 4 5 6)) ; Define a variable list
; mylist='(1 2 3 4 5 6)

(println a mylist)        ; Print our variables
; println(a mylist)

(first (rest '(1 2 3 )))  ; Get the 2nd element of the list
; first(rest('(1 2 3)))

(.println System/out "Hello World from Java!")
; System.out.println("Hello World from Java!")
; or Java(System.out.println("Hello World from Java!"))

(defn factorial           ; Now let's do the classic Factorial function
  ([n]                    ; when only one argument is passed in
    (factorial n 1))
  ([n acc]                ; when two arguments are passed in, with recursion
    (if  (= n 0)  acc
    (recur (dec n) (* acc n)))))
(factorial 6)             ; And test it
; factorial(n) = factorial(n 1)
; factorial(n, acc) = if((n==0), acc, recur(dec(n), n*acc))
; factorial(6)

The overall purpose is to make code much more accessible and ‘natural’ to write as we’re essentially taught infix notation as our “second language” when we study even the most basic mathematics. None of this is really new – in the beginning, things look like our old friend BASIC, with direct assignment and loose typing, which easily map to Clojure. You’ll also notice that access to Clojure and Java is provided by the respective functions. Speaking of functions, these are written similar to Prolog and other languages (eg Erlang) which allow for “pattern matching” in function definitions. In the beginning, the capabilities would be mapped directly to Clojure (as shown above), but eventually it would be nice to go to a full Prolog style, so the factorial function could be written like

factorial(0) = 1                ; The base termination case
factorial(n) = n*factorial(n-1) ; Iteration by recursion

which I think is way more elegant.

That’s about it for this post, as this really contains the base concepts for what I’d like to do. There’s obviously a lot more scope and subtlety to this, some of which I’m aware of and probably a lot more which I’m not, but I personally would much prefer to use a language like this and have access to Clojure and Java when needed for efficiency or easy code porting.

What do you think? All comments / suggestions / critiques would be gratefully accepted as I haven’t really done much more work than this, other than having a 1/2 working translator for this syntax which I’m going to (hopefully) get to work on in the next few weeks before I start my job.

Watched Over By Machines Of Evil

Machines Of Evil

I dread to think (but
cannot help!)
of a cybernetic dystopia
where mammals rule computers rule mammals
living in a sad world with no humanity
algorithms polluting
our water
and our sky.

I dread to think (but
cannot help!)
of a cybernetic garbage dump
filled with dross and electronics
where deer are killed
by protective drones
as if they were objects
with no remorse.

I dread to think (but
cannot help!)
of a cybernetic boot
stomping for continual labor
detached from nature,
detached from mammal
brothers and sisters,
and all watched over
by machines of evil.


The above is the exact opposite of “All Watched Over By Machines Of Loving Grace” by Richard Brautigan. And no, I don’t actually think of that as our future, but more of a warning of where it could go if certain human dynamics in our world system are left unchecked ;-)

Star Trek Beyond – BRILLIANT!

StarTrekBeyond

NOTE: Spoiler Free Review :-)
VERDICT: BRILLIANT!

Before going to see Star Trek Beyond (in VMax & 3D at Crown Cinemas in Melbourne) I just happened to see one review which was rather negative, so I thought I’d write this one as my (and IMDB & Rotten Tomatoes) experience was pretty much the opposite. The film is GREAT! It’s probably the best of the Abrams reboots (at least as good as the first, and better than the second in my opinion).

With the price of movies (and Popcorn!) these days I’m pretty picky about what I see at the cinema, but the Abrams Star Trek movies need to be seen on a large screen in 3D. Speaking of 3D, I think they got it right as some films have given me a bit of a headache – this one was fine.

As this is a spoiler free review, there’s a lot I won’t cover, except what is revealed in the trailer – the Baddie (Krall) and his force are great, and there’s a clever twist at the end. Jayla is a great new character and hopefully we’ll see more of her. As to the ‘old gang’, well, they’re the crew of the Enterprise and all seem to get pretty even exposure throughout the movie.

Some of the highlights for me were:

  • The graphics in general – no more lens flares ;-)
  • “Gravity Scenes” – obviously a lot of thought put in to them
  • The view of warp from the outside – such a great new visualisation
  • The “Super Star Base” (York Town)
  • There’s a Gay character – obviously not groundbreaking in movies, but at least for Star Trek – and it’s handled well in that it’s “no biggie”, but “just the way it is”

Any Cons? Not really… this movie is not perfect, but it’s very good and moves along at a reasonable pace. You have to “suspend disbelief” to be in the “Star Trek Universe” – I can’t comment on what this film would be like for an “objective person” (who I presume would of never seen anything Star Trek in their life ;) as I literally grew up with Star Trek (my early first memories of TV were Star Trek as it was very (on the edge) scary to me at the time). There was some criticism of “dark scenes”, but there’s only a few really dark ones and it’s used effectively to dictate the mood.

Overall, I think they’ve now got a really good “tone” to Star Trek Beyond (thanks in part also Justin Lim’s (Fast and Furious) direction) which sets things up very nicely for the next movie – seems like they’ve really found their feet. As I mentioned earlier, this is a movie to see on a large screen and 3D. It’s also a movie I’d definitely see again (on DVD) as I’m sure there’s some bits I missed.

Back in Australia

MoranReserve

WOW! I just realised that it’s been a year since I did a blog post. I knew it had been a while, but I figured around 6 months max… Well, I suppose I needed it, and the good news is that I’M BACK!

I’m not going to go in to what has transpired over the past year since an agile adoption, as it’s quite involved and will come out in some successive posts, but will focus on where I am now and what my Posting Plans are.

Near the end of last year we started planning a return to Australia after almost a decade in the UK – what a BLAST! So many lovely experiences, people, places and new friends :-) Eventually though, it was time to return to Australia as it really is my home and although I may have a few gripes about it, Australia really is an amazing place and as the old cliche goes: I now really appreciate how lucky I am to live in this country after being away so long. That shot above is from my local beach which is 3 mins drive, and I can get in to the city (in the distance) in around 1/2h with a walk and public transport – that’s a pretty good lifestyle.

So what’s in the pipe? A much more varied mix than when I started out doing just “software stuff”:

  • Reflections on life in the UK and Europe
  • Observations on life in Australia now I’m back
  • Reviews of gadgets
  • Travelogues as I explore my own country – now I’ve probably seen more of Europe than I have of Australia, so it’s time to correct that
  • Process  – yes, I’m still on the agile path
  • Architecture – looks like that will be my primary area of work still
  • Software – which I’m gradually getting back in to, with the current focus being Clojure
  • Probably the odd bit of music or photography to round things out
  • Anything else anyone would like me to write about…

YachClub

an agile adoption

Tai Chi Statues

My approach to agile* adoptions is based quite a bit around Tai Chi and Taoist philosophy which I won’t go in to as you can search about that on the net. There are a few principles worth noting from these:

To the mind that is still, the whole universe surrenders ~ Lao Tzu – 6th century, BCE

Empty your mind. Be formless, shapeless. Like water. You put water into a bottle and it becomes the bottle. You put in a teapot, it becomes the teapot. Water can flow, or it can crash. Be water, my friend! ~ Bruce Lee, 1971**

which are a good philosophical summary of my approach to agile adoptions (well, actually life in general ;)

This series of posts is not directly about philosophy, it’s about the day-to-day progress of an agile adoption: The Good, The Bad and The Interesting.

So stay tuned, check back and drop in if you’re interested as this is just the beginning…


* In this series I’ll use the term agile with a lower-case ‘a’ to indicate “real ‘good’ agile” which I’ll explain as we go, compared to “Industrial Agile”, “Consulting Agile” and “Corrupted Agile” which start with an upper-case ‘A’

**

Swift to Objective C to C

ObjC swift COne of the things Swift promised was interoperability with Objective-C and C/C++. Well, it’s now here – relatively easily…

asciitrek asciiIf you follow me on Twitter (@RiczWest) then you’ll know I was working on an iOS game called ASCIItrek which is derived from Super Star Trek that was written in C. I’ll eventually do a complete rewrite in Swift, but before that I’m taking the existing code and integrating it in to an iOS interface. In order to do this I’ll need to call C code from Swift. The Architect in me however wants to cleanly separate things and use Objective-C as a “bridge”, which as you’ll see later is probably a pretty good idea.

It’s always been “theoretically possible” to do this in earlier releases of Xcode prior to 6.3, but the whole process seems fraught with potential errors and I could never get it fully working. With the recent release of Xcode 6.3 I thought I’d give it a go and am glad I did as it seems to work relatively easily as I’ll describe.

Note: In this post I’ll assume that you’re relatively familiar with coding in Xcode

Firstly, you’ll need to create a project, which is no-brainer – just create a Swift one which we’ll adjust as we go… At the highest level we’ll have some code which acts as a test harness which I just added:
SwiftHarness

where chopper (tribute to American Chopper :) is an Objective-C method and c_chop is a c one which is invoked from Objective-C. First, the Objective-C one which is relatively simple:

OCC

if you just look at the chopper method where I’m basically doing a string concatenation – we’ll get on to the c_chop method  after we’ve examined the C code:

chop

which has one basic method/function called chop that like the Objective-C one just prepends the parameter which is obviously more complex in C. The one thing that worries me slightly is the fact that I’m mallocing memory which is passed to Objective-C which I’m kind of assuming will be deallocated – I’ll probably revisit this later…

If you go back to the Objective-C code above for c_chop you’ll see there is a bit of complexity, which is why I think it’s better to wrap a C call in Objective-C. The stringWithFormat: method is just a concatenation, but notice that you have to convert the Objective-C/Swift string to UTF8Sting before passing and then convert the result back with stringWithUTF8String. To me, this is enough reason to have an Objective-C layer interposed between your Swift and C layers.

Hopefully this post has made it easier for anyone else who is on the same path – the code is on GitHub at https://github.com/RiczWest/swocc – feel free to mail me if you have any questions. Later, I’ll be doing another post on C to Objective-C to Swift (which I also need)

PS Having HUGE problems with syncing GIT, which I have just checked and they are a BUG – I will attempt to fix later…

The End of the Apple Honeymoon?

Note: If you think I’m some kind of “Apple Hater”, read My History with Apple at the bottom

Apple seems to be suffering an all-round lack of quality in their software and some would say hardware – what to do? Before we get in to this, let me tell you my tale of woe…

FlamingHoneymoonThis post has been 6 months or more in the making, but has culminated with the problems I’ve been having with my iPad Air 2 over the past months. It all started so innocently – I was happily using iOS 7 and I’d installed a new App which said “In order to use this, you must use iOS8”. Fine, I thought – it’s been out for a while and there have been a few incremental updates (something like 8.0.3) so I upgraded. From memory, this one was OK, so when 8.1.2 or 3 came out I didn’t really think much and just upgraded, and that’s when my problems started.

Apple Horror MovieIt was a bit like a horror movie – you know, everything is fine, the sun is shining – living the good life (on iOS 8.0.3 :). Then, one day (some time in 8.1), something a bit out of place happened – I was finding it hard to close browser tabs – didn’t really think much of it. Unfortunately over the next few days, things got worse! Typing started either not getting the characters or doing multiple characters and it just got worse and Worse and WORSE! Basically, my iPad was bricked. “Luckily”, 8.2.2 had been out for a while so I upgraded, after checking the forums as some people reported it solving the problem.

Groundhog DayThen, like a groundhog day, all started coming back with the same pathology – first, an error here or there and after a few days – bricked again. 8.2.3 came out so I went to this – same thing – worked for a while, then bricked. I was at the end of my tether and was at the stage of buying a cheap Android tablet to use at work until Apple fixed things on the iPad. Again, as luck would have it, 8.3 is out and I’ve just upgraded today. I’m not holding my breath though as I know that this bug can surface after days or weeks…

 What’s the Problem?

My experience is not unique. In fact, I’m one of the “Lucky Ones” who didn’t have problems with iOS 7. Just Google “iOS problem” and you’ll find there are 194M pages!!! I know there are even more hits for Android (564M) and Windows Mobile problems (264M), but is that really something to compare to? Especially when both those platforms are on a wide range of uncontrolled hardware, whereas Apple is a “closed ecosystem” where they’ve designed every Apple Phone ever made. As a long-time (over 30 years – I started with an Apple II) Apple user I’ve seen an increase in the quality of their software, until the last few years. A bit like my touch problem, they surfaced occasionally, but were not of significance, but now we’re talking about many, releases with the same or worse problems – where will it end? Don’t think iOS 9 will necessarily fix everything as as iOS 8 was supposed to fix the problems of iOS 7!

What’s even worse, the “Crappy Quality Virus” seems to of infected the Mighty OS X. Touch wood and 3 Hail Mary’s I’m actually OK – running Yosemite 10.10.3 and no problems. Again, Googling “OS X problem” gives 264M hits – more than iOS! For both OS’s, there’s now a huge industry around documenting and fixing the various problems – all on platforms that Apple has total control over – THERE IS NO EXCUSE!

What’s the Solution?

As I mentioned at the beginning, I’m not an Apple Hater. In fact, I’m an Apple Lover – I used to have the attitude of buying Apple for anything personal. Unfortunately, I’m now in the situation where if this doesn’t improve I’ll be replacing my iMac with one of the many all-in-one PC’s, and my Tablet with an Android or Windows one. I already have an Android phone as I was about to get a 5, but the company I was working for got pre-release devices and they kept (physically) breaking.

Apple JobsTo the solution: I believe this malaise set in with the passing of Steve Jobs. For all his faults, the amazing thing about Jobs was that he got understood the Business, Design, Hardware and Software of making “Insanely Great Products”.

What have we now? We have Tim Cook who’s background is in Sales and Manufacturing and Jony Ive, the reclusive yet internally influential and widely acknowledged design genius (although I do question the “new blue folders” on Yosemite and the Apple Watch). What’s missing?

        Hardware & Software

Name the people associated with those… There’s a hardware guy who we see in their videos, but I can’t find him on Google. For software, there’s Craig Federighi and I must admit I thought Phil Schiller was until I looked up Google and found he’s VP of Marketing! Therein lies the problem – there’s no outstanding person across Hardware and Software. Although the ideal would of been to find another Jobs to replace them all, I don’t think that would ever happen. What is needed is someone responsible for “Integrated Design” who can work with Ive, ensure the highest standard of hardware and software is produced to go in to the Objects of Desire that Apple makes and has the same visibility as Cook and Ive.

Why did I write this?

Probably mostly to get all this off my chest and also as a warning of what may happen to Apple if they don’t get back on track. We’ve seen so many companies like IBM and Microsoft fall so far when they lost their way, it would be a pity to see the same happen with Apple…

Finally, I have the tiny hope that someone at Apple sees and relates to it – I’d love to continue the conversation…


original-apple-logoMy History with Apple

As mentioned at the beginning, before anyone thinks of criticising this piece (which you’re free to do after you’ve read this :) here’s a brief history of my (hopefully ongoing) time with Apple products:

  • Started with an Apple II
  • Used a Lisa – a rich friend had one when I was in my senior school years
  • Got caught up in the “PC Revolution”
  • Shipped some of the early NeXTs* to Australia, did the Australian product launch, taught NeXT programming, created software for NeXT, attended most NeXTworlds and met Steve Jobs
  • Got caught up in the “Java Revolution”
  • Employed by a company in the 90’s who used Apple gear, got my own and went to a few WWDCs (before they were hip)
  • Have continuously bought Apple products again since the 90’s
  • Currently have an iMac, Mac Mini, iPad 2, iPad Air, two Apple iPods and an Apple TV

* For you young’ns, NeXT was what Jobs created after Apple fired him and NeXTstep was the operating system which became Cocoa – all those NS prefixed classes stand for NextStep