Why Janet? (2023)

(ianthehenry.com)

121 points | by yacin 1 hour ago

16 comments

  • krinne 1 hour ago
    This post is refreshing - smells of the pre AI discussions on the internet. A new language, a new syntax, heavy debate with people who have spent years writing code. I think someone should start a community online where AI isnt allowed.
    • probably_wrong 49 minutes ago
      > I think someone should start a community online where AI isnt allowed.

      In case you haven't followed the saga, the latest[1] digg.com relaunch failed because they couldn't deal with the bot onslaught [2]. Whoever finds a reliable way to keep AI out of an online community first is likely to become a very rich person.

      [1] Second-to-last, actually, seeing as there seems to be a new homepage right now.

      [2] https://www.techspot.com/news/111698-digg-relaunch-fails-two...

      • geokon 35 minutes ago
        lobste.rs uses a web-of-trust referral system. I guess it still involves a moderator killing off bad nodes, but it seems to scale well
    • DoughnutHole 31 minutes ago
      The amazing thing about AI is that you don’t even need AI superfans to shoehorn it into a conversation that doesn’t even touch on AI. Detractors will do it for them.
      • NuclearPM 0 minutes ago
        Yes, it’s similar to Trump. But that makes sense right? AI is changing the world drastically, and so is Trump and his fascist friends.
    • shevy-java 47 minutes ago
      > a new syntax

      How is the syntax new?

      It looks like lispy - see the outer parens in the examples given.

    • soomtong 1 hour ago
      It’s been a few months, but I built a tool by Janet lang to communicate with an LLM via HTTP. Of course, I probably had Claude Code write it for me. It turned out better than I expected.

      I was really impressed by how small the executable file was. I’d only ever done web development with Node.js up until then.

  • 0x0203 30 minutes ago
    Seems some of the listed advantages for Janet would also apply for tcl (small/simple, easy to learn, embeddable, usable as a shell, great for domain specific languages). It would be interesting, to me at least, to see a fan of Janet compare the two.
  • ramblurr 30 minutes ago
    Always nice to see janet getting some attention.

    shout out to one modern feature: sandbox

    "Disable feature sets to prevent the interpreter from using certain system resources. Once a feature is disabled, there is no way to re-enable it."

    https://janet-lang.org/api/misc.html#sandbox

  • uka 1 hour ago
    > But by allowing you to unquote literal functions, Janet makes it possible to write macros that are completely referentially transparent.

    These lisp guys really get excited over very abstract things. If you say this to an average person on the street they will probably try to run away.

    • bryanrasmussen 1 hour ago
      you ever try to explain object oriented programming languages and their benefits to the "average person on the street"?
      • rambrrest 1 hour ago
        somehow i also never got the idea around these languages like lisp. I remember i studied them in school - but i quickly forgot and never got around to relearning it.
        • zelphirkalt 42 minutes ago
          Probably depends on whom you are asking. For me the essence is (1) having functions or procedures as the basic building blocks, not classes. (2) Having all the utility and higher order functions you need to deal with the functions and procedures first idea. (3) Having a very powerful syntax, that allows great semantic editing and is never ambiguous. Oh and can actually be extended in useful ways, without having to wait for a committee to decide upon "the one syntax to rule them all".
        • xigoi 48 minutes ago
          The idea is that instead of having to learn tens of different syntactic constructs with subtle and often arbitrary differences, you just have parentheses and use them to build everything.
    • prerok 19 minutes ago
      Average programmer too /j

      Frankly, though, I think lispy community has benefited from being smaller. For example, even though the now ancient Design Patterns already warned programmers to prefer composition over inheritance, the OO programmers still created 15 levels deep hierarchies.

  • lindig 1 hour ago
    > Instead of regular expressions, Janet’s text wrangling is based around parsing expression grammars. Parsing expression grammars are simpler, more powerful, and more predictable than regular expressions.

    I would dispute that this is the case. In PEGs, alternatives are not commutative, unlike in regular expressions. This can lead to quite frustrating debugging. While a valid choice, the advantage over REs is overstated.

    • zelphirkalt 32 minutes ago
      PEGs are just soooo much easier to read than regexes for anything more complex than a few words or single line matching. REs are a hammer that tempts people to see everything as a nail, but once one progresses beyond that phase one usually wants as few REs as possible.
    • xigoi 14 minutes ago
      The non-commutavity is a feature, not a bug. It allows you to have clearly defined parsing for grammars that would traditionally be considered ambiguous.
    • bmn__ 42 minutes ago
      Came here for this comment. Janet would score positively in my mind if the evolutionary dead-end PEG were replaced with a grammar parser that is known to work under all circumstances.
  • wodenokoto 55 minutes ago
    I've been drawn into the Janet posts that surface every once in a while here on HN, but found the otherwise highly praised "Janet for Mortals", not being for mortals at all.
    • lelanthran 20 minutes ago
      > I've been drawn into the Janet posts that surface every once in a while here on HN, but found the otherwise highly praised "Janet for Mortals", not being for mortals at all.

      I'm surprised: the language is very straightfoward, simple, very few rules to remember. It's a Lisp but with a very small surface area.

      I mean, compared to other languages, Janet really is easier to lean, so I'm surprised that the book for it is difficult (did not read the book, but familiar-ish with the language. I don't have anything but praise for it, TBH).

    • shevy-java 46 minutes ago
      > not being for mortals at all.

      I had that with Haskell. Although, while Haskell is too hard for me, I actually like its syntax.

      Janet seems to be Lisp 2.0, so the syntax is lispy.

  • defrost 1 hour ago
    Previously (April 2023) | 140 comments: https://news.ycombinator.com/item?id=35539255
  • skeledrew 1 hour ago
    This got me thinking of Hy. I wonder how syntactically close they are; there might be an exploitable Python -> Hy -> Janet path here.

    [0] https://hylang.org/

    • rcarmo 55 minutes ago
      I used Hy for a long time, then tried Janet, and ultimately realized that I wanted more batteries included but didn't want Python... So I forked https://github.com/rcarmo/go-joker and am tinkering with it until it does all I want.
  • wolfi1 35 minutes ago
    why is it called Janet? perhaps to prevent it to be identified with the acronym for Lots of Irritating Single Parenthesis?
    • petee 7 minutes ago
      It was named after the sentient computer system in the TV show "The Good Place"

      https://youtu.be/etJ6RmMPGko?si=W98LdG1jDdUCXsHV

    • xigoi 8 minutes ago
      If it was called [Something] Lisp, Lisp enthusiasts would complain that it’s not a lisp because it does not use linked lists as the primary data structure.
    • Imustaskforhelp 18 minutes ago
      I know that Lisp has lots of paranthesis and I don't have enough experience with Lisp at all.

      But from the looks of it, Janet has some great ideas like the one that @ramblurr shared here about sandboxing ("Disable feature sets to prevent the interpreter from using certain system resources. Once a feature is disabled, there is no way to re-enable it.")

      Lisp from my understanding is incredibly polarizing and many people love it and many people hate it and that's fine, but at a certain point wouldn't it feel repetitive for statement like this and I am unsure of how healthy discussion about programming concepts can be done this way.

      There are so many interesting things from lisp-y languages like Janet and Julia is technically lisp-y too and Julia's compilation to GPU is awesome and Nim too which can compile to C/C++/JS!

      It's just so many interesting concepts overall in programming that paranthesis don't seem a concern to me as the underlying concept can be translated to something else, like sandboxing feature, transpilation to GPU or multiple targets!

      And there are many unique concepts in non-lispy languages like golang (cross-compat, portability with static binaries), elixir (concurrency!) too.

      It's just good to see the amount of innovation within programming from all spheres of influence :-D

  • 6LLvveMx2koXfwn 1 hour ago
    Maybe needs a (2023) in the title?
  • anthk 20 minutes ago
    Luxferre.top has some Janet based softwrae.
  • gspr 1 hour ago
    The embeddability sounds very appealing. Does anyone have experience with using this somewhere one might traditionally reach for Lua?
    • xigoi 46 minutes ago
      I have built a markup language with embedded scripting in Janet. I originally tried to use Lua, but found the verbosity extremely frustrating.
  • IshKebab 1 hour ago
    Pretty compelling, especially "Janet does not adhere to the ancient customs. CAR is called first. PROGN is called do. LAMBDA is fn, and SETQ is def." - a sign of good sense for sure!

    How fast is it?

    Also my main objection to Lisps is still the horrible bracket syntax. Yes it's unambiguous and easy to parse, but it's HORRIBLE to read and edit. I wish this project had been a success (or something similar to it): https://readable.sourceforge.io/

    Also I don't think static typing is really optional for me at this point.

    • xigoi 1 minute ago
      > Also my main objection to Lisps is still the horrible bracket syntax. Yes it's unambiguous and easy to parse, but it's HORRIBLE to read and edit.

      I use Parinfer, which allows me to edit Janet as if it was an indentation-based language.

    • setopt 1 hour ago
      > Pretty compelling, especially "Janet does not adhere to the ancient customs. CAR is called first. PROGN is called do. LAMBDA is fn, and SETQ is def." - a sign of good sense for sure!

      Just FYI, many of these are also done in Scheme and its derivative Racket. They kept lambda (but even Python did that), but progn -> begin, setq -> set!, car -> first, and so on.

      > Also my main objection to Lisps is still the horrible bracket syntax. Yes it's unambiguous and easy to parse, but it's HORRIBLE to read and edit.

      I have pretty mixed feelings at this point. I don’t mind it for normal programming, but when I do numerical programming (physics models, etc.) you often get extremely long and verbose expressions that are IMO difficult to parse compared to the math-like infix operator notation used in other languages.

      • adrian_b 17 minutes ago
        Actually not all those are ancient customs, and not all that Janet uses is newer.

        In the first description of the language LISP, from March 1959 (AIM-008), John McCarthy had used the names "first" and "rest", instead of what later will be called "CAR" and "CDR".

        The names of "CAR" and "CDR" appear to have come from the students who worked at the practical implementation of the LISP interpreter on an IBM 704, and unfortunately we have remained stuck with them, like also with other features that were intended only for a temporary use, until being replaced in the "final version" (which was abandoned).

      • aeonik 1 hour ago
        I'm starting to prefer the s expression syntax when dealing with tree structures like json.

        I wonder if we were raised on tree based algebra if math would be easier to do, or harder.

        Like, solve for x.

           (= (+ (* 2 x) 3) 11)
           (= (* 2 x) (- 11 3))
           (= (* 2 x) 8)
           (= x (/ 8 2))
           (= x 4)
        
        Though this isn't too bad.

            (= (+ (pow x 2)
                  (pow y 2))
               (pow r 2))
    • graemep 1 hour ago
      Syntax is not that important to me. I prefer Python style indentation, but its really not that important - its just something to get used to for me.

      Is static typing that important for a scripting language? From the intro to the book:

      > And to be clear, I’m not going to try to convince you to bet your next startup on Janet, or even to use it in any sort of production setting. But I think it’s an excellent language for exploratory programming, scripting, and fun side projects.

    • e12e 47 minutes ago
  • shevy-java 47 minutes ago

        (defn foo [first & rest] ...)
    
    So basically Lisp 2.0.

    Although, this here is a good idea:

    "pass values from compile-time to run-time"

    Would be nice if some kind of "scripting" language be as fast as a compiled language, but without ruining the syntax. Just about 99% of the languages that are shown, have a horrible syntax. Syntax is not everything, but most language designers don't understand that syntax also matters. So tons of horrible languages emerge. Nobody will use those languages, so 99% of them will die off quickly.

    • xigoi 4 minutes ago
      What would be a better syntax according to you? I have found Janet’s syntax very pleasant to work with as opposed to JavaScript, Lua or even Python.
    • Imustaskforhelp 13 minutes ago
      can't there theoretically be a language which transpiles to Janet to get all the benefits without additional paranthesis too?

      Not sure if such transpilation would have a perf hit though, I hope somebody responds who knows about it more.

      I don't deny that syntax matters itself too but there are some ideas of janet like sandboxing and other features which seem to me to be worth implementing in other languages too.

      Personally, I would be really interested in a language like lua/wren which can transpile to Janet too.

  • makach 42 minutes ago
    Excellent. Although I suspect the author of the programming language invented this Janet for all the perfect puns. Yes, Janet. No. Janet.