yamlscript

Markus Agwin 2024-04-21T16:40:19.988299Z

I think there is a story for YAMLScript in Python-dominated data-science. I used ys --compile to feed the Ferret-Clj->C++ compiler and do C++ interop with CERN's data analysis framework. The comparison Python/Clojure/YAMLScript is on https://github.com/kloimhardt/LisRoot#yamlscript .

😲 3
❤️ 2
Ingy döt Net 2024-04-22T11:42:57.656149Z

This is neat. Sorry I didn't see it until now. Been in transit. I'll see if I can get it running per the README. I might have a couple YS suggestions to make.

Ingy döt Net 2024-04-22T11:58:32.569189Z

I was a bit confused by the identity call in

newTF1: identity('pyf2') l -1. 1. 2
but I get why now. You wanted:
newTF1: 'pyf2' l -1. 1. 2
but that's invalid YAML. This is common in YS; a plain (unquoted) scalar begins with a yaml syntax char. These are common '"*[{. YS let's you escape that with a leading . , so:
newTF1: .'pyf2' l -1. 1. 2
is idiomatic there 🙂

Ingy döt Net 2024-04-22T12:02:45.242679Z

YS ends up having many ways to write expressions.

newTF1 'pyf2': l -1. 1. 2
# or:
=>: newTF1('pyf2' l -1. 1. 2)
Would have worked also.

Ingy döt Net 2024-04-22T12:05:44.540749Z

You could have even gone full-lisp with something like:

doto:
  (newTF1 "pyf2" l -1. 1. 2)
  (SetParameters 5. 2.)
  (Draw)
I wouldn't, but just showing you you can.

Ingy döt Net 2024-04-22T14:05:02.737439Z

I got it working!

Ingy döt Net 2024-04-22T14:05:23.031549Z

Working on a PR for you 🙂

Markus Agwin 2024-04-22T14:33:37.745399Z

I am so glad that this really works! You made my day. I think no-one ever tried this shade-blossom. Based on your suggestions I tinkered a bit with the syntax. Decided to use S-Exp for the ROO/T macro, Yes-Exp for the higher order function Linear and YAML-Exp for the normal functions.

Ingy döt Net 2024-04-22T14:46:10.486629Z

If you

defn Linear():
  fn([x] [d k]):
    (+ d (* k x))
you can get rid of:
sed 's/+_/+/g' |
  sed 's/*_/*/g' |

Markus Agwin 2024-04-22T14:46:55.143369Z

Here my three (S, Yes, YAML) versions of higher order function calls, The YAML-Exp needs to involve apply, right?

(f(1 2) 3)

f(1 2): 3

apply:
   f: 1 2
   list: 3

Ingy döt Net 2024-04-22T14:47:02.750519Z

The +++ thing I was already planning to remove. I can get that released soon

Ingy döt Net 2024-04-22T14:47:30.823929Z

and the blank:: thing is a bug on my part

Markus Agwin 2024-04-22T15:04:49.160079Z

I do not want to move to prefix-math. That is because in our research paper, saying that for science Lisp is better than Python, one weakness is exactly the prefix-math. And YAMLScript removes this weakness, that is a major improvement. I need to stick to infix math.

Ingy döt Net 2024-04-22T15:07:26.492239Z

makes sense. YS uses polymorphic +_ and *_. I'd like it if you didn't have to postprocess the compiled YS. Can you define your own clojure.core/+_ and *_?

Ingy döt Net 2024-04-22T15:09:49.855969Z

$ ys -Cpe '[+_ *_ + *]'
[#object[ys.std$_PLUS__ 0x3dd86908 "ys.std$_PLUS__@3dd86908"]
 #object[ys.std$_STAR__ 0x6bf4819b "ys.std$_STAR__@6bf4819b"]
 #object[clojure.core$_PLUS_ 0xfebe864 "clojure.core$_PLUS_@febe864"]
 #object[clojure.core$_STAR_ 0x472cbef2 "clojure.core$_STAR_@472cbef2"]]

Markus Agwin 2024-04-22T15:13:10.841679Z

I am currently looking into Ferret how to define + and *

Ingy döt Net 2024-04-22T15:15:05.209669Z

I'm looking at the blank:: problem

Ingy döt Net 2024-04-22T15:35:04.975399Z

fixed the blank:: problem 🙂

🎉 1
Ingy döt Net 2024-04-22T15:40:08.049549Z

Pushed: you can test with:

git clone git@github.com:yaml/yamlscript
make -C yamlscript/ys install
will install ~/.local/bin/ys

👍 1
Ingy döt Net 2024-04-22T16:59:11.353159Z

I fixed +++

Markus Agwin 2024-04-22T17:22:03.374719Z

I fixed blank +++ +_ *_ on my side. Still using ys0.1.56 so the world can continue to conveniently digest the first example of the future standard scientific notation :-)

