Tsuji Ayano – Sweet Happy Birthday

Posted: November 19th, 2008 | Author: Remi | Filed under: Japan | No Comments »

A video from the best album ever!

YouTube Preview Image

Kotoringo

Posted: November 17th, 2008 | Author: Remi | Filed under: Japan | No Comments »

One of my new favorite Japanese music artists is Kotoringo. I found out about her by the iTunes Japan free single of the week.

Not sure is this is the real video for her song, but its a good song anyway! enjoy!

YouTube Preview Image

Comparing Different Languages: A Simple Program

Posted: November 16th, 2008 | Author: Remi | Filed under: Programming | 1 Comment »

At my school’s computer club we are doing a comparison of different programming languages.
We took a simple program written in BASIC and examined how it works. Then I translated it to both C and Javascript.

Here is the program in BASIC which is a procedural language, unlike non-scripting languages it is non-compiling, this means that it is translated to code the machine can understand one line at a time when the program is actually run. Because of this, it is incredibly slow when compared to modern languages like C.

DIM r, q, p, m
INPUT "What interest do you expect? ", r
INPUT "How much % do you withdraw per year? ", q
p = 1! 'Principle
m = 0! 'number of months so far
DO WHILE (p > 0!)
    FOR i = 1 TO 12
        p = p + ((r / 1200) * p) - ((q / 1200) * 1)
        IF (p < 0) THEN             PRINT "your number of years = "; m / 12             i = 12         END IF         m = m + 1     NEXT i     IF m > 1200 THEN
        PRINT "you won't live that long!!!"
        p = -1!
    END IF
LOOP

Here it is in C, another procedural language.
To compile on Unix or Linux based computers, type in a terminal

gcc path/to/sourcefile.c -o output_program
then to run it
./output_program

#include 
 
int main()
{
float r, q, p, m;
printf("\nWhat interest do you expect? ");
scanf("%f",&r);
printf("\nHow much %% do you withdraw per year? ");
scanf("%f",&q);
p = 1.00; //Principle
m = 0.00; //Number of months so far
int i;
while(p > 0.00)
{
for(i = 0;i <= 12;i++)
{
p += ((r / 1200) * p) - (q / 1200);
if(p < 0) { printf("\nyour number of years = %f\n", m/12); i = 12; } m += 1; } if(m > 1200)
{
printf("\nyou won't live that long");
p = -1.00;
}
}
return 1;
}

And here it is in Javascript, an object-oriented scripting language. Although basically since this program is so simple, and there was no need to use objects except document, it looks almost identical to the program in C. Test Out The Javascript Here

 
<script type="text/javascript"><!--mce:0--></script>
 
<form id="theForm">
What interest do you expect?
<input id="r" type="text" />
 
How Much % do you withdraw per year?
<input id="q" type="text" />
<input type="submit" value="Calculate" />
</form>
<div id="result"></div>

After looking at the code for all three, it seems that they are for the most part very similar. The syntax from BASIC to C is quite different, but they both use loops and if statements. One difference that can be seen particularly in this program is the lack of variable types in BASIC. You can see in C that we have to declare the variables as float so that they will hold a decimal. Another difference is that there is no shortcut it seems in BASIC for variable = variable + number; as there is in C. As you can see in C it goes like variable += number; . Also it is worth nothing that comments in BASIC use a single quote mark ( ‘ ) to denote comments, while almost all more modern languages use the double forward slash ( // ). And of course, BASIC doesn’t use braces at all. Instead it has a sort of tag way of enclosing statements. These are just some of the differences. A lot of languages used nowadays follow after C, the javascript is the case in point. It is always worth looking at older languages to really see if the way languages today do things is really better or not.

Try it out for yourself and see the differences

Download Source for All Three


Hello World!

Posted: November 14th, 2008 | Author: Remi | Filed under: Site News | No Comments »

Welcome to my blog!  I started this blog mainly to write about programming topics, but I’m sure I will be able to write about some other things as well.  I like to program in many languages but mostly Objective-C and Cocoa.  I’ll hopefully be posting some helpful stuff to some programmers.