lingy

slipset 2023-07-27T16:17:30.614579Z

@slipset has joined the channel

Ingy döt Net 2023-07-27T16:17:49.891699Z

Welcome @slipset;)

slipset 2023-07-27T16:17:57.721669Z

Thank you 🙂

Ingy döt Net 2023-07-27T16:18:30.910099Z

Actually I thought of something that you could help with opinion-wise

slipset 2023-07-27T16:18:43.543669Z

Shoot

Ingy döt Net 2023-07-27T16:18:59.386429Z

Lingy(Perl) has OO interop...

Ingy döt Net 2023-07-27T16:19:14.479979Z

Let me repl a couple things. sec

Ingy döt Net 2023-07-27T16:23:07.261989Z

user=> (import YAML.PP)
YAML.PP
user=> (println (.dump_string (.new YAML.PP) [2 3 4]))
---
- '2'
- '3'
- '4'

Ingy döt Net 2023-07-27T16:23:39.023959Z

https://metacpan.org/pod/YAML::PP

Ingy döt Net 2023-07-27T16:23:54.386529Z

also perl eval...

Ingy döt Net 2023-07-27T16:25:54.282869Z

user=> (perl "for my $i (1..4) { print \"$i\\n\" }; 123")
1
2
3
4
123
user=> 

Ingy döt Net 2023-07-27T16:26:15.770719Z

the 123 was to hide a bug I just found 😄

slipset 2023-07-27T16:27:30.262089Z

I see that in difference to Clojure, you treat new as a fn (or method). Which makes sense for Perl I guess because it is just that.

slipset 2023-07-27T16:28:06.553189Z

In Clojure you’d write (YAML.PP. )

Ingy döt Net 2023-07-27T16:29:51.432349Z

sorry had to file bug: https://github.com/lingy-lang/lingy/issues/55

Ingy döt Net 2023-07-27T16:30:44.725949Z

user=> (println (.dump_string (YAML.PP.) [2 3 4]))
---
- '2'
- '3'
- '4'

nil

Ingy döt Net 2023-07-27T16:30:47.476359Z

🙂

slipset 2023-07-27T16:31:54.732989Z

-> FAIL Installing Time::HiRes failed. See /Users/erik/.cpanm/work/1690475412.86147/build.log for details. Retry with --force to force install it.
-> FAIL Installing the dependencies failed: Installed version (1.9760) of Time::HiRes is not in range '1.9764'
-> FAIL Bailing out the installation for Lingy-0.1.19.
😞

Ingy döt Net 2023-07-27T16:32:43.521409Z

is that cpanm Lingy?

slipset 2023-07-27T16:32:52.293909Z

yes

Ingy döt Net 2023-07-27T16:33:05.267929Z

trying on my M1

slipset 2023-07-27T16:33:31.654559Z

erik@keep  % perl --version

This is perl 5, version 30, subversion 3 (v5.30.3) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)

Copyright 1987-2020, Larry Wall

slipset 2023-07-27T16:33:43.992059Z

With a very fresh cpanm install

slipset 2023-07-27T16:34:10.891299Z

erik@keep  % cpanm --version
cpanm (App::cpanminus) version 1.7046 (/opt/homebrew/bin/cpanm)
perl version 5.030003 (perl)

Ingy döt Net 2023-07-27T16:35:02.767799Z

worked here 😕

Ingy döt Net 2023-07-27T16:35:38.739509Z

I get it

Ingy döt Net 2023-07-27T16:36:58.187499Z

sec

Ingy döt Net 2023-07-27T16:40:44.589109Z

That's my fault and I will fix it fast but can you try something?

Ingy döt Net 2023-07-27T16:41:07.312839Z

Run cpanm --look Lingy puts you in a subshell

Ingy döt Net 2023-07-27T16:41:33.920809Z

edit Makefile.PL and set the Time::HiRes version to "0"

Ingy döt Net 2023-07-27T16:41:45.580899Z

then run cpanm .

Ingy döt Net 2023-07-27T16:42:04.604329Z

if you don't mind

slipset 2023-07-27T16:45:10.609449Z

Getting there

slipset 2023-07-27T16:46:08.416709Z

erik@keep  % lingy -D
Please install Term::ReadLine::Gnu from CPAN
erik@keep  %

Ingy döt Net 2023-07-27T16:57:15.572559Z

do it 🙂

Ingy döt Net 2023-07-27T16:57:42.204289Z

