Programming and general geekiness.

Archive for the ‘Uncategorized’ Category

UI Animation

I spend a lot of time developing software and it means that I have to put far too much effort into designing the UI. I don’t really like UI design because I prefer the actual backend programming because it is far more interesting. I tend to be incredibly lazy when it comes to design.

Over the last few years we’ve had loads of new design technologies that have made it easier to develop great user interfaces for our applications. Microsoft adopts an XML based markup language whereas Apple still maintains its Interface Builder which hasn’t really changed too much since the last 1990s. Other systems adopt similar technologies.

I’ve recently noticed that animation has become a more prominent thing in UI design. Many smartphone apps tend to animate between screens by sliding or flipping and websites are gradually adopting animation between states. Sometimes this works very effectively but most of the time people will go over the top.

UI animation is only really useful if it adds something to the UI and doesn’t slow down the application. I am concerned that with the introduction of CSS3 and other technologies animation is going to become more commonplace as bad UI designers add it to almost everything – it will be like Flash all over again.

I personally don’t use animation at all, but that probably stems from the fact that I prefer the actual programming to the UI design. When working on projects I generally employ a 10:1 ratio of programming time to design time purely because it means my apps generally run better.

Firefox 9

Firefox shipped their latest update to version 9 yesterday and I upgraded this morning after having my coffee. At first glance absolutely nothing is different and they haven’t changed the UI since version four (which was released at the beginning of the year because Mozilla have decided to use the Chrome style of gaining a version number every month or so) however Mozilla certainly aren’t lying in their press release: it is definitely faster. The Mozilla team reckon its about 30% faster but from what I’ve seen so far I would suggest it was probably a little less.

Firefox has only really got one job at the moment and that is to stay ahead of Chrome. Both are perfectly good browsers and if I’m honest I use both with a preference towards Chrome because it is faster and generally supports more HTML5. Therefore recently Firefox has got itself into a position where it has a team of people trying to make it as efficient and as fast as possible and another team desperately adding new features.

This release seems to be leaning more towards an improvement in speed and security however there were a few HTML5 updates bringing new support for do not track in JavaScript, font-stretch and text-overflow. A feature that Mozilla are pasting all over their website is the new type inference system in the JavaScript interpreter which in layman’s terms means that Firefox looks over the code and checks for where similar values are being produced and then generates more efficient code meaning that web apps run really quickly. It seems to be a smart move and I can’t blame them for doing it but we are yet to see if it will be faster than Chrome’s V8 engine.

Another piece of news related to Firefox is that the contract with Google has been renewed for another three years which means that Google search will continue to be integrated as the default search engine and Google will take a share in the profits, which is bad luck for Microsoft.

Why have I only just discovered HashMaps in Java?

I do a lot of programming. In my free time today I have easily written two hundred lines of code. I average over a thousand a week (although I refactor my code a lot) and I just do programming loads. But I cannot believe I’ve never discovered HashMaps in Java. They are incredibly simple: they store objects with objects as keys so I can quite easily store a load of string values and look them up with hm.get(“key”). I’ve used dictionaries in languages like Python and Objective-C before but I am actually stunned at myself that I’ve never come across them before.

Here is roughly how they are used:

import java.util.*;
class mapTest
{
    public static void main(String[] args)
    {
        HashMap hm = new HashMap();
        hm.put("PI", new Double(3.14159653589));
        hm.put("myname", new String("Thomas"));
        System.out.println(hm.get("PI"));
        System.out.println(hm.get("myname"));
     }
}

Because you are able to store values of different types it does actually provide a really easy way of using key-value data storage. I need this for a little project I’m working on, so I’m very happy…

 

DumbCMS v0.5

Despite my earlier plans for DumbCMS versions, I have decided that with a few upgrades v0.5 will be ready. I am currently using v0.4 on my website. DumbCMS v0.5 will launch with some bug fixes, and a major upgrade since the version currently available on Google Code (v0.1 beta by the looks of things!).
This version will include a really easy template designer, blogging system (done properly!), forum, code editor and enhanced admin system. I hope it will be ready in the next few weeks, as it really is something special compared to previous versions.

How to build a really simple programming language

This is not a tutorial. It is more a guide of how you could first approach things. It is assumed that you code in some object-orientated language. I think Java would be the best thing to get started with for this. I have based this on some code that I have already written as part of my ThomasScript project, which I intend to release at some point. Maybe.

First of all, I must assume that your programming language (and mine) and simple non-OO languages that have their code written out in text files, or somehow read text into some sort of String object to use as the basis of their ‘code’. Like you have a BASIC interpreter (which you would write) and a .BAS file that someone else would write and run. I’ll let you worry about how you get the content of the .BAS file.

Now that you have roughly figured this out, you need to think about how you are going to structure your language. Here is a rough example of mine:

dim $variable

set $variable = “Hello”

write $avariable

getnum $variable

set $variable + 1

write $variable

if ($variable > 10)

write “Big number”

else

write “Small number”

write “Going to run a function”

run someCode “Hello!”

code someCode $text

write $text

I think it is relatively clear how this program works and indeed how the programming language works – even though it is very simple. The first part of coding the language is to split everything into array, split into individual lines. You then take apart the first line by its spaces: dim and $variable. There is therefore a switch branch in your code that has all of these possible language keywords. The code for dim is found and the argument $variable is given to it. For simplicity purposes all variables start with a dollar symbol for easy lookup. The variable names are stored in a string array with a length of about 10,000 because it is unlikely that you’ll need more, or that you are using a language that allows for arrays of unlimited length. There is then another array with type of object (or equivalent) that stores the variable values. This is relatively simple.

Because it is relatively clear how all the other functions work from this, the next thing to look at is basic (very basic) logic. I have decided that to keep things simple at first I will only use >, <, ==, !=, <= and >=. I will not use any variation on AND or OR. The value in the brackets is now relatively easy to evaluate; you simply get the left hand value and compare using the appropriate operation to the right. After this you get all the code that is indented and run that.

This is a very basic article and doesn’t really discuss the full process, however it certainly offers a simple start. Please note I plan to write a simple version of ThomasScript to the syntax described above before releasing the source code (either C, C++ or Java).

Follow

Get every new post delivered to your Inbox.