Hello world/Newbie: Difference between revisions

m
 
(25 intermediate revisions by 12 users not shown)
Line 47:
 
<code>./hello_world</code> on Linux.
 
 
=={{header|8080 Assembly}}==
{{Works with CPM-80}}
<pre>
download simh with CPM disk from: http://cpmarchives.classiccmp.org/cpm/mirrors/www.schorn.ch/cpm/intro.php
write hello.asm with any text editor. !!!MAKE SURE ALL ASM FILES HAVE A TRAILING NEWLINE!!!
open cp/m in simh by CD'ing to director, running altairz80.exe, then 'do cpm2'
load hello.asm into image by running command 'r hello.asm'
assemble by running command 'asm hello'
load by running command 'load hello'
run by executing command 'hello'
</pre>
<syntaxhighlight lang="8080 assembly">
; Hello World!
; Prints Hello, World! to stdout
BDOS equ 5 ; BDOS call entry
PRINT equ 9 ; BDOS string stdout subroutine
 
org 100h ; (mostly) All CP/M programs start at 100h
 
start lxi d,message ; load message pointer to DE register pair
mvi c,PRINT ; set up BDOS call to do string print
call BDOS ; call BDOS routine
ret ; pop back out into CP/M
 
message db 'Hello, World!','$' ; message string, all CP/M strings have an EOL of '$'
 
 
</syntaxhighlight>
 
 
=={{header|AArch64 Assembly}}==
Line 224 ⟶ 255:
 
