Live data from Hacker News

Carp, a compiled Lisp with type inference and a borrow checker

blog.veitheller.de

31–40 of 112 posts

Re: Carp, a compiled Lisp with type inference and a borrow checker

#31
I realize that almost every language could be described as a subset of C++, but I read articles like this and think...

Deterministic language that has type inference, C interop, and uses ownership to govern object lifetimes? We have that. It's C++11. auto with std::unique_ptr and std::move().

Only slightly serious. ;-)

Re: Carp, a compiled Lisp with type inference and a borrow checker

#32

I've been waiting for a non-Clojure lisp to make some headway. Immutability is mostly a fad: look at how incredibly complicated Clojure's implementation is. It's not worth sacrificing elegance just to attract the true believers.

Clojure's implementation did not have to be so complicated, there are simpler implementations of persistent data structures.

Immutability is obviously the more elegant option as far as I'm concerned: Hickey's The Value of Values[0] lays out the case quite well.

[0]: https://www.youtube.com/watch?v=-6BsiVyC1kM

Re: Carp, a compiled Lisp with type inference and a borrow checker

#33
post #28

It seemed they don't distinguish between mutable and immutable references (?). Does Carp not handle the issue of shared mutability, eg. iterator invalidation, like Rust?

Correct, not at the moment. Overall the type system is less expressive but also less dependent on annotations. Differentiating between immutable and mutable refs is probably coming though, it’s a useful distinction for sure.

Re: Carp, a compiled Lisp with type inference and a borrow checker

#34

I really want to like Carp but I somehow feel that the Rusty memory model does not fit the Lisp philosophy... all the borrowing story comes from a basis mutability. I wish for something more Clojurish based on immutable data. Then one can exploit the power of inferred type linearity/affinity to transparently build safe "transients" and other cool stuff. Maybe some day I should write such Lisp myself on top of my C++…

One of the good LISP's back in the day was PreScheme that let it finally be a C alternative efficiency-wise. It was also used in first, verified LISP. Such a style might also be good for bootstrapping or just making more flexible ways to code C.

https://en.m.wikipedia.org/wiki/PreScheme

Looking at PreScheme, Carp doing a C alternative safe without a GC is a nice evolution of these LISP's. Next cool possibility: use a Rust-like LISP with an OS project like Mezzano on lowest-level stuff. Might even start with Redox OS just LISPifying its parts for a kernel and shell to start with.

Re: Carp, a compiled Lisp with type inference and a borrow checker

#35
post #10

Clojure + Rust => Carp?

It sounds like arrays are mutable in Carp, so it doesn't feel like Clojure to me. As far as I understand, Clojure is also not big on macros, while Carp appears to be.

Normal usage of arrays (and structs) is through an immutable api, internally it uses mutation though. See example/updating.carp for example.

Re: Carp, a compiled Lisp with type inference and a borrow checker

#36

I really want to like Carp but I somehow feel that the Rusty memory model does not fit the Lisp philosophy... all the borrowing story comes from a basis mutability. I wish for something more Clojurish based on immutable data. Then one can exploit the power of inferred type linearity/affinity to transparently build safe "transients" and other cool stuff. Maybe some day I should write such Lisp myself on top of my C++…

That’s one of its strengths though . A lisp with type inference and performance is quite rare. More lisps should be less lispy .

> A lisp with type inference and performance is quite rare.

You mean apart from several Scheme implementations?

Chez Scheme is blisteringly fast, and on-par with C for quite a few things.

Gambit-C (Compiles to C), Chicken (based on the Cheney-on-the-MTA model) and Bigloo (designed to replace C++) also deserve a reference here.

Re: Carp, a compiled Lisp with type inference and a borrow checker

#37
post #18

Earlier quoted context omitted.

Aye, that's the one big disappointment. Maybe the first pet project is an implementation of Clojure's immutable collections.

Immutable collections don't play well with non-GC memory management.

Exactly. Someone who doesn’t see the value in a GC-less language is not going to see the value here.

I personally think “functional persistent” data structures, as a language default, trade a lot of runtime performance in order to achieve some guarantees like thread-safety and functions not having side effects. Every mutation to every array or dictionary is treated like a transaction in a MVCC database, with the garbage collector in charge of cleaning up the records of every past version that wasn’t actually necessary to keep around, because no multiversion concurrency was actually necessary in that case. I encourage languages to experiment with other methods of achieving similar benefits.

I think limiting side effects and shared mutable state is very important, but at a local level, imperative code that mutates a data structure is highly readable and performant. Certain algorithms practically require it. Certain hardware practically requires it.

Functional languages let you think in terms of abstract “compound values,” but in practice these are backed by tons of little heap-allocated objects, partly so that lots of sharing can be done when the data structure is copied on every change.

Re: Carp, a compiled Lisp with type inference and a borrow checker

#38
Very excited about Carp. In general I like the simplicity of Lisp but ironically I'm not a fan of dynamic typing. Carp may be a real innovation. A bit surprised though that the Carp C runtime functions are not namespaced. With names like `IO_println` there's a risk of clashes. Unless the compiler is doing some tricks to hide names?

Re: Carp, a compiled Lisp with type inference and a borrow checker

#39

I realize that almost every language could be described as a subset of C++, but I read articles like this and think... Deterministic language that has type inference, C interop, and uses ownership to govern object lifetimes? We have that. It's C++11. auto with std::unique_ptr and std::move(). Only slightly serious. ;-)

So Carp could compile to that subset of C++. But C++11 isn't _just_ that. It is all of C++11.

C++ would even more successful if it was easy to make a proper subset of it.

Re: Carp, a compiled Lisp with type inference and a borrow checker

#40

Very excited about Carp. In general I like the simplicity of Lisp but ironically I'm not a fan of dynamic typing. Carp may be a real innovation. A bit surprised though that the Carp C runtime functions are not namespaced. With names like `IO_println` there's a risk of clashes. Unless the compiler is doing some tricks to hide names?

The ”IO_” part is the namespace, so no clashes!
Post reply on HN