Arc Forumnew | comments | leaders | submit | akkartik's commentslogin

New 2-minute video: support for strings, arrays and file handles that starts to give this the feel of a shell language.

https://archive.org/details/akkartik-2min-2020-10-27

reply

2 points by rocketnia 10 days ago | link

Did you build all these dialogue boxes yourself too? Very snazzy. :D

reply

2 points by akkartik 8 days ago | link

https://github.com/akkartik/mu/blob/3d31467c0d/apps/tile/box... :D

reply

1 point by akkartik 33 days ago | link | parent | on: Observations on homoiconicity

You might enjoy this talk which mentions this equation:

    code = AST + formatting/comments
https://www.youtube.com/watch?v=2tCY72t1nL0

reply

2 points by Mitranim 32 days ago | link

I might check it out later, but is there a gist in text form somewhere?

reply

1 point by akkartik 34 days ago | link | parent | on: Observations on homoiconicity

Thanks for sharing! It's been a while since I thought about this, but my conclusion a few years ago[1][2] was that homoiconicity was an ill-posed idea. A language only really needs two properties to make macros convenient:

* Everything is an expression, and

* Unambiguous parens.

[1] http://arclanguage.org/item?id=16924

[2] http://arclanguage.org/item?id=19485

---

That said:

* I like symbols. Having symbols and strings in a Lisp doesn't seem any more weird than having variables and string literals in Algol or Java. Even if I _could_ use one in place of the other, it seems useful to separate symbols as part of the program from strings as part of the environment/domain/data model. You could implement one with the other, sure, but I wouldn't question anyone who chose not to. After all, every attempt I've seen to support spaces in symbols has been quite ugly.

* Your other points seem to be in the context of building tools like code formatters where the output will be seen by humans. That's not really the context for Lisp macros. I haven't really thought much about how useful they would be. Since I believe in macros, I can probably be persuaded. So that might be an interesting post to write. Why do you care about emitting exactly the code that was parsed? What new apps does it enable?

Are you aware of any languages that perfectly reproduce input layout? Even Go supports gofmt only by tightly constraining how programs "should" be indented, and only outputting that layout.

reply

2 points by Mitranim 34 days ago | link

> Why do you care about emitting exactly the code that was parsed? What new apps does it enable?

Got a `gofmt` addiction, can't go back. Auto-formatting should ship with every language.

Briefly skimmed the Go implementation, and you seem to be right: it seems to lose whitespace and enforce its own formatting.

> Are you aware of any languages that perfectly reproduce input layout?

For now just my own. [1] The language isn't real yet, and might never be realized, but it has a base data notation (very Lisp-like), a parser, and I just started writing a formatter. Because the AST for the data notation preserves whitespace and comments, the formatter can print the code _exactly_ as is. This has interesting repercussions.

For a fully-implemented formatter for a fully-defined language, you wouldn't need whitespace; see Go. However, being able to print everything back means your formatter is usable from the start. It can support one or two simple rules, making only minor modifications, but you can use it on real code right away. Furthermore, this means we'll _always_ be able to choose which rules to enable or disable, which can be handy if the family of languages described in terms of this notation has different formatting preferences. I actually want the formatter shipped with the language, like `gofmt`, to be non-configurable, but this still seems like a useful quality.

[1] https://github.com/mitranim/sublime-mox

reply

2 points by Mitranim 34 days ago | link

Should clarify something (follow-up to previous reply, see below or above).

Most macros don't want to deal with whitespace and comments. We also might want to _not let_ them, otherwise people will start using comments as code, like in Ruby. Macros just want expressions. So, we would define a second level of the AST and perform a second pass.

For the same base notation, there may be multiple languages defined in terms of it. If such a language has any form of prefix or infix, or uses the `outside_parens()` calling convention, the second pass would have to group nodes into expressions, in ways specific to that language. Furthermore, it should be addled with metadata about packages, types, and so on. The resulting AST is compiled, fed to macros, etc.

reply


New 2-minute video: defining functions in this postfix language.

https://archive.org/details/akkartik-2min-20201020

reply


That's a great point. As I've built this, the keystone example in my mind has been the `square` function:

    x square = x x *
So it's really funny that I haven't added it yet. Now added.

reply

2 points by zck 43 days ago | link

Nice!

Is it that you're trying to reduce stack juggling? That's hard to understand from simple examples (that you need to have to grok the syntax). Maybe compare something like finding the hypotenuse of a right triangle given the two other sides. Without naming arguments, you'd have to do something like:

  hypot = dup * swap dup * + sqrt
But with named arguments:

  hypot x y = x x * y y * + sqrt
That seems a little easier to read, but even the original isn't so complicated. Is there an example that makes it more obvious why it's better? Even your `square` example is more tokens than with stack juggling (without arguments, `square = dup *` is just four tokens, compared to six with named arguments). I'd say the with-arguments one is easier to read, but I've far less familiar with stack-based postfix programming.

reply

2 points by akkartik 43 days ago | link

Yeah, some other polynomial might be a better example. The Pythagorean formula has a clean separation when it comes to which args each term uses. How about the roots of a quadratic equation when you start out with a, b and c on the stack?

reply

2 points by zck 43 days ago | link

Yes, that is definitely simpler, although the formula is more esoteric. At least, for me, it triggers the "I was taught this in school and haven't used it since" filter.

