Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't get this. Heres Fibonacci[1] in only 74 lines of YAML, or how about some kind of football CLI program[2] in only ~600 lines of YAML. I've got no idea why anyone would use this, or why the hell YAML was chosen to represent the AST.

Edit: Not to crap over the authors project, it seems to produce quite neat output[3][4], it's just writing 600 lines of unreadable YAML to generate a ~32 line Python program seems a bit pointless.

1. https://github.com/alehander42/pseudo/blob/master/examples/f...

2. https://github.com/alehander42/pseudo/blob/master/examples/f...

3. https://github.com/alehander42/pseudo/blob/master/examples/f...

4. https://github.com/alehander42/pseudo/blob/master/examples/f...



You apparently missed the original.py files in each of those directories.

Here is fib: https://github.com/alehander42/pseudo/blob/master/examples/f...

There is also fib.py, which seems to be the Python output of the original.py input. The other examples are better to look at in this regard.

I believe the yaml file is either an intermediary or just another output format.


See also README.me: https://github.com/alehander42/pseudo/tree/master/examples/f...

> Pseudo AST

> Generated from original.py using pseudo-python


Yep, you're not supposed to write the yaml yourself, it's just a compilation target and an intermediate format.

Why YAML then? Well it's still nice to be able to read it easily in that early phase of the project and it's fairly well supported in most popular languages(and a little bit more compact than JSON).


I would guess the idea is to create some intermediate representation to transpile between languages. The yaml is then probably not meant to be read or written manually.

This could be used in software modelling tools that use a more declarative style, which then creates that IR, which then compiles to some real world language.

I'm not saying this is a good idea, just trying to guess the intention ;) 15 years ago somebody would have used XML and created an even more verbose OMG standard based on such an idea.


I'm pretty sure that there is a XML based intermediary and associated OMG standard. But I value my sanity so I'm not going to go look it up.

Also this reminds me of the Haskell AST in "JSON format" that is available as one of the Pandoc output formats.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: