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

When I started to write BalfBlog under the name JBlogs in 2014 I began using the now deprecated mysql commands. After some time messing about I switched to the much faster and more powerful mysqli commands. 

This was the first big change in the history of the code in BalfBlog. Moving to PDO from MySQLi was another big change (probably about the sixth big change in the history of BalfBlog) and I claim it has many performance improvements.

The improvements do not come from querying the database because I know outright that MySQLi is better for that since PDO adds a layer of abstraction over the databases. No, they come from preventing running the query twice - which is an obvious waste of resources.

Now that I use PDO, this is no longer required since the way that binds are done is much better. Creating prepared statements is so easy and this is where the performance gains come from. 

Also, I will point out as it seems a good time. Performance is being thouroughly tested at this point in time under many use cases. PDO definitely seems the way to go however, and it will also allow me to easily switch around database commands to allow other databases to be used in the future. 

Also, not every part of the dashboard has converted yet, but most have.

Posted in BalfBlog
balfblog
pdo
2.3
efficient
faster
mysql
mysqli

So you already know about some of the new features of ZPE 1.5.3, including the new free to use parser that can be part of any project. But there's also another change coming.

ZPE 1.5.3 is a bit of a minor update in terms of features, but it brings in a sweeping change. 

I'm talking about a change that brings a change to something from version 1.3.2. One of the first features added to ZPE way back when it kicked off again in 2015 was associative arrays - almost identical to PHP's associative arrays. They were different to lists in the sense that they mapped values. Well, whilst version 1.5.3 is not a huge update, the update brings a huge change to associative arrays.

You declare an associative array as below:

ZenLang
$assoc = {50 => 10, 10 => 50}

But now, the same associative array is written very similarly to a mix between that and defining a list:

ZenLang
$assoc = [50 => 10, 10 => 50]

The update's purpose is to inline both associative arrays and lists and to free up the curly brace.

Also, I am changing the accessor symbol from => to -> for objects.

zpe
1.5
1.5.3
new
associative
arrays
changes
features
custom

It's no shock that a very useful bunch of libraries are now available for ZPE written in ZenLang. Because I have recently added jget to ZPE (a method of accessing my own repository of ZPE extensions easily, allowing easy downloads of these extensions) I have decided to give it a proper name.

Much like the way PEAR and PECL exist for PHP, ZPE will get ZULE or ZPE User Libraries and Extensions. This will be hosted on my website for now and accessible through the jget ZAC in ZPE for now. I will add the ZULE ZAC to ZPE soon however, but jget will exist for a different purpose. 

I'm now open to receiving both compiled and uncompiled scripts for ZPE to add to this repository. 

One of the biggest updates in terms of what it brings is the move from MySQLi to PDO - PHP's data objects for databases. Not only does PDO make it easier for me to add future database systems, it makes it easier for me to write the code.

MySQLi's biggest problem is the way in which prepared statements are formed:

$stmt -> bind_param("ss", $username, $password);

PDO solves this issue by making it possible for me generate any query and provide any number of parameters, thus allowing me to call the execute on the query at just one point. If you look through the new version BalfBlog you will understand why this is crucial.

Nothing will change on the front end, although the performance is much better with PDO because of the way it is written.

Posted in BalfBlog
php
pdo
balfblog
update
mysql
mysqli

I may have only posted the other day, but this update is a big update so it needs to be out there. 

Version 2.3 will be a big overhaul of the internals of BalfBlog, similar to what happened to ZPE. This is a major code refactor and therefore it will take me some time to finish it. I am now improving the comments inside BalfBlog to make it easier to work on, changing the way variables are named, defining more constants and generally refactoring the code.

If you wish to contribute, get in touch.

Posted in BalfBlog
balfblog
developer
ideas
suggestions
features
2017
2.3

Although it's easy to find out about BalfBlog through the changelog, I thought I'd update you here.

The latest revision of BalfBlog is a bit of a step up in terms of security and performance. The main new features related to user accounts. Every BalfBlog installation from version 2.3 (Goldfinger) will now feature a special user account called helpdesk. It is disabled by default, so an administrator has to enable it in settings. Once it is enabled, helpdesk is used to allow me to remotely login to your blog and help you with issues. I suggest leaving it off unless you need help.

As well as this, at the end of February I added the switch user functionality, which allows administrators to use the user account of any user without the need for a password. This also is designed for debugging and will allow administrators to debug the system themselves. I also changed the dashboard menu to a new accordian style which keeps items better organised. You will see other asthetic changes across the website, including the new login page. On the development side, you can now switch quite easily to CKEditor instead of TinyMCE for a more lightweight editor (more editors will come soon).

I have recently begun work on the new Message Centre. I will primarily be using this on my blog to record issues. This new system allows you to setup an easy to use message system whereby users can get in touch. You will be able to set expiry dates on messages so they will only remain in the system for a few days. 

Also coming in Goldfinger is the new logging system. This will allow you to see what people are doing in the dashboard. I will also be looking into building a comment system that I will integrate into BalfBlog. Version 2.3 will also possibly be changing from MySQLi to PDO, but we shall see. A new file manager is also planned and I'm looking to improve performance too.

I'm still working on improving the file upload system for images, which is no longer working. 

As with all version of BalfBlog 2.x, HTML5 and CSS2+ is required to be able to actually use it, so please just stick to Firefox, Edge, Chrome or Safari 6+.

Posted in BalfBlog
balfblog
updates
features
2017
update

