I like to build … Reusable libraries & packages#
Redistributable code with no entry point -- a Python wheel for PyPI, a JavaScript/TypeScript package for npm, or a C-ABI shared library any language can link. The public surface is whatever you mark :pub. These map to the py-package, js-package, and native-lib project kinds.
Your 5-minute quick win#
A reusable library packaged as a standard pip wheel. Any def:pub is part of the public API:
Upload it with twine, then pip install greetlib anywhere. The wheel ships your compiled modules and runs under the jac binary -- it does not list jaclang as a runtime dependency.
npm package#
The client-side counterpart: a cl component (or function) library published to npm so any JavaScript/TypeScript project can npm install it. jac build --as npm compiles your client modules to ES-module JavaScript, generates package.json, and emits .d.ts declarations. (Modules that cross a server boundary can't ship as standalone npm packages -- keep server-coupled code in your app.)
Shared library (C ABI)#
The native counterpart: an na module compiled to a C-ABI shared library (.so / .dylib / .dll) that any language with a C FFI -- C, C++, Rust, Go (cgo), Python (ctypes) -- can link or dlopen:
jac nacompile mathlib.na.jac --shared # → ./libmathlib.so
jac nacompile mathlib.na.jac --shared --target macos # → ./libmathlib.dylib
jac nacompile mathlib.na.jac --shared --target windows # → ./libmathlib.dll
Scalars pass by value; Jac objects and strings cross as opaque handles with jac_retain/jac_release for lifetime management. Jac's own linker emits the ELF/Mach-O/PE file -- no gcc/ld, and the --target cross-builds need no extra toolchain.
Your learning path#
- Concepts you need → Core Concepts -- codespaces (
sv/cl/na) decide which package kind you build - Build it for real → Publish a Library -- scaffold → test → wheel → PyPI, then the npm flow
- Look it up → Publishing packages · Publishing to npm · Native pathway -- shared libraries
Going further#
- Use a library in an app → Backend APIs & services · Full-stack web apps
- Ship an executable instead of a library → CLI tools & native binaries