Archive for the ‘Programming’ Category

Construction and programming

Saturday, May 2nd, 2015

It’s been a busy couple of months! Now that the weather has started getting warmer as Summer approaches, the studio construction project at the bottom of the garden has commenced with gusto. Progress has been good – and I’ll be putting up some photos later today to document some of the recent activity.

Alongside this I’ve been working feverishly on my virtual machine programming project, and this too is really coming along in leaps and bounds. The instruction set has grown significantly and there is now a working assembler in which applications can be created and assembled into object code that is subsequently deployed on the virtual machine.

Writing an assembler is a little more complex than a simple translation of instructions into opcodes. The implementation has involved support for labels and variables, including variables that are defined as strings. A number of addressing modes are supported, and the assembler is a single-pass implementation which means that it can assemble source code that is streamed to it over standard input.


More posts on both of these projects coming shortly 🙂

My Virtual Machine

Thursday, February 26th, 2015

I’ve been head down, working all spare hours on my virtual machine. It is 100% original code written from scratch in C. I can’t give details yet, but it’s a register-based 32-bit VM that runs within a 32-bit or 64-bit parent application (depending on the host OS) that permits me to run multiple VMs simultaneously, each of which can run the same or different applications.

The last few days have been a whirlwind of ISA tweaks code refactoring and general mania, but today I got to the point I could run a simple test. The test application ran two loops, one nested within the other, that both iterate 65,535 times for a total of 4,294,836,225 iterations.

Turns out my VM, running within a VMWare Fusion-hosted guest Ubuntu OS on my 2.26Ghz Mac, executes 117,131,896 instructions per second.

I knew that going for a register based VM (as opposed to stack based) was a good idea 🙂

I also have a number of additional things on the plan that will radically increase the effective performance. High on the agenda at this point is to finish my assembler for it, as currently I have to hand-assemble my instructions. I should get that done in the next couple of days. Later, there will be direct assembly to native code, depending on whether the VM is running on x86 or ARM… I’ve already done some successful prototyping of the concept. At that point, I start hitting the billions of instructions/sec.

Very, very happy with the way this is going!


Saturday, February 14th, 2015

I’ve not posted much in recent days, not because I’m bored or have nothing to say (as if!) but because I’m engrossed in programming my own project, which is the evolution of previous activities. Unfortunately I can’t say much about what I’m doing (for potentially commercial reasons), but I wish I could. It’s wicked fun and I will be posting little snippets of coolness that have emerged form it in coming days.

It’s interesting how I’m evolving as a programmer. The latest code is leaner, better structured and packs more ‘punch’ than pretty much anything I’ve done to date and I’m learning a lot. It’s the things I’m learning that I’ll be putting up going forward!

And there’s more…

Monday, February 9th, 2015

This makes me happy 🙂

Apple Swift

Friday, January 23rd, 2015

These days there are a lot of programming languages to choose from. New languages have appeared regularly over the last couple of decades, many of which are designed to facilitate quick development of web applications. As an ‘old school’ programmer, I have a strong preference for low level languages which are very tightly coupled to the way in which the underlying hardware works. It is for this reason that I love C, as you can write in C and maintain a reasonably good awareness of the number of machine code instructions it is turned into when it is compiled.

Personally, I like this. It means that I, as the programmer, have a huge amount of control over how my code runs. It also means that code written in C runs faster than code written in just about anything else. That said, there are a few downsides to writing in C which are primarily based around the fact that C gives you the raw tools to work with and it’s completely up to you to use them properly. The language itself has virtually no built-in protection against you doing something stupid and crashing your program as a result.

Another issue with working in C is that you end up having to write a lot of code to cater for possible errors and to manage the use of memory during runtime. I’ll repeat; for me this is not an issue, as I rather enjoy that process and I have a number of techniques for handling errors in nested functions such that I can gracefully recover. However, it remains true that this is an overhead and although a well-written C program is a thing of true beauty it is also true that mistakes can creep in which in other languages would be detected for you.

The upshot of all this is that I have resolutely remained with C as my primary programming language, and I do not see this changing, ever. However, I’m quite interested in learning a language that is a lot more modern. My requirements for such a language are as follows:

  • It must be a compiled, not an interpreted language (I like fast code!)
  • It should not force object orientated programming on you (I prefer functional programming to OO programming)
  • It should permit development of modern apps on at least one modern system (my preference is OS X)
  • It should not have a syntax that I find ridiculous (objective-C… shudder)
  • It should be accessible and easy to set up the development environment (I want to code, not mess around with IDEs)

It is for these reasons that I have spent some time recently getting into Swift from Apple. Swift seems likely to incrementally replace Objective-C for OS X and IOS development going forwards. I rather like the syntax, it is well integrated with existing Objective-C libraries and it looks extremely likely that it will be the language of choice for OS X and IOS development going forwards.

Although it was only released in June 2014, it has rocketed up the popularity ladder, and I can see why. Although the support for Swift in XCode is still a little clunky, it’s vey usable and quite fun to work with. I have a couple of projects I want to create for OS X (including a rather cool plugin idea I have for Logic Pro X) and I’m enjoying the learning process.