02 April 2017

Which programming language to teach? A principled choice

Java is still one of the most popular programming language to teach the young or newbies to programming.  It's a very problematic choice.  See:

  1. The problem of Object Oriented Programming is an education one
  2. Learn Python instead of Java as your first language [1]
  3. Java has deep expression problem for beginning students
  4. Governments mandating which programming language to teach
Having looked at some of the problems and issues before, I want to be constructive and offer some principles for how to choose which programming language to teach instead.


1. Principle of no magical incantations

This can be viewed as a language feature vs. library supplied functionality issue.  The latter is mostly okay, but the former should have no magical incantations that students need to learn.

Magical incantations are language features like the "static" keyword in Java.  You could imagine a student asking:
What does "static" mean in the "main" method declaration?  Why is it "static" and not something else?  What does "static" do?  Why do I need to write "static" when I don't know what it means to make something "static" vs not static?  I don't want it "static", I want it "grounded", can I write that instead?
Now you could imagine a teacher answering:
The answer to why, what, how, etc., would require explaining OOP and how it's implemented in Java and...  Look, just write 'static'.  It's just the way it is.  Just do it this way or else it doesn't work.  It's a magical incantation the Java gods require you to recite.
The more language features required to write even a simple program, the more things students have to learn or be ignorant of but use (i.e. magical incantations).

That makes it more likely that students have to learn everything about the programming language all at once just to do even the simplest thing at all.

2. Minimize concepts required to start doing stuff

The more that foundational programming concepts are required, the more programming language specific things students must think about whilst at the same time thinking about solving the actual (i.e. non-programming-language, "business") problem in its problem domain.

Otherwise, it'd be like students have to learn everything in the programming language all at once in order to do anything at all.

3. Idiomatic code from the start

A programming language that encourages writing idiomatic code from the very start reduces either the magical incantations required in writing idiomatic code, and reduces dumb code written stupidly just to avoid learning the magical incantations.

Otherwise, students have to learn everything all at once just to do anything at all.

Magical incantations are not hidden machinery!

I'm not advocating learning C because it doesn't have the magic of a garbage collector (GC)!  The GC is not a magical incantation: it's mostly hidden machinery.

Hidden machinery works quietly, never broadcasting its own existence, and isn't in your face about what it does.  It doesn't offer an affordance where none is called for, or where it would be inappropriate for the target user.

Magical incantations are flamboyant and in your face.  You know it's doing work because the magician is showing you that work is being done through the incantations, even if what's shown and what's done might very well be disconnected from each other.

To a newbie, the "static" Java keyword (to pick on something as an example) is magical incantation.  The Java GC is hidden machinery that we should be thankful for having every day.

Hidden machinery that makes a language easier for a newbie to learn is great.  Magical incantations that calls out its own existence is not helpful.

Magical incantations are also not Spooky Action at a Distance.  But that's a topic for another day.


Afterword
I wrote the above years ago (around 2013 February 4), and only now slightly expanded and lightly edited it to share here.

[1] I don't recommend learning Python as your first language anymore for various reasons (but I'd certainly recommend learning Python over Java as your first language!).

03 December 2016

Elixir and Phoenix on MacOS for the First Time: install to first project

Let's install Elixir and Phoenix on MacOS, and create our first web app project.

I looked through 3 separate web pages to figure it out (it was relatively easy), and thought it'd help to gather it into a single page of 10 steps.

What's Elixir?  Elixir is a programming language that superficially looks a little like Ruby, but more importantly is designed to be dynamic, functional, and capable of building concurrent, distributed, low-latency and fault-tolerant systems (perfect for the web!).

