Threads for alchemist

  1. 3

    But can you do a static portable binary from that Lisp code, comparable to C version in terms of file size?

    1. 13

      You absolutely can, on a system that has Lisp based runtime instead of C based runtime.

      1. 6

        Well-put. Probably still could with a Lisp designed for no-overhead interoperability with C compiled with a zero-runtime profile kind of like Ada/SPARK do. I don’t know if one like that currently exists, though.

        1. 4

          Not sure if Embeddable Common Lisp (ECL: https://common-lisp.net/project/ecl/ ) fits the bill but I guess it might?

          1. 2

            I forgot about ECL. Found this in its docs:

            “ECL (ECL for short) uses standard C calling conventions for Lisp compiled functions, which allows C programs to easily call Lisp functions and vice versa. No foreign function interface is required: data can be exchanged between C and Lisp with no need for conversion.

            ECL is based on a Common Runtime Support (CRS) which provides basic facilities for memory management, dynamic loading and dumping of binary images, support for multiple threads of execution. The CRS is built into a library that can be linked with the code of the application. ECL is modular: main modules are the program development tools (top level, debugger, trace, stepper), the compiler, and CLOS. A native implementation of CLOS is available in ECL. A runtime version of ECL can be built with just the modules which are required by the application.

            The ECL compiler compiles from Lisp to C, and then invokes the GNU C compiler to produce binaries.”

            That’s exactly the kind of design I’m talking about. It even matches the calling conventions for easy interoperability like I suggested for every language trying to [incrementally] replace C. Thanks for mentioning it.

      2. 4

        Not without packing the runtime with it, which is what a Lisp image does. Even after stripping unecessary stuff from the image, the binary is quite big.

        I’m a big Lisp fan, but let’s be honest.

      1. 2

        JavaScript gets the job done real quick, and you can find help for your problem basically anywhere.

        1. 4

          Well, I don’t think there is a lot of problems with this, apart from the flood of comments on the code. On that regard, it might be more interesting to consider using literate programming at once. Even Emacs has great support for these things; the code is tangled into a bloat-free file, and the whole document can also be exported to PDF, printed, and/or kept as documentation.

          1. 4

            I wish, I wish! Cue a musical where we sing about the joys of literate programming in the real world.

            Do any businesses successfully integrate literate programming style?

            One problem with it, which becomes apparent in most large scale literate programs, is that boilerplate ends up needing a literate justification. It’s hard to explain what I mean… basically, if you read that one famous literate programming book that implements a C compiler, you’ll notice a lot of sections that are necessarily repetitive because that’s how the program needs to be written. And in that context, having English prose for every piece of source code ends up adding complexity.

            It might be a good idea overall, but I’d be interested in any examples of companies using it successfully in practice. In a team setting, it requires devs be both excellent writers and excellent developers, which is relatively rare.

            1. 3

              Do any businesses successfully integrate literate programming style?

              I really don’t know. But the thing is, should the idea be discarded because apparently no one else seems to be doing it successfully? I think not.

              I’ve seen people using Jupyter notebooks for things like machine learning, and the notebooks would obviously include prose between code blocks, but that wasn’t like tangling the code blocks into a single file.

              boilerplate ends up needing a literate justification

              I completely agree, and I understand what you mean. If you really need that bunch of multiline comments on your code, common sense dictates that either something is wrong about your code, or you need better documentation. But what I meant was that if keeping the comments inside the code file is so important, then literate programming is the alternative.

              having English prose for every piece of source code ends up adding complexity

              Though I agree, I think the same can be said for excessive comment lines. The code itself seems busy and, if you scroll a little through it, you might notice that even syntax highlighting doesn’t help with legibility. The advantage of literate programming is that you can immediately identify where code and prose are, plus the parts are disposed in a topic-based approach, which makes browsing easier. That is not what you have in a plain code file; you’d have to Ctrl+F your way through it.

          1. 2

            What a nightmare I would have using this. Special keyboards and all.

            Interesting concepts though.

            1. 7

              Check out J: http://jsoftware.com/

              Same creator, but uses standard keyboard characters only.

              1. 7

                You can get used to typing `i to get ⍳ very quickly.

                The concepts are more than interesting; APL is profound in the way that Lisp and Forth are.

                1. 3

                  Modern APL doesn’t actually require a special keyboard or character set. Check out “J”.

                  1. 4

                    Actually, J and APL are different languages, see above. For modern APL development, one can try out Dyalog, or use gnu-apl-mode on Emacs to help typing the symbols.

                  2. 2

                    Sounds like what you need is an autocomplete that turns ‘Logarithm’ into ⍟

                  1. 3

                    Complexity measurement is a very interesting topic to tackle, but I am afraid that the fact that you did not specify the rules for the language used in the analysis makes it a little too hard to understand. I am interested on what you have to offer, and maybe this is a working paper, but I believe a paper on this subject is one which calls for extended explanation.

                    Maybe allow yourself to introduce the subject a little more, contextualize, propose your idea, show the tool you created in detail so that a reader understands how you are slicing a grammar into others (not talking about implementation; maybe explain the syntax of your proposed programs?).

                    Given your introduction, It does not feel like you are trying to advance the state-of-the-art, but even so, would be interesting to see a little more detail in why you think this is a good method. Perharps you should compare to other ones.

                    1. 4

                      Thank you very much for the feedback! I would agree that “this is a working paper”. At the time (2017) I didn’t have any experience or training writing papers. I’ve been at an academic lab now for 1.5 yrs and so now am coauthor on 5 or 6 peer reviewed published papers, so am starting to figure out how to do this, and perhaps now might be a good time to find some collaborators and work on these things more and get them published.

                      The language is called Tree Notation and the rules are described in a few different places: https://github.com/breck7/jtree/blob/master/spec.txt, http://treenotation.org/faq.html, https://github.com/breck7/jtree/blob/master/papers/paper/treenotation.pdf, and here https://github.com/breck7/jtree/blob/master/papers/paper2/aGrammarNotationForTreeLanguages.pdf.

                      You can also “play” with the notation here http://treenotation.org/sandbox/, here http://treenotation.org/sandbox/build/, and here http://ohayo.computer.

                    1. 3

                      It seems that it only supports PostgreSQL and SQLite at the moment, but the tutorial does a good job on showing what can be done. This made me consider Racket for database purposes. I’d like to see how it compares to Common Lisp solutions such as Mito.

                      1. 2

                        I’ll try to finish my implementation for the Jack compiler in Common Lisp. The syntax analysis is fine, but now I need to take my generated XML files and compare them with the book ones. Too good I won’t need XML for the semantic step.

                        1. 2

                          I was hoping that it was a mailing list for common lisp :/

                          1. 2

                            Aren’t there many such lists already?

                            1. 1

                              (equal common-lisp-mailing-lists ’nil)) ; ’t

                            2. 2

                              There is the lisp-hug mailing list, but it has a focus on LispWorks users.

                            1. 2

                              After mulling it over a few months, I made a controversial change to my programming language to parse foo -bar differently than foo - bar, reducing the need for parentheses (and more importantly, surprises) — as well as opening the door for new operators (like trailing * and + for building patterns without regex syntax).

                              I’m in the process of reviewing the first third-party code submission to Advanced Mac Substitute, which adds partial support for Sound Driver output, enabling Lode Runner’s gameplay sounds.

                              1. 1

                                Just a small question: I see that you are developing a language called V. Is your project somehow related to this homonimous language?

                                1. 2

                                  Nope, not related at all.

                                  Mine’s not the first language called V either, but I did check the search results for “V language” before adopting the name. :-)

                              1. 7

                                I’ve been working on the exercises on nand2tetris. Currently stuck in the second part of the VM Translator implementation, and doing everything in Common Lisp.