Ingy döt Net 2024-04-22T17:22:42.102469Z

I can put out 0.1.57 in a few minutes

Ingy döt Net 2024-04-22T17:22:50.660449Z

how long are you around?

Markus Agwin 2024-04-22T17:23:36.591789Z

I am around for the next hours including some breaks

Ingy döt Net 2024-04-22T17:24:11.896709Z

cool

Ingy döt Net 2024-04-22T17:24:21.858599Z

have you pushed your changes?

Markus Agwin 2024-04-22T17:25:04.943579Z

pushed yes. I just added the namespace yslib.cxx

Ingy döt Net 2024-04-22T17:25:46.499359Z

cxx would work with 0.1.57, but that's fine

Ingy döt Net 2024-04-22T17:26:03.931959Z

glad to find/fix the bug

Ingy döt Net 2024-04-22T17:26:50.428349Z

are you on linux or mac?

Markus Agwin 2024-04-22T17:26:59.929319Z

I am mac

Ingy döt Net 2024-04-22T17:27:25.318229Z

intel or arm?

Markus Agwin 2024-04-22T17:27:56.055979Z

Intel i5

Ingy döt Net 2024-04-22T17:28:11.792139Z

ok thanks

Ingy döt Net 2024-04-22T17:29:28.140559Z

pushed the +++ fix if you want to rebuild and test while I release this

Markus Agwin 2024-04-22T17:31:44.237379Z

Its time for supper around here, I‘ll pass on the rebuild…

Ingy döt Net 2024-04-22T17:31:54.978169Z

ok

Ingy döt Net 2024-04-22T18:29:21.808449Z

https://github.com/yaml/yamlscript/releases/tag/0.1.57 Released

🙏 1
Ingy döt Net 2024-04-22T18:56:05.332989Z

dang it. I made this work:

require foo: => bar
but not this:
require:
  foo: => bar
😕

Ingy döt Net 2024-04-22T18:56:24.261279Z

will fix later. you don't need it anyway 🙂

Markus Agwin 2024-04-22T18:58:01.203869Z

I was just writing about this...

Markus Agwin 2024-04-22T18:58:28.759529Z

thank you for the hint

Markus Agwin 2024-04-22T19:02:06.487989Z

got the require foo: => bar to work. I'm happy!

Markus Agwin 2024-04-22T19:08:58.685069Z

Thanks a lot for the special cut release! I'll call it a day...

Ingy döt Net 2024-04-22T19:09:11.867689Z

You bet...

Ingy döt Net 2024-04-22T19:09:21.834489Z

I'm working on a PR still

Ingy döt Net 2024-04-22T19:09:29.317279Z

you'll see it tomorrow

Ingy döt Net 2024-04-22T19:09:41.196009Z

I need to switch gears for a while

💯 1
Ingy döt Net 2024-04-26T02:36:18.857869Z

I made the fix this morning but haven't had time to release it yet. FYI

🙏 1
Markus Agwin 2024-04-26T09:27:36.524639Z

as week draws to an end ... tried git clone - make build ... my i5 Mac breathed heavily ... my nerves steeled enough in weekend prospect ... it worked! (I should have bet, I know, but I wouldn't have before seeing the success) ... !!! the Graal build magically worked without having Graal on the machine in the first place!!!... now if you have a git branch with the newest updates, pls. post its name.

🙌 1
Ingy döt Net 2024-04-26T09:50:03.419089Z

Your machine also didn't need Clojure or a JDK. The YS Makefile build system downloads 2 things (into /tmp): • The OS/Arch appropriate GraalVM tarball • The 458 line Bash script called lein And sets 2 env vars: JAVA_HOME and PATH The tarball contains a complete JDK, so now you have everything you need to run Clojure, Java and GraalVM's native-image compiler on any machine that native-image supports :)

