For my next website I've decided to go with AngularJS as part of an effort to enhance my long outdated web development methods, opting for a modern MVC front-end with RESTful Java back-end in place of the old JSP mess I'd used previously (such as on this website). The first component I've built is a menu, which you can see in action here. The code is listed below.

Testing (an important part of the Angular development process) proved difficult for such a complex component. All examples I could find online were for directives that were trivially simple, which had me worried I was using the framework incorrectly. I've included the test specs below.

I've barely scratched the surface of what's possible with Angular; there is still much to learn. Comments are welcome.

Read more

I wanted to get better at JavaScript so I spent a few days making a game of Tetris. It's purely SVG and JavaScript; no libraries.

Play full screen

Download compiled source

View original source on GitHub

Read more

I've been working my way through a book called The Elements of Computing Systems, which teaches you how to build a simple computer from scratch, starting with just NAND gates. The hardware is specified in a hardware description language and simulated on a typical desktop machine.

Chapter six entails building an assembler. Here is my rough solution in C++. I only spent two days on it so it's not written to the highest standard.

Read more

[Click 'Read more' to see image]

Imagine a pie chart representing the range of skills that the economy needs—that is to say, if we were to inject into the nation's workforce a new population of young people equal in size to that of the current student population, what would be the breakdown-by-expertise among them that would most benefit the economy? And next to that imagine another pie chart representing the areas of study chosen by the actual student population today. In an ideal world the two charts would match, but in reality there is little resemblance between them, and this is a problem.

In a free market economy, prices are determined by supply and demand, and wages, from the point of view of an employer, are prices like any other. It is supply and demand of human capital, therefore, that determines how much an individual is paid, where human capital refers to the various attributes of worth with which a person is endowed—be it by nature, education, work experience, or otherwise—that are sought by employers who must compete in the marketplace for good workers, each of whom is at the same time seeking an employment deal that offers them a favourable balance between work conditions and pay. In short, jobs requiring skills that are scarce and in high demand will tend to pay more than those requiring skills that are abundant and in low demand.

Read more

[Click 'Read more' to see image]

You may not be as smart as you think. When you look into it, the set of opinions and values you've adopted, which define you as a person, are probably not the result of any great research effort on your part, but instead have been settled on automatically in accordance with your existing identity.

To give an example, most of us believe in anthropogenic climate change. Some of us believe it very strongly despite knowing very little of the science behind it. Some would even vouch complete, total conviction without knowing anything about it. How did we come to believe in such a thing?

The unconscious thought process might go as follows:

I'm an intelligent and respectable person. I'm liberal, progressive, and scientifically literate. I'm a decent and kind person who cares about the environment. By contrast, those who deny global warming tend to be unreasonable, immoral, unintelligent, right-wing, overly religious, and scientifically illiterate. I will side with the former group, as they stand the greatest chance of being correct. It is highly unlikely that the latter group is correct, and moreover they are nasty and stupid.

Read more
Thoughts on Bitcoin

I don't know all that much about bitcoin, but I've heard some arguments from its detractors (e.g. Peter Schiff) that I don't agree with. Here are some brief thoughts in defence of bitcoin.

Bitcoins themselves have no intrinsic value; the only thing you can do with a bitcoin is pass it on to someone else. This argument is missing the point. The bitcoin protocol and infrastructure has value because it's a technological solution to an important problem—the age-old currency problem. Humans have always sought better ways of transferring wealth from one person to another, and now with bitcoin we have a means of doing so instantly and anonymously.

A high-speed rail network has value as a means of transporting people around. Like anything, its value is determined by supply and demand, which in turn is represented in the ticket price. The tickets are mere pieces of paper. Similarly, a bitcoin gives the bearer access to a system that provides a valuable wealth transfer service, and thus represents a portion of that value.

Read more