
Forest, a multi-syntax functional language that compiles to WebAssembly - eterps
https://github.com/forest-lang/forest-compiler
======
slx26
Well, this seems like an interesting project. Although very ambitious, the
author seems to know what he's talking about, and has been going at it for a
while, so kudos for that.

I find the design principles interesting. We might talk a lot about syntax
abstraction, but I feel like that's not even the most interesting idea (it's
very likely that many people who thought about making languages thought about
it).

There are a few trends I find interesting, though. Programming languages are
pretty tricky. You need to think about style and readability, performance and
optimization, scalability and maintainability, data types and abstractions,
algorithms and data transformations, parallelism and concurrency, etc. It
seems to me like we have been introducing systems that progressively try to
modularize and isolate those issues, sometimes completely hidding them from
us. Syntax abstraction shouldn't be so surprising if we follow this idea. We
got garbage collection, most optimization is done by compilers, we got dynamic
typing, endless discussion about models for data representation, even visual
languages, etc. The idea that programming languages shouldn't be limited to
text in a single source file is very important in my opinion. I often envision
future programming as "powerful IDEs" (and I never use IDEs nowadays) that can
represent different properties/aspects of programs/code in different
ways/views, isolating them or showing relationships/interaction between them.
The complete opposite of what we see in movies, as always happens in reality,
hahaha. Well, went a bit off-topic so I'll stop here.

------
samcodes
Someone already mentioned Luna Lang. Another similar project that is further
along is isomorf. You get projections into 6 or so syntaxes, and deployment to
AWS Lambda.

