I've thought about Paul Scott Robson's Structured BASIC, and I think that's pretty much a kind of ALGOL, and also pretty near the apex for any imperative language "running" "native" on the X16.
* * *
Suppose I were to migrate an imperative language to the X16.
import java.util.regex.*;
public class GFG {
public static void main(String[] args)
{
// Get the regex to be checked
String regex = "Geeks";
// Create a pattern from regex
Pattern pattern = Pattern.compile(regex);
// Get the String to be matched
String stringToBeMatched = "GeeksForGeeks";
// Create a matcher for the input String
Matcher matcher = pattern.matcher(stringToBeMatched);
// Get the Pattern using pattern() method
System.out.println("Pattern: " + matcher.pattern());
}
}
1. I'll start with Java, JavaScript, or, yes, Python or Smalltalk or other OO-like languages. First, I suspect that resources are too limited for a class and object system, though I could be wrong. So the syntax of these critters effectively reduces to that of Perl or C, perhaps with some special extra types for things we lose when leaving OO.
import java.util.regex.*;
void main(int argc, String[] argv)
{
// Get the regex to be checked
String regex = "Geeks";
// Create a pattern from regex
Pattern pattern = Pattern_compile(regex);
// Get the String to be matched
String stringToBeMatched = "GeeksForGeeks";
// Create a matcher for the input String
Matcher matcher = pattern_matcher(stringToBeMatched);
// Get the Pattern using pattern() method
println("Pattern: " + matcher_pattern());
}
2. Now we're at Perl, C, and related things. These will experience the same reductions when porting to the X16: braces don't exist, and significant regular expressions don't either, and so we reduce scope while also moving to syntax brackets like BEGIN and END. Thus the syntax of these tend to merge with Pascal.
import java.util.regex.*;
void main(int argc, String[] argv)
begin
// Get the string to be checked
String regex = "Geeks";
// Create a pattern from regex
pattern_compile(regex);
// Get the String to be matched
String stringToBeMatched = "GeeksForGeeks";
// Call the simple pattern matcher on the input String
simple_pattern_matcher(stringToBeMatched);
// Get the match using matcher_pattern() method
println("Pattern: " + matcher_pattern());
end
3. Now we're at some variant of Pascal, and we find we probably have to lose slices, strong "do it yourself" type systems, structures (?), any sense of an object system, and probably the general use of hashtables. Maybe we can save an "environment" table, which may have interesting environment variables and be partly useable as one general purpose hashtable. Maybe. This moves us to some version of ALGOL -- complete with capital letters.
IMPORT JAVA.UTIL.REGEX.*;
VOID MAIN(INT ARGC, STRING[] ARGV)
BEGIN
// GET THE STRING TO BE CHECKED
STRING REGEX = "GEEKS";
// CREATE A PATTERN FROM REGEX
PATTERN_COMPILE(REGEX);
// GET THE STRING TO BE MATCHED
STRING STRING_TO_BE_MATCHED = "GEEKS_FOR_GEEKS";
// CALL THE MATCHER WITH THE INPUT STRING
SIMPLE_PATTERN_MATCHER(STRING_TO_BE_MATCHED);
// GET THE PATTERN USING MATCHER_PATTERN()
PRINTLN("PATTERN: " + MATCHER_PATTERN());
END
4. Now we're somewhere in ALGOL. The type system is next to be simplified.
After using CC65 and considering Paul Scott Robson's posts and S-BASIC, I recommend throwing out floating point. Also, we use something like the ALGOL key word REF, (or the more obvious PTR), to indicate a pointer. The word itself isn't important.
IMPORT JAVA.UTIL.REGEX.*;
PROC MAIN(INT ARGC, PTR STRING ARGV) // ??
BEGIN
// GET THE STRING TO BE CHECKED
STRING REGEX = "GEEKS";
// CREATE A PATTERN FROM REGEX
PATTERN_COMPILE(REGEX);
// GET THE STRING TO BE MATCHED
STRING STRING_TO_BE_MATCHED = "GEEKS_FOR_GEEKS";
// CALL THE MATCHER WITH THE INPUT STRING
SIMPLE_PATTERN_MATCHER(STRING_TO_BE_MATCHED);
// GET THE PATTERN USING MATCHER_PATTERN()
PRINTLN("PATTERN: " + MATCHER_PATTERN());
END
5. The X16 doesn't really have a shell environment, so we change MAIN to be a regular PROC with params.
I doubt libraries will exist, so that goes.
Maybe (not sure) sigils come back in. If it reduces the complexity or resource use of the runtime, then sigils are an obvious choice. If not, then no need to have them. But if so, it would plant us firmly back in a form of Structured BASIC.
CALL MATCH_TEST( "GEEKS", "GEEKS_FOR_GEEKS" );
END
// REGEX$: THE STRING TO BE CHECKED
// STRING_TO_BE_MATCHED$: THE STRING TO BE MATCHED
PROC MATCH_TEST(PTR REGEX$, PTR STRING_TO_BE_MATCHED$)
BEGIN
// CREATE A PATTERN FROM REGEX
PATTERN_COMPILE(REF REGEX$);
// CALL THE MATCHER WITH THE INPUT STRING
SIMPLE_PATTERN_MATCHER(REF STRING_TO_BE_MATCHED$);
// GET THE PATTERN USING MATCHER_PATTERN()
PRINTLN("PATTERN: " + MATCHER_PATTERN());
END