5 ms·
Typed Lisp, a Primer
- codr7 2y agoThe main issue I have with CLs type checking is the clunky syntax and the fact that it looks different in different contexts. I made an attempt to fix that for eli: https://github.com/codr7/eli#type-checking https://github.com/codr7/eli#type-checking
- rjsw 2y agoYour eli looks clunky to me.
- codr7 2y agoWell, use something else. And maybe ask yourself why you felt saying so was important to you.
- dokyun 2y ago(the number (+ 35 7)) is a lot less clunky than (+ 35 7)@Numeric
- codr7 2y agoThat's your opinion, I don't agree. And the other reason is I can use the same syntax wherever I want type checking.
- epgui 2y agoOpinions aside, it is objectively an increase in syntactical complexity, and many people who love lisp enjoy its relative syntactical simplicity. Whatever is gained in exchange for this additional syntactical complexity may not be valued in the same way by everyone. So that almost certainly explains that reaction.
- codr7 2y agoYes, and a lot of people recognize the value of having a little bit of syntax in their Lisp.
- klibertp 2y agoYup. Somehow, I prefer[1]: (funcall #~s:gi/abc/def/ "Testing abc testing abc") to the five lines of the equivalent made with macros, function calls, and keyword arguments. I know all the problems with reader extensions, really. I understand being cautious. But at some point, you gotta wonder: what's the point of the programmable reader when you're unwilling to add programs to it? [1] Let over Lambda: https://letoverlambda.com/index.cl/guest/chap4.html https://letoverlambda.com/index.cl/guest/chap4.html
- kazinator 2y agoI'm reasonably happy with: 1> (regsub #/abc/ "def" "Testing abc testing abc") "Testing def testing def"
- HexDecOctBin 2y agoOne problem with Lisp is everything, including variable bindings, increases the nesting level making the code illegible. Last thing you want is for the type declaration to have their own nesting.
- zarathustreal 2y agoThis is not necessarily true, you can pretty easily implement just about any syntax you want
- dokyun 2y agoIf you hate nesting, just do this (defun foo (&aux bar baz) (setq bar (quux) baz (xyzzy)) ...)
- epgui 2y agoThe nesting level doesn’t necessarily impair legibility, it depends how it’s done. Nesting levels in homoiconic & referentially transparent languages have an impact more comparable to nesting levels in yaml or json than nesting levels in a language like python or javascript. The tradeoff weighs in a completely different way. First you will usually want to write small chunks of code, instead of a large soup. Second, you can make intentional decisions with your use of newlines in order to highlight specific aspects of the code. I find clojure more readable than most other languages… However, bad code stands out horribly (which is actually great if you have at least one experienced engineer in the team- I’d argue there’s nothing worse than bad code that looks normal). Just like anything else, writing good lisp takes some skill. Your specific editor and its configuration will also have a big impact on your experience.
- sdsd 2y agoYou'd love threading macros in Racket: https://docs.racket-lang.org/threading/index.html https://docs.racket-lang.org/threading/index.html It's like Unix pipes for functions: (~> "hello" (string-ref 1) (char->integer))
- klibertp 2y ago
- deleted 2y ago[deleted]
- recursivecaveat 2y agoAre those compile-time type checks or runtime assertions?
- codr7 2y agoMix, similar to CL but slightly more runtime atm.
- norman784 2y agoI don't particularly like the syntax for the types, but I can't also think of a better way to implement it without adding a special case in the parser/compiler for it, right now with your syntax I believe, correct me if I'm wrong, it can be implemented with a macro in any Lisp
- NikkiA 2y agopraising 'loop' in the same post as describing lisp as 'elegant' shakes head
- codr7 2y agoSome people seem to like it, and be very effective using it. The problem is it's a walled garden, with its own quirky syntax; nothing that happens inside of loop is applicable outside, and the other way around.
- shawn_w 2y agoI feel bad for people who haven't discovered ITERATE yet.
- Jtsummers 2y agoITERATE still breaks when you use `count` inside it, the built-in CL function. If they ever address that problem I'll get back to use it but having a time bomb in my programs isn't something I like. Trivial example of breakage: (iter (for i from 1 to 10) (print (count i some-sequence)))
- shawn_w 2y agoBreaks how? I'm on my phone, not a computer right now and can't test, but that should call the CL function - ITERATE uses `counting` for that particular operation to avoid conflicts; see https://iterate.common-lisp.dev/doc/Gathering-Clauses.html https://iterate.common-lisp.dev/doc/Gathering-Clauses.html Or is the documentation wrong?
- breadchris 2y agoI have really fallen in love with LISP recently, specifically clojure. A strong type system is really needed for it to make me feel like I can confidently develop with it.
- vindarel 2y agojust get Common Lisp with this new Clojure collection and sequence API! https://github.com/dtenny/clj-coll https://github.com/dtenny/clj-coll
- nextos 2y agoA modern CL that borrows ideas from Clojure, and with a strongly typed language (Coalton) also available is indeed very appealing!
- vosper 2y agoHave you (or anyone else reading this) used Coalton? What's your experience been like? Seems quite appealing to me.
- Y_Y 2y agoThe language looks amazing on paper, the install process (last I tried) was a nightmare of fighting quicklisp.
- klibertp 2y agoThat's on quicklisp, not Coalton. Honestly, quicklisp is one of the worst parts of CL nowadays (right after the lack of coroutines[1], which is by far the worst offender.) It should have been replaced a long time ago. ASDF3 provides a lot of flexibility, and quicklisp uses maybe 15% of its capabilities. There are reasons why it's still so bad, but it gets less and less excusable each year :( [1] Does anybody know how to ping Kartik Singh about the coroutines implementation in SBCL? Apparently, he made an experimental port of the green threads implementation from CMUCL, but I can't find it anywhere online, nor any obvious way to catch anyone involved. Is the mailing list the only way?
- gitroom 2y agohonestly i kinda love when deep dives like this pop up, makes me rethink stuff i thought i'd settled on - you think things ever get simple with lisp or it always stays quirky no matter how you do it
- wizzard0 2y agoof all things, this is the most beautifully formatted and organized LISP guide i've ever met.
- eggy 2y agoYou should check out Shen[1]. It is a portable functional programming language. Optional type checking and it solves my affair with Lisp and Haskell. It is a Lisp. [1] https://shenlanguage.org/ https://shenlanguage.org/
- klibertp 2y agoIt needs a lot more good tutorials about its type system. Lacking the background in whatever subfield of math that would help here, I couldn't type my way out of a wet paper bag in it. I'd love a concise, down-to-earth, exposition of the type system "for the working programmer". It's just so different than anything else I know (from Haskell to Prolog) that I had a really hard time understanding Shen's type system.
- eggy 2y agoYou're right: Shen's mathematical underpinnings (sequent calculus, dependent type theory) can intimidate programmers without a formal logic background. I bought the "The Book of Shen" (TBOS) revision 1 and revision 3. Revision 4 is available on the website. It's a great book with some CS history, logic, and development of Shen from Qi as well as how everything works in Shen including the type system. Shen uses a dependently typed Sequent-Calculus based Type System (SCTS). It uses type rules vs. type classes, and type checking is optional, you can turn it on or off. Haskell's type inference makes things a bit simpler, and is a battle-tested static type system with excellent type inference which lends itself better for functional programming and large-scale software engineering (for the moment). Shen's TC is more expressive, but requires more effort. Aditya Siram has some old but goody YT videos on Shen.
- klibertp 2y agoI wanted to buy it - I don't remember exactly, but I think I couldn't find an e-book version, and the paper one was expensive and didn't even ship to my country :( I hope to be wrong on that, though, do you know if there's an ebook available from somewhere?