News for hackers. Stuff that matters.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by brudgers on Friday April 13, 2018 @09:59AM (#16830018)
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by tombert on Friday April 13, 2018 @10:10AM (#16830129)
This is insanely cool. To me, once I learned Lisp (Clojure and then Racket), it kind of gave me this "OMG why isn't every language like this????" feeling.

I wonder if Carp could fair well with a more academic, heavy-processing sector....

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by oblio on Friday April 13, 2018 @10:53AM (#16830514)
> I wonder if Carp could fair well with a more academic, heavy-processing sector....

Could you expand on this? I'm not sure I understand your comment.

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by tombert on Friday April 13, 2018 @01:41PM (#16832173)
Academia, in my experience, has a tendency to use more theory-heavy languages (Haskell, OCaml, and of course Lisp), or the "easy-for-engineering" languages, like R or Matlab. When I used to work for a university, our stuff was done almost exclusively with Haskell.

This is fine, but a lot of academic work (bioinformatics, video processing, advanced statistical analysis, etc...) can be very computationally heavy, leading to a lot of academics and post-docs writing some ad-hoc C++ in order to squeeze out better performance.

What I was suggesting is that, since Carp might have better performance characteristics for more CPU bound tasks than something like, say, Racket, it might satisfying the niche of academic-friendly languages.

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by cies on Friday April 13, 2018 @10:55AM (#16830529)
Really well done. The lang design, the docs: intend is clear in every case and very on point.

I've never been a fan of lisps, but that has more to do with the common lack of strong typing discipline, than that it was a syntax issue. Currently I'm using Haskell a lot.

But this lisp is a breath of fresh air to my type-loving brain.

Maybe I've overlooked them, but what about higher kinded types and reflecting purity at type level? Are they not-in-and-never-will-be-by-design, or maybe-if-someone-implements, or on-the-road-map?

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by aidenn0 on Friday April 13, 2018 @11:51AM (#16831163)
Have you looked at Shen[1] at all? It is a lisp dialect with a reasonably full featured type system[2]

1: http://www.shenlanguage.org/

2: http://www.shenlanguage.org/learn-shen/index.html#9%20Types

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by djur on Friday April 13, 2018 @12:32PM (#16831553)
Is the open source version of Shen suitable for production use? It's not clear to me how actively it's developed or how much it differs from the "professional" version. The website suggests it lags far behind, but I recall there being an acrimonious split between the original creator and the open source community.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by gnulinux on Saturday April 14, 2018 @05:08AM (#16836587)
I second this. Shen is probably my favorite lisp.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by skybrian on Friday April 13, 2018 @01:40PM (#16832162)
Dynamic types at compile time combined with static types at runtime seems like a nice tradeoff. After all, the types will be checked for all the code actually generated. It probably makes error messages more confusing, though.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by M_Bakhtiari on Monday April 23, 2018 @05:16AM (#16901795)
I agree in that I don't like weak typing discipline, but Lisp was pretty much always strongly typed.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by radarsat1 on Friday April 13, 2018 @12:16PM (#16831402)
Any discussion about real-time Lisp is incomplete without a mention of Snd-RT: http://archive.notam02.no/arkiv/doc/snd-rt/ so I'll just drop that here ;)

It's very ground-breaking work imho that is unfortunately very poorly known/cited, having been presented mainly to the computer music community, but it represents a real-time garbage-collected Scheme.

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by j_m_b on Friday April 13, 2018 @09:36AM (#16829812)
It's really nice to see Clojure syntax being adopted in newer lisps.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by M_Bakhtiari on Friday April 13, 2018 @10:31AM (#16830306)
Well, I suppose it's better that they re-use someone else's gratuitously different syntax than invent their own gratuitously different syntax.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by fsloth on Friday April 13, 2018 @11:26AM (#16830856)
I think most modern programmers prefer explicit destructuring and taking an element from a collection by its key rather than excplicitly traveling node links using car and cadr. The 'original' lisp has some really arbitrary naming conventions. Languages are cognitive tools and as such they should be able to evolve, rather than dogmatically stick to a specific formulation laid down in the formative years of a field.

It does not manner how you name your tokens or how you choose to destruct your data structures. It's still lisp.

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by aidenn0 on Friday April 13, 2018 @11:56AM (#16831212)
I disagree that Clojure's AST changes are gratuitous. Rich has repeatedly provided his reasons for them. You may think they are bad reasons, but it's not like he just said "ZOMG there are too many parens!"

That being said, I tend to use destructuring in common-lisp, and if you are taking an element from a collection by using c*r then you are probably doing it wrong.

Optima has more complete support for destructuring, but this works just fine in CL with out any libraries:

    (let ((some-plist '(:foo 1 :bar 2)))
      (destructuring-bind (&key foo &allow-other-keys) some-plist
        foo))
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by kbp on Friday April 13, 2018 @04:52PM (#16833806)
And while it didn't make it into the Common Lisp version of LET, there were versions in earlier dialects that supported destructuring. For example, the Maclisp reference manual's description of LET[0] says:

It is permissible to place an s-expression pattern in place of a symbol in the (sym init) form of an element of the bvlspec. The symbols in the pattern will become bound to the matching elements of the initialization (see DESETQ). This kind of pattern-matched assignment is called destructuring.

    (let (((a b) '(1 2)))
      (cons b a))
    => (2 . 1)
0: http://www.maclisp.info/pitmanual/contro.html#5.6.1
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by kbp on Friday April 13, 2018 @04:23PM (#16833596)
> I think most modern programmers prefer explicit destructuring and taking an element from a collection by its key rather than excplicitly traveling node links using car and cadr.

Then they'd be happy with Lisp from 40 years ago. Common Lisp (which was not the first to have either feature) has DESTRUCTURING-BIND (as well as some other constructs like extended lambda lists and within LOOP) where you can use destructuring, and it has generic sequence functions that work on more than lists like MAP, REMOVE-IF-NOT, REDUCE, etc, as well as lookup functions for getting things out of key-value maps (list-based or not) by key, or from sequences by index. Explicitly cdring down lists is mostly only done in introductory textbooks.

It feels like a lot of Clojure advocacy is written in terms of this "Lisp before Clojure" strawman of some minimalist Scheme subset. Lisp has had arrays, dictionaries, records, etc (with literal syntax and proper accessors), as well as destructuring and generic sequence functions, for almost half a century (more than half a century for some of that). Whether or not you prefer Clojure's syntax for those things, Lisp had those things long before Clojure existed.

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by kazinator on Friday April 13, 2018 @04:42PM (#16833740)
It also feels a lot like Clojure advocacy is simply written in terms of "Lisp before Clojure is something I have zero experience with".
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by kbp on Saturday April 14, 2018 @02:47PM (#16838787)
I think for a lot of people, they "learned Lisp" from the Little Schemer and stopped there.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by _delirium on Friday April 13, 2018 @11:48AM (#16831131)
> taking an element from a collection by its key rather than excplicitly traveling node links using car and cadr

Isn't that also the norm in Common Lisp? You can do any convoluted thing you want, of course, but in my own code, I retrieve elements by key using e.g. 'getf' or 'gethash'. (I do agree that there are many naming warts.)

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by lispm on Friday April 13, 2018 @11:53AM (#16831182)
> original' lisp has some really arbitrary naming conventions.

Like car and cdr? Check the Carp manual for some surprise arbitrary naming.

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by pjmlp on Friday April 13, 2018 @11:50AM (#16831153)
Actually I do prefer Clojure's approach better than traditional Lisp syntax.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by fithisux on Friday April 13, 2018 @12:10PM (#16831323)
Me too. My only problem with Clojure is that it is not available in a native flavor like most Schemes or CLs. Otherwise it is a very good substrate for the evolution of CL. Despite the functional style advertised by Javascript, at least for me Clojure ticks almost all the points of a proper functional language except one, which is fixed by core.typed. SML should take a closer look at what is happening with Clojure for its SMLnext proposals.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by OtterCoder on Friday April 13, 2018 @09:40AM (#16829856)
The readme is very terse, but exciting. Can anyone elaborate about the ownership model?
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by tonyg on Friday April 13, 2018 @11:41AM (#16831045)
The page on syntax and semantics says "To learn more about the details of memory management, check out Memory.md", linking to https://github.com/carp-lang/Carp/blob/master/docs/Memory.md
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by laxentasken on Friday April 13, 2018 @10:08AM (#16830104)
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by jgh on Friday April 13, 2018 @10:34AM (#16830332)
Whoa time to try this out, this seems awesome. (nb: c++ guy who love clojure)
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by amelius on Friday April 13, 2018 @11:40AM (#16831027)
How and when does it clean up memory allocated for closures?
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by andy_ppp on Friday April 13, 2018 @11:41AM (#16831054)
Presumably it's up to you to manage that?
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by andybest on Friday April 13, 2018 @10:41AM (#16830393)
Will be interesting to see how compiling to C affects debugging in the real world. LLVM is nice as a target, since it allows you to map generated IR blocks to source locations. Of course, it also means that the compiler needs to link to all of the LLVM libs, which is a bit of a hassle too. (I've found this when working on a Clojure->LLVM compiler bootstrapped from Clojure).
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by groovy2shoes on Friday April 13, 2018 @10:56AM (#16830539)
You can map locations in generated C code to locations in some other file, too. Standard C has a pragma for it:

    #line <num> "filename"
or, if the filename is the same as the previous pragma, you can omit it from the pragma:

    #line <num>
This pragma is used to inform the compiler of what information it should use when displaying error messages and such. I think it's meant to be used by the C preprocessor, but the preprocessor isn't required to use it, and other programs aren't prohibited from using it.

You might wind up generating a lot of these, but they're really easy to generate as long as you preserve that information all the way through compilation (which I'd assume you'd have to do for LLVM IR regardless).

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by andybest on Friday April 13, 2018 @11:18AM (#16830775)
Interesting, I wasn't aware of the #line directive, thanks!

Yes, you would need to keep track of the source locations for each node in the AST. There is a nice example in the LLVM Kaleidoscope tutorial here: https://llvm.org/docs/tutorial/LangImpl09.html

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by gnulinux on Saturday April 14, 2018 @05:16AM (#16836603)
Bison and lex use #line to make generated C/C++ code (lexer, parser) debuggable, or at least their GNU implementation does, I don't know about other implementations.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by nerdponx on Friday April 13, 2018 @10:19AM (#16830218)
I've been wanting a true statically-typed Lisp for a while. Very excited to try this for keyboard firmware!
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by fiddlerwoaroof on Friday April 13, 2018 @10:49AM (#16830469)
There’s also Hackett which provides a Haskell-style type system: https://github.com/lexi-lambda/hackett
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by leshow on Friday April 13, 2018 @11:40AM (#16831024)
Typed Racket has been around for a while, is that not close enough to a lisp for you?
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by nerdponx on Friday April 13, 2018 @02:33PM (#16832685)
I tried using it for some small projects, and it was really fun but seemed to not mesh well with the rest of the Racket ecosystem.
Re:Carp: A statically typed Lisp, without a GC, for real-tim... by Koshkin on Friday April 13, 2018 @12:10PM (#16831335)
> (defn

What's wrong with "def"?

Re:Carp: A statically typed Lisp, without a GC, for real-tim... by jetrink on Friday April 13, 2018 @12:12PM (#16831364)
At least in Clojure, (defn my-function [] ...) is syntactic sugar for (def my-function (fn [] ...)), removing one level of nesting.