MUF (programming Language) - Hello, World

Hello, World

The standard "Hello World" program would look like this:

( a standard demo program ) : HelloWorld me @ "Hello, world!" notify ;

The first line is a comment. Text in parentheses is ignored by the compiler and during program execution. MUF is not a particularly readable language, and MUF programs are used, installed, and maintained in a hurly-burly environment by users and programmers of widely varying capabilities. Comments describing a program's authorship, terms of distribution, means of installation, and program flow are helpful and important.

The second line — a colon followed by a name, set flush left — opens the declaration of a word. This program contains one word; its name is HelloWorld.

The third line contains all the executable code in the program. "me" is a variable; it holds the dbref of the user running the program. "me" is a special variable that is declared and initialized by the server when the program is run. The programmer can also declare and initialize his or her own variables.

The @ at sign is the FETCH operator. It "fetches" the value stored in the variable "me" (the user's dbref), and puts it on the stack.

"Hello, world!" is a string. Simply including the string in the code does an implicit PUSH, putting the data on the stack. After this statement, the string will be put on the stack (above the user's dbref).

"notify" is a primitive. It instructs the server to output the string on the top of the stack to the player with the dbref that is currently stored as the second-from-top element on the stack. The user will see the string on his or her screen, and both data will be removed from the stack. If the stack did not contain a dbref and a string, in the proper order, the program would crash.

The semi-colon on the fourth line marks the end of the word.

The stack trace for this program would be:

2 ("") (HelloWorld) 3 ("") V0 3 ("", V0) @ 3 ("", #1) "Hello, world!" 3 ("", #1, "Hello, world!") NOTIFY Hello, world! 4 ("") EXIT

Data types can be differentiated by their appearance within a stack trace. Strings appear as characters surrounded by quotation marks ("Three Thousand" or "3000"). Dbrefs appear as an integer preceded by an octothorpe or pound sign (#3000). A number will appear as the number itself (3000). A variable appears as an integer prefixed with either "V" (for global variables that are shared between all programs and libraries in a call chain), "LV" (for variables local to the given program — module scope) (LV3), or "SV" (for function-scoped variables) (SV2).

(There is an empty string (also called a "null string") at the base of this stack because the program was called with no arguments. If the command that invoked the program were called "hello", and the user typed "hello", then the stack trace would be as above. If the user typed "hello foo", then "foo" would be an argument to the command. The stack trace would show "foo" in place of "", but since the program never references this element, it makes no practical difference.)

Note that "notify" appeared in lower case in the source code, and in all upper case in the stack trace. MUF is case insensitive, but some programmers follow a convention of typing primitives and server-defined variables in uppercase, and all other statements in Upper-lowercase or lowercase.

Turning HelloWorld into a functioning program on a MUCK would require the following steps:

  1. The programmer acquires a Mucker bit if he or she does not already have one.
  2. The programmer types "@program HelloWorld" to create the program object and edit its contents.
  3. The programmer types "i", to begin Inserting source code.
  4. The programmer types or uploads the source code.
  5. The programmer types a . period to exit the editor's Insert mode.
  6. The programmer types "c" to compile the source code into an executable program.
  7. The programmer types "q" to exit the editor.
  8. The programmer creates a command to invoke the program, by typing in MUCK commands such as:
    1. @action hello=here
    2. @link hello=HelloWorld

Read more about this topic:  MUF (programming Language)

Other articles related to "world":

Economy (disambiguation)
... to The quality of being efficient or frugal in using resources see energy conservation World economy, the economy of the world Virtual economy, an economy simulated in a ...
Arthur Schopenhauer
1788 – 21 September 1860) was a German philosopher best known for his book, The World as Will and Representation, in which he claimed that our world is driven by a continually ... which examined the four distinct aspects of experience in the phenomenal world consequently, he has been influential in the history of phenomenology ...
Nine Largest Wars (by Death Toll)
... These are of course the two World Wars, then followed by the Second Sino-Japanese War (which is sometimes considered part of World War II, or overlapping with that war) ... The death toll of World War II, being 60 million plus, surpasses all other war-death-tolls by a factor of two ... Deaths (millions) Date War 60–72 1939–1945 World War II (see World War II casualties) 36 755–763 An Shi Rebellion (number exaggerated based on census system,but not considering the territorial shrink ...
Effects of War - On The Economy
... war has stimulated a country's economy (World War II is often credited with bringing America out of the Great Depression) but in many cases, such as the wars of Louis ... For example, Russia's involvement in World War I took such a toll on the Russian economy that it almost collapsed and greatly contributed to the start ...
Types of Warfare - Behaviour and Conduct in War
... dampening of hostilities occurred in World War I by some accounts, e.g ... Other examples of non-aggression, also from World War I, are detailed in "Good-Bye to All That." These include spontaneous ceasefires to rebuild defences and retrieve ... The most notable spontaneous ceasefire of World War I was the Christmas truce ...

Famous quotes containing the word world:

    It is a pleasant thing to reflect upon, and furnishes a complete answer to those who contend for the gradual degeneration of the human species, that every baby born into the world is a finer one than the last.
    Charles Dickens (1812–1870)