Skip to content

Instantly share code, notes, and snippets.

@nwillems
Last active August 29, 2015 13:56
Show Gist options
  • Save nwillems/9342899 to your computer and use it in GitHub Desktop.
Save nwillems/9342899 to your computer and use it in GitHub Desktop.
A language - thoughts on a higher level language

This is a gist describing some random thoughs on a possible programming language. It is by no means a specification or in anyway something concrete, at the moment it is some thoughts, put in this gist, to remove them from my head.

Comments are very welcome.

Forgiveness

It should be possible - without making them symbols - to have a compiler recognise public and pubilc or even pubic as the same symbol. Of course if you ever choose to use a variable name called pubilc this would not be possibl, but whatever else you do this should be possible.

Syntax

Curly braces are not bulky and blocky enough! Squarebrackets should indicate code-blocks! /sarcasm-off

It should be evaluated wether there are more suited symbols for common things. Like code-blocks, are the C-style curly-braces good enough, or should there be another indicator of blocks fx §! Is exclamation-mark the right symbol for boolean-negation or what?

It sort-of boils down to what language you are coming from and what you are comfortable doing. Python is using indentation, BASIC uses Then-end, so...

Typing

Something about type-system

Semantics

First see typing, i beleive that static typing would be great, but inferred(C#, SML...). Therefore it should also be possible to allow functions returning thruth values, to have an negated counter part automatically generated.

Paradigm

After working with C# for quite some time, I have fallen in love with the multi-paradigm way. Having functional conctructs right at your hand, when a task calls for it, has been very pleasant, and has led to some very elegant solutions.

The problem is the limitations(where can they be used and how, scoping, and so on), and that C# is mainly imperative. I find Haskell to be more elegant, by being functional first.

Special features

Default error handling

Exceptions are inherently hard to catch, and make exahusting catch-es very hard. Therefore the following solution is proposed. It should be noted that the concept of checked vs unchecked exceptions from Java, is quite liked, instead of the more loose C# way. Either you declare or you dont throw. The following solution doesn't provide a way for unchecked exceptions, but I beleive that it could quite easily be achieved.

All methods should return an Either type, to signal error conditions. The below link, presents a very elegant solution for C# which could be possible.

http://siliconcoding.wordpress.com/2012/10/26/either_in_csharp/

The signature should be something like:

function int Foo(){
  ...
  return 42;
}

let f = Foo()
case f:
  Left val: NextOp()
  Right err: HandleError()

Further, it should be possible to have "clean" functions, that doesn't at all provide room for error, or at least makes a promise not to return any.

Pre- and Post-conditions

If the runtime could provide a way for checking pre/post conditions, that would be nice. And the code, a way to annotate methods with conditions.

Parallel/Concurrent

Look at erlang - Message passing is the way to go. Btw Atoms are great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment