
Designing a functional programming language: Yatta - todsacerdoti
https://functional.blog/2020/05/25/designing-a-functional-programming-language-yatta/
======
gdsdfe
they should have just shared the project landing page => [https://yatta-
lang.org](https://yatta-lang.org)

why another language? why not, who cares

------
bitwize
Yatta: It's so easy, happy go lucky!
[https://youtu.be/rW6M8D41ZWU](https://youtu.be/rW6M8D41ZWU)

------
toolslive
maybe steal some date flow ideas from Oz

[https://en.wikipedia.org/wiki/Oz_(programming_language)](https://en.wikipedia.org/wiki/Oz_\(programming_language\))

------
leafmeal
> I do not want to fall in the trap of slow compilations and debugging
> mysterious typing errors again

I always found that, instead of debugging type errors, in dynamic languages
you end up debugging runtime errors.

The errors don't go away, but with compiled languages at least they're easier
to catch.

~~~
mumblemumble
I'd add to that that type errors can happen at run-time, too, in any language
that allows any level of dynamic typing. That includes fully dynamic languages
(I swear, the most mysterious type errors I've ever fought with concerned
Python libraries with insufficient documentation), but it also includes static
languages like Java that permit unsafe downcasting.

------
tshanmu
Elixir for the graalVM

------
axilmar
It seems the main point of this language is implicit concurrency. From what I
have read, from the link above, the main idea is that it executes individual
expression trees in separate threads, taking care of dependencies between
threads and handling promises appropriately.

It's a nice idea on paper, but I wonder how soon developing a "real"
application with it will result in performance bottlenecks because the
compiler could not capture the intentions of the programmer or the program is
really difficult to untangle into different threads of execution.

~~~
akovari
It doesn't parallelize just "any" expression though. Only blocking functions,
such as those working with IO. Similarly, in JS for example you would use
callbacks to avoid blocking. In Yatta you don't have to explicitly worry about
callbacks, Promises or alike, because they are hidden into the runtime itself.

If you want to parallelize a computation, you can use function async,
providing it a lambda, and then yes, Yatta can parallelize that as well (given
that there are no other dependencies on it). But this is an explicit thing in
control of the programmer.

------
gliese1337
It appears to me that the main selling point here is automatic
parallelization, with futures/promises being abstracted away.

~~~
adamkl
Agree:

 _\- Dead-simple concurrency model. Even if it won’t be the most performing
one for some (or most) situations, it should be built into the language and be
very easy to use. Ideally built with functions alone, requiring no special
syntactic constructs. Advanced concurrency possible via STM._

Most of the other design considerations sound like a description of Clojure:

 _\- Plain and simple syntax, minimal boilerplate, few keywords, no need for
OOP constructs. The code must be very easy to read through._ (this one is
subjective I suppose. :-))

 _\- Everything is an expression, no statements. The program itself is just a
single expression._

 _\- First-class functions and modules. Modules are simply sets of functions
and records. Modules can be further organized into packages. Function calls
supporting tail-call optimizations._

 _\- Few data types. Yatta comes with the following built-in types: integer
(64 bit), floating point number (64 bit), character (UTF-8), symbol, sequence
(variable length, constant-time access to both ends), tuple (fixed length),
dictionary, set and STM (Software Transactional Memory – coming in beta). No
implicit conversions between types though!_

 _\- Custom data types, or records. Records are basically just tuples with
named fields, and syntax sugar that goes with it._

 _\- Run on JVM (GraalVM) and allow polyglot cooperation with other JVM
languages. Very important if integrating with existing code-bases._

------
StreamBright
It would be great to start a new programming language by stating what sort of
actual problem it will solve (or handle better) than the other gazillion
languages. Example: Rust -> memory safety, because based on many studies
memory safety is responsible for ~70% of bugs. If you are just doing a
language for the fun of it is still ok, even though I would be less interested
in reading the post. As far as Yatta goes:

"allows me to write programs as simple expressions, without having to worry
about low-level stuff such as concurrency, with a beautiful syntax and a
strong but dynamic type system."

The first part is true to I do not know how many languages, the second part is
subjective, I think LISP and ML have the best syntax some people throw up
after opening the hello world examples.

~~~
_bxg1
Yeah, nothing is a bigger turn-off for me on the home page for a language or
framework than starting off with "Helps you build [some combination of]
_simple_ , _maintainable_ , _fast_ , _scalable_ software". No kidding! You and
every single other language out there.

This one isn't nearly as bad as that, but the point remains: tell me up-front
why I should care.

------
blackrock
I would like the Elixir without the Erlang.

I would like the Python with some pipe forwarding.

I would like the Python as a binary.

I would like the package management of Rust.

The speed and flexibility of C, but more consistent, and with less ability to
make mistakes. Allow for a power mode, that turns off bounds checking, to
boost speed.

~~~
kwhitefoot
I would like a language that allows seamless piping to and from programs,
specifically Unix tools. Just now my favourite language is Bash because:

\- concurrency is so simple that you forget you are doing it,

\- I can easily use other tools that far smarter people have written.

The ability to execute other programs and capture their output always seems to
be an afterthought in most languages.

~~~
akovari
I agree, I want that too. It was not an afterthought in case of Yatta but
rather a difficult tradeoff to make in terms of extending the syntax (which I
try to keep minimalistic) and providing an easy interface for interacting with
external processes.

You can see the result of making this tradeoff here: [https://yatta-
lang.org/docs/stdlib/system/#running-a-pipelin...](https://yatta-
lang.org/docs/stdlib/system/#running-a-pipeline-of-external-process)

Not as "seamless" as bash maybe, and perhaps not feature-complete yet, but I
hope this can serve as a starting point and we can build on this for future
releases.

~~~
kwhitefoot
Brilliant!

I should have read more of your documentation. Which is very readable by the
way.

~~~
akovari
Thanks! Don't hesitate to get in touch in case you encounter anything unclear,
wrong, or missing.

------
weego
What is it with functional advocates and their obsession with brevity to the
point of reductivism, and lack of visual structure

~~~
tomp
What do you mean? The code example is more verbose than Python, and has about
as much structure.

~~~
dnautics
what's the equivalent python? (must include async, and proper error handling
over the async connections). I'll give you a break on the "not parallelizing
if it's got datapath dependencies".

------
carapace
FWIW, Frank Atanassow, "Some words of advice on language design"

[http://lambda-the-ultimate.org/node/687#comment-18074](http://lambda-the-
ultimate.org/node/687#comment-18074)

> Before you go off inventing new programming languages, please ask yourself
> these questions:

> 1\. What problem does this language solve? How can I make it precise?

> 2\. How can I show it solves this problem? How can I make it precise?

> 3\. Is there another solution? Do other languages solve this problem? How?
> What are the advantages of my solution? of their solution? What are the
> disadvantages of my solution? of their solution?

> 4\. How can I show that my solution cannot be expressed in some other
> language? That is, what is the unique property of my language which is
> lacking in others which enables a solution?

> 5\. What parts of my language are essential to that unique property?

~~~
ModernMech
This post has always irked me. It reads as straight up gate-keeping,
especially when what follows these questions are a litany of negativity ("go
home" "no one cares" "you are kidding yourself" and "you are wrong."). This is
especially frustrating as the author later admits he himself cannot answer
these questions honestly and yet persists in designing his own language. He
certainly hasn't "gone home" so why should anyone else?

Here's my advice: Want to invent a new programming language? Dive in. It
doesn't matter if someone invented it before. It doesn't matter if you can't
formalize it in mathematical notation at the outset (or ever). It doesn't
matter if your language could be implemented in a library of another language.
It doesn't matter if you can't articulate the precise benefits of your
language. It doesn't matter if there are any benefits at all. It doesn't
matter if you can't answer a single of the above questions. Have at it. You
are guaranteed to a) learn a lot, and b) have fun. Maybe you do something
completely derivative and that's fine. Maybe no one will appreciate what you
do and that's fine. Maybe it will go nowhere, maybe it will never compile.
Maybe you will be the only user. Maybe some guy on the internet will tell you
to go home and no one cares. So what?

~~~
carapace
I don't see it that way. There are _thousands_ of languages now. It's wise
counsel to people (like me!) who hope to introduce a language that actually
gets used. If you can't "check those boxes" on this handy checklist, well,
maybe you gotta spend more time at the drawing board.

For those of us that are going to do it anyway, with no expectation of
becoming popular and widely-used, I would treat it a stimulating challenge
rather than a slammed door.

~~~
creatornator
I think there's something to be said for going through the exercise even if
the answer to every question actually does indicate the language shouldn't be
written. What happens when you come up with an idea that actually does have a
place? It's better to start with the background of having done it before than
try to create a dream project with no experience in making some toys.

