Skip to content
Trizen edited this page Sep 22, 2023 · 519 revisions

Introduction

Sidef is a modern, high-level, general-purpose programming language, focusing on simplicity, readability and elegance, taking the best from languages like Ruby, Raku and Julia.

BOOK

The Sidef Programming Language: https://trizen.gitbook.io/sidef-lang/ (legacy)

Full documentation

The content of the wiki has been moved to:

Installation

Sidef can be installed automatically from the MetaCPAN, by invoking the following command:

$ cpan Sidef

If the testing takes a long time, add the -T flag to build and install Sidef without testing:

$ cpan -T Sidef

When the cpan command is not available, try:

$ perl -MCPAN -e "CPAN::Shell->install(q{Sidef})"

IMPORTANT: Sidef needs the GMP, MPFR and MPC C libraries.

Installing from git source

To install Sidef manually, download the latest version, unzip it and follow the installation steps:

$ perl Build.PL
# ./Build installdeps
# ./Build install

When Module::Build is not installed, try:

$ perl Makefile.PL
$ make test
# make install

Linux installation

Arch Linux

Sidef is available on the AUR and can be installed using an AUR helper, like trizen:

$ trizen -S sidef

Debian / Ubuntu / Linux Mint

On Debian-based distributions, Sidef can be installed from the CPAN, by executing the following commands:

$ sudo apt install libgmp-dev libmpfr-dev libmpc-dev libc-dev cpanminus
$ sudo cpanm -n Sidef

Android installation

It's also possible to install Sidef on Android, by installing Termux and executing the following commands:

$ pkg install perl make clang libgmp libmpfr libmpc
$ cpan -T Sidef

If the installation succeeded, the sidef command should be available:

$ sidef -h

Run Sidef without installing it

It is also possible to run Sidef without having to install it. In a Unix-like environment, the following commands can be executed:

$ wget 'https://github.com/trizen/sidef/archive/master.zip' -O 'master.zip'
$ unzip 'master.zip'
$ cd 'sidef-master/bin/'
$ ./sidef -v

Those commands will download and unpack the latest version of Sidef and will execute the bin/sidef script which will print out the current version of the language.

To execute a Sidef script, run:

$ ./sidef ../scripts/sierpinski_carpet.sf

It's also possible to add the following alias to ~/.bashrc or ~/.zshrc:

alias sidef="/path/to/bin/sidef"

Packaging

For packaging Sidef, run:

$ perl Build.PL --destdir "/my/package/path" --installdirs vendor
$ ./Build test
$ ./Build install --install_path script=/usr/bin

Creating the first Sidef script

A Sidef script can be written in any text editor and, by convention, it has the .sf extension.

The content of a simple Hello World program looks like this:

#!/usr/bin/sidef

say "Hello, 世界";

If we save the content in a new file called hello.sf, we can execute the code by running:

$ sidef hello.sf

More examples

For more examples, see: https://github.com/trizen/sidef-scripts