Maybe something like:

  total-price cost-per-item number-of-items shipping-cost-per-item rush-cost = cost-per-item number-of-items * shipping-cost-per-item number-of-items * + rush-cost +
This doesn't seem super great; it could be refactored to use each thing once, but it's late and I can't think of any better example.

reply

2 points by akkartik 43 days ago | link

You're right that in general any such example can be refactored to reduce stack operations. That's even a fun game for many Forth programmers to play. (We lispers have our own equivalents.) But it usually makes the code less comprehensible, in my experience.

reply


I've been hanging out on the Handmade Network Discord channel recently. Mostly because I've developed RSI so can't work as much on Mu, and because I'm bored staying home for months on end.

https://handmade.network/manifesto

The site seems to be some sort of offshoot from a channel where a game developer used to screencast himself developing a game: https://handmadehero.org/watch

From what I can piece together, Handmade Network periodically has some sort of Jam for a few days where a few people hack on projects following some theme.

The most recent theme was Lisp: https://handmade.network/blogs/p/7390

Flip was built for the Lisp Jam. You can see a demo about it here: https://discord.com/channels/239737791225790464/485261036308... (though you'll need to sign up to that Discord group)

There was a discussion about it, a sort of debrief after the Jam, that you can read at https://discord.com/channels/239737791225790464/707742863076....

It's already sparked a bunch of ideas for me: https://mastodon.social/@akkartik/104780599045128839. So decent payoff on being bored and finding this community :)

-----

2 points by jsgrahamus 82 days ago | link

Sounds interesting. Sorry about the RSI. Went to using an ergonomic keyboard, which seems to have squelched it for me.

-----

2 points by akkartik 97 days ago | link | parent | on: Still alive?

It's still running HN :)

Previous thread: http://arclanguage.org/item?id=21205

Edit: Another thread from 5 years ago: http://arclanguage.org/item?id=19408

-----


This is awesome. Particularly the instructions for rerunning a single test in isolation.

-----

2 points by zck 172 days ago | link

Thanks! The goal is to make it _way_ easier to reproduce a single test, and investigate what's going wrong.

And it's a testament to the power of Lisp that I didn't have to change much to make it happen.

-----


I just encountered the GraphBLAS project which feels like maybe a more mature approach to this idea: https://www.acm.org/articles/people-of-acm/2019/tim-davis

-----

1 point by akkartik 177 days ago | link

"See, most data structures aren't really data structures at all. They're _acceleration_ structures _for_ data."

http://acko.net/blog/software-development-as-advanced-damage...

-----


I just remembered that I don't understand this comment. Arc stores forum data in s-expressions, not JSON. How would we expect a JSON parser to work?

Is making it work just a matter of calling the Racket primitive on `rep.template` instead of `template`?

-----

2 points by krapp 190 days ago | link

I spend all my time with Arc working on the forum, so JSON is more important to me than it might be to someone else who primarily focuses on the language.

I was working on the data export feature, which before just dumped a user's posts and comments as a printed statement, but I wanted it to export JSON because that's more portable. Racket has a really nice JSON parser, unfortunately all the forum data is templated, so I can't just pass it to Racket because it doesn't understand the type. There may be a way to get it to work at that level but I don't know what it is.

So I had to get an old JSON parser for Arc and rewrite a bit of it to be able to generate JSON from forum data. I think it was zck's parser but I'm not entirely sure ATM. It works, but it's an awkward workaround. Any data coming from the forum has to go through one parser, and any other data, such as from a remote API would be going through another (Racket's.)

>Is making it work just a matter of calling the Racket primitive on `rep.template` instead of `template`?

Yes, I had to hunt around to even know that existed, because it's not in the docs.

-----

3 points by rocketnia 189 days ago | link

Not that it helps you much now, but the best documentation for tagged types (including the `rep` operation) is probably this: http://arclanguage.github.io/ref/type.html

You can get to it from the "Type operations" link in the table of contents. Of course, you might've been drawn to the "Templates" page instead.

And unfortunately, that documentation describes Anarki's stable branch. Making documentation of similar quality for Anarki's master branch might be quite a bit more work. So even if you were familiar with tagged types already, the knowledge that template instances were a tagged type on Anarki master might be hard to discover.

I suppose a more ideal form of the documentation would describe on the "Templates" page that template instances were a tagged type with a certain representation. It could describe the direct implications of that, but it would also have a link to the "Type operations" page for more background.

-----

2 points by krapp 188 days ago | link

>I suppose a more ideal form of the documentation would describe on the "Templates" page that template instances were a tagged type with a certain representation. It could describe the direct implications of that, but it would also have a link to the "Type operations" page for more background.

That would have been tremendously helpful, can we do that? Who actually maintains the documentation, can it be updated?

-----

1 point by akkartik 189 days ago | link

Perhaps we should maintain the docs only in plain-text and only within the repo, just because of the operational overheads of managing multiple branches. At least that way they won't seem to lie to a newcomer. I'm curious to hear what others think.

-----

2 points by krapp 188 days ago | link

There is already a wiki that isn't getting much use[0].

[0]https://github.com/arclanguage/anarki/wiki

-----

1 point by akkartik 188 days ago | link

It sounds like you mean a JSON generator (emitting JSON) rather than parser (ingesting JSON). Is that right?

-----

2 points by krapp 188 days ago | link

Yes.

-----

More