How to learn programming without dying of boredom

From my experience, traditional learning techniques get boring fast. A lot of learning on their own start by reading a how-to book. Books are excellent resources to get the ball rolling.

The trouble is, it just doesn’t stick.

I found books quickly demotivated me, my enthusiasm towards learning would quickly diminish. I’d still finish them, but with much reluctance.

Common tasks found in beginners books are to create things like Fahrenheit to Celsius converters. As you woefully tap away at your keyboard, copying the code letter for letter as the book tells you to, you begin to contemplate how the universe even came to be, and why it has lead you to this moment.

Well, maybe I’m exaggerating. Though, learning to create something so distinctly uncreative is a frustrating experience. No one enjoys making a program so simple that the solution could be reached much more efficiently using any of the many devices that surround us in our daily lives.

For me, programs are much more exciting to create when they are unique each time they are ran. It gives a real sense of excitement when you hit compile and you have only a vague idea of what to expect. Sometimes the output will be bad, not what you anticipated and less than exciting. Other times however, it will just piece together by chance and your own skill to create something wonderful.

Something fun to try could be to tell a story that is different every time based on user input, using arrays, a loop or two, and a randomiser. An awesome, humorous, advanced example of this can be seen here.

So, I suggest if you are struggling, take a break, think outside the box a little. Don’t worry if your code doesn’t work, just read some more and I’m sure you’ll figure it out.

Host migrated (and a lesson learned)

I just finished migrating web hosts, the site seems to be fully functioning… and smoother!

I previously hosted this site with a company in the USA, because it was what I believed to be the most affordable package. Unsurprisingly; because I live in the UK, I encountered quite high ping (delay) when I wanted to view my site. The lag was most noticeable when I moved around directories using an FTP client.

I found that pretty agitating really, but I could just about bare with it because I had a clone of the site on my local computer that I could edit and toy around with and then just drag it into the FTP client. That obviously helps reduce the noticeability of latency.

However. Then came the first crash.

I opened up the live chat and asked the support representative why the IP address was unreachable. They responded plainly with the obligatory thank you message (and sadly without the use of grammar or punctuation). They then proceeded to leave me hanging for 15 minutes without uttering another word.

Finally, they responded telling me that the node had been shut down due to a suspected DDoS attack on a website in the node.

“Oh…” I typed, trying to coax out some more information as to when it would be resolved.

The support representative once again was silenced for at least another 10 minutes. Once he returned, he simply responded saying that he wasn’t sure when it would be resolved.

Somewhat infuriated, I decided to close the chat.

Eventually, after about 5 hours, the site was back up and running again. My previous anger had diminished by that time, and so I decided to not cease the recurring monthly payment for the hosting.

And then, a mere two days ago, it happened again (or so I thought). The site was inaccessible. This time, I wasn’t really up for contacting support again, I decided it was time to get some new hosting.

I contacted a friend on Skype who hosts a couple of small scale websites and asked what host he uses. He showed me. It’s based in the UK, nice and cheap, looks very professional. I created an account and paid the bill!

Now, I figure it’s time to move all the files to the new host. I try to login to my downed website (forgetting the flaw in my logic there) via FTP, it connected. I then proceed to realise what just happened, and check the site in my browser. However, it still appeared to be down…

I delve a little deeper and discover a flaw in one of my PHP scripts was causing the problem. Well, that’s embarrassing! Turns out this time it wasn’t their fault!

So, now I’ve paid for the new hosting but it turns out that the old one wasn’t broken. I decide to explore the new server (which was setup in about a minute of my payment). I click around in the default directory structure in my FTP client, and the ping is just phenomenal, almost instantaneous!

It turns out that the bill is just cheaper than the US host, too!

So there you have it, my story on how I decided to migrate my website to a new server! (Also, wow! This post is far longer than I anticipated!)

Theme redesign in progress

EDIT: I have uploaded my theme (24/04/13). Some browser inconsistencies remain, but it currently looks good on modern browsers. I will work on fixing it for older browsers.

The current theme design (as of 18/04/13 and prior) for the blog is slightly modified version of “Twenty Twelve”, WordPress’ default theme. It is widely used across websites running WordPress and isn’t very unique.

I recently stumbled upon SVBTLE, a private blogging network filled with excellent writers and bloggers. The style of the site is beautifully hand crafted, solid, minimalist, and intuitive. It inspired me to redesign my own.

I felt that I needed to learn more about CSS anyway, so I set off to create my own stylesheet from scratch. It’s not as beautiful as svbtle, no. If I wanted to rip off svbtle, I could just download the open-source (recreated) wordpress theme, wp-svbtle.

