cmu-infix VS trivia

Compare cmu-infix vs trivia and see what are their differences.

cmu-infix

Updated infix.cl of the CMU AI repository, originally written by Mark Kantrowitz (by quil-lang)

trivia

Pattern Matcher Compatible with Optima (by guicho271828)
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
cmu-infix trivia
4 7
32 322
- -
0.0 0.8
over 7 years ago 7 months ago
Common Lisp Common Lisp
GNU General Public License v3.0 or later GNU General Public License v3.0 or later
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

cmu-infix

Posts with mentions or reviews of cmu-infix. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-11-08.
  • From Common Lisp to Julia
    6 projects | news.ycombinator.com | 8 Nov 2022
    Fortunately doing infix math in CL has since the 90s been one small library include away: https://github.com/quil-lang/cmu-infix
  • Failing to Learn Zig via Advent of Code
    17 projects | news.ycombinator.com | 17 Jan 2022
    The Lisp version can also be more readable with a macro (like https://github.com/quil-lang/cmu-infix): #I(a(1.0-t) + bt). Or something else that would let you write GP's preferred syntax. One of the things that makes Lisp Lisp is that if the parens are over-cumbersome, you have the tools to take them away. See also CL:LOOP.
  • Why Lisp? (2015)
    21 projects | news.ycombinator.com | 26 Oct 2021
    (The list of forms are passed, unevaluated and at compile time, to nest, which rewrites them using a right fold to nest things properly.)

    Somewhat similar is the arrow macro that Clojure popularized, which lets you get rid of (deep (nesting (like (this ...)))) where you have to remember evaluation order is inside-out and replace it with a flatter (-> (this ...) like nesting deep). Its implementation is also easy -- many macros are easy to write because Lisp's source code is itself a list data structure for which you can write code to process and manipulate just like any other lists.

    Another cool macro that's been around since 1993 is https://github.com/quil-lang/cmu-infix which lets you write math in infix style, e.g. #I( C[i, k] += A[i, j] * B[j, k] ) where A, B, and C are all matrices represented as 2D arrays. It's a lot more complicated than the nest macro, though.

    There are some other things that still make Lisp great in comparison to other languages, but they don't exactly have one-line code examples like [::-1] and so I'll just describe them qualitatively. Common Lisp has CLOS, the first standardized OOP system. It's a lot more powerful than C++'s system. It differs from many systems in that classes and methods are separate; among other things this gives you multiple dispatch (you can define polymorphic methods that don't just dispatch to different code depending on the first argument (the explicit 'self' in Python, implicit 'this' in other langs) but all arguments). One thing it can be useful for is to get rid of many laborious uses of the Builder and Visitor patterns. e.g. the need for double dispatch is a common reason to use the Visitor pattern, but in Lisp there's no need. CLOS also does "method combination", which lets you define :before, :after, and :around methods that operate implicitly before/after/around a call. This gets rid of the Observer pattern, supports design-by-contract, and jives well with multiple inheritance in that you can create "mixins" that classes can "inherit" from with the only behavior being some :before/:after methods. (e.g. logging, or cleaning up resources, or validation.)

    Everything is truly dynamic -- a class can even change its type at runtime, which may be an acceptable solution to the circle-ellipse problem, or just super convenient while developing. More fundamentally, "compile" is a built-in function, not something you have to do with a separate program. "Disassemble" is built-in, too, so you can see what the compiler is doing and how optimized something is. You have full flexibility to define and redefine how your program works as it's running, no need to restart and lose state if you don't want to. Besides being killer for development (and all the differences in development experience comprise a big part of why I still think Lisp is great compared to non-Lisp), this gives you a powerful way to do production debugging and hot-fixing too -- a footgun you might not necessarily want most of the time, but you don't have to do anything special for it when you do want it. It can be very useful, e.g. if you've got a spacecraft 100 million miles from Earth https://flownet.com/gat/jpl-lisp.html I've also put some hobby stuff on a server, just deployed as a single binary, but built so that if I want to change it, I can either stop it, replace the binary, and start again, or just SSH in and with SSH forwarding connect to the live program with my editor and load the new code changes just like I would when developing locally, and thus have zero downtime.

    Lastly, Lisp's solution to error handling goes beyond traditional exception handling. Again this ties into the development experience -- you have some compile-time warnings depending on the implementation (e.g. typos, undefined functions, bad types) but you'll hit runtime errors eventually, Lisp provides the condition system to help deal with them. It can be used for signaling non-errors, which has its uses, but what you'll see first are probably unhandled errors. By default one will drop you into a debugger where the error occurred, the stack isn't immediately unwound. Here you can do whatever -- inspect/change variables on different stack frame levels, recompile code if there's a way to fix things, restart computation at a specific frame... You'll also be given the option of "restarts", which might include just an "abort" that unwinds to the top level (possibly ending a thread) but can include custom actions as well that could resolve the error in different ways. For example, if you're parsing a CSV file and hit a value that is wrong somehow (empty, bad type, illegal value, bad word, whatever), your restarts might be to provide your own value or some default value (which will be used, and the computation resumes to parse the next value in the row), or skip the whole row (moving on to the next one), or skip the whole file (moving on to the next file, or finishing). Again this can be very useful while debugging, but in production you can either program in default resolutions (and a catch-all handler that logs unhandled errors, as usual) or give the choice to the user (in a friendlier way than exposing the debugger if you please).

  • An Intuition for Lisp Syntax
    4 projects | news.ycombinator.com | 27 May 2021
    You don't have to give up on anything, that's the beauty of Lisp. Here's a library from 1993: https://github.com/quil-lang/cmu-infix

    Though personally I don't particularly find (+ 1 2 3 4 5) less readable than 1+2+3+4+5, and since most of my programs don't have math expressions much more complicated than that, even without cmu-infix I'd find the rest of the tradeoffs worth it, much like once I thought despite Python not having i++ or ++i it was still worthwhile. (In Lisp, by the way, one would use (incf i).)

trivia

Posts with mentions or reviews of trivia. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-02-03.
  • Compiling Pattern Matching
    3 projects | news.ycombinator.com | 3 Feb 2024
    I've used it. :)

    https://github.com/guicho271828/trivia/issues/108

  • Pattern matching macros vs functions?
    1 project | /r/emacs | 29 Nov 2022
    You can see it, for instance, in the Trivia library ( https://github.com/guicho271828/trivia/blob/master/level0/impl.lisp ): the macro match0 is a thin wrapper around the function parse-patterns, and this, in turn, calls the function make-pattern-predicate which performs the recursive destructuring of patterns.
  • From Common Lisp to Julia
    6 projects | news.ycombinator.com | 8 Nov 2022
    I can agree it's not the same, but what's the point? A more interesting disagreement is that I wouldn't say it's a downside (though yes, there are tradeoffs). Especially in Current Year when open source is fashionable and pretty much every language has a package manager to make pulling in or swapping out dependencies pretty easy, I don't see the issue. It's also interesting to note that of all the things Clojure did to "fix" shortcomings of past languages with a more opinionated (and often more correct I'll admit) design philosophy that users are forced to use (even when it's not more correct), infix-math-out-of-the-box wasn't one of them. I don't think that specifically really hurt Clojure adoption. (But of course Clojure is reasonably extensible too so it also has a macro package to get the functionality, though it's more fragile especially around needing spaces because it's not done with reader macros.)

    I've brought the library up many times because CL, unlike so many other languages, really lets you extend it. Want a static type system? https://github.com/coalton-lang/coalton/ Want pattern matching? No need to wait for PEP 636, https://github.com/guicho271828/trivia/ If all that keeps someone from trying CL, or from enjoying it as much as they could because of some frustration or another, due to lacking out of the box, chances are it is available through a library.

  • LEM - What If Emacs Was Multithreaded
    6 projects | /r/emacs | 23 Apr 2022
    Great libraries like trivia, iterate/for/alternative loop libraries, alexandria, and a hundred others. Common Lisp is a general purpose programming language with good support for ffi, working with files, databases, images, audio, etc. Just skim awesome-cl if you haven't. You could argue this doesn't have to do with the language, but a lot of these libraries are so good (or even possible) in part because of language features elisp does not have.
  • Pattern Matching Accepted for Python
    11 projects | news.ycombinator.com | 9 Feb 2021
    > After much deliberation, the Python Steering Council is happy to announce that we have chosen to accept PEP 634, and its companion PEPs 635 and 636, collectively known as the Pattern Matching PEPs

    This is why I'm still enamored with Lisp. One doesn't wait around for the high priests to descent from their lofty towers of much deep pontification and debate with shiny, gold tablets inscribed with how the PEPs may be, on behalf of the plebes. One just adds new language feature themselves, eg. pattern matching[1] and software transactional memory[2].

    1. https://github.com/guicho271828/trivia

    2. https://github.com/cosmos72/stmx

  • Show HN: Powerful Python Pattern Matching Library
    2 projects | news.ycombinator.com | 2 Jan 2021
    The source is impressively simple! Good job!

    I have been implementing a pattern matcher for scheme based on the Balland pattern optimized, and every time I see pattern matchers for python I always get the feeling that the code you are replacing have to be truly awful for the rather contrived pattern matching syntax to be a net win. Compare any of the python pattern matchers to something like trivia in Common Lisp [0] and you see what I mean.

    How do people use the python pattern matchers? I am genuinely curious. One benefit that I see is that you can build patterns at run-time which could be useful.

    [0]: https://github.com/guicho271828/trivia/wiki/Type-Based-Destr...

What are some alternatives?

When comparing cmu-infix and trivia you can also consider the following projects:

LoopVectorization.jl - Macro(s) for vectorizing loops.

python-imphook - Simple and clear import hooks for Python - import anything as if it were a Python module

cl4py - Common Lisp for Python

MLStyle.jl - Julia functional programming infrastructures and metaprogramming facilities

fructure - a structured interaction engine 🗜️ ⚗️

awesome-pattern-matching - Pattern Matching for Python 3.7+ in a simple, yet powerful, extensible manner.

LIBUCL - Universal configuration library parser

peps - Python Enhancement Proposals

janet - A dynamic language and bytecode vm

awesome-cl - A curated list of awesome Common Lisp frameworks, libraries and other shiny stuff.

zig - General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

flynt - A tool to automatically convert old string literal formatting to f-strings