Five Programming Top Tips (from a seven year old)

Earlier today I tweeted the above image of five handwritten top tips from a seven year old female who had been learning programming; these were extremely astute observations and were a delight to read.

After digging a bit deeper, I found the original blog post, describing in more detail the poignant observations of @fjsteele‘s daughter after spending an hour using Hopscotch, a visual programming language for the iPad. In the blog post, he explains that this was his daughter’s first programming lesson and he asked her to write down instructions on how to draw a square, and then use Hopscotch to make one; after that, they tried a triangle:

It was fun to see the `lightbulb’ come on as she tried different blocks, failed, tried something else. It was really fun to watch her discover debugging. She quickly learned not to do too much work before testing it out.

Not a bad summary from an hour of programming! What else would you add to this list?

Is the Universe a simulation?

From an article by Edward Frenkel in today’s New York Times:

Many mathematicians, when pressed, admit to being Platonists. The great logician Kurt Gödel argued that mathematical concepts and ideas “form an objective reality of their own, which we cannot create or change, but only perceive and describe”. But if this is true, how do humans manage to access this hidden reality?

We don’t know. But one fanciful possibility is that we live in a computer simulation based on the laws of mathematics — not in what we commonly take to be the real world. According to this theory, some highly advanced computer programmer of the future has devised this simulation, and we are unknowingly part of it. Thus when we discover a mathematical truth, we are simply discovering aspects of the code that the programmer used.

This hypothesis is by no means new; in Are you living in a computer simulation, Nick Bostrum argues that one of the following propositions is true:

1. the human species is very likely to go extinct before reaching a “posthuman” stage;
2. any posthuman civilisation is extremely unlikely to run a significant number of simulations of their evolutionary history (or variations thereof);
3. we are almost certainly living in a computer simulation.

What Superman III teaches us about programming

I’ve always had a soft spot for Superman III (1983), the third film in the original franchise starring Christopher Reeve as Superman. While it’s generally regarded as being below the standard of the first two films, it has some great moments e.g. the scene where evil Superman fights Clark Kent.

In Superman III, Richard Pryor plays Gus Gorman, a man with no known computing skills whatsoever, who — when his social security is stopped — turns to programming out of desperation.

After completing a programming course (presumably in BASIC or COBOL), Gus soon lands a job at Webscoe Industries, unaware that he’s working for Evil Robert Vaughn. He stays back after work one night, to hack into the work computers and award himself a few extra expenses. But what possible lines of programming genius will it require? What would you need to type in to override all the ruthless security of the Webscoe Payroll Division?

Err…it’s a good job he did that course.

After receiving a cheque for \$85,789.90 and turning up to work in a new Ferrari, it all goes rather downhill: Evil Robert Vaughn coerces him into hacking the Vulcan weather satellite, as well as manipulating the global financial system, damaging the world’s oil supplies by moving every tanker into roughly the same place and replicating kryptonite by tracking down unknown elements in outer space. With the programming educational element of the film done by this point, Gus proposes building a “supercomputer”, eventually leading to the creation of a Robocop prototype.

Read the full Den of Geek analysis of Superman III‘s contribution to the teaching of programming; and remember: all of this computer mayhem came from a man who answered an advert on the back of a book of matches.

Tagged , ,

FuckIt.py: The Python Error Steamroller

Having problems with your Python code? Try FuckIt.py by ajalt:

FuckIt.py uses state-of-the-art technology to make sure your Python code runs whether it has any right to or not. Some code has an error? Fuck it.

FuckIt.py uses a combination of dynamic compilation, Abstract Syntax Tree rewriting, live call stack modification and love to get rid of all those pesky errors that makes programming so hard. All functionality is provided through the fuckit module: add import fuckit to the top of your script, then you can use fuckit in a number of ways e.g. as a replacement for import when a module has errors — just change import some_shitty_module to fuckit('some_shitty_module'):

```import fuckit
#import some_shitty_module
fuckit('some_shitty_module')
some_shitty_module.some_function()
```

Still getting errors? Chain fuckit calls. This module is like violence: if it doesn’t work, you just need more of it:

```from fuckit import fuckit
fuckit(fuckit('some_shitty_module'))
# This is definitely going to run now.
some_shitty_module.some_function()
```

You can also use fuckit as a decorator and a context manager; plus check out its extremely permissive public license.

(also see: FuckItJS, the Javascript Error Steamroller)

Tagged ,

2014 Software Sustainability Institute Fellowship

I’m delighted to have been named today as one of the sixteen Software Sustainability Institute Fellows for 2014.

The Software Sustainability Institute (SSI) is an EPSRC-funded project based at the universities of Edinburgh, Manchester, Oxford and Southampton, and draws on a team of experts with a breadth of experience in software development, project and programme management, research facilitation, publicity and community engagement. It’s a national facility for cultivating world-class research through software, whose goal is to make it easier to rely on software as a foundation of research; see their manifesto. The SSI works with researchers, developers, funders and infrastructure providers to identify the key issues and best practice surrounding scientific software.

During my fellowship, I’m particularly keen to work closely with Software Carpentry and Mozilla Science Lab to highlight the importance of software skills across the STEM disciplines. I’m also interested in a broader open science/open computation agenda; see the Recomputation Manifesto and the recently established recomputation.org project.

A set of top Computer Science Education blogs

Further to my most-read blog post (from May 2012: A set of top Computer Science blogs, 80,000 hits and counting), here’s a follow-up: blogs on computer science education.

As before, instead of a list, it more closely resembles a set: the order is irrelevant and there are no duplicate elements; membership of this set of blogs satisfies all of the following conditions:

1. they focus on computer science education (research, policy and practice);
2. they are of consistently high quality;
• Computing Education Blog by Mark Guzdial (@guzdial)

Mark is a professor in the School of Interactive Computing at Georgia Institute of Technology and a researcher in computing education. His blog is about how people come to understanding computing, and how to facilitate that understanding, cross-cutting research, policy, practice and wider societal issues. And while it is US-focused (as you would expect), it is an excellent venue for the discussion of key topics in computer science education.

• Teach Computing by Alan O’Donohoe (@teknoteacher)

Alan is a busy chap: as well as being principal teacher of Computing at Our Lady’s High School in Preston, he’s the founder of both Hack To The Future and Raspberry Jam, the global community of events for everyone to discover the wonders of the Raspberry Pi. His blog tracks his five-year computing journey: from improving classroom practice (listen to his Teach Computing podcasts), contributing back to the community as a CAS Master Teacher, to shaping the development of a new curriculum subject in England.

• Miss Philbin’s Teaching and Learning Journal by Carrie Anne Philbin (@MissPhilbin)

Carrie Anne is an award-winning secondary teacher at Robert Clack School in Essex and a passionate advocate for women in technology. She is the creator of Geek Gurl Diaries, a YouTube web series for teenagers who want to be makers and creators of technology (which recently won a Talk Talk Digital Hero Award) and vice-chair of the CAS initiative #include to address diversity issues in computing. Her blog also covers the gamut of classroom practice, the transition from ICT to computing, supporting the wider community, to shaping policy in England.

• Academic Computing by Neil Brown (@twistedsq)

Neil is a research associate in the Programming Languages and Systems Group at the University of Kent, working on the BlueJ and Greenfoot projects. He writes thought-provoking pieces on topics spanning computing (and more broadly, STEM) education, programming and socio-technical issues. He also has a second blog on learning and applying mathematics through computing: The Sinepost.

• An Open Mind by Miles Berry (@mberry)

Miles is a principal lecturer and the subject leader for Computing Education at the University of Roehampton. He sits on the boards of both CAS and Naace, with wide experience of curriculum development in the UK. His blog, a personal perspective on education, technology and culture, covers a range of interesting pieces on computer science and programming pedagogy, CPD and agile practice.

• Computer Science Teacher by Alfred Thompson (@alfredtwo)

Alfred is a high school computer science teacher in New Hampshire, having previously been the K-12 Computer Science Academic Relations Manager for Microsoft and a software developer for 18 years. He currently sits on the board of the Computer Science Teachers Association. His blog covers a wide range of topics, including computer science and programming pedagogy, curriculum development and US education policy.

• Knowing and Doing: reflections of an academic and computer scientist by Eugene Wallingford (@wallingf)

Eugene is an associate professor and head of the Department of Computer Science at the University of Northern Iowa. He has been blogging since 2004 on topics across computing, software development, higher education, learning and teaching, as well as managing and leading.

• Raspberry Pi Blog by the Raspberry Pi Foundation (@Raspberry_Pi)

These guys need no introduction, especially after the two millionth Raspberry Pi was sold in October! With the huge success and penetration of the Raspberry Pi over the past two years, the platform now exists for the Foundation to fulfil its wider educational objectives. A diverse blog, ranging from technical posts, peripherals and resources, to superb examples of innovative uses of the Raspberry Pi.

• CSTA Blog by the Computer Science Teachers Association (@csteachersa)

The Computer Science Teachers Association is a membership organisation (free to join), supported by the ACM, that promotes and supports the teaching of computer science and other computing disciplines in the US, providing opportunities for K–12 teachers and students to better understand the computing disciplines and to more successfully prepare themselves to teach and learn. Its blog covers a wide range of topics across computer science education, programming, curriculum design and education policy,

• CAS Online by Computing At School (@CompAtSch)

Computing At School is a membership organisation (also free to join), supported by the BCS, that promotes and supports the teaching of computer science in UK schools. Formed in 2008, it now has over 7000 members from across schools, colleges, universities, industry and government and is the subject association for computer science. Along with numerous high-quality articles in the quarterly CAS newsletter, Switched On, CAS Online provides the UK computer science education community with a wide range of forums, events, policy discussions, consultations and a veritable wealth of resources to support learning and teaching.

This set is most definitely incomplete — please post your computer science education blog recommendations in the comments below. You can also read some of my posts on computer science education.

Ten Simple Rules for Reproducible Computational Research

In a paper published last week in PLoS Computational Biology, Sandve, Nekrutenko, Taylor and Hovig highlight the issue of replication across the computational sciences. The dependence on software libraries, APIs and toolchains, coupled with massive amounts of data, interdisciplinary approaches and the increasing complexity of the questions being asked are complicating replication efforts.

To address this, they present ten simple rules for reproducibility of computational research:

Rule 9: Connect Textual Statements to Underlying Results

The rationale underpinning these rules clearly resonates with the work of the Software Sustainability Institute: better science through superior software. Based at the universities of Edinburgh, Manchester, Oxford and Southampton, it is a national facility for cultivating world-class research through software (for example, Software Carpentry). An article that caught my eye in July was the Recomputation Manifesto: computational experiments should be recomputable for all time. In light of the wider open data and open science agenda, should we also be thinking about open software and open computation?

Interview with ITWales

I was interviewed last month by ITWales, to talk about computer science education, CAS Wales, the Technocamps project and the future skills and expertise required to underpin the digital economy in Wales.

(full interview here)

Barack Obama on computer science and programming

Watch Barack Obama’s recent Google+ Hangout, in which he discusses the importance of computer science in preparing the USA’s future workforce, in association with the ACM (following on from a successful CSEdWeek in December).

A very clear message about teaching computer science and programming at high school, to develop creators and not just consumers of technology:

(N.B. Obama seems fairly comfortable with computer science, as this interview with Eric Schmidt from 2008 highlights…)

Tagged , , , ,

The Times: “Program or Be Programmed”

A lot of computer science in The Times today: a full-page article on page 3 entitled Play the game, but write the software too (£), a four-page pullout on learning how to code, as well as the following leader (£) on page 2:

Program or be Programmed

The best time to start learning the language of computer code is now

void draw() {
background(255);
stroke(0,0,0);
line(0,0,60,hour());
line(0,0,120,minute());
stroke(255,0,0);
line(0,0,180,second());
}

The world divides into a majority of people for whom the preceding four lines are meaningless and a minority for whom it is clear at once that, given the right breaks between them, these lines will create on your computer screen a simple clock.

For the majority, the world of software is a built world that, like a city, helps us to organise and to consume. But it has been built by others. For the minority, software is merely a curtain that can be pulled aside to reveal a wild world of confusion, trial and error, but also of potentially unlimited creative and commercial potential. It is time for Britain’s schoolchildren to be granted access to this world.

For a brief period in the 1980s, British schools and universities punched far above their weight in the production of graduates who spoke the language of computers. This was partly a legacy of Britain’s pioneering role in the fundamentals of computer science and partly thanks to the BBC Micro, which appeared in most schools in the country but required a basic understanding of code for even its most basic functions.

The Micro generation went on to dominate the creative side of the computer gaming industry, but mainly in other countries. Since then Britain’s top three universities for computer science — Oxford, Cambridge and Imperial College, London — have kept their rankings in a global top 20 predictably dominated by the United States. But for a wasted generation, computer science in schools has languished at the expense of something else entirely.

As Michael Gove lamented in a speech in January, the national curriculum’s vision of Information and Communications Technology (ICT) had atrophied to little more than a primer in the use of Microsoft Word and PowerPoint. What pupils got, if they could stay awake, were simple skills that conferred little competitive advantage and in most cases could anyway be self-taught. What they needed was a rigorous but rewarding grounding in code as a foreign language.

At the Education Secretary’s invitation, industry has produced a blueprint for a new computer science curriculum. It would start early. By the end of primary school, pupils would be able to build an app for a mobile phone. By 16 they would be able to write a program to solve a Sudoku puzzle. By 18, if they took computer science at A-Level, they would be able to write the code to guide a van along the shortest route between two points on a digitised map.

Under this scheme, coding would start at 7. Its advocates say this would produce, eventually, the number of computer-literate graduates that British employers need; equip all pupils with the ability to compartmentalise and sequence their thinking as coding requires; and reflect the new reality that no rounded education is complete without an introduction to programming.

It is a compelling case. Some schools may respond that they cannot possibly have enough qualified teachers ready for a curriculum by 2014, when the successor to ICT is due. That is no reason to push back the deadline. It is a reason to speed up the necessary training. That clock on your computer screen is ticking.

While it has been widely reported that industry have taken the lead on developing the new ICT Programme of Study in England, this is not quite correct. It has been coordinated by the BCS and the Royal Academy of Engineering on behalf of the Department for Education, with input from key stakeholders across education, academia, government and industry. They may have been indirectly referring to Computer Science: A Curriculum for Schools, the CAS curriculum which has been endorsed by industry and the examination boards.

N.B. The Times also cleverly demonstrated that programming is non-trivial, by inserting a couple of typos in the code fragment at the start of the article…

Useful methods in Android 4.2: isUserAGoat()

android.os.UserManager, a new class added in Android 4.2 (Jelly Bean) which manages users and user details on a multi-user system, has exposed a very useful public method:

(source and an explanation)

Tagged , , ,

Fancy joining Mike Bloomberg (Mayor of New York), New York University and millions of people across the world (including the people of Colombia) in learning how to code? While learning how to program should be the start, not the end, 2012 seems like a pretty good year to do this.

Codecademy, one of the largest online interactive platforms for learning how to code, think the same way as Computing At School: everyone should be exposed to programming and computer science — especially kids. Codecademy can help you learn how to program, create your own courses and support programming in schools. And this is where Codecademy is partnering with CAS Wales: Codecademy Cymru — to create a bespoke and adaptable environment to support the teaching of Computer Science and ICT in schools across Wales — the first official Codecademy collaboration in Western Europe!

Codecademy is really excited to partner with teachers in Wales to make the learning and teaching of coding easier than it has ever been before. It is fantastic that the Computing At School teachers have embraced Codecademy, and we look forward to seeing the results from the students!

Zach Sims, CEO and co-founder of Codecademy

We are looking for teachers across Wales who would like to join the Codecademy Cymru trial phase to see how it can best be used to support your students. For example, the Web Fundamentals and Javascript Fundamentals courses could be used to support Key Stages 2-3, leading into the Python course for supporting the new GCSEs in Computer Science. However, there is flexibility to find how we can best support your school and your students (as well as helping Codecademy to develop the necessary support functionality and processes) — we need your help!

Programming is the start not the end: let’s develop computational thinking and problem solving skills

(N.B. This is the original unedited version of an article published online today in The Telegraph)

I wholeheartedly support the high-profile initiatives to get more children programming, especially as part of the rethinking of the ICT curriculum in UK schools. The publication of the Royal Society’s report Shut down or restart? in January highlighted the unsatisfactory state of ICT education in the UK, recommending that every child should have the opportunity to study the rigorous academic discipline of computer science. With the disapplication of the existing ICT Programmes of Study and the development of a new programme of study as part of the National Curriculum Review in England, we are at an exciting crossroads, with a real opportunity to make computing and technology a key focus of our education system. But if there’s one lesson we should take away from the problems of the past 15 years it is that we must not focus on transient and superficial technology skills. Computer science is not programming (and vice versa) and we should be wary of teaching programming just for the sake of teaching programming, without thinking about why we want to get kids to program.

When Michael Bloomberg, Mayor of New York City, tweeted in January that he was going to learn how to program, there were strong opinions expressed implying that programming is not for everyone. This is untrue. One of the reasons that programming is increasingly perceived to be a 21st century literacy in our technology-dependent society is because it is ultimately empowering, developing the ability to manipulate and control your digital world. But the key message is that learning how to program is not the endpoint, but part of the journey of equipping children with the necessary digital skills to solve problems. Our high-level aim should be to develop technology-independent skills and techniques, such as data literacy and computational thinking.

Computational thinking is a way of solving problems, designing systems and understanding human behavior that draws on concepts fundamental to computer science. Computational thinking includes a range of mental tools that reflect the breadth of the field of computer science. Computational thinking means creating and making use of different levels of abstraction, to understand and solve problems more effectively; it means thinking algorithmically and with the ability to apply mathematical concepts to develop more efficient, fair, and secure solutions; it means understanding the consequences of scale, not only for reasons of efficiency but also for economic and social reasons. And this is why it is important to teach computer science in schools: we need to embed principles and theory to develop a deeper conceptual understanding of how technology works and how it can be leveraged to solve problems. There is a quote commonly misattributed to Edsger Dijkstra: “Computer science is no more about computers than astronomy is about telescopes.” — this is where computational thinking fits in, abstracting away the technology.

Hence, there is an important balance to strike between focusing on developing practical programming skills (i.e. being able to write code for a specific task) and embedding a deeper understanding of languages and constructs: principles of programming. We know technology changes quickly, so we need to make sure that when “Technology X” appears, we have transferable knowledge and a deeper conceptual understanding of how it works and how it can be used.

But there are significant challenges ahead in changing the status quo and enthusing and engaging children in schools. Programming is a creative endeavour and offers a tangible way for children to express themselves by hacking, making and sharing. We now have the hooks to use in schools e.g. Raspberry Pi, Arduino, .NET Gadgeteer, LEGO Mindstorms, etc, offering opportunities for embedding computing across the curriculum. But we also have to recognise the importance of developing this deeper conceptual understanding, the problem solving and analytical skills, as well as knowledge of the underpinning theoretical foundations of computing.

So let’s change the focus from just writing code to developing the crucial thinking skills and the ability to solve problems. To quote Jeannette M. Wing, Professor of Computer Science at Carnegie Mellon University: “Computational thinking is a fundamental skill for everyone, not just for computer scientists. To reading, writing and arithmetic, we should add computational thinking to every child’s analytical ability.

NASA’s Magellan spacecraft and Perl’s pack function

I recently found this description of the origin of a number of the pack format specifiers in Perl’s pack function (which takes a list of values and converts it into a string using a specified rule template). Larry Wall recalls that they were added for processing data from NASA’s Magellan spacecraft (launched in 1989, also known as the Venus Radar Mapper):

+=begin comment
+
+Larry recalls that the hex and bit string formats (H, h, B, b) were added to
+pack for processing data from NASA's Magellan probe. Magellan was in an
+elliptical orbit, using the antenna for the radar mapping when close to
+Venus and for communicating data back to Earth for the rest of the orbit.
+There were two transmission units, but one of these failed, and then the
+other developed a fault whereby it would randomly flip the sense of all the
+bits. It was easy to automatically detect complete records with the correct
+sense, and complete records with all the bits flipped. However, this didn't
+recover the records where the sense flipped midway. A colleague of Larry's
+was able to pretty much eyeball where the records flipped, so they wrote an
+editor named kybble (a pun on the dog food Kibbles 'n Bits) to enable him to
+manually correct the records and recover the data. For this purpose pack
+gained the hex and bit string format specifiers.
+
+git shows that they were added to perl 3.0 in patch #44 (Jan 1991, commit
+27e2fb84680b9cc1), but the patch description makes no mention of their
+addition, let alone the story behind them.
+
+=end comment

N.B. I’m a big fan of Perl — this kind of ad hockery perfectly encapsulates why!

Microsoft’s 0xB16B00B5

Last week on the Linux Kernel Mailing List, a minor question was raised about the suitability of certain magic constants in the support code in the Linux kernel for Microsoft’s Hyper-V virtualisation environment. This was widely reported a week later. So how did a hexadecimal string cause so much offence? Well, it turns out that the constant passed through to the hypervisor was 0xB16B00B5, or in English, BIG BOOBS. And this was not an exception: when the code was originally submitted it also contained 0x0B00B135 (BOOBIES). While this looks to be a puerile joke, it could be potentially problematic because Azure (Microsoft’s cloud computing platform) may depend on this constant, so changing it could break things.

Even though the Linux kernel itself contains a fair amount of profanity, Microsoft swiftly apologised: “We thank the community for reporting this issue and apologize for the offensive string. We have submitted a patch to fix this issue and the change will be published in a future release of the kernel.” (in fact, the patch changed the string to its decimal representation: 2976579765). However, as Matthew Garrett notes on his blog, this can be easily attributed to straightforward childish humour (and the use of pseudo-English strings in magic hexadecimal constants is hardly uncommon; you can even generate hex poetry, if you so wish), but sniggering at breasts contributes to the continuing impression that software development is a boys club where girls are not welcome.

Lots of Irritating Superfluous Parentheses

After seeing last week’s xkcd, I was reminded of the delights of learning Lisp (or in my case, Scheme) as an undergraduate. I’m a big fan of declarative programming in general — I think exposure to functional and logic programming languages develops your problem solving skills and refines how you think about programming, by focusing on the logic of a computation without getting distracted by its control flow (although this discussion has been going on for many years). It has served me well: I used logic programming (Answer Set Programming) extensively in my PhD and I dabbled with OCaml whilst a research intern at ARM; although I have used very little Haskell, I know a man who does. There seems to be a wider trend of functional programming techniques moving into the mainstream, especially with the release of F# as part of Visual Studio 2010.

Anyone who has used Lisp for any amount of time will fondly remember its enthusiastic use of parentheses. But you can embrace the Lisp philosophy a little too much. Parenthetic is a programming language that only uses ( and ) as code; all other characters are considered comments. Parenthetic uses Lisp-style expressions where parentheses enclose expressions; programs with unmatched parentheses are invalid. It looks pretty similar to another esoteric language called Parenthesis Hell, and has most of the basic Lisp features, including lambda for anonymous functions. To demonstrate a nice simple code example, the following Parenthetic program prints ‘Hello World‘:

```((()()())(()(()()))((()(()))((())()()()()()()())((()()(()))((())()()()()()()()()())
((())()()()()()()()()()()))))((()()())(()(()()()))((()(())(())())((())()()()()()()(
)()()()()()()()()()()()()()()()()()()()()()()()()())))((()(()))((()(())(())())((()(
()))(()(()()))((())()()()()()()())))((()(())(())())((()(()))(()(()()))((())()()()()
)))((()(())(())())((()(()))(()(()()))((())()()()()()()()()()()())))((()(())(())())(
(()(()))(()(()()))((())()()()()()()()()()()())))((()(())(())())((()(()))(()(()()))(
(())()()()()()()()()()()()()()())))(()(()()()))((()(())(())())((()(()))(()(()()))((
())()()()()()()()()()()()()()()()()()()()()()())))((()(())(())())((()(()))(()(()())
)((())()()()()()()()()()()()()()())))((()(())(())())((()(()))(()(()()))((())()()()(
)()()()()()()()()()()()()())))((()(())(())())((()(()))(()(()()))((())()()()()()()()
()()()())))((()(())(())())((()(()))(()(()()))((())()()()))))
```

Pretty expressive, I’m sure you’ll agree.

There has been a rich history of developing bizarre programming languages; for example, Brainfuck, an eight-instruction Turing-Complete programming language, and Ook!, a programming language designed for orangutans (essentially isomorphic to Brainfuck, but with even fewer syntax elements).

Tagged , , , ,

2011 ACM Software Systems Award: Eclipse

Today, the 2011 ACM Software System Award has been awarded to Greg Adams, John Duimovich, Erich Gamma, Kevin Haaland, Julian Jones, Philippe Mulet, Steve Northover, Dave Thomson and John Weigand:

For the Eclipse platform and its visionary design of a universal IDE (Integrated Development Environment) which provides developers with an extensible platform for application development tools, fostering an impressive world-wide open source software development community.

The Eclipse project (full award citation) began in 1999 and was initially conceived to address a number of perceived shortcomings in proprietary software developments tools. Eclipse is a programming environment that provides kernel IDE (Integrated Development Environment) functionality and allows developers to easily integrate their own extensions, specialisation and personalisation. The Eclipse team identified the conceptual kernel underlying any IDE and was the first to bring the microkernel approach to another domain.

Eclipse changed the way programmers think about building tools: instead of building tools by using stacks of libraries and then trying to integrate them, one starts with the Eclipse platform, which provides a set of general capabilities. The tool developers then teach Eclipse about their domain (Java, UML, modelling, etc). From the very beginning, Eclipse was designed as an open and extensible platform for application development tools with a Java IDE built on top. The platform provides a nucleus of building blocks and APIs including extension points though which new functionality can be easily integrated, providing high component reuse rates. It has transformed the market for software development tools, fostering a large open source community well beyond the original platform.

(also see: the 2010 recipients, as well as the full chronological listing of awards)

(HT xkcd)

Tagged , , ,

Will 2012 be the Year of Computer Science?

2011 was a promising year for computer science in schools, with government ministers (even the Prime Minister) appearing to recognise its importance from both an educational and economic perspective; all in the midst of a uncertain large-scale education review in England. 2012 is shaping up to be just as promising, starting with the publication of the Royal Society’s 18 month study on computing in schools in a fortnight. Computing At School (CAS) have been busy on a number of fronts over the past year, but in particular advocacy at national policy level (along with the BCS Academy of Computing).

However, we have to remain grounded — there is still a huge amount of work to be done (and nothing is yet guaranteed). As well as continuing the policy work, one of the priorities for CAS is to further connect with and support the network of Computing and ICT teachers across the UK, as well as changing the wider public’s poor perception of computer science — into a rigorous, practical and intellectually useful academic discipline (and as a pathway to a wide range of careers). There are also a number of excellent initiatives to support that focus on developing the key skills of computational thinking and programming, as well as genuinely engaging young people with technology: Young Rewired State, Hack to the Future, Apps for Good, Codecademy et al.

After a recent conversation with @BringBackCS, it seemed an opportune time to coalesce Twitter discussions under a unifying hashtag:

I will be using this hashtag to promote Computer Science in 2012; please use and spread the message!

And why is 2012 especially important? It’s also the Turing Centenary, a celebration of the life and scientific influence of Alan Turing on the centenary of his birth on 23rd June 1912. A number of major events (such as the Computability in Europe 2012 conference) will be taking place throughout the year, with many linked to places with special significance in Turing’s life, including Cambridge, Manchester, Bletchley Park and Princeton. 2012: The Alan Turing Year and the Year of Computer Science.

We can only see a short distance ahead, but we can see plenty there that needs to be done.

Alan Turing, Computing Machinery and Intelligence (1950)

Powers of two

I was looking back through some C code I had written a while ago and found a concise little function for calculating whether an integer is a power of two. In general, there are two main ways to do this: either using its decimal or binary representation. The former approach can be more human-friendly, but generally less efficient; the latter approach is more machine-friendly, but tends to be more efficient. Since integers are stored as binary values in C (precisely how is dependent on the machine architecture), you can see why slicker methods are possible using binary. Essentially: an unsigned integer is a power of two if and only if it has exactly one `1` bit.

```int isPowerOfTwo (unsigned int x)
{
return ((x != 0) && !(x & (x - 1)));
}
```

There are two halves to the expression: `x != 0` and `!(x & (x – 1))`. The first half makes `0` a special case, since the second part of the expression only works correctly for positive numbers. The second half is true when `x` is a power of two and false when `x` is not. It turns out that this decrement and compare function is how the power-of-two check is implemented in `malloc` in the GNU C Library (`glibc`); let’s see how it works.

Let `n` be the position of the leftmost `1` bit in `x`. If `x` is a power of two, its lone `1` bit is in position `n`. This means `x – 1` has a `0` in position `n` (recall how binary subtraction works: when subtracting `1` from `x`, the borrow propagates all the way from position `n`; bit `n` becomes `0` and all lower bits become `1`). Now, since `x` has no `1` bits in common with `x – 1`, `x & (x – 1)` is `0`, and `!(x & (x – 1))` is true. Since subtraction borrows from the lowest `1` bit, when `x` is not a power of two this will be before position `n`, so it will not propagate. Now `x` and `x – 1` have at least one `1` bit in common (at position `n`), so `x & (x – 1)` is non-zero, and `!(x & (x – 1))` is false.

Here are some simple 8-bit unsigned integer examples to illustrate:

`x` `x - 1` `x & (x – 1)`
`00000001` `00000000` `00000000`
`00000011` `00000010` `00000010`
`00000110` `00000101` `00000100`
`00001000` `00000111` `00000000`
`00001011` `00001010` `00001010`
`10000000` `01111111` `00000000`
`11111111` `11111110` `11111110`

You can find more tips and tricks like this in the original HAKMEM (or updated HAKMEMC), as well as the book Hacker’s Delight by Henry S. Warren.

(A big thanks to Rick Regan and his in-depth Ten Ways to Check if an Integer Is a Power Of Two in C blog post)

Tagged ,