Friday, 29 April 2011

Ubuntu Natty - First Impressions

I managed to remember to try out the new Ubuntu 11.04 on the day of it's release, so I grabbed an iso and booted a flash drive up on my bog standard Acer lappy (Intel T4200, 4GB RAM, nothing special).

The thing that hit me hardest has got to be the new 'Unity' interface. It's pretty, waay prettier than anything else - the smooth sliding of the 'dock' on the left, the practically edible buttons thereon.
I know it doesn't sound like much, but that's the point. Unity is pretty damned lean.
Touchscreen-friendly; The buttons are big, and the 'left-click' context-menus are kept to a minimum. It almost makes me want to fit a touchscreen in my laptop(I WILL do it).


It's not too slow, either. I'll play around with it some more, but it seems more than adequately zippy on this no-frills machine. I'd be interested to see how unity would perform on my HTC Magic.
But there's little point to that until I can get Xorg accessing the framebuffer (the FB driver in the android kernel needs a fixup to work with Xorg (Or Xorg needs a hack (Oh, 1 sec...just found this:
http://wiki.meego.com/ARM/MSMQSD#MSM_XOrg_driver))).


And that's the end-a'-that chapter...

Saturday, 23 April 2011

Done done done :D

Just a quick update;
The data extraction project is finally over!...well probably not -
I imagine I'll have something else to do for it before long, but the database is now sane(as far as I can tell), and filled with specs for about 600 laptops. W00t!

Now, my AI project - still haven't done much on it, but have been reading up on Turing machines/FSMs a bit, and have been awestruck on multiple occasions by the genius of Alan Turing and Alonzo Church - These guys were unbelievable.


Toodle-oo, folks.

Friday, 22 April 2011

Work work work

Just finished a large lump of code for my university group project's data-extraction job.
The data for 1500-odd laptops has left the HTML and is now in MySQL INSERT queries, ready to be loaded into the database. This part will surely expose some small flaws in my processing. But not for tonight, though.

Still not much closer to pulling a nifty AI-demonstrating scenario out of my arse for the 12th of May, when I must have a working implementation, lest I lose 12.5% of my mark for CS3516.
After the database is built, I'll be able to devote time to that, before the big holidays.


Had my Haskell assignment due in today and completely forgot about it. It's been done for over a month, as well. Ffs, I've even helped a mate do this one... bet he didn't forget to hand his in on time.
Not sure exactly how much it's worth. maybe 10% of my final mark, maybe more :\
Ah well...





ARM are still taking their sweet time with my application, not a titter yet. Starting to get paranoid gmail is somehow broken. 

After all this crap with deadlines, BASH, Ruby, HTML and regular-expressions, I now intend to thoroughly chill out. That is, if I don't get lured away from sleeping by some interesting thing which I must, must, must, read about.

Thursday, 21 April 2011

Starting Lisp

First off, Lisp isn't a language. At least, it's not just 1 language - it's a family of them which all share a similar syntax and manner of operation.
The variant I've been acquainting myself with is Common Lisp.
It's intimidating for several reasons, the main one being the elitist attitude attached to many of those who use it. Maybe it *is* the best, most advanced language in the world(I can't say), but hearing that makes it no easier to learn.
The syntax looks....bloated. One would tend to skim though a line of code and assume there is some kind of unnecessary, 'yet beautiful' paradigm at work which could only be appreciated by an academic, but in all makes a less useful language.
It definitely helps to have a background in functional languages to understand just how useful Lisp can be. 

After downloading and installing a Lisp runtime (clisp, for example), you will notice that the front-end takes the form of a Read-eval-print loop, something very familiar if you come from a ruby/python/similar background.

For those unfamiliar with this concept, it's exactly what it says it is. You type text in the correct syntax, which gets *read* into an internal format, then gets *eval*-uated, and the resulting data *print*-ed on the screen.

Now to the code :)

In the loop try evaluating some data, like 1 or 3 or "sandwiches", and hitting enter to evaluate. That shouldn't do anything really very surprising at all.
What's happening here is that the reader is converting the text, "1", into the internal Lisp object which represents an integer.
This object is then passed to the evaluator, which does nothing with the object.
Still the integer object representing 1, it gets passed to the printer, which converts it to a textual representation "1".

Thrilling stuff, eh?
Not really, no. In that example, the evaluator did absolutely nothing, but it's in fact the most complex part which makes up a Lisp system, as we shall see.

But, how do we write out a Lisp list?
Like this: (1 2 3 4), this is a list containing 4 objects.
Lists can also contain other lists: (1 2 3 4 (1 2 3))

Now lets try to evaluate a list.
Type (1 2 3 4) into the read-eval-print prompt, and hit enter.
This will now throw a potentially very ugly error(ugliness is implementation-dependant).
clisp responds with the following insult:


