Hacker News new | ask | show | jobs
by spsesk117 1706 days ago
This looks really interesting, going to check this out later today. Anyone using Janet for anything that would care to comment on their experience?
5 comments

I'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

Demo of pixel editor: https://www.youtube.com/watch?v=KOBi805nxNc

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)

Freja 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.
Thank 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.

Wow! Some really cool projects, thanks for sharing, I'll definitely check out Freja later this evening!

Thanks so much for the info and commentary!

Thank you. :)

If you do try it out, I'd be happy for any feedback on Freja! :)

I should mention that Windows support is currently a bit behind, so if you're on Windows I could fix that then comment here again when it's done. :)

Why do you mean by ‘throw exceptions from C’? C has no exceptions.
In libjanet you can use a C call like janet_panic() that'll "panic" and throw an exception/error up in the active Janet runtime (so when something bad/unexpected happens in your C code you are providing an API to from Janet, you'd use this).
This is what I was referring to, sorry for being unclear. :)
That is like saying Scheme does not have exceptions, except in C, we have setjmp instead of call/cc. It is technically correct, but there is something more flexible that can be perverted into doing the same thing.

https://en.wikipedia.org/wiki/Setjmp.h#Exception_handling

I've been writing about my first impressions of the language here:

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/

Except... without the rich standard library :)

Thanks 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.
Your writing style is really enjoyable, I binged the 3 posts and really enjoyed, especially the macros post
I'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.)
I wrote a few websites with it, notably:

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/swlkr/osprey

I'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!
Hey! 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

Haha, 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), but didn't get it to work on the first try. If I do make it work I'll create a PR :)

Oh 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.

Because 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”)
haha 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

Thanks 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.
Hey no problem! It's always great when something I make for myself works out for someone else too!
Oh awesome, thanks for sharing, I have already been looking at some community examples on there!
I use Janet most often as a glue for shell utilities using the sh package (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.

> 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

When I tried to use jaylib I was not able to get it to work at the time. Might have to give it another shot.

The http server used in Chidi is actually fairly new and I was not aware of it. It is part of the spork package. About two months ago I chatted with the creator of Janet about whether or not an http server will be added. He said it would not be added to core, but it looks like he added to spork about a month ago. It looks like it is a pure Janet implementation so there should be no licensing conflicts. I'll have to try it out.

I know I had some trouble with raylib's dependencies on Linux. If you get stuck, feel free to at me at the janet gitter.
Will do, thanks!
The Mongoose github says it's MIT Licensed https://github.com/Automattic/mongoose
Different mongoose in this case: https://cesanta.com/
Doh!
I'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).

2. PEG (Parsing Expression Grammars - https://janet-lang.org/docs/peg.html )