libera/#lisp - IRC Chatlog
Search
5:09:34
lisbeths
lambda calculus is the simplest lisp but that needs the best optimizations to be fast
5:30:55
lisbeths
what most lisps seem to be able to agree on in terms of design is how lambda functions should work with only minor syntactical or internal differences between them
5:32:39
lisbeths
algorithms written purely in lambdas in scheme can run in haskell so long as they don't refrerence any object that isn't a lambda
5:44:54
lisbeths
many lisps have tried and failed to be the next JSON and this is arguably because not everyone can agree what lisp to use
5:52:00
rozenglass
lisbeths: Can a JSON replacement be completely made up of lambdas? How would it differenciate between a key-value collection, and an array/list of objects for example? Without using any language-specific features.
5:53:23
lisbeths
I think you can encode s expressions in json that way the technology doesnt need to be changed much
5:53:52
lisbeths
thus you can encode a lambda expression with json syntax such as an algorithm in pure lambda calculus
5:55:36
lisbeths
otherwise the naming of objects and data would be to just create s expressions with symbol names in them
5:57:16
lisbeths
you can write an s-expression like structure with json. You can write a json like structure with s expressions. Json is the more complex and less elegant of the two
5:59:11
rozenglass
The only way I see to do the second (write something JSON-like in s-expressions) is to use symbols to denote some things (like arrays or key-value objects), and thus, I think, we can all disagree on what symbols to use for what, and then we fail again :p
5:59:11
lisbeths
think about if an s expression was an object, how would you "dehydrate" that object into json
6:00:22
rozenglass
I remember having to deal with the various ways different Lisp to JSON libraries treated `false` vs the empty array.
6:01:26
lisbeths
this is why you cant agree how to encode lisp you can agree how to encode PURE lambda calculus
6:02:09
lisbeths
meaning that to process data from the outside world that data first has to be transformed into pure lambdas which is often an immutable datstructure
6:02:19
rozenglass
changing parentheses into braces to denote objects sounds like something external to lambda calculus though, no?
6:03:27
lisbeths
pure lambda calculus can be represented as s expressions with nothing but symbols and parentheses. by converting the parentheses into braces and adjusting the symbol somewhat it can be encoded as JSON
6:06:14
lisbeths
not necessarily you can encode 1101 as the list containing four objects consed together
6:07:24
moon-child
at some point you end up wanting to type these monsters. That way lies ml, and no lisp
6:07:27
lisbeths
you dont have to use church numerals you can use the pair combinator, the head combinator, and the tail combinator
6:07:56
rozenglass
I think fundamentally, JSON as a serialization protocol is giving basic types to things using specific symbols, and the agreement to use JSON is an agreement on those types and symbols. It seems we need the agreement anyway (on symbols or something) to do anything similar to JSON, even if we use lambda calculus. Lambda calculus is too generic to replace the specific guarantees that JSON gives (for
6:08:02
rozenglass
example, that { "key": "value" } would translate to something dictionary like with efficient key->value access).
6:09:23
lisbeths
well I have been working on a way around this but it uses combinators instead of s expressions
6:10:45
rozenglass
(key value) is ambiguous in that way; is it [key, value] or { "key": "value" }, the moment we do something to remove the ambiguity, like (obj key value) for example, we require agreement on something; why not (dict key value) or (kv key value).
6:11:22
lisbeths
you can go like , 'h' , 'e' , 'l' , 'l' , 'o' false to build strings in the named lambda calculus but this is tedious
6:12:15
lisbeths
you can have a function which forever produces a function thay takes an int as an argument and if that int is nonzero it appenda the int to a string but if it is zero it returns the string
6:13:26
lisbeths
one could narrow this further if every single character function was assigned to that church encoded or list encoded character without the ' symbol
6:14:41
lisbeths
there is a way to encode it without the spaces but it changes the grammar syntax and semantics of lisp to be more like gnu dc
6:16:09
lisbeths
with currying the output of the function to the left is the input to the function on the right
6:18:04
rozenglass
Anyway, it seems like we'd lose the human readability property of JSON if we go to such lengths with lambda calculus to represent basic types abstractly, right?
6:18:10
lisbeths
imagine an interpreter where every character being input to the interpreter is immediately parsed as a church encoded character, and then a state machine written in pure lamba expressions takes an action based on what character was input
6:18:46
lisbeths
and imagine that you can input characters in such a way that you can completelu reprogram the state machine
6:20:10
lisbeths
currying is a more purely functional ways to get the syntactical advantages of forth
6:20:45
rozenglass
lisbeths: what would be the practical use of such an interpreter / state machine?
6:22:10
lisbeths
I often talk about something called dynamic finite state machines which is a reprogrammable finite state machine that has open-ended objectives at runtime
6:22:36
Lycurgus
didn think so but it comes to mind in the context of forth, a not very well know application of similar idea
6:22:42
lisbeths
in the lambda calculus arrays of functions can be used as switch statements and arrays can be implemented as balanced binary search trees which have a pretty good o notation
6:24:12
lisbeths
a truly dynamic virtual machine can be reprogrammed in the way that it can interpret code
6:24:26
rozenglass
currying to get the syntactical advantages of forth? in my mind forth's advantage is the ability to execute any instruction immediately, and thus, being super simple to implement a simple forth.
6:24:31
Lycurgus
'nother funny thing: "IDL" which is often used as if there was only one well understood thing called that
6:25:14
lisbeths
currying offers much if not most of the syntactical symmantical grammatical benefit of forth
6:25:31
lisbeths
The environment is not sandboxed but in currying the environment is sandboxed between function calls
6:26:23
lisbeths
as far as I understand it with lisp syntax macros isn't it true that you must always have parentheses
6:26:37
lisbeths
with the type of macros I'm describing you can omit the parentheses you can invent macro systems that are very different from the way the machine initially starts out
6:29:39
rozenglass
lisbeths: homo iconic while also allowing arbitrary syntax changes? how can that be?
6:34:44
lisbeths
well what I should say then is that it is supportive of homo iconicity but it doesn't guarantee it depending on what the user does
6:34:55
lisbeths
The user can use it to write a program that guarantees home iconicity but then it would lose the ability to have arbitrary syntax
7:05:09
rozenglass
I've been thinking about ways to allocate and deallocate memory deterministically without GC, and I keep getting hopeful with the ideas I get, but I also keep thinking there _must_ be some reason no one did this and that before.
7:05:29
rozenglass
There must be things wrong with those ideas that I will only face once I try to actually implement them instead of thinking about them on a whiteboard. I'm not a programming languages expert, so that is very likely.
7:11:53
lieven
rozenglass: one solution explored in lisp is linear types. Henry Baker wrote some papers about it.
7:15:24
rozenglass
for some reason, forth, being a stack-based language, and the idea of immediately-executed commands, is what triggered that thread of exploration in my brain
7:21:38
moon-child
borrow checker is some syntax sugar and a fancy smt solver thrown at plain linear types a la clean
7:43:18
rozenglass
lisbeths: I always felt I should stay away from reader macros in any production code, because the added convenience in the DSL never felt worth the loss of the s-exp syntax and the potential disastrous design errors that I might unintentionally build.
7:44:02
lisbeths
reader macros are a complicated and sacred thing not intended to be taken lightly or use in arbitrarily
7:44:33
lisbeths
in a hundred years we might only come up with some of the most basic possibilities that reader macros and domain specific languages give us
7:44:47
lisbeths
but we would come up with 100 times the amount of inextensible garbage that is anti-design pattern
7:46:22
rozenglass
Oh, also the fear that the moment this is introduced into a team-maintained code base, someone, usually inexperienced, will just go wild and use it for everything everywhere and no one would know what's happening anymore.
7:48:04
lisbeths
one anti pattern is you can use reader macros to make a system that does not have reader macros
7:48:38
lisbeths
just as you can use a turing complete language to make a language that is not turing complete but that is consistent and complete
7:49:13
lisbeths
it also allows you to create separate independant non compatible type systems and object systems
7:49:56
lisbeths
programming *already* has many competing and incompatible systems with major design flaws and antipatterns
7:52:04
lisbeths
being afraid of reader macros because of anti-patterns is like being afraid of the ocean because of the lack of air underneath the water
7:52:39
lisbeths
I argue that there is such a harvest to be had with reader macros and my thesis work hinges on it
7:55:10
rozenglass
lisbeths: I feel their potential too, and it kinda feels like unexplored territory; we probably can collectively develop good patterns and find anti-patterns, if we spend enough man-hours exploring.
7:55:43
lisbeths
The first thing I ever wanted to implement in my first day at programming class was reader macros
7:56:04
rozenglass
I was mostly talking about fear of using them in production team contexts, where sadly many people are hardly familiar with Lisp in the first place.
7:56:10
lisbeths
Pearl is a good exploration into what happens when you are allowed to add whatever kind of syntax you want to language
7:56:56
lisbeths
I think that lisp should be taught in school as the notation for math because then you would have the same notation that you learn in algebra class written in the computer
7:57:25
lieven
probably not the way you meant it but I've always been interested in literate programming
7:59:05
rozenglass
People create custom syntax, DSLs, and what not, they aren't losing on what reader macros provide, it's that people "just" use lex / yacc or "just" write a parser, or use JSON or whatever.
9:33:32
port19
Hi fellow lisp enjoyers. I've been writing clojure for several months now and am greatly enjoying the combination of lisp and functional programming. One thing that becomes increasingly annoying tho is the platform. I mostly develop small webscraping utilities for my own enjoyment and would greatly prefer to distribute a binary. Because of this I'm considering common lisp and racket as alternatives. I have toyed around with common lisp
9:33:32
port19
before, but CLOS seems to not work well with the FP mindset on first glance, not to mention archaeic function names (wtf is "car" or "cdr" supposed to stand for). What can you recommend for a lisp with native compilation?
9:55:49
aeth
CL has some poorly named things and some things with inconsistent orders (e.g. NTH vs ELT) because it can't break compatibility.
9:57:40
aeth
SBCL is the main compiled CL implementation (CCL the next most popular); Chez is probably the "main" compiled Scheme implementation but is far from the most popular; Racket has the most focus on FP and is mostly Scheme
9:58:26
aeth
CL probably has the most libraries, but you have to use one if you want a bunch of FP data structures
9:58:51
port19
I assume the performance differnece is small enough that it won't matter in a program that does network requests
9:59:38
mariari
copying objects haven't been too noticable in applications I write. It seems yours is network bound so that would be bigger
9:59:54
mariari
when thinking about functional things, you have to consider the allocation of a new object, but this is true in ocaml, haskell, clojure etc
10:01:09
mariari
yes, I mention them solely to show you what functional compilers do, which isn't magic
10:01:13
port19
I might want to read up on CLOS. Can you, or someone else, recommend a good article providing a high level overview?
10:01:44
mariari
I don't have anything off hand sorry, I use some MOP to make it work nicely functionally
10:03:18
aeth
in particular https://gigamonkeys.com/book/object-reorientation-generic-functions.html and https://gigamonkeys.com/book/object-reorientation-classes.html
10:05:03
aeth
In practice, CL mutates a lot less than you would think for a language that isn't strictly FP because of the expression-based syntax... a lot of things that would normally set don't need to when everything returns a value, even e.g. COND (if/then/else)
10:16:01
pranavats
port19: About CLOS, Daniel Bobrow has an excellent lecture on it. From 1987: https://www.youtube.com/watch?v=IrmHp1rRQ68