My intention is to make everything that isn’t the content as unintrusive and unobstructive as possible. Removing the large header for example, allows for immediate viewing of the content without having to scroll down. Sure, I enjoyed designing that header; but it’s bulky and sticks out like a sore thumb.

The new theme, styled from scratch with CSS.

The new theme in development (as of 18/04/13), styled from scratch with CSS.

Old (removed as of 24/04/13) theme for comparison.

I’m still ironing out some kinks, notably cross-browser compatibility. It’s a small CSS stylesheet, with only 40 rules, 280 lines, and 4.63KB (no compression, highly readable). The reason it’s so small is because I have only styled the things I can see currently on the blog. Things I don’t commonly use, or haven’t yet used; I don’t style. In the future, If I include something in a post that is unstyled, I’ll simply load up the stylesheet and style it.

Pretty renders using terrain generator and Blender

I fixed the problem with my heightmap generator and uploaded version 0.20, here are some renders I created to show off the outputs from it.

I imported the heightmaps to Blender and used its beautiful rendering engine “Cycles” to create the images.

Large Landscape rendered in Blender. Terrain rendered in Blender. Green (velvet material in Cycles) terrain rendered in Blender.

Hopefully this will be my final post about the heightmap generator, since it has been the overruling topic of the blog thus far.

A wild Sierpinski triangle appeared!

While working further on the terrain generator, I decided that my implementation of the diamond-square algorithm was too messy. So I started rewriting it, this time using my trusty whiteboard on my wall to plan ahead.

Once I was done writing, I executed the script but set the roughness down to zero. The output gave me quite a surprise! 

Crude, but pretty cool! Except, I wasn’t trying to make Sierpinski triangle at all… sigh. I’m honestly not even sure how I did it, but I rather wish it would go away!

It’s not perfect, but…

I’ve just uploaded my heightmap generator (diamond-square algorithm) over on the projects page. I haven’t been able to work on it for a while due to personal/private projects and other things, but today I opened up the Unity project and tinkered around with it again and thought it would be nice to publish it. There’s a few problems with it (grid patterns; especially at low roughness), but all in all it works nicely!

You can try it in the web player or download the executable (Windows and Mac). The executable has the advantage of being able to save the heightmaps to PNG. Feel free to use the exported heightmaps for whatever purpose you please!

Diamond-square in Unity

On Monday, I started working on implementing the diamond square algorithm in Unity with C#. I’m rewriting it for Unity for no real reason, but in the back of my mind somewhere, I’d like to think I might have a good use for it one day!

I’ve written an implementation of the algorithm previously in a cool language called Processing, and I probably could have ported it really easily since the syntax is similar.

I didn’t though, maybe I’m a fool, but I wanted to write it from scratch. I still ran into a handful of problems. Hell, some of them I still haven’t solved!

Mainly, a grid-like pattern popped up all over the terrain. Which I kind of predicted, since I also had a similar problem when I implemented it in Processing, except this time it was less noticeable.

After about a day of brain-scratching, I found the problem. It was caused by the combined efforts of a poorly set step-size value (the distance that the next pixel is set from the previous pixel) and also the size of the array, which was one too big. Or was it one too small? You get the gist.

At a low roughness value, there is still a slight grid pattern which I need to look into. For now though, I’m pretty satisfied with the results:

513×513 Terrain output. (Yes, this is an animating gif, sadly the largest image on this blog. At a whopping 2.2 megabytes, it has 30 frames and progresses at a rate of approximately 1.875 frames per second. Beautiful!)

Progression

Happy (much belated) new year!

So I’ve been working with Unity trying to get “Falling Fish” finished, which, had I planned it out first, would have probably been finished by now…

I am pleased with the amount that I have learnt from the experience so far (especially the importance of planning, something I regrettably haven’t done at all…), albeit, I have found my self lowering my expectations for the game (more precisely, its graphics). I’m pretty bad at texturing and modelling at the moment, so I think it would be best to keep the originally-place-holder boxes and work primarily on the code and gameplay. Lets just pretend that’s the art style!

Unity and I

I’ve been learning my way around the awesome Unity 3D for a couple of weeks, and getting to grips  with C#, which thankfully hasn’t been so bad since I knew a bit of Java and they are incredibly similar.

I’ve been working on a little 2.5D arcade like game, if you will. It’s technically 3D, but it’s displayed in an almost 2D perspective. Essentially, my idea for it is as follows: You are a fish inside a room whereby platforms are constantly rising out of the floor, slowly increasing their pace as time goes on. If you touch the ceiling or the floor, game over. The longer you survive, the more points you rack up. In fact, the floor is on fire, so the closer you remain to the floor, the more your points multiplier increases (because you want to cook the fish, right?).

Or, something like that.

Of course, it’s not the best of concepts. It’s just something I hoped would be easy to make.

Head on over to the new projects section of the site to see more info.