Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Jamie Balfour'sPersonal blog

Helvetica returns! And on this occasion, I am not talking about you Calum Cormack. 

As I have been conducting feedback surveys on my website to select visitors for the last few days I have discovered that many do not like the Open Sans font since it is too light to read. I also felt like this from time to time and have considered the change to the slightly heavier Mac favourite font, Helvetica. 

Helvetica was once the default font on OS X (soon to be macOS) but Apple dropped it for the San Francisco font in both iOS 9 and OS X 10.11. I also once used Helvetica as my default font but dropped it for the sake of cross-platform support and have switched font on my website quite a lot since then. I am hoping that Helvetica will be staying, I will be running a trial run of this for four weeks from today. If I get more positive remarks about the font on the website I will retain it. 

As the result of the information from some feedback I received, Roboto has become the new site font - the third attempt at a font from Google Fonts.
Posted in Website news
helvetica
arial
sans

As you are maybe aware, Microsoft announced Project Scorpio at E3 a few days back; a second iteration of the Xbox One with more power and capabilities of 4K video output that will also includes 4K games. However, some of us will be disappointed Microsoft is making games specifically for the new console.

My brother used to argue that the Xbox is great because all you do is press a single switch and it's on in a few seconds and because it didn't need upgrading every four or so years. In direct comparison to my 2011 and 2013 PCs, the time for the Xbox One start up is actually about 3 or 4 seconds longer than them. So this argument is now void. The argument about upgrading has also become invalid due to Scorpio

Another argument was the lack of exclusive and fresh games on PC, but I think Steam has since taken care of this. And a lot of Xbox exclusives such as Titanfall have since come to PC. Microsoft also announced that many new 'exclusives' would now come to PC too.

So really, what is the difference between the Xbox One and your gaming PC?

The Xbox One is an x86 based machine, running Windows under the hood, and games at less than 1080p. So it's the same architecture as your PC. Why would you really bother with a system that doesn't do half of what your gaming PC can do? 

