[HN Gopher] TXR Lisp
___________________________________________________________________
TXR Lisp
Author : tosh
Score : 122 points
Date : 2023-12-08 14:02 UTC (8 hours ago)
(HTM) web link (www.nongnu.org)
(TXT) w3m dump (www.nongnu.org)
| nerdponx wrote:
| Every once in a while I come back to this, and walk away feeling
| like it's not worth my time to learn.
|
| The language might be "objectively" simple, but it's not at all a
| simple language. There is no user guide, nor is there a nice
| readable language spec like R7RS. There's a reference manual, and
| a bunch of StackOverflow examples that look like Perl with
| S-expressions. I'd love to sit down and work through a reference
| manual, but who has time for that nowadays?
|
| I love the idea of a Lisp purpose-built for data processing, but
| practically I don't know what I'll gain by learning this that I
| don't already have with Python, Zsh, and Gauche Scheme.
|
| Can someone convince me otherwise? What's the killer feature of
| TXR that makes it worth the effort of learning it the hard way?
|
| Also, what's with the leading @-signs in some of the examples?
| Does that (try) form delimit some kind of block or region? Why
| are there some lines that look like bare string literals? It's
| clever and impressive to manually build a patch that can be
| applied with Git, but is this solution any cleaner or faster or
| easier to write or read than the equivalent in Python or Perl or
| Gauche or Guile or Common Lisp?
| https://stackoverflow.com/a/37336801/2954547
| usgroup wrote:
| You should learn Prolog sir: for the man that has everything.
| nerdponx wrote:
| I actually started down that path last year, with the
| incredible Power of Prolog book and video series. It's one of
| the more impressive learning resources I have ever come
| across.
| usgroup wrote:
| Prolog is only for the brave and true: when the student is
| ready, the teacher will appear :-)
| mmcdermott wrote:
| I think a lot of the difficulty in Prolog comes down to
| the fact that you can read Prolog programs three ways: as
| a restricted form of first order logic (Horn clauses), as
| a procedure, and as an execution model. The last is
| double confusing because almost all programmers are used
| to controlling the execution model and Prolog demands
| that you relinquish a lot of control there ("Algorithm =
| logic + control" by Kowalski talks about this a bit). You
| also cannot ignore any of them because any non-trivial
| Prolog program exploits all three.
| usgroup wrote:
| Yeah I think that's right. I'm doing Advent of Code in
| Prolog at the moment and checking other people's
| solutions -- I've yet to see 2 Prolog solutions which are
| mostly the same. The admixture you described results in
| code that aligns very closely with the thinker, and less
| closely with a specific procedure. Its very weird to see.
|
| Having said that -- once you get Prolog and use it for a
| while, your brain (at least my brain) wants to replace
| EVERYTHING with Prolog.
| stcg wrote:
| > The language might be "objectively" simple, but it's not at
| all a simple language.
|
| You could say that it's simple but not easy
| vcdimension wrote:
| I got stuck into txr lisp a few years ago, and wrote some code
| for parsing bank statements. It has a builtin DSL (the @
| syntax) which is great for text processing (better than perl
| IMO). It's also a fun language to learn, with lots of cool
| features such as combinators, continuations, macros, pattern
| matching, range objects, JSON objects, etc. It's more powerful
| than python, R or julia and would make a great successor to
| those languages for data science, but there are very few
| libraries ATM so that's a long journey. Here are some I wrote
| (including a zsh script for browsing the manual):
| https://github.com/vapniks/txr-libs IMO a good first step would
| be to use the txr FFI to write a library for Apache arrow:
| https://arrow.apache.org/
| nerdponx wrote:
| Thanks for that! Do you have advice for learning it? How did
| you get started, and what made you decide to stick with it
| instead of other languages?
|
| I'm happy to try to use it for Advent of Code 2024, but it
| would help if I could at least get oriented so I'm not going
| in totally cold (and thereby likely to fall off the wagon
| after 3 days because each one takes 2 hours in an unfamiliar
| language).
|
| The data science use case is particularly interesting and not
| something I had considered here. Arrow bindings help
| immensely. Of course at work I'll probably never get a chance
| to use anything other than Python and R for many years to
| come; maybe Julia is the most exotic I think I'd ever be able
| to go, and that's only if I ever hit a performance bottleneck
| in Python that can't be remediated with Numba.
| kazinator wrote:
| There are some Advent of Code 2021 solutions in TXR:
|
| https://www.kylheku.com/cgit/advent/tree
|
| That gives a flavor of how those kinds of problems can be
| approached.
|
| The solutions are all self-contained; they don't share any
| AoC-specific library or anything, and were developed with a
| throwaway program mindset, where we just solve that problem
| and don't try to produce anything that is reusable other
| than by copy paste into the next program.
| kazinator wrote:
| > _that I don 't already have with Python, Zsh, and Gauche
| Scheme._
|
| Those times when it would be nice for the Python-Zsh-Scheme
| solution to be in one language and program.
|
| > _is this solution any cleaner or faster or easier to write or
| read than the equivalent in Python or Perl or Gauche or Guile
| or Common Lisp?_
|
| I believe so because we can see the salient parts of the diff
| hunk structure appearing literally in the code, so we know at a
| glance where it is pulling what. I've not looked at that since
| 2016 but it's transparent.
|
| On top of that, any Python, Perl, Guile or Common Lisp solution
| can be transliterated to decent TXR Lisp. There are multiple
| ways to attack that same problem in TXR, not necessarily using
| the TXR Pattern Language.
|
| There are "spiritual ties" between TXR Lisp and Common Lisp.
| There probably isn't another language distinct from Common Lisp
| that is as similar to Common Lisp as TXR Lisp. The TXR Lisp
| reference manual mentions ANSI CL numerous times in various
| Dialect Notes.
|
| There is a translation to TXR Lisp of the CL-WHO HTML
| generation library called TL-WHO. It's a function-by-function
| translation that retains most of the structure of the original
| code. https://www.kylheku.com/cgit/tl-who/about/
|
| If you have CL skills and knowledge, a lot of it will transfer
| over to TXR Lisp, and vice versa. There will be things you will
| miss in either direction.
|
| By the way, here is another TXR program that matches unified
| diffs: diff2err:
|
| https://www.kylheku.com/cgit/diff2err/tree
|
| This reads diff material from standard in and converts it to
| compiler error format, stored in a file called errors.err
| (implicitly used by "vim -q" quickfix mode). This is useful for
| visiting differences in the actual code, with the editor: you
| can jump to all the places that were changed, and at every
| location, the diff info appears in diagnostic format: how many
| lines were changed, and what the original lines are.
| kazinator wrote:
| R7RS is readable because it's small; you could read it in one
| sitting.
|
| The writing style isn't particularly better than the one in the
| TXR manual.
|
| Both are specifications, and not tutorials.
|
| The Scheme world depends on R7RS for giving the requirements
| for the portable, common language core.
|
| Since TXR isn't a fragmented language family of incompatible
| implementations, there isn't any need to have a small document
| laying out what is common.
|
| Where is the hyperlinked, HTML version of R7RS? Every time I
| need to look up something in that, I have to use a clunky PDF.
|
| A search "HTML R7RS", shows mostly old posts in mailing lists
| and forums asking the same question. That and someone's github
| repo containing what seems to be source for generating a HTML-
| ized R7RS.
|
| The TXR manual is available in usefully (though imperfectly)
| hyper-linked HTML, PDF as well as a man page: just "man txr"
| and /search. When you type (doc 'symbol) in the listener, it
| jumps your browser to that section of the manual (the
| externally hosted version, easily retargetable to a local copy
| by changing the value of *doc-url*.
| nathell wrote:
| The author, Kaz Kylheku, hangs out on HN as kazinator.
| Loxicon wrote:
| > remove verbosity from Lisp programming
|
| Common lisp verbosity is a feature. It make's it very clear what
| is happening. Everyone understands.
| SuperNinKenDo wrote:
| Yeah. I personally agree, though maybe we're not the target
| audience. If I saw some examples of exactly how it does this I
| might change my mind, but with none right there on the page,
| I've lost interest before I can muster motivation to go look
| for them myself.
|
| Apparentlt the author hangs out here, so I'd recommend the
| author stick in some links to examples there if they don't want
| to muddy up the introduction page, because I think plenty of
| people that like lisp (not all, but plenty) will see this as an
| anti-feature without proof to the contrary.
| ww520 wrote:
| This looks like an interesting language. It tries to address many
| shortcomings in old lisp by introducing new semantics and new
| syntax. It looks like a pragmatic language aiming to get out of
| the programmers' way and let them focus on solving problems.
| dang wrote:
| Related:
|
| _TXR Lisp - an innovative, original dialect from the Lisp
| language family_ - https://news.ycombinator.com/item?id=24449511
| - Sept 2020 (1 comment)
|
| _TXR Lisp_ - https://news.ycombinator.com/item?id=22683735 -
| March 2020 (9 comments)
|
| _TXR: An Original, New Programming Language for Convenient Data
| Munging_ - https://news.ycombinator.com/item?id=21699927 - Dec
| 2019 (2 comments)
|
| _TXR - A Programming Language for Convenient Data Munging_ -
| https://news.ycombinator.com/item?id=19908197 - May 2019 (73
| comments)
|
| _TXR: An Original, New Programming Language for Convenient Data
| Munging_ - https://news.ycombinator.com/item?id=12338441 - Aug
| 2016 (2 comments)
|
| _TXR: A Programming Language for Convenient Data Munging_ -
| https://news.ycombinator.com/item?id=8409391 - Oct 2014 (38
| comments)
|
| _Show HN: Munge your data with TXR_ -
| https://news.ycombinator.com/item?id=8020106 - July 2014 (1
| comment)
___________________________________________________________________
(page generated 2023-12-08 23:00 UTC)