As part of the major restructuring of the internals of my ZPE project, I rewrote the whole parser. Before I explain what's changed with it, let me explain how ZPE works (and still does).

The basic layout of ZPE

The previous image shows precisely how everything interacts. The second step is the most crucial, at least I see it that way. I say this because this is how my latest project functions. The project was known as Project Diamond originally, and I have no idea why I chose to name it that. This project looked at a new way of making the ZPE parser flexible and as a result ended up with me rewriting the whole ZPE parser (it's not that big though, only about 100 odd lines). Because of this rewrite it can be used to parse any language with minimal effort. Simply including the parser and requesting it does an action (such as eat a word) or return something (such as the current symbol or the current word) is all that is needed to write a programming language using it. 

As a result of this, I wrote JBSON, which is my JSON parser. It works using my ZenithParser which is now fully open to use. It's very easy to use and I will share the source code of JBSON. Whilst JBSON is actually part of the ZPE package, it can be used completely separately and the whole ZPE package is not that heavy. However, as I am restructuring ZPE's internals I may make it a public library that's not a part of ZPE. The main motivation behind doing this was the Google's JSON was too big for ZPE, adding it doubled the size of the distributable JAR file.

json
parser
java
lightweight
easy
to
jbson

Back in the days of version 1.3 it was always my intention to make it possible to add custom compiler syntax to ZPE. I did this originally in a very simple way that made it easy for me to develop but harder for others to develop. Today, version 1.5.2 brings this feature back. It improves it considerably and makes it fully possible to write your own syntax. I've even decided to make it possible to overwrite the built in keywords including things like if and while. 

How does this work?

It's not the easiest of things to explain but I will try. Firstly, when ZPE is launched it will search through all of it's plugin directories. A new directory called 'keywords' has been added to version 1.5.2. This directory contains all of the user's custom keyword plugins. The manager then adds these to the compiler based on the name value given to the keyword plugin.

The next stage is for the compiler to compile the word. The plugin handles the compilation job and can access the owning ZPE's public functions (including the new ExternalMethods object) before returning an AST.

Within the interpreter the plugin's traverse method is called. It is then the plugins job to traverse when the plugin is given an AST back (the same AST given previously) and to run it as code. It's pretty easy to do and it's designed to be easier than doing it the way the internal compiler does it.

Below is a plugin called 'jack'. It simply takes the next word and stores it as a value.

Java
import jamiebalfour.zpe.core.AST;
import jamiebalfour.zpe.core.ZenithEngine;
public class ZenithCustomModule implements jamiebalfour.zpe.core.ZenithCustomModule {

	@Override
	public String GetName() {
		return "jack";
	}

	@Override
	public AST CompileToAST(ZenithEngine z) {
		
		AST a = new AST();
		z.ExternalMethods.EatSymbol();
		a.value = z.ExternalMethods.GetCurrentCompilerWord();
		
		return a;
	}

	@Override
	public void Traverse(ZenithEngine z, AST node) {
		
		System.out.println(node.value);
		
	}

}

Below is a sample of the ZenLang code that runs this:

ZenLang
function main()
	jack x
	$a = 0
end function

Thanks to some of the comments I received today about my website, which were largely positive, I will be changing my website quite considerably.

The comment that has stuck with me, and it's reinforced by the fact I've thought about it myself is that my website has become too big. I've developed a plan of action to tackle this problem in as few distruptive steps as possible (since now my tutorials have been gaining more popularity and my website is being used by many, I don't want to disrupt that).

My plan is this:

  • Revert back to a single blog again, my Projects Blog will move back into my main blog. 
  • I will merge Software into my Projects section. 
  • I will create a completely new website (I've been thinking about this since early December) for my professional works
Posted in Website news
website
update
new
features
changes

Whenever I am asked why I bothered building a personal website or why someone needs a personal website my reply is often something along the lines of 'it's fun' or 'it's my hobby'. But I very rarely touch on the benefits of my personal website.

There are a huge number of benefits to my own personal website. I get around 500 visitors a month on my website. I use it to showcase my work to potential employers, to get myself on the internet in a public way that people can connect with me through but there are also other things. I enjoy learning and teaching, so my website is also a source of information where I put tutorials to help others learn stuff that I know. 

But really what's the benefit? My first answer is that it's professional. The brand that my website pushes forward gives me a uniqueness that appears on all of my work now. The orange and blue theme of my website is also apparent on my CV, any letterheads I send and on certain emails. This looks highly professional and people like to see this. I also believe that having your own brand puts you above others who do not. 

The second reason that having a personal website is that the website is, well, personal - it's all about you. LinkedIn is great for connecting but it's full of other people too. Go to jamiebalfour.scot and who do you think you are reading about? That's right, some guy called Jamie Balfour. There's nothing about John Szymanski or Murray Smith on there (well there might be). This keeps the reader focused on you. You can write soley about how good you are and all of your achievements and yeah, be a narcissist, blow your own trumpet!

The third reason I would say having a personal website is a must is because it gives people an easy way to read about you. A personal website allows people to read about you from all corners of the globe. Social media is great, but it's also ladden with other things, like other people, a like LinkedIn.

I will admit my website is more of a personal project that evolved into something more. For anyone in computer science it's pretty nice to show that you can build a website from scratch, so I did exactly that (it shows a lot of perseverance too). 

Posted in Tech talk
benefits
personal
website
professional
Powered by DASH 2.0