The controller, right? I do admit the controller for the Xbox One is amazing (it's why I chose it over the PS4). But wait, what's that you say? You can use your controller with your PC?! Indeed. This is a crucial point to me, since there are games that I would rather play with a controller such as GTA V, but then there are other games I'd still rather have my WASD key combination for.

So now the Xbox One will be a PC you cannot upgrade yourself but will need to update by buying a new one every few years, am I right? Well this is what Scorpio makes it look like. 

So give me one argument for why an Xbox One is better than a PC. I really am having a hard time trying to figure out why I bought an Xbox One, since I've not enjoyed many of the games I own so far. 

Please note, this post is not a criticism of the Xbox One, more of it's upgrade strategy.  

Posted in Gaming
xbox
one
scorpio
pc
gaming
future
console
games

WWDC is getting less exciting as the innovation begins to get less innovative. I'm personally no longer shaken by the new releases of iOS since version 7, which was the last real iOS that I could say was exciting. Since then Apple's software releases have become less exciting and certainly don't hold the same level of innovation.

Anyway, WWDC last night was the moment Apple dropped the name OS X and named it macOS. So now, my Mac will no longer run on OS X but on macOS. The new version will be known by the name macOS Sierra. I'm happy to say the inclusion of Siri is something that I am excited about. This is something OS X should have had a long time ago.

iOS 10 is opening up to developers and third-party apps more and more. First off, Siri is being given an SDK and opened to developers so that apps can take advantage of the power of Siri. Third party developers such as WhatsApp will have more power over the iOS device too.

The most interesting part however was with tvOS. I feel that Apple has made a few crucial updates such as the new dark mode, which you may think is not crucial but let me tell you, it is. There was also the addition of the new single-sign on option for different apps stream through cable TV. 

Overall, WWDC 2016 was very lackluster and one of the least interesting WWDCs of all time. A lot of this is down to the fact that Apple have run out of fresh innovation since they've already implemented most of the important features of our smartphones - all they do now is move things around.

Posted in Apple Corporation
wwdc
apple
2016
exciting
macOS
iOS
tvOS
10.12
10
watchOS

WWDC

Today is the day. WWDC 2016. Have you thought much about what we might expect?

One of the main things that I am expecting is Apple finally dropping OS X and naming it macOS (stylised exactly like that). Doing this would make macOS feel right at home with iOS, tvOS and watchOS.

Of course, iOS 10 is expected and OS X 10.12 (or macOS 10.12). Apple will probably also announce tvOS 2 and watchOS 3. Also, there may be a few more watch straps announced today. With macOS 10.12 I am expecting that Apple will finally bring Siri to us Mac users.

Anyway, that's my thoughts. Let me know what you think below.

Posted in Apple Corporation
wwdc
apple
2016
exciting

My blog all about BalfBlog, which was formerly the BalfBlog blog has been renamed my Project blog. This blog will no longer focus solely on BalfBlog, but it will now discuss all of my projects.

On that subject, whilst ZPE is one of my main projects, it will not really be discussed too much on this blog since there is a dedicated blog on the zenlang.net website. I think it would be wise for me to keep submitting there rather than at both places.

Posted in Miscellaneous
project
blog
jamie
balfour

It's considered pretty bad practice to use a class selector in CSS as a single instance, for instance, you would not choose to the name the main_container element .main_container, would you? Or would you?

Well actually, I was thinking about this today, and I've come to the conclusion that yes, maybe you would. That's because of the DOM buzz word specificity.

Any CSS developer who has been using it for a while will know that the ID selector (#) is more powerful than the class selector (.), but do you know how much more powerful it is? Well 10 times to be exact. For more information on this, read the linked article.

It's important to note that throwing in an ID selector makes it very difficult to overwrite, so using one is not always the best way to achieve something. For instance, say you wanted all the anchor elements inside your main body section to be displayed with a style where you've got the code such as:

HTML
<div id="main_container">
    <a>Test</a>
    <a class="tester">Test</a>
</div>
<div id="sidebar">
    <a class="tester">Test</a>
</div>
</div>

The anchors could simply be selected using the #main_container a selection. But this means, according to specificity rules, that the anchor would have 101 points (100 + 1), meaning overwriting this anchor with a class is not easy and would require the ID at all costs. Now you want to style the links with the class tester too, but across the whole site. So we have two choices, either rewrite the page so that the body has an ID too, or, create a selector like #main_container a.tester, #sidebar a.tester.

Both of these solutions are inadequate.

The single use class

Let's rewrite the HTML and CSS. Add the class singleton to the main_container:

HTML
<div id="main_container" class="singleton">
    <a>Test</a>
    <a class="tester">Test</a>
</div>
<div id="sidebar">
    <a class="tester">Test</a>
</div>
</div>

Now our selection can be much weaker, albeit less specific (but since singleton will only occur once and only once we do not care). We can now select using .singleton a. We have reduced the specificity to 11 (10 + 1). To overwrite it, we can now just use a.tester since this also has a specificity of 11 (1 + 10). However, this will only work if it is placed in the CSS file after the reference to the original tag (i.e. after the .singleton a). 

So there you have it, a way to use the class selector as a single instance effectively.

Over the last few years, I've done a lot of work on building my own programming language and platform known collectively as ZPE. 

Perhaps the most important lesson I have learned from this is how to make a program more efficient. I focus a lot on shifting things from the interpreter/runtime side to the compile-time side in ZPE, which has been a major focus of the latest version. However, there are some things that I cannot do very easily.

I recently started thinking about making one of my programs more efficient and how this would work in ZPE. Let's take a look at some code:

YASS
$l = range(1, 5000)
//For x is less than the length of the list (i.e. 5000), increment by 1 
for ($x = 0, $x < list_get_length($l), 1)
    print($x)
end for

Notice how we check the size of the list at the top of the for? This means each iteration will need to call that function to find the size of the array. If a variable had been defined before the for loop and contained the length of the list, one could simply reference the variable, which in turn would be much faster than constantly asking the system to find the length of a 5,000 element array. Here is a sample of this in action.

YASS
$l = range(1, 5000)
$len = list_get_length($l)
//For x is less than the length of the list (i.e. 5000), increment by 1 
for ($x = 0, $x < $len, 1)
    print($x)
end for

Times were measured using the Unix time command and were as follows:

For the first test:

real 0m1.821s

user 0m2.862s

sys 0m0.363s

And for the second test:

real 0m0.437s

user 0m1.051s

sys 0m0.099s

This is the first tip I have for you. This tip will also work in other languages such as JavaScript or Java or whatever. 

Difference in speed

In 2020

In 2020 when I was looking through my blog, I came across this post and thought I'd test it out again for a bit of fun. Interestingly, running both for loops is considerably faster than even the faster for loop example provided here. Compiler optimisations, runtime improvements and much more have made this much faster in ZPE 1.8.5. The version shown above is running on ZPE 1.4.2E, which is still available to download and compare.

Posted in Programming
efficient
efficiency
programming
speed
fasterfficient
efficiency
programming
speed
faster

To me personally, there is no greater sense of achievement than what I have now achieved! I've finally finished my four long but fun years at Heriot-Watt University and have recently learned that I have achieved a First Class Honours degree. 

I cannot tell you in words how proud I am to have achieved this! 

I also posted this to Twitter: 

I'd like to also congratulate all my friends and thank them for supporting me through this time! I really couldn't have done this without all the support from them.

On the subject of support, I also must thank my lecturers for their support as well, since there is absolutely no way I could have done this without them.

Posted in Life
university
heriot-watt
life
jamie
balfour
honours
first
class

Windows 10 was an amazing operating system for a few days when I first installed it on to my gaming PC. My gaming PC, The Zebra X2, is a beast of a machine which can run most games that I play like Starcraft II and GTA V in the highest available settings (Core i7 4770K, 256GB SSD, 8GB DDR3 RAM and an AMD 7950) but latterly it struggled with simple things like starting up.

After I installed Windows 10 the machine ran fine. However, one day when I was playing a favourite game of mine, Command and Conquer 3, I noticed a slight drop in framerate from playing it the time before. I didn't think too much of it at the time but gradually I noticed that each time I played this game it was getting worse. At the very end before I ridded myself of Windows 10 it was running so slow that when I used the graphics intensive Ion Cannon superweapon the game would just freeze and the animation for the superweapon would not be shown. The game would resume after the Ion Cannon blast was finished. So what the heck was going on?

My initial thoughts were that the hard disk drives that I stored my games on were starting to fail. I tested them all with SMART tools and none of them showed any signs of failure. I then assumed that it was my SSD so decided to install an old SATA III HDD into the system and installed Windows 7 on to it. It ran fine. I upgraded it to Windows 10 and again, it ran fine. So I assumed it was the SSD. I left the SSD in the system just disconnected. 

After time, the same weird thing happened to my system - it began slowing and the graphics were getting messed up in games. So now I assumed it was the graphics card or the PCI controller that had failed on me. I took the GPU out of the system and used the dedicated graphics built in to the CPU. The system ran just the same so I now knew it wasn't the graphics card that had failed, but wasn't sure if it was a motherboard fault such as the PCI controller or the memory controller.

I decided to reinstall the SSD and flash my BIOS. Clearing the BIOS meant that I could set it back to the factory defaults and test it with them (I had tried this several times before but to no avail). Nothing changed. 

My next choice was to clear the SSD and install Windows 7 on it. After reinstalling I panicked slightly as it wasn't working well at all with the Desktop Window Manager crashing on startup. After installing Service Pack 1 everything seemed to work perfectly. I would like to say that Windows 7 was the solution but I can't be sure. 

I would probably put the problem down to several things: Windows 10 was clogging up the system (don't know why), the original BIOS was not designed for Windows 10 and would have required an update (I have since updated again and may try it again in the future with Windows 10) and that Windows just needed that little reformat that us Windows users need to do on a regular basis.

My fix appeared to have come from the reinstall of Windows 7 and the BIOS reset. I will keep everyone up to date with my progress with Windows 10 again in the future.

The Windows 10 upgrade tool can be a pain!

Due to the upgrade tool in Windows 7, I have been upgraded to Windows 10. This time the system appears to be running well - that is at least in comparison to how it was before. I will keep you posted when it begins to slow down again (if it does).

Posted in Tech talk
windows
10
7
8.1
8
later
os
failure
gpu
bios
computer
custom
cpu
ram
sata

In the past, I have been told that my code samples are really good, but they lack one or two things. The most crucial one of those is the ability to copy the formatting. Unfortunately, this is not possible at the moment due to the fact they are written as a ordered list element. This means that each line of code is put in a new li element. When one comes to attempt to copy from the element, the formatting (e.g. the indentation, which is completely controlled by a CSS margin property) will not be retained. 

After some perseverance, I have begun the transformation of my samples. Currently in the ol element, they will now be nested within the pre element. What this also means is that it will be much easier for me to update them using my content management system. As of this second, the CSS tutorial has been partially updated, and my articles, reviews, blogs and the software section completely use this new system. 

The main theory behind doing this is to make my website more accessible and easier to use, whilst not making any real visual changes. At the current time, you may see that some of the older samples no longer appear properly. This is a known issue and will be fixed when they switch to the new style.

Please bare with me whilst I make this change, since it will take some time for me to fully implement across my tutorials. 

I have since updated my HTML and CSS tutorials with the new pre-based samples. It's taking a long time to do but I will be done with the PHP tutorial by the end of the day.
All pages on my website now use the new pre-based code samples so all code from these samples is now fully copyable. JavaScript must be enabled for the pre elements to display properly, but it will work without JavaScript anyway. 
Posted in Website news
website
update
modern
post
code
sample
Powered by DASH 2.0