19 ms·
Carp lang: statically typed Lisp, no GC
- deleted 4y ago[deleted]
- philbo 4y agoFound this page to be a nice intro to the syntax and semantics: https://github.com/carp-lang/Carp/blob/master/docs/LanguageGuide.md https://github.com/carp-lang/Carp/blob/master/docs/LanguageG... This part hits a real sweet spot for me: > Carp borrows its looks from Clojure but the runtime semantics are much closer to those of ML or Rust. One of my current side-projects is a little Civ-style game I'm working on in Racket, which I decided to start coding in on a whim. Will see how it goes moving pieces of it across to Carp.
- fbn79 4y agoMore on memory management https://github.com/carp-lang/Carp/blob/master/docs/Memory.md https://github.com/carp-lang/Carp/blob/master/docs/Memory.md And yes is Open Source (Apache Licence)
- zem 4y agois it open source? sounds very interesting!
- deleted 4y ago[deleted]
- moomin 4y agoCiv 4, of course, is mostly Python.
- heinrichhartman 4y agoThe project compiles LISP to C (with Haskell code-base) and relies on a C compiler to generate executables. This means you will have to get your C dependencies in-place to work with carp. I was trying this from `nix-shell -p carp` and immediately ran into issue with this when building the hello world example from the README. (Package sdl2 was not found). Not sure how to fix this just adding `- p SDL` to the nix-shell prompt does not help, as the invoked compiler does not know where to look. Any recommendations here? I want to avoid using a global clang/gcc installation for various reasons. Is running this under `nix` a good idea? Should I move this into a container?
- tazjin 4y agoYou might have to add `-p pkg-config` (important: in the same invocation!), that may be the lookup mechanism they use.
- xcdzvyn 4y agoSounds like a bug with the Nix package, it should be bundling SDL2 as a buildInput if Carp depends on it. I'd open a issue at nixos/nixpkgs. As the other comment mentions, installing pkg-config and sdl2 alongside carp might work, but I suspect Nix is smart enough to properly isolate derivatives such that it wont.
- tazjin 4y ago> I suspect Nix is smart enough to properly isolate derivatives That's not really relevant here, as carp itself seems to basically do code-gen and then compile stuff on its own (outside of any Nix build), so the environment in which you run carp must be set up such that the compiler and linker running in it can discover the needed libraries. Very often the mechanism used for that is pkg-config. If you wanted a more "Nixy" way to do this, you could write a `buildCarp` suite of functions in Nix that correctly sets all this up inside of a derivation build and takes the Carp code you're compiling as an input, yielding the compiled one as a Nix store path. For just playing around, it seems more reasonable to just add the needed dependencies to the runtime environment of carp.
- shric 4y agoWhy does a hello world need SDL?
- fbn79 4y agoNot needed. I think the example use SDL because the language was born in games dev context.
- tazjin 4y agoWasn't this at some point written in Rust? What prompted the Haskell rewrite? I tried looking through the issue tracker but didn't find anything, just curious.
- DoctorOW 4y agoClicking around commits, it used to be C.
- tmtvl 4y agoTo be specific, quoting the website: > The first version of the compiler was made 2015 - 2016, attracting a fair bit of attention in the programming community. In the spring of 2017 I rebooted the project, rewriting it in Haskell (it used to be C).
- bandrami 4y agoI only read the front page, but I can't figure out what "statically typed" even means in the context of lisp. If it isn't doing manifest value typing it's hard for me to call whatever it is "lisp"; it's something else with a lot of parentheses. Does it just mean once a symbol has taken a value of one type it can't ever take a value of another? What would the point of that limitation be?
- CodeArtisan 4y agoAs its name implies, Statically typing does mean that the typing is resolved in the static environment (before execution). Dynamic typing is resolved in the dynamic environment (during execution). Both enabling all kind of techniques. You need dynamic typing to have eval which is the core of the lisp language therefor you can't have a "true" lisp without dynamic typing.
- pohl 4y agoLooks like Carp does also have eval. It’s nice that one gets to choose to pay the cost here. https://carp-lang.github.io/carp-docs/core/Dynamic.html https://carp-lang.github.io/carp-docs/core/Dynamic.html
- jeremyjh 4y agoAt the top of that page, it says it is used in the REPL and during compilation and not available in compiled code. The guide elaborates they are also available in macros. But I don't see a mechanism for runtime eval.
- crabbone 4y agoThere's no real definition for "static typing". It's an opaque marketing term that somehow made it into programming lexicon. Don't ask what "static typing" is, you are simply supposed to love it, because it's good.
- naasking 4y ago
- kristiandupont 4y agoTo me, the most interesting aspect of S-expression programming languages is that they are very well suited for other editors than the text editor. I know of a number of experiments in this regard but I have yet to see anything quite as ground breaking as what I can imagine is possible. How come we don't have Google Maps-like zooming with LOD mapping to abstractions at different levels?
- deleted 4y ago[deleted]
- jerf 4y agoMany have tried. The upshot is, it is either not as cool as it is in our heads if you get it, or it isn't as easy as it is in our heads. You don't even really need s-expressions to do what you're talking about. You can do it off of any grammar, which all current programming languages have[1]. S-expressions are slightly easier, but they aren't easier in the place where the real problem lies. The real problem lies in the fact that the code isn't shaped the way you think it is and it isn't as nice as you think it is and it turns out nearly every attempt to project code into something other than our current plain text representation flounders on the pathological nature of source code. Personally I think this is a fundamental problem, but there is an avenue to where I would be wrong. If somebody who respected text and understood why it is currently so dominant, in a positive sense, also took on the task of trying to transcend it based on that understanding, perhaps they could find something, revealing the current lack of such editors to be accidental after all. But as long as the only rebels trying it also labor under the crippling error that text is a weakness that needs to be discarded as quickly as possible, rather than the only methodology currently known to be even remotely strong enough to support our programming endeavors [2], they're never going to get anywhere in trying to deploy a system that for anyone to be even remotely interested in it pretty much has to immediately be able to scale up to some reasonably fraction of what text editors already do. I find it telling that the stickiest such effort I've seen to date is literally to simply provide the programmer with a completely zoomed out graphic of the text file in the scrollbar area. [1] Since nobody has yet had the resources to try to figure out how to take a language model and turn it into a programming language. Patience. [2] Or, to put it another way... make a list of all the weaknesses text putatively has for programming languages. Then sit and stare at it for a while until you grok that that is still the shortest list of weaknesses we know of, and all other efforts have even worse weaknesses at scale. It isn't that I deny the weaknesses; they are manifest and obvious to pretty much everybody. It is that it's still the shortest such known list at scale.
- register 4y agoA looked at it a couple of years ago. It didn't have a Lisp like repl in the sense that it was not possible to recompile running code. I don't know if that has changed in the meantime.
- schemescape 4y agoSounds similar to Cakelisp. Has anyone tried both and is able to contrast them? The author of Cakelisp notes that Carp requires writing bindings, but Cakelisp apparently does not: https://macoy.me/code/macoy/cakelisp/src/branch/master/doc/VsOtherLanguages.org https://macoy.me/code/macoy/cakelisp/src/branch/master/doc/V... Edit: I think Cakelisp has you explicitly generate C code, and maybe Carp does it behind the scenes?
- tmtvl 4y agoThe difference as far as I can see is as follows: Cakelisp is an S-expression representation of C++, kind of like how Assembly language is a nicer representation of machine code. Carp is its own language which transpiles to C, like a bunch of other languages that get transpiled to C (e.g. Nim, Chicken Scheme,...). I suppose the main trade-off (besides Clojure syntax) is RAII and MMM versus a borrow checker, consult your nearest Rust article for much back and forth about that stuff.
- schemescape 4y agoMMM = manual memory management?
- tmtvl 4y agoYep, good old malloc and calloc (and if you absolutely undeniably have to, free)... well, or your own hand-rolled variants. Come to think of it, that could work well with S-expressions: (with-arena my-arena (let ((foo-a (allocate foo))) ;; yadda yadda yadda ))
- LispSporks22 4y agoI tried it out months ago. It has a really limiting REPL if you’re coming from other lisps like Common Lisp or even Clojure. If your bag is interactive development, then that might be a bummer. https://github.com/carp-lang/Carp/blob/master/docs/Manual.md#differences-compared-to-repls-in-other-lisps https://github.com/carp-lang/Carp/blob/master/docs/Manual.md...
- seabass-labrax 4y agoI'm excited about Carp's comprehensive and well documented[1] interoperability with C, which unlocks lots of potential for interfacing with existing libraries. Tim Dévé has even created a game for the Nintendo Game Boy Advance by using Carp's C interoperability; you can play an emulated version online[2]. [1]: https://github.com/carp-lang/Carp/blob/master/docs/CInterop.md https://github.com/carp-lang/Carp/blob/master/docs/CInterop.... [2]: https://radicorn.do.timdeve.com/ https://radicorn.do.timdeve.com/
- Konohamaru 4y agoDynamic typing and garbage collection are kind of inherent to being a lisp. Without those you just have C or Java but with sexprs.
- speed_spread 4y agoYou still get homoiconicity from the syntax which is nice since you can easily transform data into code into data into code into data... At build time. Metaprogramming in C or Java is not fun. It's either code generation integrated with the build system, preprocessor (yuck), annotations processors or runtime weaving. Which all suck at different levels.
- Konohamaru 4y agoFair point. 99% of the pain of C and Java comes from their clunky build system.
- deleted 4y ago[deleted]
- layer8 4y agoHaving used https://perldoc.perl.org/Carp https://perldoc.perl.org/Carp in the past, I always have to remind myself that this is the noun, not the verb.
- v3ss0n 4y agoWhy Lisp people keep making lisp after lisp alternatives and pretty much almost all of them have no users except Scalar.
- timdeve 4y agoDon't get too hung up on the "lisp" in that title. I think the language would better be described as statically typed, with s-expr syntax, inspired by Clojure|Rust|ML and with a lispy language accessible for use in macros. But that's less catchy. Source: I contribute to the language.
- bmitc 4y agoIs it suitable for real-time embedded programming? How about audio libraries? Does it have microcontroller support? I've heard about Carp before, but haven't ever tried it. I've longed for an embedded ML language, and I like Lisp and Scheme, so this seems right up my alley. Apologies for all the questions, but I'm just curious about potentially applicability to some things I have in mind.
- timdeve 4y agoThe goal is certainly to have a language suitable for "real-time applications" (read games/audio), that's not my area of expertise however so your definition of real-time might not be different than mine. As it compiles to C, any microcontroller with a compiler that supports something that looks like C can work. I've run Carp code on a GBA (as mentionned somewhere else in the comments), esp32, esp8266, as well as Arduboy & Pygamer via Arduino. There is some more information about running Carp on embedded platforms in the docs[0]. One last thing I wanted to mention is that Carp is still very much in flux so it might not be the best choice for longterm projects, but if you're interested in playing with the language there is usually always someone to answer questions on the Gitter[1]. [0] https://github.com/carp-lang/Carp/blob/master/docs/Embedded.md https://github.com/carp-lang/Carp/blob/master/docs/Embedded.... [1] https://app.gitter.im/#/room/#eriksvedang_Carp:gitter.im https://app.gitter.im/#/room/#eriksvedang_Carp:gitter.im
- bmitc 4y agoThanks for the response and details! I'll try and start playing around with it.