Tuesday, May 25, 2010

Reddit

To the person from reddit. You know who you are. If you have made it this far, you are on the right track, and I applaud you for your effort. Note, however, this blog contains the emo rantings of a... me... which should be taken with a grain of salt.. if not down with the trash.

Saturday, January 02, 2010

I don't want to give my cat up so soon. :'(

Monday, November 30, 2009

Structured (procedural) VS Non-Structured Programing

Here are a couple wikipedia links to start off.

Most people learn to program the "Non-Structured" way. It's more simple to implement, easier to understand, and a great starting point for new programmers. However, the simplicity is often it's downfall. And more complicated tasks will likely be hindered by the lack of modularity and ridiculous looping or duplicated code.

Take, for instance, the Fibonacci sequence. Imagine trying to implement that without any procedures (functions). It might look something like this:

#include 

int main()
{
int y=0,z=0;
for(int i=0; i < 10; ++i)
{
if (i == 0)
y = 0;
if (i == 1)
y = 1;
z = z + y;
y = z - y;
std::cout << z << std::endl;
}
return 0;
}


I shudder to think of how that would look if I didn't make use of the for loop. And even with it, there are needless variables. When looking at the alternative which uses procedural programming...

#include 

int fib(int);

int main()
{
int y=0,z=0;
for(int i=0; i < 10; ++i)
{
std::cout << fib(i) << std::endl;
}
return 0;
}


int fib(int number)
{
if (number == 0)
return 0;
if (number == 1)
return 1;
return fib(number - 1) + fib(number - 2);
}

Though it may not be immediately obvious, this is a better solution. The fib function allows you to pick any number in the sequence. Also, it off loads the bulk of the work to a separate entity, which makes it easier to change. If I wanted to make it faster, I could simply add a static vector to hold the previously calculated numbers. If I wanted to allow for larger Fibonacci numbers, I could change the return type to an unsigned int, or a long long, or an unsigned long long. The possibilities for expansion are only limited by your needs.

However, structured programs can sometimes add more complexity than is necessary. For instance, what if all you wanted to do was write a short hello to whoever in the world may be running your program? This seems like a great way to do it:

#include 

void output(string);

int main()
{
output("Hello World!");
return 0;
}

void output(string message)
{
std::cout << message << std::endl;
}


Yeah no. Why do you need another function to do what is already part of the output library? And if you only wanted to print "Hello World!" it would be much simpler to do this:

#include 

int main()
{
std::cout << "Hello world!" << std::endl;
return 0;
}


In short, the style of programing you use for any given project should depend on the goals. If you want to get a small program done quickly and or statically, there is no reason to use structured programming. But if you have a large project that changes requirements and flow, the more structured styles will suit it better.

Friday, January 23, 2009

Unrequited

I wish I had some person, some task, something that gives back to me more than I put in. Whatever I do, I find that it was not worth my effort in the first place. One exception to this, is programing, but that has delayed gratification. It takes hours upon hours of research, trial and error, and purely briliant ideas to get something tangible. And even after reaching that point, another extra long time is required to achieve the next goal.
People always seem to let me down. I expect more sometimes, for all I give. I know it sounds selfish, but there aren't many people who will do what I do. It would be nice if other people noticed...
Though I have to say, my niceness probably barely makes up for my many flaws. I guess it should be good enough that there are people in this world who will put up with my bullshit. If only there were more.

Friday, November 21, 2008

glaqwidousky - yes, it is a word

I'm a bit depressed. For whatever reason it has been particularly bad today. College is pretty horrible for everybody involved. My few friends all seem to be in the same boat as me. One has girl troubles. Another has school troubles. I could be said to have both plus family troubles, though I won't go into any of them at the moment. Stress is very high. Every little thing has been setting me off. There has to be some good way to deal with it, but so far I haven't found a good one.
I tried /b/ which worked for a while. I find that it gets really boring really quickly. Trolls and newfags ruin the experience for me, though some of them are pretty clever. The only usefulness of /b/ shows itself in the wealth of porn posted all the time. As an intellectual stimulus it falls short. Also, listening to a bunch of people begging for someone to "an hero" doesn't help for someone who'd depressed.
I tried taking a drive. I figured the speed and the sound of the engine would help relieve my stress. As usual, things did not go my way. My car sucks for picking up speed and there was always a red light to slow me back down. I find myself cursing, often loudly, at drivers who trip the traffic light sensors away from my favour.
I tried chocolate, and that seems to work, but damn is it expensive. I have discussed it before, I'm sure. Bought $10 worth of dark chocolate. 60%, 72% and 85%. Starting with the 60, and working up from there.... TTFN, too tired to write more.


P.S. It's not a word. Did you just look that up? Epic fail if you did.

Tuesday, October 07, 2008

I can count my friends on one hand. :(


-3nvy

Tuesday, July 29, 2008

What you don't know can hurt you

I don't know something. And even if I did I couldn't tell you. But I don't. How can I tell you something I don't know? Basically I can't tell you what I don't know, so don't ask... But what if I did know? That's just stupid, I already said I don't know. I'm not going to waste my time answering what-ifs. But it still hurts. What is "it"? I don't know, don't ask me.

revolvo ut infinitio