mudasobwa

mudasobwa

Creator of Cure

Imagine a conductor forced to relearn musical notation every time a new instrument joins the orchestra. Violin—one system of writing. Cello—another. Oboe—a third, with reversed polarity, no less. The trumpet flatly refuses to acknowledge the existence of the staff and insists on a tablature of its own invention. Absurd, of course. In the real world every instrument reads the same score. Notes, rhythm, dynamics are universal. Only the technique of execution differs.

MetaAST is that score.

Showing Posts 1 to 7

dimitarvp

dimitarvp

A bit pretentious writing style but I enjoyed the article.

Extremely ambitious project that I’d join and would try to help. I do agree that each language’s AST is kind of a distraction and if we can standardize a converter from that to the meta-AST then we’d score huge wins in code analysis. Which we desperately need recently.

One problem is that many languages don’t have a stable AST – Elixir is one of them. However, combining the language and its version allows us to pin down exact AST details. Requires more work – but it’s only done once.

Really though: amazing idea. Would love to see it bear some fruit.

Asd

Asd

Strange post.

First of all, there are no concepts which exist in all languages. Even variables don’t exist in all languages (like stack-oriented languages or assembly languages).

Second, is that purity is a higher-level construct and what pure and what is not — defined strictly by the developer. In a language like C, setting data by some local pointer can be a side effect, given that it can be used as a way to share some information with another thread. And even if you define what is pure and what is not (what will most likely be different from the developer’s understand), you can’t just write a generic analyzer, because not all languages have functions, and those who have them, usually can’t provide a guarantee that all code reachable by the function will be a part of the call graph.

Even in Elixir, this code is pure

def add_five(x) do
  x + 5
end

But so is this

def add_five(x) do
  ref = make_ref()
  caller = self()
  spawn_link(fn -> send(caller, {ref, x + 5}) end)
  receive do
    {^ref, result} -> result
  end
end

And the fn inside is invisible in the call graph. You may argue that the latter version changes the state of the system by introducing a new process. But I will say that the first version changes the current_stacktrace field of the process info. So, again, developer defines what “pure” means.


I mean, you can represent different languages in the similarly structured AST, but this would just offload semantic differences of the languages on the programs which would analyze such AST. There would be no universal algorithms, just universal representation with lots of language-specific algorithms around it

mudasobwa

mudasobwa OP

Creator of Cure

Exaggeration is my middle name. That’s the way I hook not only the reader to continue reading but also myself to not give up writing.

Well, many languages don’t have a notion of AST in the language itself. I use 3-rd party S-expr generators for Ruby, for example. And yet that’s not the biggest problem, trust me :slight_smile:

It’s coming. I wrote it when I figured out it finally got somewhat shaped. Stay tuned.

mudasobwa

mudasobwa OP

Creator of Cure

In the Yakut language, there are 14 words for snow of varying degrees of whiteness. In Japanese, 裸木 (Hadakagi)—is a seasonal word that means a tree that has shed its leaves for the winter.

And yet we can talk to Yakuts and Japanese.

Sure I can. It won’t be bullet-proof, it would make mistakes, and I am fine with that. Everything “unclear” goes to “non-pure” and I get back the list of definitely pure functions. That’s ok for my needs.

May I argue that I would consider the latter function being a non-pure one, and that’s totally fine? False-positives are harmless, unless, of course, you are after an academic thesis that nobody would even read.

May I allow `:language_specific` nodes in my AST and support plugins dealing with the transformation?

Not so lots in the first place. Disjunction of the languages would require some additional effort, but conjunction is already a very valuable asset.

This thing cannot be generalized flawlessly to the universe is the judgement that buried a ton of great solutions six feet under.

Asd

Asd

I did the same approach in my elixir compiler called Tria. It turned out that there were very very few pure function (and by “pure” I mean those that can be evaluated at compile time). I ended up implementing approach of postponing effect when evaluating code at compile time. But that resulted in code explosion, where a single call would evaluate to 10 or 20 effects.

But I don’t know your final goal, your blog post says nothing about it, so I don’t know if you want to have an AST for all languages or only for a subset, if you want analyzers to be completely universal or somewhat universal, etc.

I would also suggest to take a look at MLIR project. It has a wide adoption, lots of translators and a bunch of algorithms about it, including reachable code analysis which is essentially a “purity” analyzer

mudasobwa

mudasobwa OP

Creator of Cure

Thanks!

That’s a teasing post without spoilers, mostly designed for responses like yours, thanks for that. The answer everywhere is “somewhat.” I am not a perfectionist when it comes to the choice between ideal and working.

Lucassifoni

Lucassifoni

Pandoc for programming languages ? I like the idea, the “common core” as other posters said needs to be arbitrarily defined because concepts vary a lot across languages. But that kind of constraint is what makes those endaevours both desperate and interesting - best kind of project if you ask me. Good luck !

— All posts loaded —

Where Next? Top

Trending in Blog Posts Top

bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
pckrishnadas88
Hey everyone! :waving_hand: I’ve published Part 7 of the Building Distributed Systems in Elixir series, where we build core distributed ...
New
mudasobwa
So, instead of wasting my afternoon arguing with anonymous handles on X, I turned to my trusty, soulless assistant and said: “Listen, ple...
New
zorn
An educational side project in Elixir, Phoenix, and Tauri. I share what I learned while wiring Automerge into the BEAM, including how I s...
New
abreujp
New article: Elixir Project Structure — From mix new to a Growing Codebase I’ve published a new article in my Elixir learning series on d...
New
nathanl
Process labels are useful for visualization and debugging. Here’s why you should use them.
New
mudasobwa
Somewhere, right now, a senior engineer is on the verge of a nervous breakdown because his company will not let him switch from Claude to...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews