17 ms·
Janet: a lightweight, expressive and modern Lisp
- gozzoo 6y agoIs it compiled or interpreted? If interpreted does it use existing interpreter? The description mentions Lua, does it use the Lua engine? Does it have JIT? If it is compiled is it based on LLVM?
- anonymoushn 6y agoI don't know much about Janet (all I've done is complain that create-fiber did not work the way the docs say it did), but I'm pretty sure it uses its own bytecode interpreter.
- pull_my_finger 6y agoIt doesn't "depend" on Lua at all, but you can definitely feel inspiration from Lua in the language. Has coroutines, tables, small and easy to embed as a design goal, has a LPEG-like PEG built-in. Really lovely if you can appreciate those things in Lua-land.
- mlatu 6y agoThis sounds awesome! I was about to try and extend a software-product with graalvm to extend it live in clojure. But Janet sounds like a couple less hoops to jump through. Also, I won't have to deal with Oracle at all :D which is really the main reason I haven't begun work on this project yet.
- augustk 6y agoHow does this language compare to, say Scheme?
- technoplato 6y agoPlease tell me this was somehow inspired by “The Good Place”...
- deleted 6y ago[deleted]
- Witoso 6y agoYep. > Janet is named after the almost omniscient and friendly artificial being in The Good Place.[0] [0]https://github.com/janet-lang/janet#why-janet https://github.com/janet-lang/janet#why-janet
- orwin 6y agoI'm beginning to create a lisp webserver using sbcl for a personal project. I find this interesting but i'd like to know if a webserver library exist for janet yet, and how does it perform compared to sbcl performance-wise (x2 to x5 does not bother me, anything beyond that would not be great). I'd like to know if a slime/swank can be used with janet (although this is really not a requirement) [edit] i just thought that creating a webserver would be a nice introduction to the language. Also can you compile janet into wasm?
- srle 6y agoIt’s right on the bottom of the page my dude, just scroll down or C-f circlet
- orwin 6y agowow i stopped at "try it". thank you.
- pull_my_finger 6y agoI'd offer an alternative to the one linked on the main page in Joy[1]. Quick and easy to get started with. 1: https://github.com/joy-framework/joy https://github.com/joy-framework/joy
- mapcars 6y ago2020: a programming language is named Janet; a child is named X Æ A-12. How did we come to this.
- oblio 6y agoIt's not really something new. Ada (https://en.wikipedia.org/wiki/Ada_(programming_language) https://en.wikipedia.org/wiki/Ada_(programming_language) ) was created 40 years ago. Kids with crazy names is a long standing tradition, going back millenia :-)
- mhd 6y agoAlso Amos, Haskell, Idris, Joy, Miranda or Yorick. Arguably Dylan or Pascal. I'm more confused by a name starting with a capital "J" not being associated with Java, as once was custom. As for kid's names, definitely[1]. [1]: https://www.youtube.com/watch?v=Jg9w0YSMLHY https://www.youtube.com/watch?v=Jg9w0YSMLHY
- mapcars 6y agoYou are right, just the timing and example is so striking :)
- aasasd 6y agoYou mean that the language should've been called ‘XÆA-12’ instead?
- phoe-krk 6y agojanet:1:> (cons 1 2) compile error: unknown symbol cons on line 1, column 1 while compiling repl janet:2:> (list 1 2) compile error: unknown symbol list on line 2, column 1 while compiling repl janet:3:> (vector 1 2) compile error: unknown symbol vector on line 3, column 1 while compiling repl I certainly need to learn the basic idioms of this dialect; it looks nothing like Common Lisp under the hood.
- pjc50 6y agoIs it really Lisp without cons?
- deleted 6y ago[deleted]
- phoe-krk 6y agoYes, it seems so. Try the REPL available at the website.
- oblio 6y agoI wonder if his question was not rhetorical, as in: It is really Lisp if it doesn't have cons?
- phoe-krk 6y agoThat question has been a source of multiple flamewars in the past that have only made the world worse as a result. I prefer not to go down that hole again.
- lispm 6y agoIs it really Lisp without 'lists'? https://janet-lang.org/api/index.html https://janet-lang.org/api/index.html that does not mention list in meaningful ways. It seems to prefer to work with other data structures (like arrays) - which is okay, but then I won't call it a List Processor dialect.
- w0utert 6y agoLisp languages should be great for embedding into games to implement game logic, instead of more straightforward solutions such as embedding Lua. I've always wanted to explore this for my iOS side-project game, which now uses an event-based system inspired by ReactiveX, implemented in Lua. This works pretty well but is very hard to debug. The main thing holding me back to try to replace it with something Lisp-like is that I have zero experience in Lisp programming. I know some FP theory (in fact the Lua-based event system lends some concepts from it), but when I try to reason about common subproblems I really have no idea how to map them to something like Lisp. For example how to efficiently implement a message bus with observers that can register themselves, using state-based functions to execute when certain events are received, scheduling events, async/await to suspend processing until some event is received, etc. Does anyone have pointers to books or websites to learn 'real-world' LISP programming? In other words not yet another introduction that shows the same old forced examples that just show you how to evaluate an expression or use higher-order functions to solve artificial toy problems, but resources that teach you how to be productive in a Lisp language?
- phoe-krk 6y ago> but when I try to reason about common subproblems I really have no idea how to map them to something like Lisp. For example how to efficiently implement a message bus with observers that can register for certain events. I think that's a badly posed question. The main benefits of using Lisp are its introspection and interactivity. You can use the REPL to inspect your message bus at runtime, you can modify parts of it as it runs, you can interactively debug errors as they happen, but none of that is directly related to "how to implement a message bus". I think that is more of an ADS question that it is a Lisp question; an efficient message bus, no matter whether you implement it in Lisp or in C or in Haskell, needs some synchronization primitives from the programming language core that are likely backed by OS primitives, as well as some data structures that need to be cleverly designed to be fast. Neither of these is language-specific - only means of implementing and using those might be language-specific. In other words: Lisp makes it possible to be more productive by means of dramatically reducing the time of feedback loop and by means of providing in-depth language introspection, but it doesn't solve the problem of actually needing to figure out how to design programs and data structures. That's why e.g. SICP is not a Scheme tutorial, despite using Scheme throughout the whole book.
- pjc50 6y ago1) How is this different from other Lisps or Schemes? 2) When promoting a new programming language, always provide a nontrivial example. Couple of pages of code. Mandelbrot generator, desk calculator, notekeeping app, that sort of thing.
- augustk 6y agoAnd the motivation for designing the new language. What problems does it solve better than existing languages? How does it promote the creation of maintainable programs? Etc, etc.
- phonebucket 6y ago> What problems does it solve better than existing languages? How does it promote the creation of maintainable programs? I broadly agree that widespread adoption probably requires answering some sort question like these. But sometimes people create languages just because they are fun to create, and they think other people might enjoy using them.
- pjmlp 6y agoJust taking into consideration that most engineering degrees have of some of compilers design course, there are thousands of programming languages born every year across the globe. So it needs more than just "grammar + semantics + basic library" to actually be relevant. However that is how many nowadays mainstream languages have started, so luck also plays a big role.
- cellularmitosis 6y ago1) the startup time is fantastic https://github.com/janet-lang/janet/issues/324#issuecomment-623123272 https://github.com/janet-lang/janet/issues/324#issuecomment-... Function call throughput is just behind the JIT’ed lisps, which is understandable for a bytecode runtime.
- oalae5niMiel7qu 6y ago> How is this different from other Lisps or Schemes? Janet has almost nothing in common with Lisp or Scheme, besides the parentheses and the presence of some form of macro system.
- kleiba 6y agoOkay, so when Clojure came along, it came with a strong underlying philosophy of what the language was supposed to be/do. Among them were design decisions such as, e.g.,: - VMs, not OSes, are the platforms of the future, so target the JVM - Object Orientation is overrated, but polymorphism is a good thing - Multi-core is here to stay, so use immutable data structures to greatly facilitate writing correct concurrent programs - Leverage the strengths of LISP but give it a modern overhaul (most notably, throw in different parenthesis) Now, you may or may not subscribe to any of these but my question is just: how does Janet compete on that front? What is the problem it is trying to address specifically? I looked at the web page a bit but it's still not clear to me.
- winter_blue 6y agoIt’s hard to read the bullet points on mobile — can you remove the indentation so it is formatted normally. Other than that, good points.
- pjmlp 6y agoYet Clojure supports a subset of CLOS, so not so much overrated after all.
- dkersten 6y agoClojure was never against any of the ideas in OO, just that they should be accessible individually if or when they make sense. Traditional OO is very “all in”, while Clojure is very a-la-carte use the bits that make sense for the problem you are trying to solve. Clojure also encourages a data-over-objects and a functional-first approach, but when you need the OO features, they’re there and you should use them.
- junke 6y agoJust to clarify, CLOS is very a-la-carte too.
- pjmlp 6y agoEven Smalltalk supports the other way around, although very few are aware of it, because they never bother to learn it. You can do LINQ style coding in Smalltalk-80, and modern Smalltalks like Pharo do support traits as well. So the point being that all major languages embrace both paradigms. "Traditional OOP" basically boils down to Java until version 8 or C# until version 3, and very little else, but unfortunately most teachers fail at giving overviews of programming languages thorough computing history, and many just learn what they can reach out for.
- lenkite 6y agoCan't find the tutorial or language manual.
- hanche 6y agoI see no tutorial either, but did you try clicking the prominent link near the top labeled “Documentation”? The language manual seems to be all there. Once you're inside the documentation, there is a hamburger menu exposing a comprehensive table of contents.
- lenkite 6y agoI am an idiot. Somehow I went to the API documentation and examples instead on the github site. Thanks.
- emmanueloga_ 6y agoI'd love to hear more from the author (can someone interview him for a podcast please? :-). He also has another programming language called Fennel [1] which compiles a lisp like language to Lua. Both Fennel and Janet seem to orbit around Clojure ideas.... interestingly one of Fennel's main contributors [2] is also the author of Clojure's most popular build system, Leiningen. 1: https://fennel-lang.org/ https://fennel-lang.org/ 2: https://technomancy.us/186 https://technomancy.us/186
- aasasd 6y agoI kept thinking that in the ‘small scripting Lisp’ category, a startup-time/performance comparison with Fennel would be apropos, as the latter is blazingly fast and thus well suited for scripting in interactive contexts.
- Koshkin 6y agoFor those who would prefer a more traditional albeit possibly less “lightweight” alternative there’s always Embeddable Common Lisp.
- flavio81 6y agoOr, since Janet is a bytecode interpreter with a download size of <2MB, there's CLISP which also fits that criteria, while providing the full power of Common Lisp and a nice FFI with C.
- pauljurczak 6y agoCall me when you modernize parenthesis out. ;-)
- pauljurczak 6y agoTouchy subject. As expected, downvoted by the Brotherhood of Defenders of a Holy Round Bracket.
- ristos 6y agoThis looks so awesome! It's got the best parts of a lot of languages. This is what sticks out to me: - Really simple lisp like scheme, but reminds me of lua (and not bloated like CL) - Has resumable fibers, no callcc like scheme - Not missing the lack of lists tbh - A module system that doesn't feel awkward like CL - A built-in package manager (unlike CL) - Good lua and C support - Threads have a shared-nothing approach with message passing (reminds me of Erlang actors) - Destructuring - Good PEG support, encourages it over regex - (Im)mutable versions of data structures (ie tuples vs arrays, structs vs tables) for maximum flexibility - Prototypal inheritance - Docs are clean and easy to read I'll definitely have to try this out, it looks really cool. Some stuff I'd like to see: - Pattern matching support (could be a library I guess) - Multimethods - Full numeric tower with arbitrary precision types - Javascript compilation -- I could see this language being really useful for web and game dev Does it have good debugging support? I'm thinking of something like slime, swank, etc. Can I set up emacs and/or vim to work the same way I can use CL with slime + swank? I'm also wondering about the stack traces -- one of the downsides to CL is sometimes the stack traces are nasty to read
- ristos 6y agoWhy was this downvoted? I don't get it :/
- lispm 6y agoCategory error maybe: CL is a language standard with several very extremely different implementations and a diverse tool landscape. Janet OTOH is a single language&implementation.
- carapace 6y agoLikely for bashing CL (however lightly). People get tetchy.
- deleted 6y ago[deleted]
- nromiun 6y ago
- macleginn 6y agoI looked at the first two libraries listed on the landing page, and they seem to be mostly implemented in C. (The same goes for the 3rd lib, but it's SQLite bindings, which makes sense.) This is a bit discouraging.
- prirun 6y agoI have been looking at Nim, Go, and D lately, as a follow-on to Python. Good SQLite support is something I need for HashBackup (author). Nim has a direct interface to SQLite's C API and a higher-level db_sqlite interface. The higher-level interface doesn't support prepared queries so Nim's SQLite performance on a small test is slower than Python using the sqlite3 API which automatically compiles and caches queries. The Nim binding replaces all parameters, specified with ?, with quoted values. That means: - you can't have a null-valued parameter - numbers get inserted as text (I think) - blobs are string quoted and get changed to text instead of using SQLite's X'(hex)' blob notation All returned values from db_sqlite are strings. If you want integers, you have to parseInt() the column. I do like that Nim's db_sqlite interface is very simple so that you can still use the lower-level sqlite interface with the same db connection. So at least I could cache prepared queries if I wanted, but I have to do the work. Checking out Go's SQLite interface, there are some issues posted on the repo (mattn/go-sqlite3) about performance problems because Go uses cgo for SQLite. Haven't test that yet. Since the SQLite module was listed on the front page of Janet's site, I decided to check it out. It, like all the other C code I looked at in the project, is rather beautiful, and that's not a compliment you see very often about C code, my own included. The SQLite interface handles multiple types, including nulls, blobs, and numbers (everything is a float, I'm guessing because that's how Janet implements all numbers). It appears to not cache prepared statements (that would probably be a big performance boost), but does allow parameter substitution by name. If you want to see some really nice C code, check out this project!
- oknoorap 6y agoAny tutorial about Janet?
- jbritton 6y agoThe Janet documentation is sufficient to get going. It reads pretty much like a tutorial. At least if you have any lisp/scheme experience. https://janet-lang.org/docs/index.html https://janet-lang.org/docs/index.html I downloaded a couple weeks ago. I really wanted to build an executable, but I couldn’t. It seemed all the docs on this aspect were out of date or my build was broken in this respect.
- oknoorap 6y agooh okay, freecodecamp course would be great :-D
- thanatropism 6y agoNot mentioned here: Hy (hylang.org), a Lisp that manipulates/converts to the Python AST and therefore is fully interoperable with the whole vast Python ecosystem. Although the language is still somewhat short of 1.0, it has stopped changing (after a fairly dramatic turn circa 18) and I’ve been writing more Hy than straight Python for a while now. When I started using Streamlit (and then you can’t have a main.hy function that it will recognize, although you can import arbitrary Hy modules) I started writing straight Python again for my weekend project and boy, do I regret it. I’m seriously considering pausing everything to port to Hy.
- mark_l_watson 6y agoI certainly agree that if you need the Python ecosystem, then Hy makes development much more enjoyable, at least it does for me. I look at Hy in the same way as Armed Bear Common Lisp: as a great tool is I need the Java ecosystem.
- natrys 6y ago+1 for Hy. I recently did a project where I needed to embed a lisp. I actually considered Janet (since Schemes are a little too threadbare), but there was no binding for a non-C language. I might consider creating Rust or Nim binding myself later, but Hy proved to be immensely easy and satisfying to work with.
- shirian 6y agoWow, this is exactly what I've been looking for. Also, I'm not a C-programmer, but I think the source code is good-looking.
- Sawamara 6y agoFor what it's worth, the win x64 installer died on me at "creating desktop icons", not exactly the most confidence-inspiring start, but lets see again.
- eggy 6y agoI like it, and I am considering using it as a scripting language. It was clear and easy how to build it for my Windows 10 box, and it is relatively small. I have always like the small Lisps like PicoLisp, but PicoLisp is not Windows friendly; it's very POSIX-dependent. I haven't had great experiences with Cygwin. PicoLisp works on WSL/WSL2 though.
- OmegaBlight 6y agoDid you find the transition to be relatively easy on you? I am considering building a few W10 Box with it.
- kmwr 6y agoHave you seen https://janet-shell.org https://janet-shell.org ?
- eggy 6y agoI had, but it is for unixes, and I am primarily on Windows. I have a Linux box, WSL2, and an iMac, but all of my paying work is on Windows. I like them all, and I like Janet a lot!
- firepoet 6y agoSo, I do a lot of string manipulation using regular expressions, and Janet doesn't support that, in favor of PEGs, which I've never heard of. Does anyone know of a "PEGs for RegEx addicts" resource or something similar? :-) What an interesting project! I'm sorely tempted to examine it more closely for one of my side projects I've been working on in Clojure.
- firepoet 6y agoWhile I'm asking for help.. does anyone know of any crypto bindings? I've been working with libsodium lately, and there is a Clojure library that binds to it.
- billfruit 6y agoHow does this compare with Carp?
- mr_custard 6y agoMany people seem to be comparing Janet and Clojure here as if one had to choose to use only one or the other. Most of my daily work is done in Clojure or ClojureScript and that will continue to be true. However, I am excited by what I've seen in Janet and I'm already thinking that I'd love to call this from bash scripts to do system tasks (devops for example) that don't need the JVM cranked up. I'm choosing both :-)
- dleslie 6y agoI'm not really clear why I would use this and not one of the small embedded Schemes that have srfi-18 support. Chibi and S7 are both "drop some C into your project" levels of trivial to get running, and reasonably zippy. And there's an upgrade path by using the standard: you can move to Chicken, Gambit, Guile, Racket or Chez and keep your code.
- frankpf 6y agoI don't use lisp languages, but one basic difference this has from other lisps is that functions accept multiple expressions, e.g.: (defn greet [firstname lastname] (def fullname (string firstname " " lastname)) (string "Hello, " fullname)) In other lisps, you'd have the last expression nested inside a `let` block: (defn greet [firstname lastname] (let [fullname (string firstname " " lastname)] (string "Hello, " fullname))) which makes the code hard to read and edit IMO. Languages like Haskell and OCaml suffer from a similar problem too.
- threatofrain 6y agoin Racket you can do it either way, and perhaps these sorts of issues should just be solved with an auto code formatter?
- thayne 6y agoIn common lisp `defun` does not require using `let`.
- junke 6y agoThere are two things at play here (1) the implicit body and (2) being able to add new bindings in an existing scope with "def". CL has an implicit body, but does not allow defining new bindings outside of some dedicated forms (let, etc.). I really prefer having to write "let" forms instead of having new variables added inside the body.
- nathcd 6y ago> which makes the code hard to read and edit IMO. Languages like Haskell and OCaml suffer from a similar problem too. That's interesting, I've always really loved the "return last expression in a block" syntax. (Ruby and Rust can be added to your list as well.) That syntax just reads really naturally to me.
- frankpf 6y agoI like that too, but both Rust and Ruby allow multiple expressions/statements before the last expression. In Haskell and OCaml IIUC you need to use things like `let x = ... in <expr>` or `<expr> where x = ...`, so you still have a single expression in function bodies.
- rcarmo 6y agoJanet is quite nice, and I was playing with it only the other day: https://taoofmac.com/space/blog/2020/05/10/1300 https://taoofmac.com/space/blog/2020/05/10/1300 However, nobody here seems to have mentioned Joker, which is a Go interpreter/linter for Clojure: https://joker-lang.org/ https://joker-lang.org/ I'm rather torn between Janet and Joker, but am considering using Joker instead (even though it is single-threaded and lacks SQLite support) because it's closer to Clojure syntax.
- pixelrevision 6y agoWow a lot of care was put into making a complete out of the box readable library but not including too much fat. Looking forward to my weekend.
- Jaruzel 6y agoThere is already a JANET in the computing place, please rename your project: https://en.wikipedia.org/wiki/JANET https://en.wikipedia.org/wiki/JANET Next time, actually Google your proposed name before you use it.