Skip to Content
This is just the clippings from my life. I currently reside in beautiful downtown Vancouver where I am a Drupal developer at Affinity Bridge and software engineering student at the University of British Columbia.

Hello World in C, C++, and Java in Eclipse

A friend emailed a few months ago wondering how to compile a C program. Since this is an important first step for developers and I found that there were no simple and clear resources available related to Eclipse, I thought it might be good idea to go over it. So... here's how to setup and compile a "Hello world!" program in C, C++, and Java using the Eclipse IDE.

I've broken this up into five parts:

  1. Installing and setting up Eclipse
  2. Hello world in C with Eclipse
  3. Hello world in C++ with Eclipse
  4. Hello world in Java with Eclipse
  5. Compiling from the command line

1. Installing and setting up Eclipse

Eclipse is a free, cross-platform, open-source integrated development environment (IDE) that makes development easier. It features plugins for many languages, including PHP and Google Android, but it is also great for C, C++, and Java.

To download Eclipse, visit their download page (http://www.eclipse.org/downloads/) and choose either "Eclipse IDE for Java Developers" or "Eclipse IDE for C/C++ Developers". Install as is standard for your operating system. If you are going to be developing in different languages (I've been using all three at school right now) just download either one and install the other's packages later. To install additional packages, open up Eclipse and click Help > Software Updates, then click on the Available Software tab, expand "Ganymede Update Site", choose which plugins you want (probably either C and C++ Development or Java Development), and click Install on the right.

Eclipse keeps your panels organized using what's called a "Perspective", if you have both Java and C/C++ development installed you will have two perspectives which you can switch between:

Eclipse perspective buttons for C/C++ and Java

To compile programs in C/C++ or Java you may need to install the appropriate compiler. So, go ahead and install Java or GCC. On Mac OS, installing Apple Developer Tools (http://developer.apple.com/tools/xcode/) should do the trick if it's not already installed.

Now create a new project by clicking File > New > Project.. and follow the wizard. It will allow you to choose which language you want to use and setup all the necessary files for it. You'll have to give it a name, but can probably ignore the rest of the options in the wizard.

Now that we have Eclipse setup, lets compile a program.

2. Hello world in C with Eclipse

You should now have a new project setup and need to create your first source file. To do this, click File > New > Source File. I named mine HelloWorld.c.

Lets add some code to this file:
#include <stdio.h>
main() {
  printf("Hello world!\n");
}

Now click on the little hammer build icon and then the big green play button. This will compile and then run the program, showing "Hello world!" printed in your Console window.

3. Hello world in C++ with Eclipse

With a new C++ project setup, create a new file called HelloWorld.cpp. Then enter the following code:
#include <iostream.h>
main() {
  cout << "Hello World!\n";
}

Now click on the little hammer build icon and then the big green play button. This should compile and then run the program showing "Hello world!" printed in your Console window.

4. Hello world in Java with Eclipse

Now that you have a new project setup, you have to create your first class. To do this, click File > New > Class. Give it a name, I chose to use "HelloWorld". For now, you can probably ignore all of the other options. It will bring up a new file called HelloWorld.java which contains the following code:
public class HelloWorld {
 
}

Let's add our Hello World code by changing this to:
public class HelloWorld {
  public static void main( String[] args ) {
    System.out.println("Hello world!");
  }
}

Now click on the big green "play" button to compile and run the program - you will be prompted to choose how you want to run this, choose "Java Application". Then magically in the Console window you will see "Hello world!" printed!

5. Compiling from the command line

Since I think getting familiar with the command line (Terminal.app in OS X) is important I will also add instructions for compiling each of these files from the command line.

C:

  1. Navigate to the directory containing your files.
  2. To compile, run: gcc HelloWorld.c -o hello
  3. Then to run the program: ./hello

C++:

  1. Navigate to the directory containing your files.
  2. To compile, run: g++ HelloWorld.cpp -o hello
  3. This will probably give you a bunch of warnings but it will be fine. Then to run the program: ./hello

Java:

  1. Navigate to the directory containing your files.
  2. To compile, run: javac HelloWorld.java
  3. Then to run the program: java HelloWorld

Art in Technology, Art in the Web

At Northern Voice this year Darren Barefoot led a discussion surrounding online art — mostly just asking the question of where are the great works of online art? The most common theme was that of the collection, where curation and organization are what makes online art. Some examples are mashup music and the Big Picture photo blog.

I wanted to expand on another idea that was briefly brought up. Most people would agree that art is personal and one of my favourite quotes is that “art is for making people feel less alone.” Following that, what if art was very personal? Some services that can provide this for you are Last.fm or Apple's Genius. For Last.fm, it builds a database of your preferences based on the kinds of music you most commonly listen to and the music that you ‘favourite’. It then compares your preferences to that of the wider community to help bring you custom playlists with new music. Here, the art is in building a playlist that can mean something to you.

Last.fm, to me, is somewhat hit or miss, but here is what Last.fm just did for me (don't watch the videos, just listen, hopefully it's raining where you are).

It is raining outside and I turn on Last.fm. As I'm getting my umbrella out, walking down the steps, crossing the street, and walking through the mushy park up to the bus stop, this is playing:

If you can see this, then you might need a Flash Player upgrade or you need to install Flash Player if it's missing. Get Flash Player from Adobe.

(Fila Brazillia – Place de la Concorde)

Then as I hop on the bus, which is mostly silent and wet, this is playing...

(Blockhead – A Better Place)

It takes me to my stop where I get out and wait with another dripping woman for the elevator.

As soon as I enter my apartment, the following starts playing. It's warm, and fun but still sounds like rain:

If you can see this, then you might need a Flash Player upgrade or you need to install Flash Player if it's missing. Get Flash Player from Adobe.

(People Under the Stairs – Time To Rock Our Shit)

Sometimes technology can bring a little nuance.

Library Voices in Vancouver again!

Last week I had the chance to attend not one, but two Library Voices shows here in Vancouver. As I've mentioned before, Library Voices is one of my favourite upcoming Canadian bands, and neither show disappointed. Yelling along with their lyrics was definitely the highlight of last week which coincidentally was my Spring break!

Library Voices has been touring constantly for at least the past two years and they're starting to get some wide recognition. They have tons of literary influence along with a strong dose of good old Canadiana — they are from Regina after all. Following are some photos I took at the shows.

February 15, 2009 at The Media Club:

DSC_8704  DSC_8735

DSC_8744-Edit DSC_8719 DSC_8698

DSC_8678  DSC_8650

The Media Club show was definitely the best. The venue is slightly larger and for whatever reason everyone at the show was just... nicer.

Here are some pictures from February 18, 2009 at The Railway Club:

DSC_8860-Edit DSC_8821

DSC_8819 DSC_8883

As kind as Library Voices were to come to Vancouver twice, Vancouver was not nice to Library Voices. While they were here they had about $10,000 worth of gear stolen from their van. Here is an appeal to get there gear back from CBC Radio3 on YouTube:

If you can see this, then you might need a Flash Player upgrade or you need to install Flash Player if it's missing. Get Flash Player from Adobe.

If you haven't listened to them yet, check out their Myspace page; they're really nice people and it's been great to see their fan base grow. Definitely excited to see them come around again!

Here's some more press on Library Voices:

Surveillance in the Classroom

In this TED presentation, Bill Gates talks about a couple of big areas where he is doing philanthropic work. The first part of the video is devoted to his help in eradicating malaria and the second part talks about bringing US teaching standards to a much higher level. Following is the Flash video of his talk from TED:

His insights on both topics are generally quite interesting and good, but one idea stuck out as particularly frightening to me:

The following quote begins at 16:58:

Of course, digital video is cheap now... putting a few cameras in the classroom and saying that things are being reported on an ongoing basis is very practical in all public schools. And so every few weeks teachers could sit down and say "ok here's a little clip of something I thought I did well. Here's a little clip of something I think I did poorly. Advise me when this kid acted up, how should I have dealt with that?" And they can all sit and work together on those problems. You can take the very best teachers and kind of annotate it. Have it so everyone sees who is the very best teaching this stuff. You can take those great courses and make them available so that a kid can go out and watch the physics course — learn from that. If you have a kid who is behind, you would know you can assign them that video to watch and review the concept. And in fact, these free courses could not only be available just on the internet but you could make it so that DVDs were always available. So anybody who has access to a DVD player can have the very best teachers.

While this idea sounds rosy — I think it can genuinely be used in a proper way — I think there is also considerable room for misuse. This is a great example of where using technology to solve problems can have unseen side effects. For example, teachers would now have their beliefs and views on the public record and anyone can go back and find what they've said. Maybe their jobs would be in jeopardy if their views don't align with the current government? They know they are being surveilled and now have to restrict what they do, kind of like a panopticon or even Nineteen Eighty-Four's use of CCTV. If you treat someone like they are a bad teacher, maybe they will become a bad teacher. I can imagine that staff who are watched would be stiff, regulated, and not free to really teach. Even from my own experience it was not always bad to have a teacher who was wrong; I think this enabled me to form my own opinions through teachers I didn't always agree with.

As an alternative to monitoring, why not a kind of buddy system? To a certain extent new teachers are a part of this. They learn to be teachers by working alongside more experienced people in the profession as a kind practicum. Why couldn't this extended a little further into their careers, especially for teachers who are struggling?

Where I think this is being properly applied is in post-secondary institutions. By this point students are supposed to be mature enough to form their own opinions, and lectures at this level are often about the discussion and dissemination of ideas. Broadcasting a post secondary lecture is usually with the request or cooperation of the instructor and, often, only great lecturers are featured. Some examples are with the MIT OpenCourseWare or even the Feynman lectures recorded in the 1960s (also available as a book). The important thing to note here is that these instructors were recorded with their consent. It is no longer an issue of surveillance because of their willingness to be recorded and they know that people are listening to gain knowledge, not to judge them. With surveillance in the classroom it may not always be by consent, and supervisors will not be looking for what a teacher has done right, but what they have done wrong. Teachers in the public system are hard enough done by as it is — why subject them to surveillance?

Finally, would you like to be recorded all day at your place of work, knowing that someone is evaluating your performance?

Business Cards for Violin and Stuff - Music for weddings

Casey and I spent some time over the weekend with our friend Adrienne putting together a brand for their little music collective, which is named Violin and Stuff. Casey plays cello and Adrienne plays violin and together they play wedding music and are also available for studio work. They are both classically trained but what makes them special is their indie-feel and ability to play creatively by ear. They offer a base of normal wedding pieces and will also learn your requests to make each performance unique.

We created a nice logo that has some of the feel of what they represent. Casey really wanted a highly typographic logo with a serifed, traditional font and we thought it might be neat to incorporate the F-hole from a violin or cello. We started with some more traditional fonts like Caslon, Garamond, and Times but none looked quite right. We eventually drifted towards Jos Buivenga's fantastic free font, Fontin. To get an F-hole we needed a nice italic F. Fontin's F wasn't quite what we wanted so we ended up blending together the stem from Garamond with the serifs from Fontin. Here is our final result:

Violin and Stuff

Next we needed to make some nice business cards so that they can market themselves in the real world (a lot of their business will be word of mouth). We pictured something handcrafted and because Casey had some of the equipment hanging around, ended up silkscreening them. We bought neon pink paint and some nice paper from Opus. We had some friends over and had a little business card making party — and with a lot of help from our friend Caitlin they turned out great:

DSC_8003 DSC_8011

DSC_8013 DSC_8017

DSC_8018 DSC_8026

DSC_8028 DSC_8037

DSC_8006 DSC_8041

DSC_8046 DSC_8060

DSC_8059 DSC_8065

Finally, since all that the business cards have is a URL we needed to get the site up as soon as possible. I created a design mockup a few weeks back and it was just a matter of translating it to real HTML and CSS. It is built in Drupal and should be easy to extend and for Casey and Adrienne to change when they like. Now that the basics are done, I would eventually like to get a Muxtape-like player up in order to easily sample their music.

Violin and Stuff Website

I'm very happy with how this turned out. We created a strong brand for them to market themselves and we have so many good ideas on how to build on this in the future — we're even thinking of a photo shoot sometime soon!

Syndicate content