[https://isomorf.io/#!/syntax-picker/tours-
ideas](https://isomorf.io/#!/syntax-picker/tours-ideas)

~~~
aaron_kent
Just a quick update on isomorf.io, we are bootstrapping the projections on the
platform itself and so soon you will be able to design and implement your own.
Stay tuned.

------
feniv
The multi-syntax support is really interesting. [https://www.luna-
lang.org/](https://www.luna-lang.org/) is another language with a similar
concept, with both a visual and a textual representation of the same code.

Would love to read more about the immutable data structures it supports. Rich
Hickey has some great talks on efficient immutability in Clojure.

I really believe we're going to see a lot more new languages targeting web
assembly. I wish it supported a standard, pluggable garbage collection system
that could be easily adopted.

~~~
platz
also GraalVM

------
westoncb
I've been trying to get some feedback on a related idea for making 'view-
independent program models', which could be rendered with alternate syntaxes
(or even richer visual augmentation than strictly text).

The main idea is to represent languages as a graph of 'language constructs'
and individual programs as paths through some language graph. That path is the
'model' which an editor or compiler/interpreter would operate on—but in the
case of the editor, since the program model has no connection to syntax, you
can configure how it's rendered on a per-user basis (or use it to experiment
with new language UI concepts, etc.).

Here's a write-up with illustrations:
[http://westoncb.blogspot.com/2015/06/how-to-make-view-
indepe...](http://westoncb.blogspot.com/2015/06/how-to-make-view-independent-
program.html)

I've had this on the back burner for a while now, waiting for the write moment
to try building out a proof-of-concept version—but if someone could point out
some kind of critical flaw in it and prevent me from wasting so much time,
that'd be awesome :)

~~~
nemaar
Hi, I am working on something similar, it's nowhere near usable but I hope
that a proof of concept version could be ready this year. My variant is
focused on visual programming with various representations. I will definitely
read your docs. I am very interested in the models you have come up with.

~~~
westoncb
That's great, definitely send me a message if you want to talk about it more
at some point. You can find my website with contact info on my profile here.

------
jlarocco
I don't know if I buy the justification for supporting multiple syntaxes. It's
a slippery slope towards appeasing a million people's particular syntactic pet
peeves, and it's not worth the effort of supporting them all.

With the exception of s-expressions (too many parentheses) and
mandatory/significant whitespace, most people don't seem to care too much
about syntax, IME. Semantics are much more important.

~~~
macintux
> most people don't seem to care too much about syntax

Speaking as an Erlang enthusiast, I must disagree. I love the syntax, but most
people see "different" and think "bad".

~~~
camgunz
Yeah, I generally agree. But I think our understanding of like, language
popularity is a little colored by "the era of language fads". C++ is probably
first, then Java, PHP, Ruby, and now JavaScript. If a language doesn't build a
huge mainstream base (Ruby maybe failed at this but maybe only for lack of a
big corporate backer) or 100% occupy the dev zeitgeist for an extended period
of time, we think it hasn't caught on. But like, Erlang powers a lot of web
infrastructure. Whatsapp is most famous, but there are a lot of services I'm
personally aware of that are written in Erlang, and often these were
situations where a mature dev team wanted to see if Erlang solved the problems
they'd experienced writing backend services in Java or Python.

So yeah while syntax probably prevents you from achieving rockstar status or
world domination, I think those days might be over, and I think the true
measure of success is whether or not experienced dev teams are using the tech
to solve real problems.

------
macintux
"Syntax is polarizing, so we'll move the decision to the team level where they
can argue endlessly about which to prefer."

Interesting project, I like the emphasis on immutable data and pattern
matching.

~~~
Fellshard
It does raise a question of cross-team communication. If one team proposes a
change in their dialect, can another team review it in a different dialect?

At that point, developing semantic diff capabilities seems to become vastly
more important. At the same time, syntax abstraction might already give you
the tools to start from as well.

~~~
timb07
> How do I edit the code in my preferred syntax? Do I need an editor plugin?

> When working on the project, each developer runs forest dev, which mounts a
> virtual filesystem in the local directory using FUSE, called dev/.

> dev/ contains all of the source files, projected into the developer's syntax
> of choice.

~~~
Fellshard
Right, the projection part is clear. The question was one of diffs, reviews,
etc. What does a diff look like when projected between languages? Can you
still feasibly use a line-based diff format, or do you have to account for
transforming syntax structure? Do you just try to diff the projections
instead? Lots of interesting things to try out.

------
camgunz
1\. Holy shit they use FUSE, that's pretty bananas.

2\. We're definitely getting closer to the era of language swappability, where
language X transpiles to language Y, language Y compiles to language X, and
strict code formatters clamp down on corner cases. I think it's great and
welcome, but I would expect a side effect of this to be that more "free"
languages pop up that allow programmers to be a little looser in their
implementations.

------
anentropic
Why does anyone think multi-syntax is a good idea?

They think it will help adoption? But surely it also hinders it by fragmenting
code examples in the wild (Stack Overflow, docs, blogs etc) into different
syntax populations?

------
auggierose
Lots of nice ideas which I don't think will work together. Nevertheless, it's
always a good idea to give it a go, and the next time around maybe it will
work out. For example, I don't think there is any sense whatsoever to have
different syntaxes for exactly the same structures and semantics. You want
different syntaxes to make different semantics more accessible. Also,
reference counting and functional programming doesn't seem like a good fit, as
much as I get the performance aspect.

------
rch
Doesn't Reason leverage syntax abstraction in a similar way?

[https://reasonml.github.io/](https://reasonml.github.io/)

~~~
chenglou
Yep, though we don't put much emphasis on it for now:
[https://twitter.com/jaredforsyth/status/1026706210043490304](https://twitter.com/jaredforsyth/status/1026706210043490304)

This is a lisp syntax for Reason, that works already with our language-server
integration, etc.

------
zitterbewegung
I like the idea of abstracting the syntax so that if you want to program in
something Haskell like you can or program in a JavaScript like language. (I
had a similar idea). I hope that the developer ergonomics that this provides
is enough to balance the trouble of multiple people reading different syntax .

------
aij
> For the sake of collaboration, we agree on structure and semantics, and
> agree to disagree on syntax.

`FooError on line 111` suddenly becomes a lot less meaningful... I suppose
that's what the canonical representation is for, but having to map between the
two seems like it would be at least somewhat annoying.

------
Lichtso
"Projectional Editing" is coming to my mind, in case you are looking for more
input on the topic.

------
ChickeNES
The Loyc project has similar goals: [http://loyc.net/](http://loyc.net/)

