Hello world/Newbie

From Rosetta Code
Revision as of 09:11, 30 March 2012 by rosettacode>Dkf (whitespace / formatting)
Hello world/Newbie is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Guide a new user of a language through the steps necessary to install the programming language and selection of an editor if needed, to run the languages' example in the Hello world/Text task.

  • Assume the language-newbie is a programmer in another language.
  • Assume the language-newbie is competent in installing software for the platform.
  • Assume the language-newbie can use one simple text editor for the OS/platform, (but that may not necessarily be a particular one if the installation needs a particular editor).
  • Refer to, (and link to), already existing documentation as much as possible (but provide a summary here).
  • Remember to state where to view the output.
  • If particular IDE's or editors are required that are not standard then point to/explain their installation too.
Note:
  • If it is more natural for a language to give output via a GUI or to a file etc, then use that method of output rather than as text to a terminal/command-line, but remember to give instructions on how to view the output generated.
  • You may use sub-headings if giving instructions for multiple platforms.

C

Using gcc

Debian Based Systems

Install gcc

$ sudo apt-get install gcc

All Distributions

After you have installed gcc using instructions above. Create helloworld.c. This uses HERE document and bash, the standard shell.

$ cat > helloworld.c <<HERE
#include <stdio.h>
int main( int argc, char *argv[] ) {
     puts( "Hello World!" );
     return 0;
}
HERE

Compile it using gcc.

$ gcc -o helloworld helloworld.c

Run it

$ ./helloworld

J

Download J602 from http://jsoftware.com/stable.htm

Install it, using the defaults.

Run the program, and bring up the ide.

Type in: <lang j>'Goodbye, World!'</lang>

Mathematica

Buy & Install the program from http://www.wolfram.com/mathematica/

Start Mathematica either :

  • by calling math.exe(Windows) or math (Others)
  • by double clicking on the Mathematica icon.

Open a new notebook and type : Print[ "Goodbye, World!"]

PARI/GP

PARI's official site is http://pari.math.u-bordeaux.fr/ .

PARI/GP on Windows

Go to the download page of the PARI/GP website and download one of the following:

  • The latest self-installing binary distribution 2.4.2. This is the most full-featured but lacks some of the newer bugfixes and commands.
  • The basic GP binary 2.5.0. This lacks some features like high-resolution graphing but has newer features.
  • The SVN version 2.6.0. This has the bleeding-edge features but lacks many nicities and may contain bugs.

PARI/GP on the Mac

Install the latest available gp version on

or

PARI/GP on Linux

Install PARI/GP with an appropriate package manager: RPM, apt, etc. Alternately, install it from source.

Your first program

Open a text editor of your choice and type <lang parigp>print("Hello, world!")</lang> Save the file in your PARI working directory and start the program, either in a console (command: gp) or in the GUI in Windows (by double-clicking the shortcut). Type \r filename to read in the program. (If you saved the file with a .gp extension, you can leave it off here.) The program executes, displaying "Hello, world!".

PicoLisp

Debian-based systems

Install

$ apt-get install picolisp

then run it

$ pil +
: (prinl "Goodbye, World!")

Other POSIX systems

Fetch and unpack the tarball

$ wget software-lab.de/picoLisp.tgz && tar xfz picoLisp.tgz

then build the executable (see http://software-lab.de/INSTALL file for 64-bit systems)

$ cd picoLisp
$ (cd src; make)

and run it locally

$ ./pil +
: (prinl "Goodbye, World!")

Non-POSIX systems

On non-POSIX systems only limited implementations of PicoLisp are available.

If Java 1.6 is installed, get and unpack either the tarball given in "Other POSIX systems", or just "software-lab.de/ersatz.tgz", and run

$ ersatz/pil
: (prinl "Goodbye, World!")

(see also http://software-lab.de/ersatz/README).

If no Java is available, you can compile "software-lab.de/miniPicoLisp.tgz" and run it

$ ./pil +
: (prinl "Goodbye, World!")

Python

Pythons official home site is http://www.python.org/. It will point you to everything Python.

Python on Windows

(Tested on Windows 7 but should be similar for XP & Vista ).

You need to download and install Python. Use the latest Windows installer for Windows (64bit if you have a 64bit Windows installation). It is a standard Windows click-through installer with an Open-source compatable license.

Once installed, use the new start-menu entry to open the "Idle (Python GUI)" application, which opens a GUI window with a command line and cursor at the bottom. This window displays program output and is a REPL for Python.

Use the File->New window item of the GUI to bring up new blank window and copy the text from Hello world/Text#Python into it, i.e. <lang python>print "Goodbye, World!"</lang> use the File menu to save the file with a name hello.py, (remember the .py extension). Use the "Run -> Run module" menu item from the hello.py Idle editor window to pop the Idle Python shell window to the front whilst executing the program. The output of the program appears in this shell window as the line:

Goodbye, World!

(Followed by a prompt that is part of the REPL of the IDE rather than programmed by the hello.py file).

Python on GNU/Linux

On most Linux distribution, just install the package named python with the package manager.

If you are using a mainstream Linux distribution, installing Idle along with Python gives you a GUI and two ways of working with your code. The easiest is through Idle, see the Windows instructions above for details. The other is outlined below:

A script can be executed with the command:

python my_script.py

or adding a shebang at the first line of the script:

$ head -n 1 my_script.py
#!/usr/bin/env python
$ chmod a+x my_script.py
$ ./my_script.py