Software for Nottingham Computer Science!

Tuesday, August 21st, 2012

It has come to my attention that recently freshers seem unsure of what tools they require for the start of their academic time at Nottingham.

So much so that one poor fresher asked:

Is there anything you’d recommend getting before starting, i.e. software and so on? (Think I got Visual Studio 2010 lying around somewhere from college, if that’ll come in handy?)

About as handy ‘as a chocolate teapot’ I replied.

Software For Year 1

Here is a short list of software I personally used during my first year for the following modules:

(Obviously, there are usually plenty of alternatives and mostly comes down to personal preference)

(Also, everything is fine with all three of Windows/Mac/Linux as far as I am aware – unless noted)

G51OOP – The Eclipse IDE – found here

G51PRG – The GCC compiler – found here

G51FUN – The Haskell Platform – found here

G51CSA – Komodo ARM Emulator – found here - Struggled to get this working on Mac/Windows. Best of just using it in labs!

G51DBS – MySQL/PHP – can be found individually here and here or use a WAMP package (recommended) – here

G51WPS – WAMP package (see above)

Other modules tend to use these tools.

Software For Year 2

G52ADS – Eclipse (see G51OOP) with JUnit test suite – tutorial here and Test Driven Development (TDD) tutorial here

G52APR – see above.

G52IFR – Coq Proof Assistant (Yes, when ~txa says it, you will cry) – found here

G52CON – ADA-S archive and compiler – here

G52AFP – see G51FUN

G52CPP – Visual Studio 2012 – (Yes, I know I said it’s as useful as a chocolate teapot but lets be reasonable here. It is) – link to be given out by ~jaa (assuming he still teaches it!)

Other modules tend to use tools already listed in first year.

Software For Year 3

G53CMP – See G51FUN/G52AFP

G53GRA – OpenGL Library & GLUT as well as Visual Studio 2012 (again) – Found on A32 Lab Computers

G53ORO – TORA System, OR Tutor, Open Solver for Excel, LP Solve (Mac), IOR Tutorial, BB for MIP

G53CWO – N/A

Software For Year 3+

G54MDP – Android Software Development Kit

Software For ALL Years!

There are some tools that are a little general that I think some people may want to use and others may not!

Doxygen - documentation generation system for multiple languages (C++, PHP, C, Java…) – found here

LaTeX – Typesetting and document preparation tool. Great for making good looking reports – found here

Latexian (Mac Only) – Quality LaTeX editor – here

LaTeX examples and templates for Nottingham are provided here free of charge from the wonderful Michael Gale

GitHub – for Windows or for Mac – here (win) – here (mac os x) or for Eclipse – here

Also before I am swamped with 20 questions: Your new timetables can be found here!

If you think I have missed something out! Please comment below and I will consider adding it!

Ed

Boolean: Yes or No. Uh or Maybe?

Tuesday, April 17th, 2012

I was casually linked to a site today that had a snippet of code that made me quite angry.

```
enum Bool {

True,

False,

FileNotFound }; ```

I feel the title of ‘logician*’ may no longer apply to this individual!

Feel free to discuss!

The Truth Behind C++

Thursday, December 8th, 2011

A friend of mine recently forwarded me an interesting article that stems from a conversation with the creator of the C++ programming language.

This man, Bjarne Stroustrup, released C++ in 1985 whilst working as an employee at Bell AT&T labs and was eventually standardized by an ANSI committee in 1998. The article is a conversation in which a reporter from IEEE‘s ‘Computer’ magazine interviews Bjarne about the progress he’s made and looking back on the changes in the usage of computer programming languages. However, the interview actually lets on a little more than was originally bargained for! Bjarne seems to imply that the language he created was made to be complex on purpose in an attempt to raise salaries of those who programmed in it!

It was only supposed to be a joke, I never thought people would take the book seriously. Anyone with half a brain can see that object-oriented programming is counter-intuitive, illogical and inefficient.

From reading the transcript I initially thought this was supposed to be a tongue-in-cheek comment, a joke. Unfortunately this didn’t seem to be the case.

I didn’t expect the thing to get so much out of hand. Anyway, I basically succeeded. C++ is dying off now, but programmers still get high salaries, especially those poor devils who have to maintain all this crap.

