Tuesday, April 27, 2010

Good work

Learned a lot about SDL in the last day or two. Making a tile-based game of some sort this evening. I'll get back with screenshots tomorrow.

Once I've got some experience, a Tetris RPG will be on its way (I've had this idea on a backburner forever waiting for a key concept to make sense that finally worked itself out in my head a few days ago)

Then I'll settle into drupal and wiki stuff, and see what I can do with a Wiimote.

Saturday, April 24, 2010

It's a reasonable thing to do

My last posts were correct, I suspect. One of my largest issues is that of distraction, and of a lack of focus. When I get focused, I can get into a fantastic groove (and produce excellent things quickly! Looking at you, lexical analyzer for pish I wrote in an evening), so the problem becomes getting focused.

My day-to-day activities have helped to breed a lack of focus in me. I switch contexts so frequently that it is now habitual. I wake up, check hackernews for articles, read a few sentences from an article, and then engage switching between MSN, email, getting ready for school, and reading whatever little bits of whatever article I go to when alt+tabbing or ctrl+tabbing around. This has left me switching contexts in places where it's not demanded, and not focusing in when that's precisely what I need.

So the question becomes, "how can I focus?". It may be something I need to learn, but again, how? My thoughts are that it comes down to the mental discipline to force myself to finish a task. If I am blogging (for example) and I decide I would like to watch the new episode of Lost today, or check out a book on my shelf, or read old blog posts, I must force myself to finish my task and then switch instead of just switching as soon as the thought occurs.

This is likely applicable at a larger scale. Getting a project off the ground, or getting a serious improvement to one's self going, takes a lot of energy, which is present in the early stages. As time progresses though, New Task Energy wears off and you want to switch to something more exciting. I've got to learn to be fuelled by Achievement Energy (when I've finished a task) instead of by the energy I get from having something new to work on. I've got to pick reasonable goals and work toward them, and not start new things until I'm done chewing what I've bitten off.

This summer, I have some hopes. I'd like to build two things minimally, and five things maximally:

compiler
code style switcher
3d drawing environment
zoomable code editor
knowledge map collaboration station

I'm not even certain which of those is toughest. I also want to do other things, like dissect some open source code and mess with it (particularly the Cube engine used in games like Sauerbraten) and learn some webGL/jQuery/drupal stuff, and then general stuff like math and science skills, etc.

So, knowing that these are the things I'd like to end up with, I should draft some goals, some critical paths to the goals, and see what seems reasonable. The things which have my attention most at the moment are the knowledge map collaboration station and the 3d drawing environment.

That said, my plan is to not be especially productive until I want to be. I'm going to watch television, sleep, play video games, and read until I'm very bored of doing these things (I predict just less than 2 weeks of slacking) and then to come out of it a masterfully productive sort of person.

The biggest point I need to make here is that once I've set these goals up, I can break down tasks for what I'd like to finish, but once I am in the midst of a task, I must perform it to completion. Working on something halfway and dropping out is how to not finish it. Once I start a thing, I will go until it's done. Then it just becomes a problem of starting.

Good luck, future me.

Sunday, March 28, 2010

Failure and success

Goals are coming along, but I didn't report back on Friday or even really start the phil paper. I'm working on it at the moment, finally picked up some steam.

Will report once it's a reasonable thing to do.

edit (many days later): post coming tonight

Wednesday, March 24, 2010

It's been a fun couple of months.

I am realizing that I need a framework for living - not as a ruleset, but as a guideline. One that permits failures, and has guidelines to return onto track.

Regularly, I'll have things to do, and I'll suddenly be really tired. Or really distracted. Or really want to do something else first (in one of those right now). Somehow I'm never getting to sleep on time, never getting home on time, never getting projects in on time, never getting to school on time. Never doing enough, always planning more than I can achieve.

This ultimately means that I'm less capable than I think. Whether that's because I lack the attention span or discipline to achieve what I would be ideally capable of, or because I set my sights far beyond even what I'm ideally capable of, I'm uncertain. What I am certain of is that I need to change, because I'm not in a good spot. There are too many deadlines approaching, too quickly, even after having made sacrifices.

So this is what my spare cycles will go into for the next while. Wait a minute, how can I have spare cycles with so much to do? Well that's precisely the problem. I feel like my programs aren't optimized to my hardware -- rather than packing 4 1-cycle instructions together for alignment, I've got empty space floating around and do nothing with it. So I'll make this my ambient thought-topic: what guidelines can get a person back on track, and keep them on track?

Off the bat, I see that I need goals. These goals will provide motivation and metrics, and from those I can set myself tasks and make plans. I can develop small heuristics to remind myself with whenever I suddenly decide "this'd be a great time to write a blog post", "I could hang out with Sophie later", or "man, I'm tired. Sleep is good for me -- I'll (stay asleep / go to sleep) even though I've got stuff to do."

Alright, hope I can stick to it even marginally. A first goal: report back on friday with some progress. A second goal: finish my philosophy paper this evening.

Wednesday, February 10, 2010

How I solve problems

I'm not really sure how I solve problems. What I'm betting though, is that I could improve my problem solving ability by paying attention to the process as I bumble through it. Maybe we all could. So let's define this with a touch of formalism.

Where I'm at

I have a problem to solve. I've got an existing program, and I need to make some changes to it to enhance its functionality. I must think that this is a hard problem, because I have procrastinated significantly on it, and every time I go to start it, I get a little lost.

The sense of being lost comes from a few directions.

1) There are multiple ways to solve the problem - some easier than others, but with hard to quantify costs of later complexity and code to rework.

