Live data from Hacker News

Carp – A statically typed Lisp, without a GC, for real-time applications

github.com

121–130 of 139 posts

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#121
post #90
post #61

Earlier quoted context omitted.

It's really surprising that it's rare in functional languages. Immutability seems like it should guarantee no cycles (?), so reference counting could be used.

Reference counting is usually very expensive, because even reading a variable updates the reference count, and ending a scope involves testing the reference count of every variable defined inside the scope and conditionally deallocating the referent. Without reference counting, here's the end of a hairy function scope that deallocates 15 local variables and restores two callee-saved registers: 11a6: 48 83 c4 78 add $…

WRT the multithreading issue, https://lwn.net/SubscriberLink/872869/0e62bba2db51ec7a/ mentions that using atomic memory operations in CPython for Py_INCREF and Py_DECREF slows down the entire CPython interpreter by 60%.

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#122

Anyone who had used or tried Carp and Janet (that was on frontpage the other day)? What are some strong points on Carp vs. Janet?

Importantly: has anyone tried embedding Janet in Carp to get the best of both worlds?

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#123
post #63

Earlier quoted context omitted.

That's a question for the underlying allocator, surely? (Quite often the answer is "it isn't")

Not just for the allocator. I always thought a main point of a garbage collector was heap compactification (shuffling things around so there is more space), but maybe I am wrong.

Not every GC has compaction phase though, but generational ones do by design.

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#124
post #119
post #22

Earlier quoted context omitted.

I think this is LuaJIT, or? Iiuc Janet is comparable to non-JITed Lua. But I actually have no clue.

LuaJIT is x86, ARM, PPC and MIPS only. However, Lua itself can run on anything with the C stdlib and a C99 compiler. Which means for realtime systems you're not generally going to be talking about LuaJIT. The speed of Lua will depend on the GC in use. Whilst that is an incremental one be default, Lua is designed to allow you to disable it altogether, use the older reference counting one, replace it entirely with your…

Aha, thanks for the info. Then I believe Janet could fill a similar role. What little profiling I've seen puts them in a similar category: https://github.com/MikeBeller/janet-benchmarksgame/blob/mast...

Though I imagine it's hard to say without actually trying it.

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#125
post #63

Earlier quoted context omitted.

That's a question for the underlying allocator, surely? (Quite often the answer is "it isn't")

Not just for the allocator. I always thought a main point of a garbage collector was heap compactification (shuffling things around so there is more space), but maybe I am wrong.

Nah, only copying / generational collectors do heap compactification. A simple Mark&Sweep collector doesn't, for example. Nor does reference counting. Both of which are used by many Lisp or Lisp-like languages.

Nothing can substitute for a really good allocator.

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#126

Earlier quoted context omitted.

Not just for the allocator. I always thought a main point of a garbage collector was heap compactification (shuffling things around so there is more space), but maybe I am wrong.

Nah, only copying / generational collectors do heap compactification. A simple Mark&Sweep collector doesn't, for example. Nor does reference counting. Both of which are used by many Lisp or Lisp-like languages. Nothing can substitute for a really good allocator.

So what happens to long running lisp programs? Running out of memory due to fragmentation eventually?

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#127

Earlier quoted context omitted.

Nah, only copying / generational collectors do heap compactification. A simple Mark&Sweep collector doesn't, for example. Nor does reference counting. Both of which are used by many Lisp or Lisp-like languages. Nothing can substitute for a really good allocator.

So what happens to long running lisp programs? Running out of memory due to fragmentation eventually?

One would expect at least a provision for a stop the world phase. where all mutator threads get to wait for a massive defragmentation.

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#128
post #105
post #97

Earlier quoted context omitted.

Oh gosh, I forgot about that. Is that Windows only though? I remember MSVC had managed/unmanaged C++ and allowed calling between the two.

Sadly yes. And although they don't have much love for it, they still keep it relatively up to date. It was one of the .NET Core 3.1 main milestones. However I would say for the purpose of binding .NET and C++, probably it doesn't need to understand everything anyway.

The C++/CLI compiler is definitely Windows-only. But I'm not sure whether the generated code would be, if you compile with /clr:pure (which can still handle everything except for setjmp/longjmp).

/clr:pure has been deprecated for some time now, unfortunately. But older compilers are still around...

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#129
post #120
post #117

Earlier quoted context omitted.

This is more specifically about any reference counted system, though it also includes unique owner approaches and others. Namely, when you free an object, whether it involves manually written code to release anything it holds recursively, or through some form of reference counter, you do not know the size of object graph you're freeing . If you add any custom release logic to the mix (destructors, any kind of shutdow…

It's worth mentioning that (1) typically even ordinary reference counting avoids large pauses, because typically objects that go out of scope aren't the sole owners of a huge object graph, and that this is often but not always a significant improvement over (other simple kinds of) garbage collection; (2) there's a readily available tradeoff with reference counting known as "deferred decrement" which can meet hard rea…

The main difference in favour of GC in the first case is that GC gets you centralised place to control it.

Generally GC offers more explicit, centralised control over allocation/deallocation, and I've seen it favoured over other schemes if dynamic memory management is necessary in critical code.

Re: Carp – A statically typed Lisp, without a GC, for real-time applications

#130
post #71

Earlier quoted context omitted.

Probably. There's 20-30ish million software developers in the world [1]. People work for 30-50 years, suggesting at least a million freshman CS students a year. It's a rapidly growing field. Plus all the lifetime learners. It's not unreasonable to estimate at least 2M CS students worldwide write or work on a compiler each year. Maybe a tad high, but also it's an idiom. https://www.daxx.com/blog/development-trends/num…

I have no actual opinion here. Just stopping by to point out that not (nearly) all software developers started as CS students.

Of course, I don't mean to imply that all software developers went to school for cs, or went to school at all. Just doing a Fermi estimation.
Post reply on HN