15 ms·
Janet – a Lisp-like functional, imperative programming language
- deleted 5y ago[deleted]
- spsesk117 5y agoThis looks really interesting, going to check this out later today. Anyone using Janet for anything that would care to comment on their experience?
- swlkr 5y agoI wrote a few websites with it, notably: https://github.com/swlkr/janetdocs https://github.com/swlkr/janetdocs I also scraped together a large web framework and a small one: https://github.com/joy-framework/joy https://github.com/joy-framework/joy https://github.com/swlkr/osprey https://github.com/swlkr/osprey
- frompdx 5y agoThanks for all of your work Sean. I've messed around a bit with Joy and have been keeping an eye on the development of the framework.
- swlkr 5y agoHey no problem! It's always great when something I make for myself works out for someone else too!
- spsesk117 5y agoOh awesome, thanks for sharing, I have already been looking at some community examples on there!
- harryvederci 5y agoI'm using your html library (a Clojure hiccup clone, sort of) and tw (tailwind) library, and often use janetdocs to find examples of how to use Janet functions. Thanks a lot man!
- swlkr 5y agoHey! It's nice to see someone using the stack! What's funny about tw is that it was kind of like a ghetto tailwind jit before it was released! Janet can really help you move fast
- harryvederci 5y agoHaha, I like that description: "ghetto tailwind jit". From your blog it seems like you're not really using it yourself anymore, though? I tried to add a styling thingy (sorry, really not familiar with the terminology) to `tw` to add support for "print" media queries (like this: https://tailwindcss.com/docs/breakpoints#styling-for-print https://tailwindcss.com/docs/breakpoints#styling-for-print), but didn't get it to work on the first try. If I do make it work I'll create a PR :)
- swlkr 5y agoOh yeah, that's a bit of journey, each variant is kind of annoying to handle manually. I always look forward to any and all PRs! Edit: Yeah I haven't used it lately, I currently use roda + sequel now (ruby libraries). I have limited time after work and I really want to get some "SaaS apps" up and running, so the trade-off was spend less time on libraries and more time on applications.
- cellularmitosis 5y agoBecause swlkr is a bit modest, I’ll take this opportunity to point out his Janet twitch streams on his behalf. Definitely check them out! (google for “twitch swlkr”)
- swlkr 5y agohaha thanks for the shout out! I’m currently working on ruby stuff on stream but maybe I won’t be able to stay away from Janet for long
- saikyun 5y agoI'm making an editor, Freja, which is like a tiny Emacs with graphical support. Makes it fun to create gui apps and games. :) Ultima Underworld inspired game I'm making for a game jam: https://youtu.be/1fWsV83P-S8 https://youtu.be/1fWsV83P-S8 Demo of pixel editor: https://www.youtube.com/watch?v=KOBi805nxNc https://www.youtube.com/watch?v=KOBi805nxNc Freja: https://github.com/Saikyun/freja https://github.com/Saikyun/freja --- My experience has overall been very nice. I come from Clojure, and comparing to that: - so nice and small! Clojure is great but has a lot of baggage from JVM, for good and bad - very easy to get started interoping with C. You need to manually wrap libraries, but I think it's pretty easy. As a benefit, you are able to throw exceptions from C that can be catched from Janet. The C support is what sells me on Janet over Clojure - repl:ing works well, but you can get tripped up by early binding and lack of namespaces. There are ways around it, but when coming from Clojure it was a bit hard to wrap my head around - many libraries that you'd want are already wrapped, like http-servers and postgresql connections. But ofc this is an area that is thinner than older languages. It's decently easy to wrap C-libs though - easy to understand data structures if you've used JS / Lua -- "everything is a hashmap" (but there are also arrays and strings)
- diskzero 5y agoFreja looks really cool! Thanks for sharing it. I find these types of projects very inspiring. They bring back the wonder and joy that I felt when I first discovered computers in the early 80s. You felt like you were in control of a whole new world and anything was possible.
- saikyun 5y agoThank you! That is exactly what I'm going for. :) My friend said "so you're just making basic?", haha. I didn't get to experience C64 / Amiga era, but after having listened to 100s of interviews with swedish game developers it seems that the automatic (or even required) access to a coding environment sparked a lot of creativity and imagination. :) I hope Freja can capture at least a part of that.
- spsesk117 5y agoWow! Some really cool projects, thanks for sharing, I'll definitely check out Freja later this evening! Thanks so much for the info and commentary!
- ianthehenry 5y agoI've been writing about my first impressions of the language here: https://ianthehenry.com/posts/janet-game/ https://ianthehenry.com/posts/janet-game/ Not a whole lot of content yet, but I plan to keep going with it. I am pretty firmly in the Haskell/OCaml "let me program with types" camp for most development, but it's a great to have a little scripting language to reach for instead of bash or Python or Perl. Using Janet (coming from Python) reminds me a bit of: https://xkcd.com/353/ https://xkcd.com/353/ Except... without the rich standard library :)
- spsesk117 5y agoThanks for the link, I'll definitely check it out! What actually piqued my interest was the surface impression of something like a Lispier Perl/Python.
- CraigJPerry 5y agoYour writing style is really enjoyable, I binged the 3 posts and really enjoyed, especially the macros post
- actuallyalys 5y agoI've thought about using Janet for a game, but there's more examples of people using love2d plus Fennel so I'm more likely to use that combination for my future Lisp game experiments. (Fennel is similar to Janet and created by the same person, but compiles to Lua.)
- harryvederci 5y agoI'm using it for some side projects, combined with htmx (htmx.org). What I like: 1. The applications start really quickly, compared to Clojure. 2. It feels like I could learn everything about the language if I ever want to dive into the internals. With Clojure/Babashka I don't think that would be possible for me. 3. A bit vague, but it really feels nice to program in this language. I can easily get things to work, I can mess around in a REPL if I want to, and #4: 4. The community is great. Instead of searching on the internet, when I don't know how to do something, I ask a question on gitter / matrix and before long there's an answer from a more experienced person (sometimes even from the creator of the language). 5. The package manager (JPM) is really easy to use. 6. In terms of download size, Janet it tiny. But compared to Lua, it's way more "batteries included" due to the great standard library. What could be better: 1. Tooling I guess, but that's logical for younger languages. I use Olical his "Conjure" Neovim plugin, which is great. I don't think it's possible to jump to the definition of a function name if my cursor is on it. Maybe that's normally done through LSP in Conjure, I'm not sure. I don't know if there are plans to add LSP support to Janet? 2. I just found out a couple of days ago that Janet has no `set` datastructure. You can work around this by using a hashmap where each key maps to a value of true, or you can use a library that adds the datastructure. 3. Not sure if this would have downsides in Janet, but something I really like about Clojure is that you can use a lot of standard library functions on all data types. In Janet sometimes you have to look up a function specific to a data type, where Clojure would be more agnostic - with functions that work on different datatypes in an expected way, and return a `sequence`. 4. Some library authors have the tendency to use "The Good Place" references in their library names. I know the name "Janet" is a reference to that series, and I know developers in all languages are always trying to be funny. But finding a library called "html" (by swlkr) is way more helpful than finding one named after some character from a series. What I think I will like, but haven't tried yet: 1. Object Oriented Programming in Janet seems nice (https://janet-lang.org/docs/object_oriented.html https://janet-lang.org/docs/object_oriented.html). 2. PEG (Parsing Expression Grammars - https://janet-lang.org/docs/peg.html https://janet-lang.org/docs/peg.html )
- frompdx 5y agoI use Janet most often as a glue for shell utilities using the sh package (https://github.com/andrewchambers/janet-sh https://github.com/andrewchambers/janet-sh). It's a great tool for building small containerized jobs. I think it has a ton of potential as the ecosystem grows and matures. Some rough spots: - No canonical http client. There are a few attempts at wrapping libcurl but nothing complete and well documented yet. However, the creator of Joy framework for Janet does have an http client library. - The main http server circlet is MIT licensed, but it is built on top of Mongoose, which is GPL/paid commercial. Something to be aware of if you want to distribute binaries made with this library. - I have never been successful getting any of the UI or drawing libraries to work. - Naming of packages is a bit confusing even if you have watched the Good Place and are aware of all of the inside jokes.
- saikyun 5y ago> I have never been successful getting any of the UI or drawing libraries to work. Have you tried jaylib (built on top of raylib)? I have gotten that to work well on macos, linux and windows. :) > The main http server circlet is MIT licensed, but it is built on top of Mongoose, which is GPL/paid commercial. Something to be aware of if you want to distribute binaries made with this library. While I haven't used it outside of development, chidi is MIT licensed. :) https://git.sr.ht/~pepe/chidi https://git.sr.ht/~pepe/chidi
- jd_mongodb 5y agoThe Mongoose github says it's MIT Licensed https://github.com/Automattic/mongoose https://github.com/Automattic/mongoose
- frompdx 5y agoDifferent mongoose in this case: https://cesanta.com/ https://cesanta.com/
- jd_mongodb 5y ago
- jordemort 5y agoThis is one of those languages I'd like to try because the people I know of that are using it seem so dang happy.
- cellularmitosis 5y agoStart by browsing some of the user submitted examples over at https://janetdocs.com/ https://janetdocs.com/
- threatofrain 5y agoAnything new happen with Janet? https://news.ycombinator.com/item?id=28255116 https://news.ycombinator.com/item?id=28255116 (August 2021) [114 Comments] https://news.ycombinator.com/item?id=23164614 https://news.ycombinator.com/item?id=23164614 (May 2020) [269 Comments]
- diggan 5y agoSome interesting changes since August this year: - Threaded channels `ev/thread-chan` (`thread` has been deprecated [and removed in latest version [[1.18]]]) - JPM (Janet Package Manager) is now separate, not distributed together with Janet anymore - Janet binary can directly run image files with `-i`
- deleted 5y ago[deleted]
- db65edfc7996 5y ago(Not a lisp guy). What is an image and why would I want to run one? My best guess is that an image would be platform independent bytecode vs compiled executable?
- mumblemumble 5y agoIt's a dump of the state of the run-time environment, including data. Probably the easiest use case is using it as a savegame feature when you're working in the REPL. It's not necessarily portable. Some lisps will use machine-independent bytecode, others use native code. I'm not sure which one Janet does.
- ianthehenry 5y agoI think of it as one of the defining features of Smalltalk, not Lisp, although there is plenty of cross-pollination. https://en.wikipedia.org/wiki/Smalltalk#Image-based_persistence https://en.wikipedia.org/wiki/Smalltalk#Image-based_persiste... Janet's object system seems to be modeled after ideas first popularized in the Self language -- a Smalltalk derivative -- so there could be some direct inspiration there. https://en.wikipedia.org/wiki/Self_(programming_language) https://en.wikipedia.org/wiki/Self_(programming_language)
- hatmatrix 5y agoWhy use this over Chicken Scheme?
- progre 5y agoI'm unqualified to answer since I haven't used Chicken Scheme, but the name implies that it's a Scheme, right? Janet is a "modern" lisp-like with [] and {} for arrays and maps. Also, I think Chicken compiles to C? Janet compiles to bytecode.
- tut-urut-utut 5y agoWhile we are at this topic: why use Chicken Scheme over this?
- oshiar53-0 5y agoor, maybe newLISP and vice-versa
- michaelsbradley 5y agoGerbil? https://cons.io/ https://cons.io/
- outworlder 5y agoDecent amount of libraries (eggs) for one(and a package manager). Follows a language spec (R5RS). Then we get to the personal preferences territory. You may prefer a Scheme(with its hygienic macros and other goodies). Or the way it generates C code (which is then compiled). As an example. At one time I was experimenting with writing iOS games in Scheme. The usual option would be cross-compilation. I would cross compile my Scheme program as a library and add the to project. But XCode is annoying because it wants ARM code for the actual device, and X86 code for the simulator. Rather than building a complicated build system, I just told Chicken to stop at C code generation, then added the generated code to the XCode project. XCode could now compile the entire thing as if it was all C+Objective C code in the first place. Add a couple of instructions for the actual embedding and there's my hybrid Scheme+Objective C program. Related to the example above, I was missing an OpenGL ES library. But I found a similar library from Gambit Scheme. Given that they are both Scheme, the code would work with almost no changes. The only changes were related to the foreign function interface (to call C), which were not standardized. So I just wrote a 'compatibility' macro, and the code would now run. Ultimately though, it's all up to you. I'm just happy there's always some healthy baseline interest in Lisp-like languages.
- abhinav22 5y agoCongratulations on it. I use Common Lisp myself, but always great to see energy and passion in other languages, especially in the Lisp family of languages (but I am clearly biased).
- jpe90 5y agoHello! I saved a URL to a great article you wrote about web development in common lisp, but the domain appears to be offline. Any chance you have a new site? Sorry for the off topic reply, I don't think this site has DMs..
- matvore 5y agoI am a happy though very new Janet user. I started migrating my existing workflow optimization scripts (e.g. Git wrappers) to--and writing new ones--in Janet as of a few months ago. I used to use Perl but I switched to Janet as it is a much simpler language and VM, and being a Lisp is ~infinitely extensible. Janet has os/ and file/ packages, as well as a PEG system which mostly stand in for the best features of Perl. Some low-level POSIX-specific operations (like daemonizing and forking) aren't practical but I can just use C for those. I am also using it to teach my son very simple programming. He can't type well yet, so the terseness of the language helps (there are cryptic symbols but he likes learning their names and how to type them). Its REPL and functional style I feel help a lot too.
- jhgb 5y agoHave you perchance tried Gerbil as well?
- matvore 5y agoI did not hear of it before. Glancing at the website, it looks rather appealing (simple language, C-friendly FFI) but I don't see anything about using Gerbil in the shebang line for scripting purposes? I may give it a closer look sometime.
- harryvederci 5y agoI've played with the idea of converting my bash path scripts to Janet, but haven't had the time yet. Have you experienced any downsides of using it for your optimization scripts?
- matvore 5y agoI would say that if you're interested, go for it. My complaints about Janet are not too big. I feel like there are many ways to do some things, and they are all basically the same. Most of this excessive flexibility is inherited from Clojure. 1. It's never clear whether I need `cond` or can get by with `case` until I've waffled around a bit 2. I don't know whether to choose `if`, `and`, or `when`, for conditionals, because there are many times when all three would work. Also, if the condition expression is trivially negated (e.g. change '=' to '!=') then even `or` would work, making 4 choices. 3. It's hard to choose between `->` vs. manually-nested expressions. EDIT: formatting
- nyanpasu64 5y ago> Multithreading Does it have a global interpreter lock (GIL)?
- pansa2 5y ago> Each thread has its own Janet heap, which means threads behave more like processes that communicate by message passing. https://janet-lang.org/docs/threads.html https://janet-lang.org/docs/threads.html Janet doesn’t seem to have shared-memory multithreading. Each thread runs independently, so a GIL should not be necessary.
- saikyun 5y agoThough you can share memory manually, i.e. in C but access it from Janet.
- deleted 5y ago[deleted]
- gwn7 5y agoOff topic: Is it just me or are there any others who find naming programming languages with women's names a bit weird? Julia, Janet, Eve... I understand the guy referring to his car as his "girlfriend" and give it a women's name. I just can't feel the same about tech. I guess this may be the nerd's way of immortalizing their sweetheart, but if I was a woman I'd rather prefer to be a car and not a programming language. A programming language doesn't feel much anthropomorphizable to me, let alone lady-like. Women, what do you think?
- avgcorrection 5y agoNo, I don’t think that giving non-objects/not objectifiable things women’s names is weird. Nor that the necessary implication is that they are named after girlfriends.
- blacktriangle 5y agoAda, Alice... Interesting question, but it might just be a yellow volkswagon effect. Quickly looking at Wikipedia's list of languages, theres Babbage, Bertrand, Cecil, Darwin, Dylan, Escher, Euclid, Euler, Godel, Hume, Orwell, Tom, Zeno, and probably a few others I missed. EDIT: Haskell and Pascal, how embarassing to miss those
- phreack 5y agoI was first introduced to programming with Pascal, can't believe I forgot about it until I saw your list.
- Tommah 5y agoalso Haskell and Pascal
- WJW 5y agoIt's a shame that Haskell Brooks Curry did not have any more names because all three of his names have already been used for programming languages by now.
- 5y ago
- ltbarcly3 5y agoMaybe I'm just too pedantic, but this is not a functional language. Yes, you can write functional style code, but you can write functional style code in C, C++, Java, Python, JS, Ruby, Common Lisp, Scheme, etc etc. That does not make any of these languages 'functional'.
- AlexCoventry 5y agoThe main question for me is whether it has persistent data structures with structural sharing. If it has that, I'm happy to call it "functional." Without that it's hard to write efficient pure functions.
- dragonwriter 5y ago> Yes, you can write functional style code, but you can write functional style code in C, C++, Java, Python, JS, Ruby, Common Lisp, Scheme, etc etc. That does not make any of these languages 'functional'. Lisp-family languages (both CL and its immediate predecessors, and Scheme) for a long time were the textbook example of functional languages. The relatively novel (and still niche) attempt to redefine things so that only pure functional languages are “functional languages”, and particularly the people that insist on this usage as if it were firmly established and abuse those who don't conform to their preferred redefinition, is a bit annoying.
- ltbarcly3 5y agoThis is not correct, lisp operations on lists have always been to modify in place, with copying versions added later. The technology did not exist to do functional programming efficiently enough (and to some extent that technology still does not exist generally).
- bluefox 5y agoSimply false. For example, LISP 1.5 manual had this definition for UNION: (union (lambda (x y) (cond ((null x) y) ((member (car x) y) (union (cdr x) y)) (t (cons (car x) (union (cdr x) y)))))) It had a MAPLIST (today called MAPCAR): maplist[x;fn]=[null[x]->NIL; t->cons[fn[x];maplist[cdr[x];fn]]] Or APPEND: append[x;y] = [null[x] -> y; T -> cons[car[x]; append[cdr[x];y]]] Et cetera. Sure, it also had, say, NCONC. But it had these operators and style from the beginning, not surprisingly, as Lisp came from lambda calculus.
- michaelhoffman 5y agoWhat's the advantage of not having lists? How does this affect one's programming style versus Scheme or Common Lisp (or Emacs Lisp, honestly the Lisp I'm most familiar with)?
- tombert 5y agoDisclaimer: I've never used Janet, but I am pretty familiar with Clojure. In Clojure, there are lists, but the most common structure for sequential data is actually a vector [1], which works more-or-less as a slightly modified version of the Clojure version of a hashmap. Advantages of doing it this way is that you get log32 indexed lookup times (vs linear for lists), and you also get log32 [2] append-to-the-end semantics instead of "push to the beginning" that you have with lists. In practice it generally doesn't affect a lot, but occasionally when I do need to put an item in the front of a collection, I will wish I had used a list instead of a vector, but I feel like the far more-common usecase is to append to the end, since in Erlang there's been a few times where I end up having to reverse the list after I'm done building it. [1] At least how I use it, I haven't done any statistics to prove this. [2] Don't let the log scare you! Log32 is very good and also effectively constant time for most in-practice use cases. Log32 of a billion is basically six, meaning you're dealing with a constant factor times six hops for inserts and lookups on a billion elements.
- mst 5y agoPhil Bagwell's VList data structure seems really interesting as a way to avoid a bunch of the pitfalls of naive lists performance-wise - the paper's good fun and there seems to be an implementation in racket for anybody who wants to play with it.
- spicybright 5y agoDoes any one have a copy of anything related to this? Wikipedia had an article on it deleted, and I'm not getting much from the first few pages of google...
- 5y ago
- ngcc_hk 5y agoWonder given it is easy to be embedded, will we have an iOS janet app?
- rcarmo 5y agoYou can build Janet in iSH and run it on an iPad that way, which is what I do.
- deleted 5y ago[deleted]
- germandiago 5y agoI would like to have a language like this that is easy to bind C++ (including classes) code to in a way as easy as ChaiScript. I did several experiments for a side-project. The end result was that I moved from ChaiScript (no generators or fibers or lightweight concurrency) to Wren language. I saw Janet, and I was very tempted, but nothing like WrenBind17 exists for it AFAIK.