2) The existing program is a hacked together mess.

3) I haven't really solved this problem before.

4) There are technical tools which would help with some of my possible plans for moving forward, but I am not certain that those are necessary or, more importantly, allowed.

Knowing this, I see my primary boundaries (and solutions to them) as:

1) I have a goal and a starting point, but no real hints about a transformation function to arrive there. I need to choose what path I'll walk along.

2) The existing program may be useful later, but for now, it must be disregarded. I'll see what I can salvage once I know how I want to do this. Note: this is easy, because the existing program is only a few hundred lines of C/C++ in a single file.

3) This just makes me a little less sure of myself.

4) I do not know enough about the limitations on the assignment to make good assessments for technology to use or to not use. It is unspecified in the design document which technology I cannot use. So, I'll just assume it's allowed unless we're told it's not. Within reason.

What next?

I need to choose a path, and that would be easiest to do if I just start working along a hypothetical path. I've been bogging myself down in the different possibilities at the start and not wanting to commit - well, I'll just start thinking my way through the beginning (and then the rest) in as high level a manner as I can. This is a problem well suited to a top-down design, and I know (from up above) that I don't have to keep much of my existing work.

So the next step is: draft out some plans.

Depending on the sort of work I'm doing, I like to make plans a variety of ways. I tend to work well by expressing things verbally, which means I like to talk through them. This is why I'm writing this blog post.

Next up, I want to do some more specific planning. Like code planning. But rather than pop open vim (where I'm fast when I know what I'm doing, and slow when I don't), or MSVC++ (where I'm constantly trying to think of how to do things better), I'll work on paper, with a pen. This will make diagramming (should I want to do it) faster, and help to free me from thinking about technical details for the moment. Right now I don't want technical details; I want high level organization, overall understanding, and to work through some math. Paper is the perfect technology for this.

But what I really have to do right now, is mark some students in a class I'm TAing, for the next three and a half hours. It'll be hard to work during, but hey, it's a living. :)

Monday, January 25, 2010

School's on

Entering week 3 of Semester 6, all looks well. The lineup for this semester:

CIS 4800: Graphics
CIS 4650: Compilers
CIS 3120: Digital Systems
PHIL 2100: Critical Thinking
PHIL 2370: Introduction to Metaphysics

The rundown for each of them:

Graphics

OpenGL and its associated helper libraries - pushing and popping matrices and gluing together random bits of code to make a game called Qix(beware the audio!), which is rather fun to play.

Compilers

