Teaching BASIC - Why Not?

| No Comments | No TrackBacks
Recently, one of my friends from college came to me asking for advice on how to start learning computer science.  He had graduated three years ago with a degree in philosophy, and, long story short, this hasn't really been working out for him.

So last Friday, he stopped by my house, and we got started.  I think since this is sort of a craftsy kind of topic, I'd like to get his hands dirty with some real programming.  My language of choice, BASIC.  In particular, I used ChipmunkBASIC (because it was the first one I could find).  Let me explain why.

1.  Simplicity.  BASIC has zero complexity.  What is the shortest program you can write in Java?

class ShortestProgramClass {
public static void main(String args[]) {
}
}

How about in BASIC?

END

For me, one of the most demoralizing thing about learning anything is to see all these nonsensical words flying around being used, and then told to wait to learn what they mean.  To me, learning is a natural progression from the fundamentals of computer science, to the more complicated stuff.  No language starts you off in a better place than BASIC (sorry Ruby users, but everything in Ruby returns a value is a concept I'd like to not cover early on).

2.  Write programs immediately.  I wrote the following lines of code, line by line.

PRINT "What is your name?"
INPUT name$
PRINT "Hello, " + name$
END

After each line, I ran the program.  In basic, there is a direct correlation between each line of code, and each action.  There's a little bit of glue explanation to connect the concept of variables being containers for values and such, but that's it.  Five minutes later, and I'm already giving him a programming assignment.

I told him, I wanted to write a simple robot that tried to find out more about you and to give you advice.  Sort of like a stunted hunch.com.  He came up with the following.

...
PRINT "How many drinks have you had?"
INPUT number_of_drinks
IF number_of_drinks == 0 THEN PRINT "Go ahead and drive!"
IF number_of_drinks == 1 THEN PRINT "Be careful out there!"
...

The assignment was organic and natural.  Okay, I know how to give instructions, and I know how to get answers.  But how do I make a decision?  So I taught him the minimalist IF.  As the night progressed, I showed him that sometimes, you needed to do more within an IF block, and slowly fleshed out the IF construct.  This took a total of 30 minutes of explanation, and coaching on a bit of the mental processes behind how you can think of what a computer interprets.

3.  Algorithms, not Semantics.  Algorithms should be the focus of any treatment of computer science.  In BASIC, algorithms are King, and it shows since the algorithm itself just pops out. 

Computer science appeals to that part of us that likes to solve problems.  Technology changes at a blinding pace, so teaching the hot new language of the day is not the way to go.  Believe me, companies would rather have the guy that knows how to solve the problems, than to have the guy (several years ago) who's a master at Python but nothing else.  Programming languages are fickle.  Algorithms are not.  My session with my friend reaffirmed this belief.  With less than an hour of teaching him and keeping him engaged, I could already see that he was struggling to change his view of how to solve problems to fit in the basic model of how computers think.  It was a joy to witness.  If anyone hasn't tried tutoring someone, I highly recommend it!

4.  Easy To Be Thought-Provoking.  I'm sorry if I appear to be repeating myself, but all the teaching becomes easy because BASIC is such a simple language.  I think it's just the right combination of power and ease of deciphering to teach a completely new student.  For instance, basic hides enough of the complexity to make programming easy, but is still constrained by basic 32-bit variables.  This seems like an oversight, but I think of it as a perfect way to end a lesson with something thought provoking.  This part took a little longer because I had to teach my friend the basics of binary, or mathematics in any base, and some of the tricks we use to represent numbers.  Now, I didn't go into specifics here, but I did more or less introduce a simplified account of mappings and set theory to introduce how we map a bunch of binary numbers to negative numbers and such (I highly recommend not even mentioning floating point numbers).

Once I finished this, I showed him a BASIC example that gives an unexpected result.  This was heavily inspired by the documented problem with MergeSort, as it applies to larger problem sets that use 32-bit built-in arrays.

...
PRINT (35000 + 35000) / 2
...

This yields a large negative number.  And asked him if he could explain why this happened.  After a bit of thinking, and a bit of guidance, I saw his eyes light up as he began to grasp the problems of wrap-around associated with essentially a clock arithmetic system.  It was amazing to see him gradually integrate these complex notions.

In any case, I decided to end the lesson at that point since I felt that I had already overloaded his brain.  The best part of the exercise was that he wanted to keep working on the little assignment that I gave him!




So why aren't we teaching BASIC in college more?  It's hard for me to comprehend.  Is it because it technically has no vocational use outside of an educational setting?  Well, that's not true.  After all, Microsoft's Visual Basic is based off of BASIC (wow, that sounded weird).  That's certainly used in industry, though it may not be platform independent.

Any other reasons?  I think the question comes down to whether a University should be attempting to teach a tool that's an industry standard, at the cost of a better quality of education.  The programming language is just a tool, in computer science.  It's important to know the tool, but if you don't develop the skills to solve problems, then you can't be a computer scientist.

The Case for Google

| No Comments | No TrackBacks
To all you aspiring people looking to enter the job force, if you take anything out of using computers as a means to make a living, for the love of god learn how to use Google.  Or Bing.  Or whatever Search Engine works best for you.

With Search Engines, you no longer need to remember web addresses, you just need to perform a search, and choose from a virtual smorgasbord of results.  Search Engines are the portal to the ultimate aggregation of human knowledge: the Internet.  Please learn how to use this important tool.  This is more important than any static knowledge you may have gained in school.

Webpage is Up!

| No Comments

Webpage is finally up! Check it out and take a look!

[Archive] Blackberry Development

| No Comments | No TrackBacks

When a company sets out to create a platform, they are essentially making gentleman's agreement with developers at large that they will try to make their lives as simple as possible to create exciting and useful applications for their platform.  In return, these apps will drive business toward that company's flagship product.

For Research in Motion, perhaps at one point in their lifecycle, this was the case.  But it is clear that at this point, this is NOT the point.  Therefore, I'd like to encourage EVERY developer (that can afford it... you do what you gotta do, you know?) to avoid designing anything for this problem.  The single most compelling reason to develop for Blackberry is to land a ludicrously large contract developing a specific application for a large company.  That is it.  The platform itself is dated, lacks any real polish underneath that title screen, and lacks any form of real tech support.

The launch of App World (Blackberry's answer to the iPhone's App Store) is underpopulated, and filled with uninspired apps.

The reason?  Simple.  Blackberry offers you technicaly support... at the gaudy price of $75/hr.  Unless, of course, you go through your carrier... which doesn't even make sense if you just want to know some specification for the hardware.

That's right, if you want to know... oh... let's say the dot pitch of the display, or the refresh rate of the screen... you (or your mobile carrier) will have to pay $75/hr to get anyone of value on the line.  And even if you do get there, you'll be told that the first hour is a flat rate 75, even if you don't talk for that period of time.  And they'll also provide tech support that include searching their own blackberry forums for the solution.

In short, Blackberry developer support is a farce.  If you can avoid it, don't develop because you'll likely cost your company more money than it's worth, and you'll have to deal with their bullshit.

As much as I don't like Apple's policies, I see the iPhone as the current most likely competitor to knock Blackberry off their high horse.  And boy do they have it coming.

For those of you that would like to give Android a spin, it is freely available at this direct link.

This post assumes the reader knows how to create a new android project and is somewhat familiar with the uses of the files automatically created in your Android project.  My personal development environment is Eclipse since it integrates everything nicely, though be warned, you will need a relatively powerful system to run the power hungry Eclipse.  If you have slower systems, be sure to read the Android tutorials on installing the SDK.

If you are like me, your first impressions of the SDK was a bit of a surprise (as with any embedded platform as this).  As someone that just came out of college in more traditional computer engineering/computer science field, we weren't exposed to the industry standard methods of building GUIs.

Let me explain.  In college, we are used to code like this:

thesetupjava.pngThis produces:

hello.png
goodbye.png

However, to accomplish the same thing in Android, it's a little less obvious.  There are multiple ways of doing it.  You can do it by putting the code into the XML, then acquiring the handle by the XML ID to change the label, or you can do something very similar to the produced swing code.

In this day and age, however, coding GUI elements by hand is tedious, and to make this future proof and as friendly a transition for college students like myself to get into this style of development, we will create this simple application using a GUI builder, then acquire those references for dynamic use in our application.

Let me start off by recommending an amazing application: DroidDraw.  This tool is much better for designing the actual positioning and relationship between your GUI elements (assuming for now that we will only be using standard Android GUI elements).  You simply draw your GUI, then click on "Generate code".

droiddraw.pngNext, paste the code it provides into the main.xml file generated by android.  Then, we write the following code in our main activity Java file.

thesetupandroid.pngI'm not quite sure why Android chose to introduce as it's first prime example such a complicated tutorial, but hopefully this early look at the corollaries between the Android platform and much more familiar widget toolkits is a help.  The final output is rather obvious, but I'll post them anyway.

hi.pngand...

bye.png

Anyway, that's a little something to whet the appetite as I patiently wait for my G1 to arrive (see my previous post's screenshot - the picture has not change... sigh).

Hope you enjoyed, and I invite you to discuss and point out any mistakes I've made in the comments section!

Cheers,
Sam










[Archive] cout << "Hello, World!" << endl;

| No Comments | No TrackBacks
Welcome to my neest tech blog.  I was hoping to kick it off with the unboxing and analysis of my new T-Mobile Android G1 phone (which I pre-ordered).  Unfortunately...

curses.png
Stay tuned for more updates in the future!  What I've got in store for you is an analysis of programming for the Android SDK, and a comparison of the Android SDK and the iPhone SDK.

Thanks for stopping by!



Welcome to My Tech Blog

| No Comments | No TrackBacks
Just getting started.  GoDaddy.com and FatCow.com have been spectacular so far, and have helped me with any questions I've had as I get everything set up.

If you haven't noticed yet, all the Movable Type paraphernalia is plastered everywhere, so it's fairly obvious what I'm using as my CMS for this blog.  So far, so good.  The one thing I really miss from wordpress is the ability to install plugins without having to drop it in FTP style.

Speaking of Wordpress, I am in the process of migrating stuff I may have all over the place to this domain!  I will be porting over my two (meek) posts from my notafruit2.wordpress.com website.  If you want to read one gripe about Research In Motion, and a small introduction to programming for Android, check it out.