This article is actually shocking in the sense of how openly Bjarne is willing to tell people this kind of information when the language he created is already so widely used in the market.

I recommend reading the transcript. It’s interesting to say the least!

I guess choosing a C++ module this coming semester might have been an error…

Ed

Friday, July 29th, 2011

Without a proper summer job, I have had a fair bit of spare time! I have decided that some summer reading may be beneficial for the start of next year.

99.9% of programmers out there will be familiar with the K&R C Programming Book as it is the de facto standard book for the language.  I have taken it upon myself to read as much of the book as possible and try to complete the exercises before I move into my new house in Lenton – (My new street in its former glory!).

To be fair, the initial exercises don’t require much thought!
Verify that the expression getchar() != EOF is 0 or 1

```//Solution to "Verify that the expression getchar() != EOF is 0 or 1"
#include <stdio.h>
int main()
{
int c;
printf("Press a key.\n");
printf("The expression getchar() != EOF evaluates to %d\n", c = (getchar() != EOF));
printf("Therefore: %s\n", (c == 0) ? "False\n" : "True\n");
return 0;
}
```

EDIT: Line 8 should read printf(“Therefore: %s.\n”, (c == EOF) ? “False” : “True”);
This is trivial, but there we go!

I also plan to read up on Java once again but I have yet to find a book that is to a similar standard to C’s K&R.

Until then I recommend the following reading:

App’s for Students - A great post by Harry Slater about the key iPhone apps he uses as a student! (No use to me…I have a Blackberry, but worth a read nevertheless)

Child’s Play in Haskell - Another problem solved in Haskell by Michael Gale

Finally, a post by my friend Tom about what he wants to achieve in the next year!

Ed

Planting the Seed Pt.2

Tuesday, May 17th, 2011

This post references Project Brownian, of which related posts can be found here.

Previous post – Part One

It was clear at this point, using a seed with a random generator was not a great idea but despite this, our understanding of Haskell’s `System.Random` library was not yet at the standard required to use a generator without a seed. To combat the issue identified in the previous post, it was necessary to write a set of functions that, without using the `System.Random` library, could create a changing seed value. For this we turned to time/dates. Dates are a unique value, there will never be another date the same as the current date (unless its 03:14:07 on the 19 January 2038?!). Converting a date to the seed would be ideal as, each day, the seed would change causing the random generator to create new values with the `make` function.

The code below documents the solution we eventually (after about 3 days of research, confusion and energy drinks) created.

`date = fmap (toGregorian . localDay . zonedTimeToLocalTime) getZonedTime`

```datetoIntg :: (Integer, Int, Int) -> Integer datetoIntg (a,b,c) = read \$ show a ++ show b ++ show c```

```seed :: Int seed = fromIntegral . datetoIntg \$ unsafePerformIO date```

First of all, I will skip straight to the point that will enrage most seasoned Haskell Programmers. The use of the `unsafePerformIO` function is usually perceived as exceptionally bad practice, making most programmers wanting to maim any soul who tries to use it without a good excuse. Why is this? Because `unsafePerformIO` type (and therefore definition) can cause serious problems or unexpected results when used poorly, hence the unsafe within the function name.

```*Main> :t unsafePerformIO
unsafePerformIO :: IO a -> a```

As you can see from the type definition of `unsafePerformIO`, it removes the IO element of a type from the type and returns with the plain IO-free type. e.g `IO Int -> Int`

This doesn’t seem a problem when you have functions with the following types:

```*Main> :t datetoIntg
datetoIntg :: (Integer, Int, Int) -> Integer

*Main> :t seed
seed :: Int```

But unfortunately `date` has the following type:

```*Main> :t date
date :: IO (Integer, Int, Int)```

Like Graham Hutton told us in one of our IO lectures

You start pure and once you’re impure, you’re impure for good. It’s the same both in Haskell and in life!

This statement explains the following error in GHC when you remove `unsafePerformIO` from the `seed`.

```    Couldn't match expected type `(Integer, Int, Int)'
with actual type `IO (Integer, Int, Int)'
...
Failed, modules loaded: none.```