Constructing a compiler to translate a Pascal-ish language (termed Pish) into MIPS Assembly. We're starting with DFAs and simplistic ideas of scanning, then walking forward through parsing, generating meaningful symbol tables, abstract syntax trees, intermediate code, register allocation, and machine code generation. It should be an awesome project to get through.

Digital Systems

Starting with CMOS networks of transistors to build basic gates and then gluing gates together to make a half-adder, then a simple 8 bit ALU, then a CPU with a data and control path. We'll be seeing the theoretical and practical side of digital design - touching on minimization of boolean expressions, hazard detection and reduction, designing for cost/speed/safety, and some neat things at the end about FPGAs and such.

Critical Thinking

A lot of hullabaloo about arguments. This is a course about using, identifying, and thinking about people's arguments in day to day life and an academic context. It's really the english half of symbolic logic (conversely the math half), which I took over a year ago. I'd better do pretty damn well in it.

Intro to Metaphysics

We read a bunch of old stuff and discuss it with the prof, basically. Good reading, good discussion, all about foundational and arguably (oh so arguable!) useless topics like identity, time, the structure of universe, and the nature of reality. Some smart people in there.

Also going to put my name in the hat for B. Comp Senator again, and.. yeah. Good semester, I think. (And hope.) (And a democamp this week! I will try to go!)

Saturday, December 26, 2009

So, generic programming

This is a good read.

It's an interview with Alexander Stepanov, and contains gems like:
"I find OOP technically unsound. It attempts to decompose the world in terms of interfaces that vary on a single type. To deal with the real problems you need multisorted algebras - families of interfaces that span multiple types. I find OOP philosophically unsound. It claims that everything is an object. Even if it is true it is not very interesting - saying that everything is an object is saying nothing at all. I find OOP methodologically wrong. It starts with classes. It is as if mathematicians would start with axioms. You do not start with axioms - you start with proofs. Only when you have found a bunch of related proofs, can you come up with axioms. You end with axioms. The same thing is true in programming: you have to start with interesting algorithms. Only when you understand them well, can you come up with an interface that will let them work."
and
"You can't write a generic max() in Java that takes two arguments of some type and has a return value of that same type. Inheritance and interfaces don't help. And if they cannot implement max or swap or linear search, what chances do they have to implement really complex stuff? These are my litmus tests: if a language allows me to implement max and swap and linear search generically - then it has some potential."
Good stuff; making me think.

Thursday, December 24, 2009

Customizing the blog a bit

This layout has always been rather insistent that I have a very thin middle column in which to place my posts. It's bugged me for a long time, but I decided that messing with the CSS template was outside of my competence level and just asking for trouble.

At the same time, I've always wanted to be able to place code into the blog without it looking like some awful monster crapped out unformatted text.

Well this morning I've fixed these issues.

The latter was as easy as googling "showing code in blogspot" and then following the instructions at the top link.

Essentially, you go to the Layout section of your dashboard, click "edit HTML", find a tag "]]></b:skin>", and insert some CSS in the section above it. It adds the necessary stuff to make pre and code tags to work wonderfully.

Then it recommends running code through a converter to quickly change it to escaped-text before posting it.

I feel like (and am, really) a script kiddie but hey, I've got code showing up in my blog like so:
#include<stdio.h>
#include<stdlib.h>

int main(int argc, char *argv[])
{
int a, b, c;
int *d = NULL;

a = 5;
b = 6;
c = 7;
d = malloc(sizeof(int));
d[1] = 8;

if(argc == 2)
{
printf("What a lame example!\n");
}

free(d);
return 0;
}
which is wonderful.

Then I got to thinking "Hey, I'm a cocky CSS editing fiend, why not solve the problem of the blog's lacking width?" And I looked over the code in the layout section.

I found in there (this is likely specific to this template)
#header-wrapper {
width:660px;
margin:0 auto 10px;
border:1px solid $bordercolor;
}
#main-wrapper {
width: 410px;
float: $startSide;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}
and
#footer {
width:660px;
clear:both;
margin:0 auto;
padding-top:15px;
line-height: 1.6em;
text-transform:uppercase;
letter-spacing:.1em;
text-align: center;
}
These all have 'width' attributes that look like they're big enough to be most of the screen, and they're the only similar ones in the file. 660 pixels isn't very wide - I imagine it was set at that to work on an 800x600 screen, should one need to see my page.

