Tagged: programming
The PyCon row
I have never written any Python. Maybe that might change in the future, but not soon I think.
So PyCon, a big conference for Python developers, normally would not matter to me, especially as it is on another continent.
But this year’s PyCon saw a huge row about allegedly offensive and sexist behaviour. In my view the sexist bit is moot, the offensive bit is mild - if stripped of context. And the context is a year’s worth of rows about much more clearly sexist and offensive behaviour at developer conferences.
I won’t go into the details of the row, because I have no real knowledge of the detail beyond what I have read this evening, but I do have a sense that this is a sign of the software industry waking up to its very serious problems with women and the ridiculous behaviour and poor socialisation of many of the men who work in it.
So the row may have a positive outcome for the rest of us. Eventually.
Related articles
- Great female participation on PyCon US 2013 (wrongsideofmemphis.com)
- What really happened at PyCon 2013 (peak5390.wordpress.com)
- PyCon’s response to an inappropriate incident on March 17th (pycon.blogspot.com)
- Woman Publicly Fired For Tweeting About “Sexual Jokes” (buzzfeed.com)
- How awesome was PyCon? (mechanicalcat.net)
Improved “Life” for Scratch
The Art of Scratch, Code Club and the ICT curriculum
Regular readers will know I have something of a small obsession with Conway’s Game of Life – the classic “game for no players” based on cellular automata, and so, naturally enough, when I decided that I really had to write my own Scratch program from, err, scratch to sharpen up my skills for teaching children via Code Club, that is what I chose to write – the (not very sophisticated) results can be seen above.
My first conclusion is that Scratch is a truly awful tool for most programming tasks. I know it is not meant to be a general programming tool, but I quickly discovered that it is hobbled even when it comes to doing those things that one assumes, at first glance, it is set up to do – like drawing on the screen. Scratch actually has very, very limited functionality/expressive power when it comes to drawing graphics – being only able to handle pre-provided sprites (as first class objects) and using a pen which marks out one pixel at a time – thus one cannot (at least easily) find a way to draw anything beyond dots and lines on the screen in response to events.
If you run the above program using the Flash player provided by the Scratch site you will probably see one of the big downsides of that as outlines of the old crosses are left on the screen (the Java player does not have this problem but it is very slow in comparison).
From a teaching point of view I also find Scratch’s message-based system less helpful than an imperative GOSUB like approach: the children I work with, after many weeks, are still struggling with the idea that messages should drive actions (probably we should blame their instructor!) – I know this event-based style is more common in the real world, but I think teaching the idea of problem decomposition via subroutines or functions is probably more important educationally.
Yesterday I went to the first London Hackntalk and gave an impromptu (and so unprepared) and brief talk on my thoughts about teaching children to program – my experience with Code Club makes me rather less starry-eyed about mass programming education. There were a few responses from the audience which suggested I had not really got my point – that we would struggle to fully replace an ICT curriculum based on usage skills with one based on programming – as the audience continually suggested ways to get motivated and engaged kids into programming (rather than make it a mass participation thing), but one point that was made by a member of the audience was very acute – given what our children see computers do in games that cost many millions to develop, how realistic is it to expect all or many of them to put lots of effort into toy programs that chug out the sort of graphics you can see above? I think that is a really difficult issue we have to consider when overhauling the curriculum and I am not sure the enthusiasts of radical change (of which I was and still am one) have thought it through fully.
(I did also encourage them to be Code Club instructors and was a bit disappointed to see that I appeared to be the only one – we urgently need to teach more programming and so these problems of the early days of the overhaul should not obscure the need for change.)
Related articles
- Here Come the Coding Girls (antsict.wordpress.com)
- Code Club doubles reach, calls for developers to volunteer (wired.co.uk)
- Coding, Computer Science and iPads – My Current View (antsict.wordpress.com)
- Code Club Crew (stclemcodeclub.wordpress.com)
- First Code Club (stclemcodeclub.wordpress.com)
- Tablets and Apps: How to ensure impact on teaching and learning (1 of 5) – The Big Picture (olliebray.typepad.com)
- The educational potential of computer programming (bobbywhyte.wordpress.com)
- Why Programming is so Hard to Teach (gflint.wordpress.com)
- Teaching Kids to Program Using Scratch and the Kinect (classroom-aid.com)
- cellular automata (cyberleague.wordpress.com)
Scratch: why, oh why, oh why?
I decided I wanted to write “Conway’s Game of Life” in Scratch (I am sure somebody else will have done this, but that’s not the point).
What a nightmare. Enough to make me rethink my views on Scratch’s usefulness as a teaching tool.
More to follow when I have actually finished it – tomorrow evening I hope.
Renamed my project Postmeta
As Steven Kelly pointed out to me there was a trade marked product called MetaEdit+ I renamed my project to build a editor/viewer of MetaPost files Postmeta: I don’t think that is taken.
I also worked out why I could not see the mplib.h header for the MetaPost library – or indeed many of the source files: I had to download the code from the MetaPost SVN repo – here – and then build the code. I think the fact it took me a day/a question on tex.stackexchange.com to get that answer shows how sadly neglected the excellent MetaPost package is.
New coding project – metaedit – started
I have started writing a MetaPost editor – metaeditpostmeta – which is on Github.
I am not sure how much time and effort I will be able to devote to it, but hopefully I will produce something somebody (even if it is just me) can use.
Yesterday I discovered someone had written a DSL with Haskell to generate MetaPost output – and so maybe I could do something similar using Groovy, but to commit myself to that would be a step too far for now.
Still, it is good to be writing some code again.
Related articles
- Embedded domain specific language (haskell.org)
- My rant about Haskell (rwmj.wordpress.com)
- Meta edit calc execution v3 (slideshare.net)
Code Club first session
At last managed to lead my first “Code Club” session – it had a slightly chaotic start as none of the computers we were using had Scratch installed and nor did we have access to a login that allowed us to install Scratch in the Windows “Programs” directory – but once we worked around that we all had great fun.
From the start it was obvious that Scratch made sense to the kids – they immediately grasped that the endless loop control would set the actions it enclosed to run endlessly. Of course nobody (apart from Visual Basic users?) works with similar simple graphics tools when writing an industrial strength program, but that was not the point: this is about teaching loops, conditionals and branches and so on.
The lost time at the start meant it was all a bit hurried so I do not know how much of the programming the children took in – as opposed to just ensuring that their Scratch scripts matched those in the worksheet. But on the first time out – none of the children had used Scratch before – simply being able to manipulate the programming elements was probably more than enough.
In any case, all of them were hugely enthusiastic when I told them they could install Scratch on any computer they had at home and practise on it there.
Code Club feels like a huge success to me already.
Related articles
- Code Club Week 1 First Thoughts (antsict.wordpress.com)
- Raspberry Pi in schools (raspberrypi.org)
- Week 6 in ScratchPiBot Club (cymplecy.wordpress.com)
- Coding for kids is as easy as Pi (wired.co.uk)
- A nostalgic look at what a 13 year old can do with a C64 (hackaday.com)
- Codecademy’s Zach Sims is leading a movement; now can he build a business? [GigaOM] (gigaom.com)
- Week 4 – ShrimpingIT Maker Club (cymplecy.wordpress.com)
Missing coding
Ever been engaged in an intellectual activity where the hours whizz by much faster than you think, as you puzzle over and round the issues while feeling an intense pleasure that makes the rest of the world seem less important? This what is called “flow” and, generally, it is what I feel when I am coding.
I am not the world’s greatest coder, to be honest I am little better than average (though doing the MSc at Birkbeck made me so much better than I used to be). The pleasure doesn’t come from having a natural skill that means I can write hundreds of lines at a single sitting: like a typical programmer, if I got 20 fully debugged lines out a day, every day, I would count that as decent performance.
But lately I haven’t done any coding at all (apart from a few lines of scripting in the office to ensure SMB mounts are automatic and such like). Instead I have read a lot of computer science papers and spent a lot of time working on a presentation I need to make and a literature review that will come after.
But I miss the coding, and I am missing it more every day.
Now, coding is also very more-ish. If you code to scratch an itch then chances are you make yourself itchy by coding. So earlier this year I wrote a Groovy/Java hex editor – Hexxed – after I wrote a Linux filesystem where I could not find a hex editor that did what I wanted to do, and so on.
So, even as I puzzle about whether I should write some code just for the sake of a mental stretch, I also wonder what I would write.
Related articles
- What Programmers Want (michaelochurch.wordpress.com)
- Your code is a liability (chrismdp.com)
- Confessions: Hacker Proof Boolean (thedailywtf.com)
- Give me Something to Code (restreaming.wordpress.com)
- University… to go, or not to go… (creatingacareer.wordpress.com)
- Command Injection (protogenist.wordpress.com)
The expressive power of BASIC
As I have been working on BINSIC – my reimplementation of BASIC as a domain specific language via Groovy- I have been increasingly struct by how unbelievably awful BASIC is (at least in the ZX80/ZX81 dialect that I am basing all this on).
My memories of it are of a fun language where it was possible to quickly pull together some useful code to do the sorts of things 15, 16 and 17-year-old geeks were interested in.
But I really have to wonder now – it doesn’t even support user-defined functions: looking back I wonder why I wasn’t more enthused by PASCAL when I met it and its procedural programming paradigm at university: it certainly feels that I ought to have seen it as a fantastic improvement (though by then I was more into Z80 machine code than any high-level language).
But BASIC does have its strengths – as I have found out.
This piece of code is a prime example: 100 INPUT V
This means create the numeric variable called V and assign to it the value typed in by the user at the keyboard.
Trying to do this in Groovy/Java requires the creation of a whole new class just to handle the keyboard input, as well as mess about with thread synchronisation to ensure that the process waits for the input … what follows is just a part:
def waitOnInput()
{
def textIn = binsicEngine.binsicWindow.textIn
clearInputs(textIn)
def countDown = new CountDownLatch(1)
textIn.getInputMap().put(KeyStroke.getKeyStroke("ENTER"),
BinsicConstants.INPUT)
def inputAction = new BinsicInputAction(textIn, binsicEngine.preProc,
countDown)
textIn.getActionMap().put(BinsicConstants.INPUT, inputAction)
countDown.await()
return inputAction.result
}
Related articles
- Who owns the perk in Java? (economist.com)
- Just like 1980 (cartesianproduct.wordpress.com)
Line numbers problem solved, after a fashion
I am currently working on BINSIC – Binsic Is Not Sinclair Instruction Code – a reimplementation of ZX80/ZX81 BASIC in the form of a “domain specific language” coded in Groovy.
The biggest problem so far has been the issue of GOTOs and line numbers. BASIC, at least classic BASIC, relied on line numbers and GOTO commands (and the related GOSUB) to control the order of statement execution – a simple, endless, Fibonacci sequence generating example is below (unfortunately wordpress.com does not appear to offer support for BASIC code listings):
10 REM Fibonacci sequence
20 LET x = 0
30 LET y = 1
40 LET i = 0
50 PRINT “Iteration “, i, ” value is “, x
60 LET temp = x
70 LET x = y
80 LET y = y + temp
90 LET i = i + 1
100 GOTO 50
But such code constructs are completely alien to Java/Groovy. Indeed the point of ‘object orientation’, as with procedural coding before it, is often said to be the removal of the GOTO: “Goto considered harmful” as one famous paper put it.
But there may be a solution: Stripping off the line numbers is the easy bit – and line numbers can then be mapped, using the map class, to lines in the file. Then the file can be reprised from the mapped in line number – in this case that means when the code got to the line numbered 100 (line 9 in computer-scientists-start-from-zero form) the code can be reprised from line 4 (i.e. the line numbered 50).
This actually works, and was not too difficult to implement: but there is a problem. The call to line 50 works like a form of recursion, creating a stack entry and awaiting further execution i.e. we pile uncompleted scripts one on top of the other after every GOTO.
A simpler piece of code might make this plainer
10 PRINT “Hello World”
20 GOTO 40
30 PRINT “Should never get here.”
40 PRINT “Finishing.”
This should generate the output:
“Hello World”
“Finishing”
But, instead, without outside intervention, would give me:
“Hello World”
“Finishing”
“Should never get here”
“Finishing”
- as once the first path of execution gets to line 40, the stacked up code is then called.
The answer is to halt or pause execution when the code returns from the GOTO. But I cannot kill the thread of execution as then the output window would also disappear. Instead I just pause it waiting for some form of input:
def getTo(def lineNo)
{binsicEngine.getTo(lineNo)
System.in.withReader { println (it.readLine()) }
}
It’s a long way from pretty, but it works: the Fibonacci sequence generator above runs into problems with MAX_INT before it crashes due to running out of stack space, for instance. But I hope I can find a better solution.
Related articles
- Struggling with line number problem (cartesianproduct.wordpress.com)
- Some practical uses of goto (ejrh.wordpress.com)
- Tell a Fib and Win a Prize (wordswewomenwrite.wordpress.com)



