Skip to content
forked from janet-lang/janet

my personal scripting language

License

Notifications You must be signed in to change notification settings

eshrh/matsurika

 
 

Repository files navigation

This is 茉莉花[matsurika], a fork of the janet programming language. It is extremely unstable, unreadable, prone to change, and should not be used for anything.

You can find the full list of changes made in ./changes.org, which may fall out of date in time. Don’t expect any super great documentation either. Many common functions and macros are renamed for concision – I like janet but i’m not too fond of the module/function naming style. Many functions and macros are included in the interpreter to make things I need to do shorter, and some objects have significantly modified behavior. Most added functions can be found towards the end of boot.janet

The goal of this fork is to essentially become my personal scripting language, which is molded to match my tastes exactly. Much of this could have been implemented as a kind of standard library on top of janet, but forking the project allows for more freedom and the advantage of having a single binary for portability; at the disadvantage that I need to manually pull in important changes from upstream once in a while.

Principles

  1. use functional structures like higher order functions, composition, lambdas, etc
  2. drop the functional baggage required to deal with statefulness
  3. provide a flexible facility to shell out to other programs
  4. provide a rich library of functional list and string processing tools
  5. **be as concise as possible!**

For instance, here’s an example script that looks in the current dictionary, finds every `.mkv` file, finds its runtime by parsing the output of `mediainfo`, sums them up and then prints a total runtime.

(def files (->> ($ ls) (filter |(s-suffix? ".mkv" $))))
(def ans
  (reduce
   (fn [ac file]
     (let [line (->> ($ mediainfo $file)
                     (find |(s-prefix? "Duration" $))) # Duration : XX min XX sec
           [min sec] (-< (->> line (s->/ ":") (snd) (s/ " ") (map s->n))
                         (get 1)
                         (get 3))]
       (+ ac (* 60 min) sec))) 0 files))
(pp (/ ans 3600))

If this is unreadable to you, then i 100% agree.

Everything in this fork is centered around concision and versatility, for example, it inclueds a powerful awk macro implemented using Janet’s PEG system that lets you map arbitrary actions onto arbitrary matching PEGs.

The emacs directory contains some extra tooling. It includes a matsurika program to generate elisp readable docs which can then be used by matsurika-mode.el to provide autocompletion via company and docs look-up of functions (C-c C-d). Matsurika-mode is derived from clojure-mode to do a lot of heavy lifting primarily with indentation. I have always clojure-mode on my emacs anyway, so I don’t care about the dependency. Most of the program is based on janet-mode by ALSchwalm (GPL).

An extra program written in matsurika can be found in the tools directory which parses changes.org to apply all function renamings to a file. This is probably enough to get any standard janet program to run in matsurika. I have no interest in build systems or executable packaging, so the fact that jpm doesn’t work is a nonissue for me.

Any new code I’ve written should be considered as licensed under the GNU GPLv3 or later, you can find the license in the file GPL.

License from upstream janet:

Copyright (c) 2021 Calvin Rose and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

my personal scripting language

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 79.8%
  • Clojure 16.3%
  • TypeScript 1.0%
  • Makefile 0.8%
  • Meson 0.7%
  • Emacs Lisp 0.5%
  • Other 0.9%