=={{header|Agda}}==
This tutorial is to install Agda-2.6.23, the most recent version as of OctoberMay 20212023, and run the "Hello world" program. The snippet is based on the [https://agda.readthedocs.io/en/v2.6.23/getting-started/hello-world.html Hello world example] given in the Agda documentation, although using less Unicode symbols. More detailed explanations can be found in the [https://agda.readthedocs.io/en/v2.6.23/getting-started/installation.html installation instructions].
 
Although Agda developers suggest using [https://en.wikipedia.org/wiki/Emacs Emacs], this tutorial does not assume having Emacs installed.
 
# Install [https://en.wikipedia.org/wiki/Cabal_(software) Cabal]. On Linux run: <syntaxhighlight lang="bash">sudo apt install cabal-install</syntaxhighlight>
# From the command line, execute: <syntaxhighlight lang="bash">cabal update</syntaxhighlight> which outputs ''Downloading the latest package list from hackage.haskell.org''
# Install Agda with: <syntaxhighlight lang="bash">cabal install Agda</syntaxhighlight> This downloads the packages and then outputs ''Building Agda-2.6.23''. The building process can take several minutes.
# After that, Cabal creates two binaries. On Linux these are <pre>~/.cabal/bin/agda</pre> and <pre>~/.cabal/bin/agda-mode</pre> Make those binaries reachable by the ''PATH'' variable.
# Create the file ''helloworldHelloWorld.agda'' with any editor and paste this snippet: <syntaxhighlight lang="agda">module helloworldHelloWorld where
 
open import Agda.Builtin.IO using (IO)
Line 245 ⟶ 274:
main = putStrLn "Hello world!"
</syntaxhighlight> (Note that "⊤" is not a capital T, but the [https://en.wikipedia.org/wiki/Tee_(symbol) top symbol]).
# Run <syntaxhighlight lang="bash">agda --compile helloworldHelloWorld.agda</syntaxhighlight> This creates the binary ''helloworldHelloWorld''
# Execute the binary. For example, on Linux run <syntaxhighlight lang="bash">./helloworldHelloWorld</syntaxhighlight> The execution outputs ''Hello world!''
 
Agda requires an editor that allows entering Unicode characters, like the online editor [https://agdapad.quasicoherent.io Agdapad].
It is possible to have [https://en.wikipedia.org/wiki/Emacs Emacs] configured for Agda. Its use is explained in the [https://agda.readthedocs.io/en/v2.6.3/tools/emacs-mode.html documentation of Emacs mode]. To configure Emacs, the steps are the following:
# Install Emacs. On Linux run: <syntaxhighlight lang="bash">sudo apt install emacs</syntaxhighlight>
# Run: <syntaxhighlight lang="bash">agda-mode setup</syntaxhighlight>
# Run: <syntaxhighlight lang="bash">agda-mode compile</syntaxhighlight>
 
=={{header|Applesoft BASIC}}==
Installation and text editors are not needed. https://rosettacode.org/wiki/Interactive_programming_(repl)#Applesoft_BASIC
Line 467 ⟶ 503:
Once the program finishes, you should have:
<pre>Hello World!</pre>
 
=={{header|Binary Lambda Calculus}}==
Although https://www.ioccc.org/2012/tromp/hint.html explains how to compile the obfuscated C code at https://www.ioccc.org/2012/tromp/tromp.c to run
<pre>echo " Hello, world" | ./tromp</pre>
 
I find that the modern clang compiler cannot compile tromp.c
 
Luckily https://github.com/tromp/AIT offers alternative implementations of the lambda universal machine in many languages:
 
* C: uni.c
* Perl: uni.pl
* Python: uni.py
* Javascript: uni.js
* Ruby: uni.rb
 
For example, one can run
 
<syntaxhighlight lang="bash">wget https://github.com/tromp/AIT/uni.pl
echo " Hello, world" | ./uni.pl</syntaxhighlight>
 
More implementations may be found at https://rosettacode.org/wiki/Universal_Lambda_Machine
 
=={{header|BQN}}==
Line 775 ⟶ 832:
The program should produce the following output:
<pre>Hello world!</pre>
 
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
The following instructions apply to any version of Delphi going back to the 1990's. They also apply to Lazurus, which is a Delphi-like programming environment based on Free Pascal.
 
1. You should install Delphi or Lazarus on your computer. Delphi installation disks will automatically install the program and all necessary libraries, editors and tools on your computer. Lazarus installation files can be downloaded from their web site. They will also install all necessary tools.
 
[https://www.lazarus-ide.org/ Lazarus Website]
 
2. Once Delphi/Lazarus has been installed, choose the "File -> New" option from menu bar. Next choose "Application" or "VCL Forms Application" depending on which language or version you are using.
 
This will cause the program to display a blank window called a "Form", with a grid of dots. The dots indicate that the program is in "Design Mode" and it is ready for you to design a GUI interface for your program.
 
[[File:DelphiDesignMode.png|frame|none]]
 
3. At the top of the IDE is a "Component Palette" that displays a bunch of icons. Each icon is an object that you can put on the form.
 
[[File:DelphiComponentPalette.png|frame|none]]
 
Select the "Memo" item by clicking on it once. (It is normally the sixth item from the left.) Now click on the form; a white box should appear. This is an object that allows you to display, enter and edit text. You can move and resize the memo, by dragging the control with the mouse or pulling on the tiny black boxes on the edges of object.
 
Next click on the "Button" object on the palette and drop it on the form next to the memo. It can also be moved or sized.
 
4. Double click on the button. This will automatically write a subroutine in the source code and bring up the Delphi/Lazarus source-code editor displaying the subroutine.
 
<syntaxhighlight lang="Delphi">
procedure TForm1.Button1Click(Sender: TObject);
begin
end;
</syntaxhighlight>
 
Between "begin" and "end" statements, enter the following line of code:
 
<syntaxhighlight lang="Delphi">
Memo1.Lines.Add('Hello World');
</syntaxhighlight>
 
The end result should look like this:
 
<syntaxhighlight lang="Delphi">
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.Add('Hello World');
end;
</syntaxhighlight>
 
5. You've now completed the program. Press the "Run" button in the upper left portion of the IDE. (It is usually the button with green arrow on it.) The program will now display your form with the button and the memo on it. Press your button. This will cause the "Hello World" to be displayed in the memo.
 
{{out}}
<pre>
 
</pre>
 
=={{header|EasyLang}}==
EasyLang programs run in the browser. EasyLang code needs to be run using a special IDE.
# Open the EasyLang IDE at [https://easylang.onlinedev/ide/]
# Type in this program into the IDE: <syntaxhighlight lang="easylang">print "Hello world!"</syntaxhighlight>
# Click the run button at the top of the IDE, and you should see:
Line 877 ⟶ 988:
</syntaxhighlight>
# Now it should be compiled (where elc is a command-line compiler):
<syntaxhighlight lang="elena">elcelena-cli.exe program1.l</syntaxhighlight>
# It will create program1.exe file which you can execute:
<syntaxhighlight lang="elena">program1</syntaxhighlight>
Line 934 ⟶ 1,045:
* press <code>F1</code> or click the <code>help</code> button to bring up Factor's help browser
* click <code>Your first program</code> to recieve step-by-step instructions on how to integrate an editor of your choice with the listener, create your own vocabularies, write tests, make scripts/binaries, and learn more about the language
 
 
=={{header|FreeBASIC}}==
<h3>Installation</h3>
FreeBASIC gives you the FreeBASIC compiler program (fbc or fbc.exe),
plus the tools and libraries used by it. fbc is a command line program
that takes FreeBASIC source code files (*.bas) and compiles them into
executables. In the combined standalone packages for windows, the main
executable is named fbc32.exe (for 32-bit) and fbc64.exe (for 64-bit)
fbc is typically invoked by Integrated Development Environments ([[IDE]]) or
[[Editor|text editors]], from a terminal or command prompt, or through build-systems
such as makefiles. fbc itself is not a graphical code editor or IDE!
Download FreeBASIC here: https://sourceforge.net/projects/fbc/files
 
<h3>Interface</h3>
FB does not have 'default' IDE
Optionally, you can install a [[Editor|text editor]] or [[IDE]] which will invoke fbc.exe for you.
<h4>[[Windows]]</h4>
* WinFBE Editor: https://github.com/PaulSquires/WinFBE
* FBIde: https://fbide.freebasic.net/
* VisualFBEditor: https://github.com/XusinboyBekchanov/VisualFBEditor
* PoseidonFB: https://bitbucket.org/KuanHsu/poseidonfb/
* Geany: https://www.geany.org/
 
<h4>[[Linux]]</h4>
Unless you already have a [[Editor|text editor]] or [[IDE]], you should install one too, as FreeBASIC itself does not include one. An [[IDE]] can be used to write and save .bas files and to launch the FreeBASIC Compiler to compile them. The following IDEs are known to explicitly support FreeBASIC:
* Geany: https://www.geany.org/
 
<h3>HelloWorld Program (Text Output)</h3>
To display the "HelloWorld!" in the Text Output, copy this code and paste to the code editor:
<syntaxhighlight lang="gwbasic">Print "HelloWorld!"</syntaxhighlight>
Then press F5 or click the play button. <br>
You have just created and run your first program. <br>
<h3>HelloWorld Program (Graphics Output)</h3>
To display the "HelloWorld!" in the Graphics Output, copy this code and paste to the code editor:
<syntaxhighlight lang="gwbasic">Cls 'Clear the graphics screen
Screen 1 'Mode 320x200
Locate 12,15
Print "Hello world!"
Sleep</syntaxhighlight>
Then press F5 or click the play button.<br>
 
<h3>Documentation</h3>
Press F1 or click the ''Help'' menu for language help/documentations.<br>
Or consult the online manual at: https://freebasic.net/wiki/DocToc
 
 
 
=={{header|Fortran}}==
Line 1,112 ⟶ 1,273:
 
A quicker alternative might be an [https://jsoftware.github.io/j-playground/bin/html2/ online version of J], if you are using a browser which supports [https://webassembly.org/ wasm].
 
=={{header|Jakt}}==
The Jakt compiler must be built from source; check [https://github.com/SerenityOS/jakt/blob/main/documentation/cmake-bootstrap.md the bootstrapping documentation] for the instructions.
As of writing, clang 14 seems to be the recommended version for compiling.
 
In summary, install cmake and run the following commands to build:
<syntaxhighlight lang="sh">
cmake -B build -GNinja
cmake --build build
</syntaxhighlight>
 
To compile hello world, save the following to hello.jakt:
<syntaxhighlight lang="jakt">
fn main() {
println("Hello world!")
}
</syntaxhighlight>
 
To compile it, run the following command in the directory containing hello.jakt.
<syntaxhighlight lang="sh">
jakt hello.jakt
</syntaxhighlight>
 
The built executable will be ./build/hello.
 
Specifying -cr will automatically run the program after building.
<syntaxhighlight lang="sh">
jakt -cr hello.jakt
</syntaxhighlight>
 
Output will go to the terminal.
 
=={{header|Java}}==
Line 1,279 ⟶ 1,471:
 
4. Choose the |> symbol to run that line of Julia code.</pre>
 
=={{header|K}}==
{{works with|ngn/k}}
<code class="plainlinks">git clone https://codeberg.org/ngn/k.git</code>
 
make using the <b>build:</b> line in <i class="plainlinks">[https://codeberg.org/ngn/k/raw/branch/master/readme.txt readme.txt]</i>
 
run using the <b>use:</b> line in <i class="plainlinks">[https://codeberg.org/ngn/k/raw/branch/master/readme.txt readme.txt]</i>
 
=={{header|Kotlin}}==
Line 1,339 ⟶ 1,539:
Congratulations, your first web page is published.
</syntaxhighlight>
 
=={{header|Lean}}==
These are the steps to install Lean 4:
# Have a look at the [https://leanprover.github.io/lean4/doc/quickstart.html quickstart], which links to [https://www.youtube.com/watch?v=yZo6k48L0VY this video].
# Install [https://code.visualstudio.com/ VS Code], if it is not installed:
#* On Linux, run: <syntaxhighlight lang="bash">sudo snap install --classic code</syntaxhighlight>
# Start '''code''' and search in "Extensions (Ctrl+Shift+X)", and write "lean4" in the text box.
# Select the "lean4" extension and install it.
# Select "File / New File... (Alt+Ctrl+N)" and create the file "HelloWorld.lean".
# A message may pop up saying "Failed to start 'lean' language server". If that happens, press the button "Install Lean using Elan".
# Write the following in "HelloWorld.lean":
<syntaxhighlight lang="lean">
def main : IO Unit :=
IO.println ("Hello world!")
 
#eval main
</syntaxhighlight>
# Place your cursor a at the end of <code>#eval main</code>, which updates the "Lean Infoview" showing the message <code>Hello world!</code>.
 
=={{header|Locomotive Basic}}==
Line 1,633 ⟶ 1,851:
 
You've just created and run a hello world program in NS-HUBASIC.
 
=={{header|Nu}}==
The Nu programming language is a part of Nushell. See the [https://www.nushell.sh/#get-nu official installation guide] for up to date instructions. If you are on Linux use your distribution's package manager (search for nushell).
 
Once installed, you can run <code>nu</code> through the command line to get a prompt. Type <code>print "Hello world!"</code> to run the hello program interactively.
 
Transcript (some content redacted for brevity):
 
<pre>
~ $ nu
__ ,
.--()°'.' Welcome to Nushell,
'|, . ,' based on the nu language,
!_-(_\ where all data is structured!
 
[...]
 
~> print "Hello world!"
Hello world!
</pre>
 
Alternatively, save the following text to the file `hello.nu`
<pre>
print "Hello world!"
</pre>
 
This can be done with any text editor, or via the command line.
<pre>
tee hello.nu << EOF
print "Hello world!"
EOF
</pre>
 
Run with <code>nu hello.nu</code>.
 
=={{header|OCaml}}==
Line 2,013 ⟶ 2,265:
 
=={{header|Processing}}==
=== Installing Processing ===
 
== Installing Processing ==
Everything Processing related lives here! -> https://processing.org/
 
Line 2,030 ⟶ 2,281:
Then open the "Processing-(version number)" folder and run 'Processing.exe', processing is now installed!
 
=== Writing your first program ===
To create a new file in processing, navigate to the toolbar at the top of the window, select file, and new.
 
Line 2,765 ⟶ 3,016:
 
=={{header|Wren}}==
Although Wren is primarily used as an embedded scripting language, there is a standalone version called Wren-CLI which can be run directly from the command line. This is available as a pre-built 64 bit executable for Linux, MacOS and Windows and can be downloaded from [https://github.com/wren-lang/wren-cli/releases/tag/0.34.0 here].
 
Having downloaded and unzipped Wren-CLI, the next job is to create a script. Any text editor can be used for this including simple general purpose ones such as gedit, TextEdit and notepad for the operating systems referred to above.
 
So open the text editor, paste in the following script (yes, it's only one line), and save it to a file called ''helloHello_world.wren'' in the same directory as wren-cli itself:
<syntaxhighlight lang="ecmascriptwren">System.print("Hello world!")</syntaxhighlight>
Now type at the command line (omit ./ if using Windows):
<pre>
./wren-cli helloHello_world.wren
</pre>
to compile and run the script and you should see the archetypal greeting :)
56

edits