Ingy döt Net 2024-04-26T09:51:00.194059Z

I'm not sure how widely this has been known/discovered in the Clojure world. I haven't seen it elsewhere.

Ingy döt Net 2024-04-26T10:11:55.316159Z

The prereqs are only Gnu make, bash and curl... I think that's pretty powerful way to sell Clojure based tools, to the Java adverse... 🙂

😎 1
Ingy döt Net 2024-04-26T10:13:25.571189Z

I haven't looked into pulling this off without lein yet (ie tools-deps)

Markus Agwin 2024-04-26T10:23:34.108959Z

this way is so awesome that noone will consciously recognize this way just by your homepage sentence „No Java or JVM installation is used to run (or build) YAMLScript programs“. It needs further expansion, at least the sentence: „your machine does not need Clojure or the JDK to even build the YAMLScript binary itself“, possibly with a link to some details to bolster confidence.

👍 1
Markus Agwin 2024-04-26T10:27:49.601709Z

maybe mention that „on Mac you need XCode package for the make util“, as for me it was not obvious how to get „make“ and a subsequent struggle to get XCode running on my i5

Ingy döt Net 2024-04-26T10:38:41.967729Z

brew install make ?

Markus Agwin 2024-04-26T10:38:48.433849Z

or maybe add a build.yaml in addition to „make“, dunno that makes sense … musing

Ingy döt Net 2024-04-26T10:39:10.836439Z

Musings welcome :)

Ingy döt Net 2024-04-26T10:40:46.269199Z

I want to have wiki pages for all kinds of stuff. Definitely for every error message (like shellcheck does) So I could link there from the ReadMe likely

Ingy döt Net 2024-04-26T10:43:26.281179Z

https://gist.github.com/ingydotnet/5fc7f0e4be87d13fb1a6094008964888#file-tmp-blxry8mlm1-L111-L114 is an example of running shellcheck on the lein command...

Ingy döt Net 2024-04-26T10:43:53.473059Z

I've long thought everyone should do this...

Ingy döt Net 2024-04-26T10:44:26.422719Z

I even bought the domain name to start that movement 😄

Ingy döt Net 2024-04-26T10:45:28.984579Z

Maybe my clone can handle that, sigh

Markus Agwin 2024-04-26T10:50:42.744249Z

well as a ClojureScript user I never heard of shellcheck let alone what it does. As well as this awsome build way, that shellcheck would need a blog post to explain the idea.

Ingy döt Net 2024-04-26T10:54:58.888819Z

Thanks for the feedback. And the encouragement. I'll give it a stab soon.

Ingy döt Net 2024-04-26T10:56:39.169649Z

Just pushed that fix I was talking about wrt require

👍 1
Ingy döt Net 2024-04-26T10:56:55.477249Z

Will do the 0.1.58 release now...

Markus Agwin 2024-04-26T11:01:10.036489Z

regarding lein vs tools-deps there is a debate. I know that the inspirer of my LisRoot, Jeaye Wilkerson of https://www.clojuriststogether.org/news/q2-2024-funding-announcement/#jank-jeaye-wilkerson is vocally pro lein.

Ingy döt Net 2024-04-26T11:17:32.108069Z

yes, I'm well aware. I know the core and most of community is moving to tools-deps, but the cool thing about lein is that it only really needs bash and curl . It needs a JDK too but now we see that doesn't need to be a permanent install. Clojurists assume a JDK and Clojure install. But that can be scary to non-java people, thus hard to sell Clojure based stuff to the world. (my opinion)

Markus Agwin 2024-04-26T13:01:03.664949Z

I certainly do share your opinion and more specifically add "Graal compilation indeed is scary". But today I saw through YAMLScript that Graal need not be scary, and that might have been a small step for you, but ...

Markus Agwin 2024-04-26T13:01:26.368069Z

... a big step for me

Markus Agwin 2024-04-26T14:15:47.832349Z

> Just pushed that fix I was talking about wrt require buildt and successfully tested the fix.

🙏 1
🍠 1
🎉 1