Tuesday, August 6, 2013

Bubble Sort

I was chatting with a friend about out kids, and he mentioned that his daughter was just getting introduced to scripting.

Basic scripting/programming is a great hobby for a kid. It costs nothing, can be done at any time, becomes a marketable skill and can greatly improve their understanding and capabilities with a computer.


When I was 13, I saw my brother starting to learn to code in QBasic. There were also a few games written in it. What struck me immediately was that the game he had brought home, because it was written in a non-compiled language, presented all the logic clearly visible, just waiting to be understood.


I took it upon my self to start modifying it bit by bit. I turned the sun into a moon. The day became night, and the buildings into neon gaudy things, I'd cringe at today. I figured out the pixel and line drawing next, and the moon was given sunglasses...


After that I started toying with my own little scripts. When  I discovered loops, animations follows. without use of an offscreen buffer, my animations were all "twinkle". i.e. redraw black over the screen, then redraw whatever. Horribly inefficient, but even my lowly 40MHz DX2 was fast enough for little vector based animations such that it wouldn't be obvious.


I kept tinkering - especially with graphics. Visual shiny fun stuff was interesting. Text was and mostly still is boring.

I started playing with Pascal and eventually, inline assembly (GOGO MODE 13H!!!), and frame buffers. With the tinkering, it expanded my understanding of logic, and math. Deriving your own 3d algorithms for animation takes a lot of thought, but eventually, I was using trigonometric functions easily, and simple physics equations for acceleration/distance/time.


While on the phone with network engineers that saw to it their hold button gets a workout, I whipped up the below demo of a bubble sort. It's the most basic of sorts, and algorithms. While it in itself is boring, it employs fundamental principles that anyone with decent scripting capabilities should be able to reproduce. This one is for our future programmers and scripters.
Reset...

No comments:

Post a Comment