Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
JOSS
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Language== JOSS so emphasized [[user-friendliness]] that "JOSS-like" became a descriptor of a new user interacting with a time-sharing system. Children and others said that unlike a "complicated" computer, JOSS was "friendly" and "kind" like "a real person with a sense of humor", with funny responses like {{code|Eh?}}.{{sfn|Marks|1971|pp=35-36, 43}} ===Direct and indirect mode=== JOSS introduced the idea of a single [[command line]] editor that worked both as an interactive language and a program editor. Commands that were typed without a line number were executed immediately, in what JOSS referred to as "[[direct mode]]". If the same line was prefixed with a line number, it was instead copied into the program code storage area, which JOSS called "indirect mode". New lines were added to the program if the line number was unique, replaced extant lines with the same number, or removed from the program if an extant line number was typed in with no code following it.{{sfn|Gimble|1967|p=v}} In contrast to most BASICs, JOSS saved the entire user input to files, not just the program code. When loaded, JOSS essentially typed the lines back in. This meant that ''program files'' could contain both program statements and direct mode instructions. For instance, it was common to see programs that listed the statement lines and then have the file end with {{code|Go.}} to immediately run the program as soon as it completed loading. There were some features that could only be used in direct mode, like {{code|Let}} and {{code|Form}}, which were input without line numbers but still returned when the program was loaded.{{sfn|Gimble|1967|p=vi}} Direct and indirect instructions could be mixed freely in a workspace. This allowed comments to be inserted in [[source code]] by adding direct-mode lines beginning with {{code|*}},{{sfn|Gimble|1967|p=65}} or by placing one at the end of a line of code and then adding a comment after it. Blank lines were also ignored, allowing the program to be broken up for clarity.{{sfn|Marks|1971|p=42}} ===Program statements=== Every line in a JOSS program must start with a line number. Line numbers are fixed-point numbers consisting of two two-digit integers separated by a period. As in BASIC, line numbers are used both as labels to target from {{code|To}} and {{code|Do}} statements, and to support editing. Entering a line of code with a new line number inserts it into a program, while entering one with an extant line number replaces the prior version or deletes it if it is empty. The portion of the line number to the left of the period is termed the ''page'' or ''part'', while the portion to the right is termed the ''line''. Thus the line number {{code|10.12}} refers to page 10, line 12. Branches can target either a page, or a line within a page. When the latter format is used, the combined page and line is termed a ''step''. Pages are used to define [[subroutine]]s, which return when the next line is on a different page. For instance, if a subroutine for calculating the square root of a number is in page 3, one might have three lines of code 3.1, 3.2 and 3.3, and it would be called using {{code|Do part 3.}} The code would return to the statement after the Do when it reaches the next line on a different page, for instance, 4.1. No need exists for the equivalent of a {{code|RETURN}} at the end, although if an early return is required, {{code|Done}} accomplishes this. Every line must start with a command keyword following the line number. No concept of a ''default command'' exists as is the case in BASIC with its optional {{code|LET}} statement. Multiple statements can be placed on one line, separated by colons or semicolons. Every line must end with a period. ===Loops and conditions=== JOSS uses a suffix notation to indicate conditional evaluation, "do this if this is true", in contrast to most languages which place the condition in front in prefix notation, "if this is true, do this". Unlike [[FORTRAN]] or [[FOCAL (programming language)|FOCAL]], any statement can be conditionally evaluated in this fashion. For example, to print a string only if a condition is met, one can combine the if with a {{code|Type}}: 1.1 Type "Hello, World!" if X=5. JOSS supported six infix comparisons, {{code|{{=}}}}, {{code|鈮爙}, {{code|鈮}, {{code|鈮}, {{code|>}}, {{code|<}}, and Boolean operators {{code|or}}, {{code|and}}, and {{code|not}}.{{sfn|Gimble|1967|p=70}} Loops were handled in a similar fashion, using the {{code|For}} command and a somewhat obscure format for specifying the loop bounds and step value, {{code|start(step)end}}. For instance, to step from 1 to 10 by 2, the format is {{code|1(2)10}}. Like {{code|If}}, {{code|For}} could be applied to any other statement: 1.2 Type "Hello, Wikipedia!" for i=1(2)10. Note that the for applies only to a single statement; if one wants to run multiple statements in a loop, they would be separated to another part and called using do: 1.3 Do part 5 for i=1(1)100. 5.1 Type "Hello, Wikipedia!". 5.2 Type "This is JOSS.". As in BASIC, any of the inputs to the for loop could be constants, variables or other expressions. As these sorts of ranges could be applied to any line of code, it was possible to define limits and loops when the program was invoked. For instance, consider the program: 1.1 Type X. Normally if one invoked this in a fashion similar to BASIC's {{code|RUN}}: Do part 1. It would produce: 0 However, one can modify this behaviour by adding a loop construct to the invocation: Do part 1 for X = 1(1)5. Which would produce: 1 2 3 4 5 This allows formulas to be constructed in programs without having to be placed within loops. Looping, if desired, can be provided by the user when they start the program. ===Expressions and propositions=== A unique feature of JOSS was its handling of logical expressions. Most computer languages offer some way to form a multi-part mathematical expression, for instance, {{code|Set x{{=}}(1+2)路3.}} which sets the variable x to the value 9. JOSS expanded on this concept by clearly defining the concept of the "proposition", an expression that returns a logical value, true or false, instead of a numeric one. They were mostly seen in {{code|If}} statements, as in the examples above, but the Boolean value could also be stored in a variable directly,{{sfn|Gimble|1967|p=77}} or one could convert true to 1 and false to 0 using the {{code|tv}} (truth value) function.{{sfn|Gimble|1967|p=24, 69}} In addition to propositions, JOSS also had the concept of "conditional expressions". These consisted of strings of propositions along with code that would run if that proposition was true. This allowed multi-step decision trees to be written in a single line. They serve a purpose similar to the [[?:|ternary operator]] found in modern languages like [[C programming language|C]] or [[Java programming language|Java]], where they are used to return a value from a compact structure implementing [[if-then-else]]. JOSS' version has any number of conditionals, not just three, so it is more of a compact [[switch statement]] than a compact if-then.{{sfn|Gimble|1967|p=75}} This example recreates the function of the {{code|sgn}} function:{{sfn|Marks|1971|p=41}} Let s(x)=[x=0:0; x>0:1; x<0:-1]. This defines a function "s" which takes a single parameter, "x", and makes three consecutive tests against it. Whichever test succeeds first returns the corresponding value after the colon.{{sfn|Gimble|1967|p=25}} ===Ranges=== Another advanced feature of JOSS was that it had the concept of a [[Range (computer programming)|range]] as a built-in type that could be stored and manipulated. Ranges are normally found as the inputs to [[for loop]]s, where they are part of the syntax of the loop itself. For instance, in BASIC one writes a for loop using this basic syntax: {{sxhl|2=basic|1= FOR I=1 TO 5 STEP 2 }} This will perform a loop that assigns I the values 1, 3, 5 and then exits. JOSS used a somewhat obscure format to define the limits of the loop. The equivalent code in JOSS would be: I=1(2)5 Note that this code does not include a for. That is because in JOSS, ranges are first-class citizens of the language, not something that is part of a loop as in BASIC. Ranges can be defined and used in many contexts outside loops. For example, here is a conditional expression that evaluates the factorial of a parameter x:{{sfn|Gimble|1967|p=75}} Let f(x)=[x=0:1 ; fp(x)=0:prod(i=1(1)x:i)]. In this example, there are two main propositions, separated by the semicolon. The first, on the left, states that if the parameter x is 0, the condition should immediately return 1. If that proposition fails, it moves to the second test, on the right. This one checks if the fractional part of x is zero (i.e., it is an integer), and if so, it calls the {{code|prod}} function to multiply a range of values. The {{code|prod}}'s parameter is also a proposition, but in this case, the test is replaced by a loop iterator that runs from 1 to x stepping by 1. If that proposition is true, which is it for all values of the loop, it returns the index i. This causes a series of values to be sent into {{code|prod}} from 1 to x.{{sfn|Gimble|1967|p=75}} The combination of these features allows for complex functions to be written in a few commands. This sort of functionality has only become common in much more modern languages, which typically use [[iterator]]s or a [[Map (higher-order function)|map function]] to provide the same outcomes. JOSS's capability to combine decisions and loops in a compact form is unknown in other languages of the era, including offshoots like FOCAL. === Commands === ====Set==== The {{code|Set}} command assigns the results of an expression to the specified variable. Equivalent to BASIC's {{code|LET}}. 01.30 Set p=3.14156. 01.60 Set i=l*(r/100)*t. {{code|Set}} was optional when used in direct mode, where one could type {{code|x{{=}}5.}} without the Set command. This was not allowed in indirect mode, in contrast to BASIC.{{sfn|Gimble|1967|p=68}} ====Let==== {{code|Let}} was used to define user-defined functions.{{sfn|Gimble|1967|p=74-75}} Equivalent to BASIC's {{code|DEF FN}}.{{sfn|Gimble|1967|p=65}} Let t(x)=sin(x)/cos(x). Set j=t(1.1). Type j. {{code|Let}} can also be used to set the value of a variable using a formula consisting of a constant: Let x=5. From that point, it can be used identically to one created using {{code|Set}}. There is a subtle difference, however, when this X is referenced in code, the value will be calculated by evaluating the right-hand side. A {{code|Set}} is only evaluated once, so it is much faster.{{sfn|Gimble|1967|p=45}} The system generally suggested using {{code|Let}} only in direct mode, saving them out for use in a program by inserting them at the top or bottom of the file. This avoided the {{code|Let}} being called multiple times during execution, as it would only be called once during the loading process.{{sfn|Gimble|1967|p=63}} ====Demand==== The {{code|Demand}} takes a list of variables and stores the user input in variables. The optional {{code|as}} qualifier added a custom prompt. Equivalent to BASIC's {{code|INPUT}}. 01.01 Type "What is your age?". 01.02 Demand A. 01.03 Type "You are", A. 01.04 Demand H as "What is your height?". 01.05 Type H,"? That tall?". ====Type==== The {{code|Type}} command outputs one or more items separated by commas. In its basic form it is equivalent to BASIC's {{code|PRINT}}. However, {{code|Type}} includes a number of optional forms that make it highly overloaded, performing a range of unrelated output tasks.{{sfn|Gimble|1967|p=66}} When used to print values, the parameters can be variables, literal strings surrounded by double-quotes, and the special {{code|_}} character that produces a line feed.{{sfn|Gimble|1967|p=7}} {{code|Type}} also supports formatted output using format strings. See the section on {{code|Form}} below for details.{{sfn|Gimble|1967|p=66}} Type is also used as the equivalent to BASIC's {{code|LIST}} statement, writing out the program. For instance, {{code|Type step 1.1.}} will print out a single line of code, while {{code|Type part 1.}} will print out the entire part, and {{code|Type all.}} prints out the entire program.{{sfn|Gimble|1967|p=66}} Further, it can also be used to print lists of internal values. {{code|Type all values.}} produces a list of all variables and their values, while {{code|Type size.}} prints out the program size. Keywords include {{code|size}}, {{code|time}} and {{code|users}}.{{sfn|Gimble|1967|p=66}} ====Page==== {{code|Page}} triggers a page feed on the special JOSS terminals.{{sfn|Gimble|1967|p=77}} JOSS would normally send a page feed when the terminal reached line 54 on the paper, so if one wanted to ensure a block of data would not be split in half, one could:{{sfn|Gimble|1967|p=49}} 1.10 Page if $>44. {{code|$}} is a pseudo-variable that returns the current line number.{{sfn|Gimble|1967|p=49}} ====Line==== {{code|Line}} triggers a line feed on the special JOSS terminals.{{sfn|Gimble|1967|p=77}} ====To==== The {{code|To}} command jumps program execution to the specified part or step number, using {{code|To part 1.}} or {{code|To step 1.1.}} respectively.{{sfn|Gimble|1967|p=67}} It is the equivalent of BASIC's {{code|GOTO}}. Contrast with {{code|Go}}, an indirect command used from the command line that starts programs, the equivalent of BASIC's {{code|RUN}}. 01.01 Demand A as "TYPE A NUMBER". 01.05 To step 1.01. 01.10 To part 1. ====Do==== {{code|Do}} is similar to {{code|To}}, but branches to a subroutine. As with {{code|To}}, you can {{code|Do part}} or {{code|Do step}}. If a step is provided, that single line is run and then returns to the statement after the {{code|Do}}. If a part is provided, execution starts at the first line of the block and continues until the end of the block is reached or a {{code|Done}} statement is encountered. 01.15 Do step 7.24. 01.16 Do part 8. {{code|Do}} had one special short form for looking in keeping with it being very common in most programs. This used the {{code|times}} modifier instead of a normal {{code|for}}, in the case for simple loops. So the following lines are equivalent:{{sfn|Gimble|1967|p=66}} Do part 1 for i=1(1)5. Do part 1, 5 times. JOSS maintains a pointer to the currently executing line, which a {{code|Do}} would change. However, it included a special "parenthetic do" that could be used in direct mode to test certain sections of the code without changing the main pointer. For instance, if the program stopped due to an error and it was not clear which section caused the problem, one might test a particular subroutine with:{{sfn|Gimble|1967|p=58}} (Do part 2.) ====Done==== The {{code|Done}} command returns from a subroutine call. As subroutines return automatically when the end of the part is reached, {{code|Done}} is only required for returning early, and is often used with a conditional. Equivalent to BASIC's {{code|RETURN}}. *Routine to ask the user for a positive value and repeat until it gets one 01.10 Demand X as "Enter a positive value greater than zero". 01.20 Done if X>0. 01.30 To step 1.1 ====Stop==== The {{code|Stop}} command terminates execution of the program and returns control to the editing environment. Equivalent to BASIC's {{code|END}} or {{code|STOP}}, although BASIC's {{code|STOP}} is intended to allow {{code|CONT}} to pick up execution at the same location, a feature that has no direct equivalent in JOSS's workspace-oriented system. 01.10 Type X. 01.20 Stop. ====Go==== Available in direct mode only, {{code|Go}} is the equivalent to BASIC's {{code|RUN}} and {{code|CONT}}, depending on whether a program is currently stopped due to an error or {{code|Stop}} command being encountered.{{sfn|Gimble|1967|p=57}} ====Cancel==== Another direct-mode-only command, {{code|Cancel}} is used when the program has stopped for an error and the user wants to reset the program, which it does by clearing the [[program counter]]. A {{code|Go}} would pick up at the last location, but issuing a {{code|Cancel}} makes {{code|Go}} start at the top again.{{sfn|Gimble|1967|p=53}} If the current breakpoint was due to a parenthetical {{code|(Do.)}}, one can issue a parenthetical cancel, {{code|(Cancel.)}}, to stop just that sub-execution and allow a {{code|Go}} to continue at the last non-parenthetical line.{{sfn|Gimble|1967|p=58}} ===Math=== JOSS stored all numbers as radix-10 floating point.{{sfn|Gimble|1967|p=69}} JOSS contained six mathematical operators:{{sfn|Gimble|1967|p=69}} * {{code|+}} for addition * {{code|-}} for subtraction * {{code|路}} for multiplication (the [[interpunct]], not period) * {{code|/}} for division * {{code|*}} for exponents * {{code|{{!}}...{{!}}}} for absolute value, with an expression in the middle Mathematical expressions could use () and [] interchangeably in matched pairs to establish precedence. For instance: 1.30 Set A=|-10路[5+1]路(1+5)|. Would produce 360.{{sfn|Gimble|1967|p=70}} ===Functions=== The language contained the following built-in functions: ====Math==== * {{code|sin()}} - Sine of an angle given in radians * {{code|cos()}} - Cosine * {{code|arg()}} - Takes X and Y values of a point and returns the angle between that point and the x-axis * {{code|log()}} - Naperian log * {{code|exp()}} - Natural base to the power of the argument * {{code|sqrt()}} - Square root * {{code|sgn()}} - Sign of the argument, 0 returns 0, -ve values -1, +ve +1 * {{code|ip()}} - Integer part of the argument, {{code|ip(22026.4658)}} returns 22026 * {{code|fp()}} - Fractional part, returns .4658 * {{code|dp()}} - Digit part, returns 2.20264658 * {{code|ep()}} - Exponent part, returns 4, the location of the decimal ====Boolean==== * {{code|tv()}} - Truth value, returns 1 if the expression is true, 0 otherwise ====Looping functions==== JOSS also defined a number of functions that performed looping internally, in order to avoid the programmer having to write a {{code|For}} loop to perform simple tasks like summing a series of numbers. The parameters could be either a list of simple expressions separated by commas, or a range construct whose command could be any statement or function call. * {{code|max()}} - Maximum value of the provided expressions * {{code|min()}} - Minimum * {{code|sum()}} - Sum * {{code|prod()}} - Product * {{code|first()}} - First item in the list that matches a condition, returns that result
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)