Pick A Language, Any Language

Posted by Justin on August 25, 2005
Open Source Projects

After you have designed out all of your requirements for your project, you will need to pick a language. Most people will already know what language they want. In fact, most hobbyists stick with one language for most of their programming lifetime and sway just a little when needed.

Personally, I primarily program in PHP with HTML, a tad bit of JavaScript, CSS, etc… If you know anything about any of those languages, you know thats all web based stuff.

Now, if you’ve been reading the past articles, you’ll figure out PHP won’t work for what I’m planning - or will it???

Lets lay it out - I need cross platform ability because I don’t feel like building libraries for every OS my project may use. For web work, PHP is fine because it can work on most web boxes.

There are a few products out there that tout the ability to be cross-platform. To name a few:

Java - This is perhaps the most widely known and distributed language.
PHP-GTK - One of the newest. Unfortunately, it requires specific builds.
C/C++ - Technically, its cross platform, but not well suited since it requires specific builds.

I wanted to give PHP-GTK a try until I found out it needed specific builds for specific systems. Its also so new that it would be a pain for someone to have to install and configure it before installing my software. Documentation is somewhat lacking since its so new too. While newer languages are sometimes better, this just didn’t seem to cut the cake for me.

Java on the other hand is already on a wealth of machines, easy to install and its a true Write Once Run Anywhere language due to the Java Virtual Machine. This takes all the commands and translates them into their OS specific commands for you - very handy.

Now, Java can be good or bad, depending on your past history with it. Personally, I HATE Java Applets on webpages. If Java isn’t already loaded, it locks up my machine for a few seconds before doing anything (I don’t upgrade machines that often). Now, on the other side of things, I can port the same application that I’m using for a GUI into a webpage (that will come later)…

The ugly part of all of this is the code itself. To simplify it - a few “hello worlds” right next to each other:

C++

#include

main()
{
cout < < "Hello World!";
return 0;
}

PHP GTK:

< ?php

if( !extension_loaded('gtk')) {
dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);
}

function delete_event()
{
return false;
}

function shutdown()
{
print("Shutting down...\n");
gtk::main_quit();
}

function hello()
{
global $window;
print "Hello World!\n";
$window->destroy();
}

$window = &new GtkWindow();
$window->connect(’destroy’, ’shutdown’);
$window->connect(’delete-event’, ‘delete_event’);
$window->set_border_width(10);

$button = &new GtkButton(’Hello World!’);
$button->connect(’clicked’, ‘hello’);
$window->add($button);

$window->show_all();

gtk::main();

?>

Java:

class myfirstjavaprog
{
public static void main(String args[])
{
System.out.println(”Hello World!”);
}
}

As you can see, depending on what language you do, things can be complicated or easy. Do a heck of a lot of research before you jump into a project.

What OS is it going to be used on?
What type of application is it? Web? GUI? Text?
What type of database interaction do you require, if any?
What interaction do you require from individuals?

If you don’t know 100% that your application will work with one language, look at several and learn if they mix well. When I say Mix, I mean like PHP and MySQL - they work very well together. Something that wouldn’t mix well would be ASP and MySQL. While its possible, ASP is better suited to work with MicroSoftSQL…

Personally, I have no clue how to program in Java, but I’m learning specifically because its what I need and its good to have a background in. Think about it for awhile before deciding what you’ll do.