Well you know what? I'm officially leaving those people in the dust.

Following some common design advice of 960 pixelwidth pages (see 960.gs), I decided to directly increase 660 to 960, and 410 (correspondingly) to 710. This widened the main post section of my blog considerably, and seems to have had no negative consequences.

Hooray for a productive blogging morning.

Python Fun

Every programmer, when learning something new, hits on that devilish quandary:

"What should I program?"

And I am a man like all others, who twiddles my thumbs and wonders "ah... if only I had something to /do/ with this language, I would really start to learn it!"

Well, I've decided to just dink around uselessly and see what comes of it. Then share.

The things we'll cover:
  • Some stupid string stuff
  • some more stupid string stuff, with numbers involved
  • then some regular old math

stupid string stuff:

First I started off playing with the string and list functions, and interchanging between them. Throughout this, I might duplicate existing functionality -- if I do, comment and tell me how to do it better! I'd love to learn.

I decied that I wanted to take a string, say "Hey man, what's up?" and insert stuff between each letter. I couldn't really find a quick way to do this, but some related things popped up.
a = "Hey man, what's up?"
a.split()
will give you ['Hey', 'man', 'what\'s', 'up?'] - and that's nice, but I want things broken down to the letter. So I wrote a function breakout:
def breakout(input):
r = []
for i in input:
r.append(i)

return r
breakout("hello") returns ['h','e','l','l','o']

