{"id":609400,"date":"2023-02-18T07:49:02","date_gmt":"2023-02-18T13:49:02","guid":{"rendered":"https:\/\/news.sellorbuyhomefast.com\/index.php\/2023\/02\/18\/the-janet-language\/"},"modified":"2023-02-18T07:49:02","modified_gmt":"2023-02-18T13:49:02","slug":"the-janet-language","status":"publish","type":"post","link":"https:\/\/newsycanuse.com\/index.php\/2023\/02\/18\/the-janet-language\/","title":{"rendered":"The Janet Language"},"content":{"rendered":"<div>\n<h2 id=\"Use-Cases\">Use Cases<br \/>\n<\/h2>\n<p>Janet makes a good system scripting language, or a language to embed in other programs.  Janet also can be used for rapid prototyping, dynamic systems, and other domains<br \/>\nwhere dynamic languages shine. Implemented mostly in standard C99, Janet runs on Windows, Linux and macOS.<br \/>\nThe few features that are not standard C (dynamic library loading, compiler specific optimizations),<br \/>\nare fairly straightforward. Janet can be easily ported to new platforms. While Janet is embeddable, it comes with a bit more out of the box than many other such easily embeddable languages<br \/>\nsuch as threading, networking, an event loop, subprocess handling, regex-like library called PEG, and more.\n<\/p>\n<h2 id=\"Features\">Features<br \/>\n<\/h2>\n<ul>\n<li>Minimal setup &#8211; one binary and you are good to go!<\/li>\n<li>Builtin support for threads, networking, and an event loop<\/li>\n<li>First class closures<\/li>\n<li>Garbage collection<\/li>\n<li>First class green threads (continuations)<\/li>\n<li>Mutable and immutable arrays (array\/tuple)<\/li>\n<li>Mutable and immutable hashtables (table\/struct)<\/li>\n<li>Mutable and immutable strings (buffer\/string)<\/li>\n<li>Macros<\/li>\n<li>Tail call optimization<\/li>\n<li>Direct interop with C via abstract types and C functions<\/li>\n<li>Dynamically load C libraries<\/li>\n<li>Lexical scoping<\/li>\n<li>REPL and interactive debugger<\/li>\n<li>Parsing Expression Grammars built in to the core library<\/li>\n<li>500+ functions and macros in the core library<\/li>\n<li>Export your projects to standalone executables with a companion build tool, jpm<\/li>\n<li>Add to a project with just <code>janet.c<\/code> and <code>janet.h<\/code><\/li>\n<\/ul>\n<h2 id=\"Code-Example\">Code Example<br \/>\n<\/h2>\n<pre><code data-language=\"janet\">(<span>defn<\/span> <span>sum3<\/span>\n  <span>\"Solve the 3SUM problem in O(n^2) time.\"<\/span>\n  [<span>s<\/span>]\n  (<span>def<\/span> <span>tab<\/span> @{})\n  (<span>def<\/span> <span>solutions<\/span> @{})\n  (<span>def<\/span> <span>len<\/span> (<span>length<\/span> <span>s<\/span>))\n  (<span>for<\/span> <span>k<\/span> <span>0<\/span> <span>len<\/span>\n    (<span>put<\/span> <span>tab<\/span> (<span>s<\/span> <span>k<\/span>) <span>k<\/span>))\n  (<span>for<\/span> <span>i<\/span> <span>0<\/span> <span>len<\/span>\n    (<span>for<\/span> <span>j<\/span> <span>0<\/span> <span>len<\/span>\n      (<span>def<\/span> <span>k<\/span> (<span>get<\/span> <span>tab<\/span> (<span>-<\/span> <span>0<\/span> (<span>s<\/span> <span>i<\/span>) (<span>s<\/span> <span>j<\/span>))))\n      (<span>when<\/span> (<span>and<\/span> <span>k<\/span> (<span>not=<\/span> <span>k<\/span> <span>i<\/span>) (<span>not=<\/span> <span>k<\/span> <span>j<\/span>) (<span>not=<\/span> <span>i<\/span> <span>j<\/span>))\n        (<span>put<\/span> <span>solutions<\/span> {<span>i<\/span> <span>true<\/span> <span>j<\/span> <span>true<\/span> <span>k<\/span> <span>true<\/span>} <span>true<\/span>))))\n  (<span>map<\/span> <span>keys<\/span> (<span>keys<\/span> <span>solutions<\/span>)))\n\n(<span>let<\/span> [<span>arr<\/span> @[<span>2<\/span> <span>4<\/span> <span>1<\/span> <span>3<\/span> <span>8<\/span> <span>7<\/span> <span>-3<\/span> <span>-1<\/span> <span>12<\/span> <span>-5<\/span> <span>-8<\/span>]]\n  (<span>printf<\/span> <span>\"3sum of %j: \"<\/span> <span>arr<\/span>)\n  (<span>printf<\/span> <span>\"%j\"<\/span> (<span>sum3<\/span> <span>arr<\/span>)))<\/code><\/pre>\n<h2 id=\"Try-It\">Try It<br \/>\n<\/h2>\n<h2 id=\"Usage\">Usage<br \/>\n<\/h2>\n<p>A REPL is launched when the <code>janet<\/code> binary is invoked with no arguments. Pass the <code>-h<\/code> flag<br \/>\nto display the usage information. Individual scripts can be run with <code>janet myscript.janet<\/code>\n<\/p>\n<p>If you are looking to explore, you can print a list of all available macros, functions, and constants<br \/>\nby entering the command <code>all-bindings<\/code> into the REPL.\n<\/p>\n<pre><code>$ janet\nJanet 1.17.0-local linux\/x64 - '(doc)' for help\nrepl:1:> (+ 1 2 3)\n6\nrepl:2:> (print \"Hello, World!\")\nHello, World!\nnil\nrepl:3:> (os\/exit)\n$ janet -h\nusage: janet [options] script args...\nOptions are:\n  -h : Show this help\n  -v : Print the version string\n  -s : Use raw stdin instead of getline like functionality\n  -e code : Execute a string of janet\n  -E code arguments... : Evaluate  an expression as a short-fn with arguments\n  -d : Set the debug flag in the REPL\n  -r : Enter the REPL after running all scripts\n  -R : Disables loading profile.janet when JANET_PROFILE is present\n  -p : Keep on executing if there is a top-level error (persistent)\n  -q : Hide logo (quiet)\n  -k : Compile scripts but do not execute (flycheck)\n  -m syspath : Set system path for loading global modules\n  -c source output : Compile janet source code into an image\n  -n : Disable ANSI color output in the REPL\n  -l lib : Import a module before processing more arguments\n  -w level : Set the lint warning level - default is \"normal\"\n  -x level : Set the lint error level - default is \"none\"\n  -- : Stop handling options<\/code><\/pre>\n<h2 id=\"Modules-and-Libraries\">Modules and Libraries<br \/>\n<\/h2>\n<p>See some auxiliary projects on <a href=\"https:\/\/github.com\/janet-lang\">GitHub<\/a>. Here is a short list of libraries<br \/>\nfor Janet to help you get started with some interesting stuff. See <a href=\"https:\/\/github.com\/janet-lang\/pkgs\">the Janet Package Listing<\/a><br \/>\nfor a more complete list. Packages in the listing can be installed via <code>jpm install pkg-name<\/code>.\n<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/janet-lang\/circlet\">Circlet<\/a> &#8211; An HTTP server for Janet<\/li>\n<li><a href=\"https:\/\/joy.swlkr.com\">Joy Web Framework<\/a> &#8211; Framework for web development in Janet<\/li>\n<li><a href=\"https:\/\/github.com\/janet-lang\/json\">JSON<\/a> &#8211; A JSON parser and encoder<\/li>\n<li><a href=\"https:\/\/github.com\/janet-lang\/sqlite3\">SQLite3<\/a> &#8211; Bindings to SQLite<\/li>\n<li><a href=\"https:\/\/github.com\/janet-lang\/webview\">WebView<\/a> &#8211; Spawn a browser window for creating HTML+CSS UIs on any platform<\/li>\n<li><a href=\"https:\/\/github.com\/janet-lang\/jaylib\">Jaylib<\/a> &#8211; Bindings to Raylib for 2d and 3d game development<\/li>\n<li><a href=\"https:\/\/github.com\/janet-lang\/jhydro\">JHydro<\/a> &#8211; Cryptography for Janet<\/li>\n<li><a href=\"https:\/\/github.com\/janet-lang\/janetui\">JanetUI<\/a> &#8211; Bindings to <a href=\"https:\/\/github.com\/andlabs\/libui\">libui<\/a><\/li>\n<\/ul>\n<p>For editor support:\n<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/Olical\/conjure\">Conjure<\/a> &#8211; Interactive evaluation for Neovim (Clojure, Fennel, Janet)<\/li>\n<li><a href=\"https:\/\/github.com\/janet-lang\/janet.vim\">janet.vim<\/a> &#8211; Support for Janet syntax in Vim<\/li>\n<li><a href=\"https:\/\/github.com\/janet-lang\/vscode-janet\">vscode-janet<\/a> &#8211; VSCode plugin for Janet<\/li>\n<li><a href=\"https:\/\/github.com\/SerialDev\/ijanet-mode\">ijanet-mode<\/a> &#8211; Emacs interactive Janet mode<\/li>\n<li><a href=\"https:\/\/github.com\/ALSchwalm\/janet-mode\">janet-mode<\/a> &#8211; Janet major mode for Emacs<\/li>\n<li><a href=\"https:\/\/github.com\/velkyel\/inf-janet\">inf-janet<\/a> &#8211; Inferior lisp Janet mode for Emacs<\/li>\n<li><a href=\"https:\/\/atom.io\/packages\/language-janet\">language-janet<\/a> &#8211; Atom Editor support for Janet.<\/li>\n<li><a href=\"https:\/\/github.com\/pepe\/janet.kak\">janet.kak<\/a> &#8211; Kakoune Editor support for Janet.<\/li>\n<\/ul>\n<p>Feel free to ask questions and join discussion on the <a href=\"https:\/\/gitter.im\/janet-language\/community\">Janet Gitter Channel<\/a>.<br \/>\nGitter provides matrix and IRC bridges as well for users who prefer those.\n<\/p>\n<h3 id=\"Other-Gitter-Rooms\">Other Gitter Rooms<br \/>\n<\/h3>\n<ul>\n<li><a href=\"https:\/\/gitter.im\/janet-language\/help\">help<\/a>:<br \/>\n        For getting help with specific problems in the Janet language.<\/li>\n<li><a href=\"https:\/\/gitter.im\/janet-language\/website\">website<\/a>:<br \/>\n        For discussion and help related to this website and documentation.<\/li>\n<\/ul>\n<h3 id=\"Forum\">Forum<br \/>\n<\/h3>\n<p>We use <a href=\"https:\/\/github.com\/janet-lang\/janet\/discussions\">GitHub Discussions<\/a> as our forum, which is more suited to long-form discussion than Gitter.\n<\/p>\n<h3 id=\"Janet-Docs\">Janet Docs<br \/>\n<\/h3>\n<p>For help, you can also check out <a href=\"https:\/\/janetdocs.com\">Janet Docs<\/a> for Janet documentation with user-provided examples. Feel free to contribute your own examples here to help fellow programmers.\n<\/p>\n<\/p><\/div>\n<p><a href=\"https:\/\/janet-lang.org\/\" class=\"button purchase\" rel=\"nofollow noopener\" target=\"_blank\">Read More<\/a><br \/>\n Erasmo Mcnaught<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Use Cases Janet makes a good system scripting language, or a language to embed in other programs. Janet also can be used for rapid prototyping, dynamic systems, and other domains where dynamic languages shine. Implemented mostly in standard C99, Janet runs on Windows, Linux and macOS. The few features that are not standard C (dynamic<\/p>\n","protected":false},"author":1,"featured_media":609401,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23710,4105,46],"tags":[],"class_list":{"0":"post-609400","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-janet","8":"category-language","9":"category-technology"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/posts\/609400","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/comments?post=609400"}],"version-history":[{"count":0,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/posts\/609400\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/media\/609401"}],"wp:attachment":[{"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/media?parent=609400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/categories?post=609400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/newsycanuse.com\/index.php\/wp-json\/wp\/v2\/tags?post=609400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}