I believe this program, as a trivial test, can justify the use of the function. You may disagree with this, but until you can present a better alternative I will stick by this decision.

So what do the other functions produce? `date `returns the current date in a tuple format whilst `datetoIntg` converts this to an `IO Integer` type by removing the individual elements of the tuples and ‘sticking’ them together. Finally, the seed function uses `fromIntegral` and `unsafePerformIO` to first remove the `IO` from the type and convert the `Integer` type to an `Int` type. The final GHC snippet gives an example of the code in use:

```*Main> date
(2011,5,17)
*Main> seed
2011517
*Main> :t seed
seed :: Int```

As you can see this seed can be used with the code found in the earlier post Random Particles to create random particles on a daily basis.

This method is by no means a great way of achieving what we set out to do. It attempts to make the best out of a bad situation! I’m sure there are people out there who can think of two dozen better ways of doing this, but this is part of the fun of learning a new language! Hack Hack HACK!

I will resume Haskell posts fairly soon but I am aware that as a blogger you cannot bore your audience to death with the same thing over and over. So expect more humor and different ‘nerditry’ to follow soon.

Yours technologically,

Ed

Planting the Seed Pt.1

Monday, May 16th, 2011

This post references Project Brownian, of which related posts can be found here.

(This is the first post under the new domain edgeorgedev.co.uk - a small moment in history, for me anyway!)

The previous post in the Brownian Motion series used the following code to create a list of random `Coord` types (a `Box`).

```randPairs :: (RandomGen g, Random a) => (a,a) -> g -> [(a,a)] randPairs range gen = zip as bs where (a,b) = split gen -- create two separate generators as = randomRs range a -- one infinite list of randoms bs = randomRs range b -- another infinate list ```
```mygen :: StdGen mygen = mkStdGen seed```

```make :: Int -> Box make n = take n \$ randPairs (0,100) mygen```

Here is GHC running this program:

```*Main> make 4
[(81,68),(18,50),(19,0),(32,9)]
*Main>```

This was initially seen as a great success. We had created a Box type with random particles. However as the next example shows there was a key issue that caused a major issue with this assumption.

```*Main> make 4
[(81,68),(18,50),(19,0),(32,9)]
*Main> make 7
[(81,68),(18,50),(19,0),(32,9),(26,29),(24,42),(67,58)]
*Main>```

As you can see from this example, the particles created by `make 4` are present in the list outputted by `make 7` . This was down to the use of a constant for the random generator; the ‘`seed`‘.

Originally this was overlooked, the seed was just a constant integer value which meant each generation of particles would be the same every time the program was run. This meant we had generated ‘random particles‘ but failed to ensure the particles were random every time the function was used

This gave us the idea to attempt to create a random seed. As it was clear, at this point, we had a limited knowledge of the `System.Random` library we concluded to attempt to create a ‘random’ seed in another fashion. Time and Dates seemed an obvious choice for uniqueness so it was these we pursued in an attempt to ensure the seed had the ability to change.

The second part of this blog post shall shortly follow.

Ed

Random Particles

Friday, May 13th, 2011

This post references Project Brownian, of which related posts can be found here.

The next step in creating the first prototype of our ‘Box’ thought experiment was to initially create a certain number of particles within the box.

A function make defined as `make :: Int -> Box` would be required  to create ‘n number of particles’ and place them in a `Box`.

The problem we came across was such: “How is it possible to create ‘random’ generated particles”. As many computer scientists are aware, randomness and the quest for creating ‘truly’ random numbers using computers can be complex and tedious as well as bringing up all kinds of philosophical idiocy such as “What really is random and how can something random be defined as random?”. For the sake of our (and now your) sanity I am happily glossing over this.

The `System.Random` library was used in our initial tests. I was previously unfamiliar with this library and its functions making this stage of the project the hardest to comprehend so far. I researched numerous sources in vain trying to find a solution to creating a list of `Coord` types that are randomly created.

The source below documents the solution we used in the first prototype:

```randPairs :: (RandomGen g, Random a) => (a,a) -> g -> [(a,a)] randPairs range gen = zip as bs where (a,b) = split gen -- create two separate generators as = randomRs range a -- one infinite list of randoms bs = randomRs range b -- another infinate list ```
```mygen :: StdGen mygen = mkStdGen seed```

