Hello World
Hello World programs/scripts are snipits of code used to test compiling engines and interpreters.
In LSL, we recieve a varient called
Hello Avatar! when we create a new script, however individuals might have their own code to test functions they are interested in and run this script at the beginning of a new version.
I persoanlly use one of my mapping tools as a hello world, in preview grid, and then on main grid, to make sure everything's working right with functions I use regularly - Ice
Hello World has a long history in programming, best read
here.
What follows are Hello Worlds from various languages, as users contribute, first the Hello World that is standard for LSL, due to the nature of this Wiki, then a listing of other languages as users contribute them.
Multi-User Forth Example
(This is a Hello World compatable with TinyMUCK, FuzzballMUCK, NeonMUCK, and ProtoMUCK)
(MUF stands for Multi-User Forth, a language based upon the Reverse Polish notation system)
(This system was credited to HP calculators, as being the reason it's the language in MUCK varients)
(The notation, simply stated is 2 2 + would give you 4, as a language read from left to right, it is fairly simple)
( Once you get the hang of the notation)
: main me @ "Hello World!" notify ;
Of all the languages to learn to code in, if anyone wonders why my code looks wierd, this and MPI are why - Ice
Java Example
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
C++ Example
#include <stdio>
int main() {
cout << "Hello World!";
return 0;
}
PHP Example
<?php
print("Hello, World!\n");
echo("Hello, World!\n");
phpinfo();
?>
This shows both ways to print out and also pulls up the PHPInfo() page. It's a bit more extensive, but the best way to test a new PHP install (in my opinion).
Perl Example
map { print chr ord($_) + 1 } split(//, "Gdkkn+\x1FVnqkc \x09")
Or this slightly less readable variation:
BYOND (DM) Example
mob
Login()
..()
world << "Hello world!"