5 ms·
Show HN: Practical programming language with expressive power, in 10K LOC C++11
- karmakaze 7y ago> the syntax of MANOOL is actually so simple that it could be “described on a postcard”. This immediately makes me want to read said postcard. Is there something to this effect? [Couldn't find it.] I didn't see the advantage in using braces instead of Lisp-parens or functional languages that use neither. The first thought that came to mind was using the semi-colon insertion parsing like Go, but on source text that uses whitespace indentation like Python and insert all the braces needed by the parser.
- karmakaze 7y agoAlso, all the Wikipedia links are annoying. Assume we know how to use the internet. I wanted every link to show me relevant content (e.g. benchmarks[0] :-) [0] https://en.wikipedia.org/wiki/Benchmark_(computing) https://en.wikipedia.org/wiki/Benchmark_(computing)
- rusini 7y agoSorry, I did not had time to add that content (I was in hurry to show my work and at least make an intro, after 4 years of silence and hard work :-) BUT thank you for the suggestion! I will include those benchmarks shortly. Refs to wikipedia help me to focus on using common terminology as much as possible (and I actually wrote the Intro also for some of my friends that do not understand what "programming" means if I do not speak of "computer programming" and add a link to wikipedia :-). BTW personally, I also find hyperrefs annoying aesthetically...
- karmakaze 7y agoIt would help a lot if the wikipedia links were visually identified by a little 'definition' graphic or something. Congrats, it looks very complete and is a great achievement.
- rusini 7y agoThank your for commenting! > This immediately makes me want to read said postcard. Is there something to this effect? [Couldn't find it.] I actually did not do such exercise, sorry :-) BUT: 1) almost all syntactic features are demonstrated in the first two examples/lessons in the wiki (and could be compressed further); 2) the formal context-free grammar can be found in the large PDF (caution: crude, work in progress!): https://github.com/rusini/manool/releases/download/v0.2-beta/MANOOL.pdf https://github.com/rusini/manool/releases/download/v0.2-beta... It has only 25 rules. That's comparable with Smalltalk. Besides, Smalltalk was a source of inspiration for the syntax, since it is culturally a cousin of LISP, does not use S-expressions, but its syntax does allow for a kind of DSLs (think ... ifTrue: ...). MANOOL is similar in that respect, but its syntax is closer to S-expressions (allows you to express name bindings). >I didn't see the advantage... S-expressions have syntactic sugar to express lists: (A B C) -> (A . (B . (C . ()))) MANOOL has that and slightly more: infix/postfix operators (and one prefix), etc.: A[B; C] -> {A B C}, A + B -> {(+) A B}, {A: B C} -> {A {B C}}, A.B[C] -> {B A C}, etc... (it does not have dotted pair notation, but I hope the idea is clear). That syntactic sugar is abstract and independent of what actually A[B; C] and A + B mean. The intention, for example, is that the syntax (at the context-free grammar level - surface syntax) does not need to change no matter what features we need in the future. It is said that context-free grammars are not modular: as the language evolves it is easy to introduce ambiguities (think C++). MANOOL approach does not suffer from that; features (like keywords if, while...) can even be made available selectively in a limited scope, if needed. I call it "universal grammar". On the other hand, I strongly suspect that the resulting syntax is better than S-expressions "psychologically" (sorry LISP'ers :-). It is not a matter of our familiarity with infix notations (from mid school), but our brain has very limited "stack". Anyway, the point of MANOOL is not its syntax or homoiconicity; it was originally just a nice implementation strategy. The point lies deeper in some semantic features... BTW that's not the first time that someone comes and suggests something to replace S-expressions and... fails. BUT one successful example is Smalltalk (albeit the result is not quite "homoiconic"), so that inspired me too. As to why {} instead of ()... the main reason is that () had to be reserved for explicit grouping of subexpressions (just like in mid school or Smalltalk): (1 + 2) * 3. BTW that's why I had to use [] for "applications" and that might look ugly to people (but think about failed M-expressions). As to optional ";", that was precisely one of those "design compromises" I am talking about. Personally, I am not a fan of "semicolon omissions" :-)
- rusini 7y agoWell, what about this program?: -- factorial { {extern "manool.org.18/std/0.2/all"} in : let { Fact = { proc { N } as : unless N.IsI48[] & (N >= 1 - 1) signal {if (~)[N.IsI48[]] then TypeMismatch else InvariantViolation} else : var { Res = 1 } in : do Res after : while N <> 0 do Res = N * Res; N = N + ~1 } } in Out.WriteLine[/* Out; */ "Factorial of 10 is "; Fact[10]$] } It has absolutely all syntactic features and even makes sense!
- karmakaze 7y agoI find the nesting of elements hard to follow and would prefer something like: -- factorial (extern "manool.org.18/std/0.2/all") in: let: Fact = proc { N } as: unless N.IsI48[] & (N >= 1 - 1) signal (if (~)[N.IsI48[]] then TypeMismatch else InvariantViolation) else: var { Res = 1 } in do Res after while N <> 0 do Res = N * Res; N = N + ~1 in: Out.WriteLine[/* Out; */ "Factorial of 10 is "; Fact[10]$]