BIBLIOGRAPHY

“The Janet Programming Language.” n.d. Accessed May 10, 2025. https://janet-lang.org/.

관련메타

BIBLIOGRAPHY

“The Janet Programming Language.” n.d. Accessed May 10, 2025. https://janet-lang.org/.

히스토리

  • [2025-06-14 Sat 21:08] Created!

The Janet Programming Language

(“The Janet Programming Language” n.d.)

Janet is a functional and imperative programming language. It runs on Windows, Linux, macOS, FreeBSD and *nix.

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 library loading, compiler specific optimizations), are 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 such as threading, networking, an event loop, subprocess handling, regex-like library called PEG, and more.

Janet은 훌륭한 시스템 스크립팅 언어 또는 다른 프로그램에 임베드할 수 있는 언어를 만듭니다. Janet은 신속한 프로토타이핑, 동적 시스템 및 동적 언어가 빛을 발하는 기타 영역에서도 사용할 수 있습니다. 대부분 표준 C99로 구현된 Janet은 Windows, Linux 및 macOS에서 실행됩니다. 표준 C가 아닌 몇 가지 기능(동적 라이브러리 로딩, 컴파일러별 최적화)은 매우 간단합니다. Janet은 새로운 플랫폼으로 쉽게 포팅할 수 있습니다. Janet은 임베드할 수 있지만 스레딩, 네트워킹, 이벤트 루프, 하위 프로세스 처리, PEG라는 정규식 라이브러리 등 쉽게 임베드할 수 있는 다른 많은 언어보다 조금 더 많은 기능이 기본으로 제공됩니다.

Features

  • Minimal setup - one binary and you are good to go!
  • Builtin support for threads, networking, and an event loop
  • First class closures
  • Garbage collection
  • First class green threads (continuations)
  • Mutable and immutable arrays (array/tuple)
  • Mutable and immutable hashtables (table/struct)
  • Mutable and immutable strings (buffer/string)
  • Macros
  • Tail call optimization
  • Direct interop with C via abstract types and C functions
  • Dynamically load C libraries
  • Lexical scoping
  • REPL and interactive debugger
  • Parsing Expression Grammars built in to the core library
  • 500+ functions and macros in the core library
  • Export your projects to standalone executables with a companion build tool, jpm
  • Add to a project with just janet.c and janet.h

First program

Following tradition, a simple Janet program will print “Hello, World!“.

Put the following code in a file named hello.janet, and run janet hello.janet :

(print "Hello, World!")

The words “Hello, World!” should be printed to the console, and then the program should immediately exit. You now have a working Janet program!

Alternatively, run the program janet without any arguments to enter a REPL, or read-eval-print-loop. This is a mode where Janet works like a calculator, reading some input from the user, evaluating it, and printing out the result, all in an infinite loop. This is a useful mode for exploring or prototyping in Janet.

This hello world program is about the simplest program one can write, and consists of only a few pieces of syntax. The first element is the print symbol. This is a function that simply prints its arguments to the console. The second argument is the string literal “Hello, World!”, which is the one and only argument to the print function. Lastly, the print symbol and the string literal are wrapped in parentheses, forming a tuple. In Janet, parentheses and also brackets form a tuple; brackets are used mostly when the resulting tuple is not a function call. The tuple above indicates that the function print is to be called with one argument, "Hello, World" .

All operations in Janet are in prefix notation: the name of the operator is the first value in the tuple, and the arguments passed to it are in the rest of the tuple. While this may be familiar in function calls, in Janet this idea extends to arithmetic and all control forms.

로그

|2025-06-14 Sat 21:08|

@user janet 를 C코드로 변환할 수있는가?

@assistant 네, Janet 코드를 C 코드로 변환할 수 있습니다. Janet은 Lisp 계열의 가벼운 스크립팅 언어로, C로 작성된 가상 머신에서 실행됩니다. 따라서 Janet 코드를 C로 변환하는 것은 이론적으로 가능합니다.

변환 방법
  1. 수동 변환: Janet의 각 구문을 C의 해당 구문으로 직접 변환
  2. 자동화 도구: Janet-to-C 트랜스파일러를 개발 (현재 공식적으로 존재하지 않음)
예시: 간단한 Janet 함수를 C로 변환

Janet 코드:

(defn factorial [n]
  (if (= n 0)
    1
    (* n (factorial (- n 1)))))

C 코드로 변환:

#include <stdio.h>
 
int factorial(int n) {
    if (n == 0) {
        return 1;
    } else {
        return n * factorial(n - 1);
    }
}
 
int main() {
    printf("Factorial of 5: %d\n", factorial(5));
    return 0;
}
수학적 표현 (LaTeX)

재귀의 수학적 정의:

변환 시 고려사항
  1. 타입 시스템: Janet은 동적 타입, C는 정적 타입
  2. 메모리 관리: Janet은 GC 사용, C는 수동 관리
  3. 런타임 환경: Janet 함수들은 C API로 구현됨

Janet의 공식 문서에는 C API가 잘 설명되어 있어, Janet과 C의 상호 운용성이 가능합니다. 더 복잡한 변환을 원하시면 구체적인 Janet 코드 예제를 보여주시면 상세한 C 변환을 도와드리겠습니다.

@user