Functional, Verbose, Sensical: A Programming Language Proposal

A while back I wrote up some quick thoughts on what a programming language would look like if it's identifiers could contain spaces. In my example program I also had the colon used for setting spaces and the single equals sign used for comparisons. The other day I had some ideas for a purely functional version of some of these same concepts.

Here are the features of the as of yet non existent programming language:
  1. The only objects are modules, globals, functions and parameters.
  2. No variables. This is a purely functional language.
  3. Every global and parameter is a stream and so can have 0, 1, or more values.
  4. Modules define, import, and export globals and functions.
  5. Each module can have a single entry function which is the function that is run when the module is run.
  6. Identifiers can contain spaces
  7. Setting globals and parameter defaults uses a colon
  8. Conditional equality expressions uses a single '='.
  9. If statements are streamlined as shown below for easy conditional handling.
  10. Each function can only contain a single expression making this language purely functional
  11. Error handling is done using the if statement.
  12. You can use values that might not exist and then handle the error cases further down the if statement.
Below is what a programming language with these features might look like. I have highlighted reserved words in orange, identifiers in blue, and literal values in green.

module age groups {
  import print from command line output;
  import error from command line output;

  max baby age: 2;
  max kid age: 12;
  max teenager age: 17;

  function tell the user they are a baby {
    print('You are a baby')
  }

  function tell the user that they are a kid {
    print('You are a kid')
  }

  function tell the user that they are a teenager {
    print('You are a teenager')
  }

  function tell the user that they are an adult {
    print('You are an adult')
  }

  export function tell the user what age group they are in (age{
    ? age <= max baby age :
      tell the user they are a baby
    ? age < max kid age :
      tell the user that they are a kid
    ? age < max teenager age :
      tell the user that they are a teenager
    ? has one value(age) :
      tell the user that they are an adult
    ? has multiple values(age) :
      error('Please provide only one age')
    ? no values(age) :
      error('No age was provided')
    : // this would be the else case, but based upon the above statements it should never be reached.
  }
}

module my program {
  import tell the user what age group they are in from age groups;
  import the users age from command line arguments;

  entry function run the program {
    tell the user what age group they are in(the users age)
  }
}

Comments

Post a Comment

Popular Articles

The Vanilla Javascript Component Pattern

The Sunless Citadel: A D&D 5e Session Report

Getting Started with Harp