Designing a functional programming language: Yatta
functional.blog
functional.blog
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?
- By doing this will I gain a deeper appreciation of the art? Will it help others to see this too?
Designing a good language is very very hard, harder maybe than a typeface, or a cathedral. But the rewards, in the terms of that question, can be inestimable.
What I am finding really nice is that I don't even have maps in my language since I can just use tables and get the benefits of maps along with indexing and all the fancy stuff.
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?
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.
On the other hand, if your intention is to make a new language that does something distinctly different and for some purposes better, then answering those questions will save you from spending time on things that don't deeply matter. Now if we're not in a circle of language design researchers, things that matter can be syntax.
I can see what's being attempted and I appreciate it. I myself have wanted a kind of 'referential transparency' when it comes to lazy values in an otherwise strict language. Or in this case async ones executing concurrently. You can use the result of the expression without the ceremony. I'm not particular to the syntax and would have liked to see it added to a popular language. Making a whole new language is scratching an itch, which is also great for what it is.
Granted, it was a bad idea to build a non-tech business on a new programming language in a region which could not hire people to fix the language, so it was the right call to give into the depression and move away from my language. However, it probably took me a decade to try again recently.
When I reflect on history and how things could have unfolded, I realize I was onto something and I was at the wrong place to exploit my ideas. As an example, if I had persisted, then my language could have been what Hack & HHVM is today. However, I was in the mid-west operating on my own.
This time, I'm swinging hard with my new language, and I hope to redefine a portion of the computing landscape. Or, at least, improve it within my myopic universe. I haven't published much, but I have a novel language at the moment which is enabling me to do things that are hard to imagine.
Reasons you might make a language that isn't bound by the above questions:
- For learning
- For fun
- To explore a concept
- For sheer novelty
- To make a point
- to indulge in syntax design
The author of this advice explicitly calls out syntax design as pointless. As if Java, Lisp, Python, Haskell are the end-all of syntax design. Haskell in particular is notorious for indulgent syntax design.
One thing I've noticed about my students (undergrads) is the first thing they are interested in playing with when it comes to language design is syntax. They have ideas about syntax they want to try out, and it gets them interested in parser design. Probably because it's the most tangible thing they have access to and experience with. When they try out their syntax ideas it opens up new pathways for them and they eventually move on to greener pastures.
But the idea that syntax is done and solved and there is no more room there for innovation is completely foreign to me. What about syntax in other (natural) languages? Languages written from left to right? Top to bottom? Languages with a non-roman character set? What about syntax with emojis? There are entire programming languages written with emojis now (https://esolangs.org/wiki/Emoji). Did the author of this consider them in 2006?
https://en.wikipedia.org/wiki/Esoteric_programming_language#...
-> to understand why things are (or were) done a certain way
-> to test the boundaries of what's possible
Surely no one thinks that current languages are the most efficient or effective possible way of doing things? That we've even come close to enumerating all useful methods of expressing program execution? (Take a look at what Racket is doing for example.)
Here's mine: https://joypy.osdn.io
> Thun is dialect of Joy written in Python.
> Joy is a programming language created by Manfred von Thun that is easy to use and understand and has many other nice properties. This Python package implements an interpreter for a dialect of Joy that attempts to stay very close to the spirit of Joy but does not precisely match the behaviour of the original version(s) written in C. The main difference between Thun and the originals, other than being written in Python, is that it works by the “Continuation-Passing Style”.
These are good questions with regards to language design.
But for some people there is a massive learning experience that comes from designing and implementing a programming language and it's compiler even if it never becomes a successful or popular language.
I feel this learning experience is has plenty of value even if the end resulting language does not.
Anders Heljiberg wrote Turbo Pascal, J++, and Delphi, before moving on to things more widely accepted as successful like C# and Typescript. Yes Turbo Pascal and Delphi had some large followings
Likely his experience from previous programming languages allowed to him be successful later.
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.
- 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.
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.
- 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.
You can see the result of making this tradeoff here: https://yatta-lang.org/docs/stdlib/system/#running-a-pipelin...
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.
I should have read more of your documentation. Which is very readable by the way.
:-)
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.
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.
why another language? why not, who cares
Paul Graham explained this way better than I could: http://www.paulgraham.com/power.html
On the other hand I don't agree with your point about visual structure. Personally I believe visual structure is mostly about code indentation. Visual structure can be apparent in any language, functional or not.
It's not really all that novel, and more of a pleasing combination of existing ideas. So why pin this on "functional advocates", whatever "this" even is?
Maybe you could expound on your ideas a bit to help me understand your reasoning. Perhaps your comment is just incomplete rather than being wrong.
(also, hopefully your qualms go further in depth than the syntax, because literally-skin-deep comparisons are a little boring)
Is it possible that your perception of a lack of structure is down to a lack of familiarity with the syntax and idioms in ML-style languages? I could see where perhaps not knowing what parts of the code are syntactic and what parts are stylistic causes it all to fade to gray.
I've noticed a phenomenon along these lines when people are learning lisp: non-lispers and lisp learners tend to see nothing but parenthesis, because that's the most visually distinctive feature of lisp code compared to other syntaxes. More experienced lisp programmers, on the other hand, have a tendency to just tune them out. In well-formatted code, the parens themselves have very low information density, so you don't necessarily get a lot of value out of scrutinizing them.
"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.
This one isn't nearly as bad as that, but the point remains: tell me up-front why I should care.
And it's fine that way. There are lots of languages out there, and very few of them have any objective problem-solving features to justify their existence. Tackling some problem in a new way like Rust does (arguable, see prior art like Cyclone) is the exception, not the norm. Lots of languages are about improving subjective ergonomy while combining and tweaking features already found in other languages.
Would it be fine to state that the language solves nothing for you and you can stop reading? But I don't think that needs to be stated any more than the post already did.
Then the rest of the readers, who have an ounce of curiosity left in them, can scroll on and take the time to appreciate the design and see if they like where it's headed.