Import Statements

April 22, 2008 § Leave a comment

Import statement is always different among programming languages. Not only the syntax, but also the concept of how codes are managed and called. Below are import statements from a couple of languages for your entertainment.

PYTHON

Python keeps track of its own modules (via PYTHONPATH) and perform import on those modules.

In Python, a module is just a file with definitions and statements. A module can also be a directory with __init__.py in it.

There are multiple ways of using import syntax in Python:

  • import [identifier] #identifier can be Class, variable, or function name
  • from [module_name] import [identifier] #specify which module do you want to import from
  • from [module_name] import [identifier] as [alias] #alias your imported identifier
  • from [package_name.submodule_name] import [identifier] #in Python you can have modules inside a package

Interestingly, Modula-3 seemed to have the same style of importing as Python.

RUBY

Now let’s move on to Ruby’s require.

Ruby found its libraries, and all modules inside them, by checking each directory inside $LOAD_PATH.

At first glance, Ruby seemed to just know where all its modules are. The require statement doesn’t need any description about path/location at all. Passing the path helps readability though.

PHP

There’s not much to say here.

In short, when PHP interprets, it will appends all the imported files and evaluates them all at once.

To import, use:

require_once [relative_path/file.php]

PERL

Perl import statement is called use. I am not a Perl expert, but here is the syntax:

use [module_name] [list_of_imported_things]

LISP

Disclaimer: I am not LISP expert, these are things that I’ve read.

LISP codes are broken into packages. To import those packages, use this syntax:

use-package [comma_seperated_packages]

JAVA

Basically the syntax is:

[directory].[directory].[directory].[directory].[directory].[directory].[directory].[directory].[class_name_which_happen_to_be_the_filename_as_well]

REFERENCES

Advertisements

Python can give soul to machine…

April 22, 2008 § 1 Comment

XKCD - New Pet

HuddleChat is taken down…

April 9, 2008 § 1 Comment

Following the App Engine launch yesterday, Google published 5 of sample applications which use App Engine.

One of them is HuddleChat, a nice web-based chat room client. It’s a simple project for simple demo.

Unfortunately, HuddleChat is taken down today.

It’s all because 37Signals told ReadWriteWeb that Google rip-off their Campfire application. Lame.

Dude, seriously, how many variations can you come up for chat client? Isn’t this a bit ridiculous?

Search Engine for Real Estate Properties…

April 2, 2008 § 2 Comments

Are mostly pain in the ass. Too much bling and very little REAL user interface.

Many of them are sporting map-like interface, which is nice, but clunky and took long time to load.

I compile a listing below based on my experiences using them:

(Note: This list is biased towards United States geographical area)

Great:

  • FrontDoor by HGTV.
    • It is easy to use, not overly crowded and loads quickly. (+123456789)
    • It gives demographic information of the area. (+1035789)
    • It contains MLS listing. (+456123)
  • Trulia.com
    • The search result page is a bit crowded, but you can customize your search in detail. (+12)
    • It provides price comparison to neighboring houses (awesome feature). (+11111111111111)
    • It also provides various public information about the property that you are looking at (E.g. how much was the seller paid last time). (+222222222222222)
  • ByOwnerMLS(NEW)
    • Clean Interface. (+912)
    • Gives you opportunity to look at listing of houses that are for sale by owner (which is a completely different market). (+1234567899)

Good:

  • Windermere
    • Its your typical local real estate agency. (They are located only on the NorthWest though)
    • It has easy to navigate interface, better than their competitors. (+456)
    • It contains MLS listing. (+456123)

So-So:

  • AOL – Real Estate
    • The search result is more visible to Google Search. (+12)
    • The search page is over-crowded, not very easy to use. (-100)
    • The advertisement slots are hard to distinguished. (-54)

Where Am I?

You are currently viewing the archives for April, 2008 at RAPD.