GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:45 JST mcc mcc

    #BabelOfCode 2024
    Week 6
    Language: Nameless experimental LISP

    Confidence level: High

    PREV WEEK: https://mastodon.social/@mcc/113975448813565537
    RULES: https://mastodon.social/@mcc/113676228091546556

    Okay… here things get weird!

    My project to, gradually over the course of 2025, do each puzzle from Advent of Code 2024 in a different programming language I've never used before, has stalled out for exactly two months now as I've instead been creating…

    …the programming language I'm going to use this week!

    In conversation about a month ago from mastodon.social permalink

    Attachments

    1. No result found on File_thumbnail lookup.
      mcc (@mcc@mastodon.social)
      from mcc
      #BabelOfCode 2024 Week 5 Language: TCL Confidence level: Medium high PREV WEEK: https://mastodon.social/@mcc/113906616486081430 NEXT WEEK: https://mastodon.social/@mcc/114308850669653826 RULES: https://mastodon.social/@mcc/113676228091546556 TCL is an odd language. I think anyone who's tried developing a programming language has probably at some point thought "what if I just didn't bother with types and did all operations as string transformations?". I think TCL is just that language. Officially, TCL is supposed to be capitalized "Tcl". I will not be complying.
    2. No result found on File_thumbnail lookup.
      mcc (@mcc@mastodon.social)
      from mcc
      I was too busy to do AOC this month (that's https://adventofcode.com/). So I'm thinking I'm going to do AOC 2024, *in 2025*, under the following rules: - One challenge per week. - I don't have to perform a challenge every week. The goal is to finish by the start of December. - I have to do a different programming language every time. - C, C++ and Objective-C are not eligible languages. - If I make an honest attempt at a language and fail, I may retry in Go (but only Go) (I need to learn Go)
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:41 JST mcc mcc
      in reply to

      I've realized something:

      mov rax, r10
      add r8, 1
      jmp _main_loop_reset

      Assembly looks a lot like LISP once you remove the parentheses! So I wanted to design an ASM syntax that exists as a data structure within a LISP, and write code as a LISP program that generates that data structure. In other words make a DSL similar to "Amaranth" or my old "No Compiler" blog posts https://msm.runhello.com/p/category/plt/no-compiler . I may be just confusing you at this point— I'm not sure I can describe this idea clearly in 500 chars.

      In conversation about a month ago permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: msm.runhello.com
        Run Hello » No Compiler
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:42 JST mcc mcc
      in reply to

      So after a prelude containing reimplementations of if, while, int comparisons, and "noop", I am now ready to implement "fizzbuzz". I do not need an implementation of "fizzbuzz", I'm supposed to be doing AOC2024 day 6. But at least I know my helper routines work!

      Fizzbuzz source:

      https://github.com/mcclure/aoc2024/blob/6d12e9cf65158b5f511da8545d263f4ed1dcad99/06-01-guard/src/test-fizzbuzz.l0

      I was GOING to implement a `proc` that modified function code in-place to add local variable support, but debugging `while` took a lot out of me, so I think I will not do that for this project.

      In conversation about a month ago permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/114/310/168/639/183/200/original/c806dbcab05c9a54.png

      2. https://files.mastodon.social/media_attachments/files/114/310/170/218/850/890/original/d7c6df6278e46ab4.png
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:42 JST mcc mcc
      in reply to

      Got part 1 of the puzzle working this morning!

      https://github.com/mcclure/aoc2024/blob/2656c75da28669ad11568fae6f5f3a9c24a311a6/06-01-guard/src/puzzle.l0

      App code "proper" starts around line 124 (43-123 are "library code" I didn't post above; I implemented "for" and "switch", and a very small vector math library.)

      Writing this program was not at all hard (other than the library code… `for` was painful), but nor was it particularly *pleasant*; it didn't feel fluid. That might speak poorly for my minimal LISP, and the question of whether I use it again after this project.

      In conversation about a month ago permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/114/314/797/078/223/945/original/caeb3e76c972c115.png
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:42 JST mcc mcc
      in reply to

      In particular, what worries me is the "hard part" of this code turned out to be the higher order functions (if, while, for, foreach, proc). This LISP is contrived compared to other LISPs, with no special "forms", and no sugar other than the {} and [] which are supposed to be swiss army knives you can construct anything else you need from. I did it this way to make self-modifying / generated-at-runtime code easy & fluid. *But that's exactly what turned out to be hardest*. And *that's* a bad sign!

      In conversation about a month ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:42 JST mcc mcc
      in reply to

      Making this little LISP was *in part* a "can I do this?" for the Babel project. But there's another thing, which is I want a general purpose assembler. I've recently started wanting to target some unusual/retro systems (NES, N64, Saturn) and I forsee frustration with having no common toolchain among these projects for any language I like, nor a common macroassembler syntax I can take with me across different ISAs.

      So I was hoping my tiny LISP could be reworked into a macroassembler.

      In conversation about a month ago permalink

      Attachments


      Janneke repeated this.
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:43 JST mcc mcc
      in reply to

      Before I can start, I need to make some utilities. By "utilities" I mean "if" and "while" statements, which again, this language currently lacks. MVP, remember. Implementing these in userland is possible! It's *ugly*, though. For `if`, I simulate branching by putting the two possible outcomes (functions) into an array, casting the condition to a bool and then the bool to an int, and using that as an index to the array.

      "while" is even more nightmarish. I don't… understand the use of make-quote.

      In conversation about a month ago permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/114/310/103/102/902/781/original/54dec10db669c1ed.png
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:43 JST mcc mcc
      in reply to

      Like, I wrote the code, but I don't understand it. I initially wrote it with all the `make-quote`s being `return`s, and that didn't work, so I experimentally replaced them with make-quotes and it did work. I need to reread the interpreter code to really understand why that was required.

      If even the designer can't understand the model here, the model is probably too complicated for anyone ELSE to write self-modifying code either! That's a sign of a problem, or better abstractions needed.

      In conversation about a month ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:43 JST mcc mcc
      in reply to

      Anyway, I like testing things before I use them, so after implementing my "if" and "while" I decide to write a simple Fizzbuzz program. This causes me to immediately realize—

      I FORGOT TO IMPLEMENT > AND <

      I just forgot!! Fortunately I *did* include bit arithmetic ops, so I implement <, >, <=, >= in userland as well, by testing bit (1<<63) as a proxy for 2's compliment negative. This is actually a little worrisome. I'm not sure if this code truly "works" or if I'm just leveraging UB in Rust.

      In conversation about a month ago permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/114/310/146/229/037/142/original/4c4a40581abf4936.png

      2. https://files.mastodon.social/media_attachments/files/114/310/155/602/750/536/original/1c1a8a4a8377663a.png
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:44 JST mcc mcc
      in reply to

      For "Week 5" I did TCL, and it kind of set my brain on fire with "wait… you can just DO that?".

      In TCL, strings are anonymous functions and vice versa. In my old Emily language, "if" and "while" blocks were implemented by passing in lambdas; but in TCL you do the same thing by *passing in a string containing {the code to execute}*. I started trying to imagine what "hygienic" TCL would be; if TCL is a C macro, I want an ML or Rust macro. I tried to imagine something closer to LISP than TCL.

      In conversation about a month ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:44 JST mcc mcc
      in reply to

      This is what I came up with; I think of it as "0-lisp". In LISP a "2-LISP" is a LISP where functions and variables live in different namespaces, and in a "1-LISP" they live in one namespace. Projecting backward, in my 0-LISP, the distinction itself disappears totally; functions are lists and *any list can be executed*. I wanted to know what this changed. Here's what I found:

      It helps very little, and makes certain important things a huge pain. Oops! Still, it was very educational to learn this.

      In conversation about a month ago permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/114/308/867/852/607/502/original/5788a7604ed44be1.png

      2. https://files.mastodon.social/media_attachments/files/114/308/877/003/654/014/original/b3b546c1530f7cc8.png
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:44 JST mcc mcc
      in reply to

      Anyway, now I have a LISP interpreter written in Rust.

      https://github.com/mcclure/lisp0-experiment/tree/2025-04-07

      It's a very minimal "MVP"; the language currently lacks:

      - Variable scopes
      - Loops
      - Conditionals
      - Floating point numbers
      - Errors lack backtraces or line numbers (and cannot be recovered from)

      It has

      - One global scope
      - Ints, strings, arrays and hashtables
      - Tail recursion
      - File I/O

      But math and recursion means it's Turing complete. Which means it's sufficient to use it for a AOC problem!

      In conversation about a month ago permalink
    • Embed this notice
      mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:44 JST mcc mcc
      in reply to

      Now, since *I'm* the one writing this LISP, I do get to make some changes. The main thing I wanted to change, as it's the #1 thing that infuriates me writing LISP, is parentheses. This "LISP" has a syntax where each line (as separated by newlines or commas) implicitly has () around it. Meanwhile, {} and [] are shorthand, for

      {x,y,z} => '((x)(y)(z))

      [x,y,z] => (make-array [(x),(y),(z)])

      In other words {} is functions (quoted lists) and [] is array literals.

      Is this still a LISP? I don't care!

      In conversation about a month ago permalink

      Attachments


      1. https://files.mastodon.social/media_attachments/files/114/308/909/950/705/843/original/9c5c90a0da7b84fd.png

      2. https://files.mastodon.social/media_attachments/files/114/308/920/710/182/197/original/e244970aaf7b7cab.png

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.