It does that by running on the Erlang VM (like a Java VM, not like a VirtualBox VM), and that also gives developers access to Erlang’s ecosystem (this reminds me of how Clojure runs on the JVM, providing access to Java's ecosystem).

What's Phoenix?   Phoenix is an Elixir framework implementing the server side of a web framework for modern web applications.  Like Ruby on Rails or Python's Django, but Phoenix is written in Elixir and derives benefits from that (in addition to whatever other advantages it may have as a framework - we're not comparing frameworks today).


(1) Install Homebrew

To begin, you need Homebrew installed on your MacOS.  Homebrew is a package management system that makes installing lots of developer software much easier on Macs.

Once installed, especially if it's been a while since you've last used Homebrew, make sure to update it (commands after "$" are to be typed in your terminal window):

$ brew update

Do a self diagnostic to make sure it's all okay, carefully read the instructions it provides:

$ brew doctor


(2) Install Elixir

Elixir requires Erlang to be installed.  Fortunately, the Homebrew package will automatically make sure of that.

27 November 2016

Sharing TrueCrypt USB volume on 3 platforms: Mac, Windows, Linux

Edited 2017-04-02.

tl;dr: TrueCrypt exFAT volume on an exFAT disk. But creating such a volume is tricky!

I've tried to find a solution to sharing a TrueCrypt encrypted volume on a USB memory stick between three platforms: Mac, Windows, Linux.  It's been tough to find something modern and reliable, as I tried HFS+, Ext2/Ext3/Ext4 on USB and in a TrueCrypt volume.

Modern means that it'll properly deal with big files (over 4 GB), and long international file names (over 8.3 UTF characters).

The best solution I've found so far is a TrueCrypt exFAT volume on an exFAT USB stick.  But creating such a volume is tricky!  Using the wrong software to do the formatting will destroy the TrueCrypt file.

It's modern, and okay but not great in reliability.  There's some caveats and things to watch out for though to make this work well for you.

Such a tri-platform TrueCrypt volume can be created in basically 2 steps:

19 November 2016

Clojure Programming Cookbook - a Book Review

It's been a while since I've looked into programming Clojure again, having been preoccupied with C++ lately.  With the new Clojure Programming Cookbook, I've gotten to see a number of new developments in the Clojure ecosystem that is quite exciting.


The book is very example oriented, basically being a collection of code recipes for accomplishing common programming tasks with Clojure.  I like how it starts from very basic interactive programming and macro usage (this is a Lisp after all), all the way to talking about concurrency, parallel processing, and cloud-based tasks.  Each recipe is accompanied by brief explanations, preambles, and some cross references to related recipes in the book.

Each recipe is basically self-contained, so I wouldn't necessarily recommend reading the book like a book, but instead to use it as a "random access" set of references.  The ebook version is probably best in terms of allowing for full-text searching for key terms, and for clicking on relevant topics in the table of contents to look up useful recipes.  I'd personally prefer having the PDF ebook, but that's just me.

As a reference book, it's great if you already have familiarity with Clojure, but this book is probably okay for those of you programmers who don't yet know Clojure and want to learn it.  I'm not sure it's that great if you just don't know how to program and want to learn programming starting from nothing.  On the other hand, I could imagine a course instructor might be able to bootstrap the book with additional content to help absolute beginners get started, then point out recipes in the book to try out from time to time.

What's neat about this book for me is that as I've been away from Clojure for a few years, looking at this book I see recipes for topics I'd like to try out.  Topics I've heard of but just haven't followed along with over the years.  Like Transducers, and Om.Next.  So it's nice to see some self-contained examples of these exciting new developments in the Clojure ecosystem.  But given that it is just a cookbook, it doesn't seem to get deep enough into any specific particular topic for me to feel like I really know what's going on.  For that, I'd need to look to additional resources.

So there's definitely some caveats, but it is a pretty decent and easy going kind of book.  For a lower intermediate Clojure programmer, it's definitely a good resource to look into, maybe to help get you from programming on a single machine to programming for the cloud (AWS, etc.).  For upper intermediate programmers who's been away from Clojure for a while and want to see some new Clojure developments, I'd definitely see about getting it if you chance upon a sale.  The book lives up to its name as a cookbook.

23 September 2016

Ubuntu 16.04 guest + VirtualBox 5 + Windows: major version coordination bugs

Trying to run the latest Lubuntu (and I presume Ubuntu) 16.04 as the guest within a recent VirtualBox version (e.g. 5.0.22) on a Windows 7 host with anti-virus installed requires a certain amount of ... version coordination dancing, because of a series of unfortunate bugs.

The main problem is that the recent VirtualBox 5.x series has some major compatibility problems with Windows and/or the anti-virus installed with it.  Launching a VirtualBox image could result in a pretty scary error message like:
Error relaunching VirtualBox VM process: 5
Command line: ...............
(rc=-104)
And it's a "hard" error, blocking the VirtualBox image from even attempting to boot the guest OS.  Apparently it's something to do with "Hardened Security" [1].  There's some proposed workarounds but none of the proposed solutions worked for me.

Worse yet, after installation of VirtualBox 5.x (on a Windows 7 host) and successfully testing my Lubuntu guest image, my TrendMicro anti-virus updated overnight which created the above "Hardened Security" problem --- literally overnight!

The only reliable workaround is to downgrade VirtualBox back to the version 4.3.x series.  That's a workaround for the VirtualBox "Hardened Security" problem, but it creates new version compatibility problems between the guest OS and VirtualBox...  argh

But I found working workarounds.