then you can do a str.join() - let's wrap it into a function!
def splitByChar(instring, splitchar):
return splitchar.join(breakout(instring)
you can, through this, call splitByChar("hello", '.') and receive 'h.e.l.l.o'

ah, stupid pointless string stuff.

more stupid string stuff, with some math

Next up, I decided to play with phone numbers. I decided to break them up into their constituent digits and add them. This was (as many things in python are), an easy task.
def summit(input):
sum = 0
for i in input:
if i.isdigit():
sum += int(i)

return sum
This function runs quickly through the string and adds to the sum for every integer found.

I put in my phone number, print(summit("519-703-3336")), and received 42. Exciting!

Then I got to wondering.... I wonder how many phone numbers out there sum to 42? I wonder what the distribution is like across the rang of sums from 0 to 90? Let's write some code to find out:
def smattering(input):
arr = []
for i in range(0,9*input):
arr.append(0)

temp = []
for i in range(0,input):
temp.append('9')

upper = int(''.join(temp))
upperStr = str(upper)
for i in range(0, upper):
arr[summit(str(i))] += 1
if i % 1000000 == 0:
print(str(i) + ", " + str(upper - i) + ", " + str(i/upper))

return arr
This code makes a 90-element list, then brute-force walks from 0 to 9,999,999,999 and calculates every single sum, stopping every million steps to print out how far we are in, how far we have left, and a percentage through the path we've walked. I did some simple calculations, every printout occurs about 9 seconds apart, and 9,999 of them are required to take the calculation to completion.

This translates to about 24.9 hours. That's a pretty long calculation -- and it's kind of required; summing each of 10 digits for each of 10 billion numbers is 100 billion operations no matter what way you cut it. I've left the calculation running in a terminal (two, actually - one which will conclude and print the values to the screen and to a text file, and another in an interactive terminal in case I come up with fun things I want to do to the list off the bat) - but I'm beginning to think

some regular old math

is in order to find out the answer to this question a bit faster. The clock is ticking, and I have a day to find out. I'll update once I've thought about it a bit.

Wednesday, December 23, 2009

Hard to settle

So far I've played with Python, learned some piano, written a program to help me learn large-number multiplication, played hours of Ogre Battle 64, and watched the first season and a half of Weeds. Also seen friends, walked many kilometers, and slept gratuitously.

I think a haircut is in order. Maybe not today, maybe the 27th or so. Also, laundry.

I'm going to move forward with watching the SICL videos, and then dive into the Graphics/Language stuff. Math can happen in my spare time, as can piano. I've also got a phone-interview for an internship today. I'm not certain quite what to expect - algorithms and code-related questions, a history of myself, or just good discussion. I hope it goes well.

It's been wonderful to have time not committed - when I decide I want to do something, I can generally just go do it. I've learned a lot and I feel much happier than I have in weeks.

I also fixed up my home-server's webpage, have read a bunch of my various books (Contact, The God Particle, the latest Wheel of Time book), listened to a TON of the music I've accrued over the past semester, and played with some VMs. Installing Slackware is an interesting experience to say the least.

I'll post back in a few days (likely just post-christmas) about my progress on SICL, Python, Graphics, and my C-spitting-extensions to C.

Wednesday, December 16, 2009

A flurry of activity

Well, that's another semester past.

I have from right now until January 10th to myself, effectively. It's time to decide how to use it.

So from what I can tell, my options are:

Graphics
Languages
Base Skills
Something Complex

Graphics would be making computers do graphical things for me and also making graphics myself. Playing with Blender, with the GIMP or Photoshop, with Paint and maybe Flash, reading about colour-theory and how to paint a perdy picture. I'd also be drawing a lot, and reading about basic art stuff. And of course, playing with C/OpenGL to make the computer do cool things, and learning related math (Matrix Algebra, anyone?)

Languages would be reading about and learning Lisp and Python through the development of simple (and slightly more complicated) projects with them. I would watch the SICL videos from MIT's Open Courseware, generally get a better feel for Lisp, and I'd just do stuff with Python. I would like to implement my scope/stack/reference/object stuff for C.

Basic Skills would be math and physics and chemistry and maybe biology, just learning voraciously over the break -- very largely just improving my mathematical skill and comfort level. I would also be spending a lot of time working on music and some basic technology things, like awk/sed and being a better vimmer, using the full extent of regexp's and scripting.

Something Complex would be choosing a project - I'd spend a few days choosing, then go through a design phase and build myself something good. Something that I could sell, or at least use in my day to day life. Maybe this could include working on an Open Source project, or attacking Sam Altman's company Loopt, which just does not seem to be doing a good job with my idea.

Anyway, one of those four things. I'll have to ask myself "Where do I want to be on January 10th", and my answer could be "I want to walk up to a Piano and lay down the driving rhythm line from 'Don't Stop Me Now'.", or "I want to be able to take 4 files of similar data in disparate formats and spit them sorted into a single new file, every 10 seconds or when the file exceeds 100 lines, and I want to be able to write the thing to do it in about two minutes.", or maybe "I want to be able to spend a weekend and make a simple game, with my own pixel graphics, my own physics, my own everything, and run it on Linux or Windows.", or maybe "I want to be able to do what I want to be able to do. In Lisp. (really poor recursion joke)". Ooh, or, "I want to be able to read a Wikipedia article on a mathematical topic and not have it go over my head before I'm halfway down the page."

So, which of those sounds best? Or at least, sounds like the one I'd like first? I'm going to spend an hour or two thinking about it.

Monday, November 9, 2009

The next few weeks, schoolwise

Networking,
Modelling,
3750,
and a tiny bit of databases

Networking I've got a good mental start on. I'm agreeing so far with Martin on using a linked list - I considered just making a big buffer and filling it in using some neat math, but that...

that sounds complicated. Easy to write out, hard to set up. I'd much rather save each datagram into a list and then sort the list, and iterate through it to write it out/test whether or not stuff was received. So I'm going to set up my listeners, send out the request, read everything in, sort and check my data (likelier I'll sort as I read), rerequest what I haven't got, repeat until I've got everything, then write the data out. Cool.

Haven't looked at modelling or databases yet. Will do so soon.

Have a meeting for 3750 tomorrow, we'll have discussion and such, and get back on track.

Alright, school is looking manageable. Modelling and Networking are both due circa Nov 26th, DB will be sooner, and 3750 is ongoing and constant. This iteration (final) is due next Thursday.

Then Finals!