*** - EVAL: 1 is not a function name; try using a symbol instead
The following restarts are available:
USE-VALUE      :R1      You may input a value to be used instead.
ABORT          :R2      Abort main loop

Not nice to look at, but it's point is that the object '1' isn't the name of a function.
Why was it expecting a function name? Because that's how Lisp code is written. It's a list. It's all lists.
Want to call a function? Create a list beginning with the function name, and the parameters as the other list elements.

Here's a practical function call, the seminal "hello world" program:
(print "Hello world")
This is a list containing two objects. One is a name, the other is a string. The reader, takes this, creates these objects in memory, and passes the list to the evaluator. The evaluator notices it's been given a list, and after evaluating all of the other elements, calls the function named by 'print' with the "Hello world" string as an argument(remember, simple objects like strings do nothing when evaluated).

But what if we feel we need to stop evaluation for some reason? What if we just want to tell the evaluator to stop and, for example, not evaluate a list. Rather, leave it as a list?

This is where the special name "quote" is used.
When the evaluator encounters a list to evaluate whose first element is the name: "quote", it simply returns the other element in the list without trying to evaluate it.
Given this, we can do what we described, and get the evaluator to leave our list alone by writing the following:
(quote (1 2 3 4))
After the reader has done it's job, and turned everything into objects(2 lists, one inside the other), the evaluator sees the first element of the list passed to it is the name 'quote'. This makes it stop in it's tracks, and simply evaluate to whatever object was given as the argument, in this case, a list of 1, 2, 3 and 4.
This is then passed to the printer, and is displayed as:
(1 2 3 4)
on the screen.

As the reader(you, not the Lisp reader) will hopefully now understand, this quote thing is useful. Most obviously, when you want to write out lists. This assumption is true enough, in fact, that in Common Lisp, there is a shorthand in the form of the single-quote, eg:
(quote someobject)
is completely and utterly equivalent to
'someobject

and (quote (1 2 3 4))
is totally and thoroughly the same as
'(1 2 3 4)


Now, a quick test. If you want the printer to show a list, why can't you type:
(print (1 2 3 4))
when instead you must type:
(print '(1 2 3 4)) ?


It may not say much, but I feel this tutorial clearly outlines the workings of the language, which are easily misunderstood.

More Common Lisp:
Make a greeting function, 'greet':
(defun greet () (print "hello"))

Make a better greeting function, which takes a string as a parameter:
(defun greet2 (name) (print (concatenate 'string "Hello, " name)))

Call the greet2 function:
(greet2 "Lee")
prints => "Hello, Lee"


That's all for now :)

Wednesday, 20 April 2011

A start

Right, first post, hmm...


I guess I'll start with what I've been up to at Uni...
On the last leg of my Comp Sci course, I'm finding it increasingly difficult not to check out of things.
I just want the damned thing to be over, and to go and do my Industrial Placement with ARM (which I may or may not get).
As of now, I've got a _sane_ database of laptop specs to pull out of my arse for my group statistics/AI project (essentially a product comparison engine). It's gonna be a long haul of ruby, sed, bash, regexes, and little manual fixups. Really, not fun stuff...


Now onto the fun stuff...
I like progamming languages. I LOVE progamming languages, I know a fair few. The newest members of my army, being scala, haskell and ruby.

Scala blew me away when I first met it. It had so many features.
Seemed like it had all the best language features, created to this date.
Then, I hated it. I hated it for it's seemingly nonsensical type-inference mechanism, which surely did little more than to make code unreadable.
A few days went by, A few days writing 1600 lines of Java for my Games AI project, and lo-and-behold, I didn't feel so bad about it.
I concluded that, aside from a few choice features (pattern matching, traits), it should be thought of as no more, and no less than Java, but with less of the verbose crap.

I still wasn't satisfied, I wanted something different. MORE different.
I attempted to write my own stack-based 'functional assembler', if you will, which actually turned out pretty nifty.
A lovechild of Lisp(as I understood it then) & FORTH, I hope to implement it on an FPGA someday when I have money.

Speaking of Lisp; yesterday, I finally managed to wrap my head around Common Lisp!
Or at least it's syntax and actual operation.
I feel somehow liberated, even though I don't know enough about the libraries, or have had enough practice, to do anything really useful with it.
I may just be doing my next Games AI project in Clojure in an attempt to get to grips with the Lisp way of thinking.

Industrial Placement...
Last week, I finally applied for the year's placement/internship at ARM, in Cambridge, that I've had my eye on for over a year now. I've yet to hear back from them, but i've got a vote of confidence from my cousin, Ben, who did this placement a few years ago.
After I complete that, I'll have - aside from experience working for one hell of a name - a designated BSc Hons in Computer Science; Hopefully enough to kick-start my career into a...direction of some kind.


That's about all for now, I believe.
I'm now off to depress myself with HTML.
Till next time :)

Lee