I had to not dep on Term:Readline:Gnu because of windows issues

Ingy döt Net 2023-07-27T16:57:57.949379Z

But the lingy --repl needs it

slipset 2023-07-27T16:58:09.951299Z

How do I install that? Perl n00b

Ingy döt Net 2023-07-27T16:58:26.721869Z

cpanm 🙂

slipset 2023-07-27T16:59:46.541379Z

D’oh, ReadLine not Readline

slipset 2023-07-27T16:32:12.140379Z

M1 Macbook Pro

Ingy döt Net 2023-07-27T16:32:13.183779Z

user=> (macroexpand '(YAML.PP.))
(. YAML.PP new)
user=> (macroexpand '(.new YAML.PP))
(. YAML.PP new)
user=> 

Ingy döt Net 2023-07-27T16:45:45.261199Z

@slipset anyway, in Java everything's an object. so interop is straightforward. In perl the data types are operated on with syntax, operators and keywords.

Ingy döt Net 2023-07-27T16:46:06.240849Z

I want to make a library/namespace for all the keywords

Ingy döt Net 2023-07-27T16:46:22.213809Z

Basically what's in *CORE::

Ingy döt Net 2023-07-27T16:47:06.536129Z

user=> (perl "pack 'WWWW', 65, 66, 67, 68")
ABCD

slipset 2023-07-27T16:47:34.920129Z

Right, where pack is an operator or somthing?

Ingy döt Net 2023-07-27T16:47:44.295149Z

I would do

(pl/pack "WWWW" 65 66 67 68)

slipset 2023-07-27T16:47:52.711539Z

yes!

Ingy döt Net 2023-07-27T16:48:07.114929Z

pack is a perl keyword func

Ingy döt Net 2023-07-27T16:48:28.611509Z

perldoc perlfunc

Ingy döt Net 2023-07-27T16:48:34.556139Z

Ok awesome

slipset 2023-07-27T16:49:17.613469Z

It’s been probs 20 years since last time I programmed Perl, so I’m a bit rusty 🙂 I also remember pack as one of the harder things to grok 🙂

Ingy döt Net 2023-07-27T16:49:25.447039Z

I was talking it over with @pez a couple days ago but good to know you agree

slipset 2023-07-27T16:50:56.697159Z

So one of the things that Clojure is struggeling with which I believe is being worked on is stuff like:

user> (map Math/abs (range 3))
Syntax error compiling at (*cider-repl ).
Unable to find static field: abs in class java.lang.Math
user> 
Which is just plain old annoying 🙂

Ingy döt Net 2023-07-27T17:10:39.521469Z

@slipset I don't really get why that doesn't work

Ingy döt Net 2023-07-27T17:10:44.315139Z

Can you explain?

slipset 2023-07-27T17:12:09.858019Z

Not really. And it’s dinner time :)

Ingy döt Net 2023-07-27T17:15:03.294819Z

Bon appetit 🙂

slipset 2023-07-27T16:52:56.576109Z

I think there is a fine line in interop between exposing too much of the idiosyncrasies of the host and hiding too much of them.

slipset 2023-07-27T16:53:59.134579Z

Like, from a Clojure point of view I don’t care if Perl has syntax or operators or keywords for doing a thing, I’d just like to gloss over that and perhaps say (perl/+ 5 6) (stupid example since + is in clojure.core.

slipset 2023-07-27T16:54:43.905929Z

But it’s also very annoying with leaky abstractions and you’d have to remember that because + is an operator in Perl it behaves slightly different than what pack does since pack is a keyword func.

slipset 2023-07-27T16:55:07.136249Z

(if that were the case, I’m being hypothetical here)

Ingy döt Net 2023-07-27T16:55:25.234149Z

(pl/-f path)

Ingy döt Net 2023-07-27T16:56:06.912489Z

Still trying to suss out why (map Math/abs (range 3)) fails

slipset 2023-07-27T16:56:08.960369Z

Yah, but you’d might want to expose that throuh clojure.io.perl or something to mimic clojure.io.java

Ingy döt Net 2023-07-27T16:56:27.558019Z

nod

Ingy döt Net 2023-07-27T16:56:44.105359Z

(this is really helpful btw) 😄

slipset 2023-07-27T16:59:13.619329Z

But then again, do you expose -f through both clojure.io.perl and perl/-f The former would be for the convenience of the Clojure programmer, the latter for the convenience of the Perl programmer 🙂

slipset 2023-07-27T16:59:15.887099Z

Perhaps both?

Ingy döt Net 2023-07-27T17:02:12.213919Z

yep

slipset 2023-07-27T17:02:54.158049Z

Lingy starts quickly 🙂

Ingy döt Net 2023-07-27T17:03:01.960699Z

it would be lingy.io.perl or lingy.io.host

slipset 2023-07-27T17:04:11.402229Z

And I saw you asked about cljc files. I believe that @borkdude implemented reader conditionals for babashka, you probably want that for lingy as well.

Ingy döt Net 2023-07-27T17:05:51.802219Z

$ time clojure -e '(time 42)'
"Elapsed time: 0.012903 msecs"
42

real	0m0.964s
user	0m2.334s
sys	0m0.085s
$ time lingy -e '(time 42)'
"Elapsed time: 0.07 msecs"
42

real	0m0.136s
user	0m0.108s
sys	0m0.029s

Ingy döt Net 2023-07-27T17:06:15.305229Z

clojure is much faster after starting

Ingy döt Net 2023-07-27T17:06:23.720169Z

(for now 🙂 )

slipset 2023-07-27T17:06:57.961219Z

At some point in time I implemented an http client in an early version of https://github.com/planck-repl/planck because I wanted to use it for some simple scripting which needed http/get now, now would I go about using something like Perl libwww (I guess) if I wanted to do (http/get "") from lingy?

Ingy döt Net 2023-07-27T17:13:34.356479Z

I'd have to try. The perl interop is still a wip. Some things don't work as expected. All Lingy data values are class objects so things need to be boxed and unboxed. Some works some not.

slipset 2023-07-27T17:08:37.466119Z

And more ideas for free. One thing that Plank was missing at the time was some way to define the packages your program depended on. So It would be neat if lingy had something deps.edn like that also understood how to depend on cpan stuff.

Ingy döt Net 2023-07-27T17:11:36.472689Z

already been discussing that with @seancorfield 🙂

2023-07-27T23:26:50.228729Z

Shadow.cljs has achieved the analogous for NPM; perhaps there is a model to consider

2023-07-27T23:30:55.305099Z

In re the namespaces for common affordances... There is also a pattern. clojure.core and cljs.core are twins. Likewise clojure.pprint and cljs.pprint, clojure.reader and cljs.reader, and a few others. The ClojureScript compiler accepts code that require's http://clojure.xyz, by using http://cljs.xyz instead. This eases writing portable Clojure-ish programs.

2023-07-27T23:37:19.942749Z

In re using Math/abs as if it were a function: in Clojure first-class functions are objects implementing IFn and Math/abs is not such a thing. (macroexpand-1 '(Math/abs 42)) shows (. Math abs 42). But Math (full name java.lang.Math) is host interop, no expectation of similarity on another host.

Ingy döt Net 2023-07-27T23:37:55.971939Z

I pay attention in about 15m

Ingy döt Net 2023-07-28T00:01:04.636449Z

Here now

Ingy döt Net 2023-07-28T00:04:40.600239Z

@phill Lingy is intending to use clojure/core.clj directly. It does so partially now: https://github.com/lingy-lang/lingy/blob/main/perl/lib/Lingy/core.clj

Ingy döt Net 2023-07-28T00:06:26.336159Z

Lingy maps Clojure clojure.lang. namespaces to lingy.lang. equivalents and known Java classes to Perl counterparts

Ingy döt Net 2023-07-28T00:08:37.275119Z

Since Lingy intends to be multi-host I am considering some class name porting to go from java.lang. to host.lang. instead of perl.lang.

Ingy döt Net 2023-07-28T00:09:19.361999Z

whatever the best ways are to get the most use and least duplication out of source files.

Ingy döt Net 2023-07-28T00:11:20.721079Z

Thanks for the insights re the java native Math class

Ingy döt Net 2023-07-28T00:13:27.550609Z

@phill if it were a clojure.lang.Math class then it would implement IFn, right?

2023-07-28T00:15:03.254699Z

Er - All (fn ...) implement Clojure's Java interface "IFn" and I'm sure the Clojure inventors would have made host functions (Java "static methods") first-class if they could figure out how to do so. If a Perl sub {...} could be a first-class function in Lingy, super!

Ingy döt Net 2023-07-28T00:15:41.765799Z

like java.lang.Long vs clojure.lang.Numbers

Ingy döt Net 2023-07-28T00:17:49.719949Z

At this point Lingy doesn't do compilation. It does make Lingy::Fn objects from (fn ...) forms. and those objects are blessed Perl closures (functions)

Ingy döt Net 2023-07-28T00:18:22.568199Z

but compilation (possibly to a super fast VM) is an intended area of research

Ingy döt Net 2023-07-28T00:19:20.213719Z

and the Lingy data types are all tied objects, not first class. for immutability and methods

2023-07-28T00:19:23.528359Z

I think the area for ideal compatibility is pretty much limited to what's documented at https://clojure.github.io/clojure/ ... minus the "clojure.java...." stuff like http://clojure.java.io. Every host differs in those respects. Presumably someone could make a clever asynchronous I/O package that could be used portably, but nothing with blocking I/O will work in JavaScript. The Java-language underpinnings of Clojure are not replicated in ClojureScript, which sort of sets the tone for other ports. According to rumor, ClojureScript is closer to "Clojure-in-Clojure" on account of having used Clojure protocols internally.

Ingy döt Net 2023-07-28T00:19:38.814319Z

but I want them to become HAMT based things

Ingy döt Net 2023-07-28T00:22:05.285779Z

interesting stuff. I'm glad to have people with this level of insight into clojurescript to chat with as I have very littel experience with it so far. but of course I have been wondering WWCSD? 😉

2023-07-28T00:29:46.589759Z

Somewhere, I saw Clojure contrasted with Ruby in this regard. Ruby wraps the whole host standard library, or so I heard. Clojure wraps almost none of it. A striking example is that the (throw ... (catch ...)) model is standard across Clojure-ish ports but it is not possible to write a portable catch clause. The exceptions are host exceptions. So Perl's $@ would fit right in.

2023-07-28T00:31:36.689589Z

I think a portable runtime library might be very welcome, as an add-on, for convenience where the cost of wrapping was not a concern.

Ingy döt Net 2023-07-28T00:32:16.299159Z

I'm thinking about something called LingyVM that might be that

Ingy döt Net 2023-07-28T00:33:28.013689Z

Re throw/catch the https://github.com/kanaka/mal/tree/master/impls does that the same for about 70+ langs

Ingy döt Net 2023-07-28T00:33:39.560829Z

including ruby

Ingy döt Net 2023-07-28T00:33:55.167229Z

or maybe I misundersand you

Ingy döt Net 2023-07-28T00:34:45.191009Z

they all do TCO too (with a test suite that won't finish if implemented wrong, to prove it)

Ingy döt Net 2023-07-28T00:35:00.983769Z

even though Clojure doesn't have native TCO

Ingy döt Net 2023-07-28T00:35:40.144829Z

Lingy has TCO and recur

2023-07-28T00:51:47.711229Z

Yeah Perl has a very nice goto that can go-to a function

2023-07-28T00:53:18.815569Z

There are some exception libraries for Clojure. I think the core language's ideal was to add no run-time cost. Therefore, it uses host exceptions, whatever those might be.

2023-07-28T00:55:09.403829Z

I thought I had seen everything, and then I noticed that in ClojureDart the "catch" clause has an extra parameter because Dart exceptions have the stack trace external to the exception object.

Ingy döt Net 2023-07-28T00:55:48.559269Z

I learned while making my MAL implementation how perl's goto actually works. Iirc it simply does a return at that point and then calls the subroutine that you goto'd to!

Ingy döt Net 2023-07-28T00:57:51.593179Z

Lingy definitely adds runtime cost at this point but since I am free to compile into whatever I can imagine and make it work, the goal is to make it as fast as C extensions in Perl.

Ingy döt Net 2023-07-28T00:58:34.580969Z

So you get a massive performance gains simply by writing parts in a lisp 😂

Ingy döt Net 2023-07-28T00:59:06.902129Z

Of course doing that and achieving really good interop is definitely a science project

➕ 1
Ingy döt Net 2023-07-28T01:03:15.939289Z

@phill did you see my DM to you?

🆒 1
Ingy döt Net 2023-07-28T01:42:28.542709Z

@phill I found that explanation of goto (sub form) in perldoc -f gotot > The "goto &NAME" form is quite different from the other forms of "goto". In fact, it isn't a goto in the normal sense at all, and doesn't have the stigma associated with other gotos. Instead, it exits the current subroutine (losing any changes set by "local") and immediately calls in its place the named subroutine using the current value of @_.

Ingy döt Net 2023-07-28T01:43:00.608969Z

I thought that was both clever and sane