```make :: Int -> Box make n = take n \$ randPairs (0,100) mygen```

The source uses three functions to create a ‘box’:

`randPairs` creates two lists of infinite random numbers within a specified range and uses the `zip` function to place them into tuples i.e `Coord` types – Creating an infinite list of `Coord` types.

`mygen` is the ‘Random Generator’ used to produce the random numbers used in `randPairs`. It uses a seed where `seed :: Int`. This `seed` will be discussed in the next blog post in detail.

Finally, `make` is the function we set out to create. It take in an integer parameter and places that number of ‘random’ particles into a ‘box’ using the `Prelude` function `take`.

I have come to realize that this is not an ideal way of creating these particles – This will also be discussed in greater detail in the next blog post.

Until then please feel free to offer advice on how I could optimize.

Yours technologically,

Ed

Initial Problem

Friday, May 13th, 2011

This post references Project Brownian, of which related posts can be found here.

Initially the problem of creating a functionally programmed implementation of a Brownian Motion environment seemed very daunting. As an undergraduate freshman, the task of creating something so complex in a language I am only newly familiar with will be tough but also extremely beneficial as a learning aide.

The first step of any program is to identify the key goals and ideas you want the program to contain and put across.

We decided  that to start of simple we would create some prototype ideas and concepts.

Initially we came up with the idea of ‘particles’ in an enclosed space. A two-dimensional thought experiment in which a number of random particles are placed in locations within a box and interact with each other.

The box takes the form of a Cartesian co-ordinate grid with only positive integers representing the x and y axises (the first quadrant). The box is of a finite size that is defined at compile time as a constant (I believe we initially had this set at 100 – giving  10,000 unique positions for a particle to be – a $(n^2)$ relationship)

The initial source code was as follows:
```-- Brownean Motion Haskell Test -- Created & Developed by Ed George -- With Assistance from Sam Davidson```
``` type Coord = (Int, Int) type Box = [Coord]```

```maxN :: Int maxN = 100```

```empty :: Box empty = []```
``` incx :: Int -> Coord -> Coord incx n (a,b) = ((a+n),b)```

```incy :: Int -> Coord -> Coord incy n (a,b) = (a,(b+n))```

```add :: Int -> Int -> Box -> Box add x y ts = (x,y) : ts```

The first couple of lines describe the two data types used within the initial program. `Coord` is the type that represents a particle and takes the form of a tuple of integers. The `Box` represents the metaphorical enclosed areas that contain the particles. It therefore takes the form of a list of ‘particles’ – `Coord` elements.

`maxn` and `empty` are two definitions that are to be used within later prototypes. (Where `maxn` is the maximum size of the box. In this example the upper right boundary begins at `(100,100)`)

`incx` and `incy` are two helper functions written to add an integer amount to a particle’s x or y co-ordinate.

Finally `add` is a function to create particles and add them to a ‘box’. It takes in the parameters of a x and y coordinate for the particle to be added as well as the list of previous particles the new particle should be added too (the ‘box’).

Currently this program contains some of the key building blocks required to create a working prototype. Plenty more functions are to be added soon.

Yours technologically,

Ed

Project Brownian

Thursday, May 12th, 2011

Many of you will be familiar with the concept of Brownean Motion. This is the is the “assumably random movement of particles suspended in a fluid (a liquid or a gas)” (Wikipedia) that occurs naturally. The maths behind this branch of particle theory can be used in a variety of ways. To describe randomness or even describe changes in stocks and shares.

I took up a project recently along side my good friend Sam Davidson - (blog) to attempt to create a functional programming language implementation of a similar system to that described by the motion observed in these suspended particles.

Haskell was our chosen language to begin the project. This blog will continue to follow the progress of the project step by step, documenting key areas of interest and problems that occurred along the way.

Unfortunately, WordPress and its built in source code highlighter does NOT yet support the Haskell language. Any code that appears in the format below is, from here on, to be read as Haskell source code.
```--Example.hs --Ed George 2011```
``` add :: Num a => a -> a -> a add x y = x + y```

(A simple addition function.)

Yours technologically,

Ed