Discussion:
"Alfa" - idea for functional language.
(too old to reply)
letowski
2012-06-17 16:24:26 UTC
Permalink
Hi,

Here is my idea for making functional language more popular:

Compound data a'la Prolog (terms + lists), pattern matching a'la Ocaml,
lexical scoping and closures as in Scheme, garbage collecting,
but all this written in classic C/JavaScript syntax (curly braces, for, while, switch, return etc.).

What do you think ?

I have a working prototype implementation (as translator to Scheme),
please look at http://ml.pdg.pl/en/alfa3.html.

For example, here is qsort in Alfa (this is a name of the language):

function qsort( [] ) { return []; }

function qsort( [H| T ] )
{
function append( [], X ) { return X; }
function append( [H| T ], X ) { return [ H | append(T, X) ]; }

function select_less( x, [] ) { return []; }
function select_less( x, [H| T] ) {
if ( H < x )
return [ H | select_less(x, T ) ];
else
return select_less(x, T);
}

function select_notless( x, [] ) { return []; }
function select_notless( x, [H| T] )
{
if ( H >= x )
return [ H | select_notless(x, T ) ];
else
return select_notless(x, T);
}

var LNotLess = select_notless( H, T );
var LLess = select_less( H, T );

return append( qsort(LLess), [H| qsort(LNotLess) ] );
}


Mark
Torben Ægidius Mogensen
2012-06-19 07:17:11 UTC
Permalink
Post by letowski
Compound data a'la Prolog (terms + lists), pattern matching a'la Ocaml,
lexical scoping and closures as in Scheme, garbage collecting,
So far, you have described all languages in the ML or Haskell family.
Post by letowski
but all this written in classic C/JavaScript syntax (curly braces,
for, while, switch, return etc.).
And now it begins to sound like Scala, though Scala is also polluted
with objects.
Post by letowski
What do you think ?
What would the point be? The syntax is one of the worst features of C.

Torben
letowski
2012-06-19 20:48:04 UTC
Permalink
Thank You for the answer.

Yes, I know the opinions on C syntax. But the C-like languages are the most common ones - C++, Java, javascript, php. Millions of coders can read such code, but only some of them read Haskell or even Lisp !

Haskell is really uncomprehensible for people ( what it means: x . y $ z ? )
And (as for Scala) - I dont like the "object pollution" too !

The "Alfa" is essentially JavaScript with pattern matching added, or Scheme with curly braces syntax. The idea was simple - well known C-like syntax plus structural constructors, plus decomposition via pattern matching.

I looked for Prolog with imperative constructs. Sequential Erlang is also such a thing, but with a limitation of single assignment.

Of course, as for now this is only my spare time experiment - self-study tool and pretext for programming enjoyment.

Mark
Torben Ægidius Mogensen
2012-06-20 12:08:15 UTC
Permalink
Post by letowski
Thank You for the answer.
Yes, I know the opinions on C syntax. But the C-like languages are
the most common ones - C++, Java, javascript, php. Millions of coders
can read such code, but only some of them read Haskell or even Lisp !
I think C-like syntax can be a red herring for such languages: The
familiar syntax gives the impression that the semantics is also similar,
which may not be the case if the language is mainly functional.

Torben

Loading...