Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Sidef - The experimental scripting language written in Perl

by trizen (Hermit)
on Apr 17, 2014 at 13:28 UTC ( #1082640=CUFP: print w/replies, xml ) Need Help??

I remember that, a few years ago, someone asked a question about Writing a Programming Language in Perl. I was a little bit skeptical at first, but very interested in this subject too. Few years passed by, until me and a friend of mine decided to create a toy-language from scratch without using anything else, but Perl. We wanted it as simple as possible and powerful as much as it can be.

Object-oriented paradigm must be the answer, right? We thought so. And it is, partially. The language we designed is called Sidef. It strongly follows the OO style; each piece of data is stored inside objects with own methods and operators defined to work on that type of data. (actually, in Sidef, an operator and a method are the same thing)

Simplicity? What do we mean by something simple? How simple can a programming language be defined? This is the main question that I wanted to answer. A year after the start of the project, I think we found a reasonable answer: objects and methods. This is, I think, the simplest way a programming language can be defined. But, what about conditional expressions? They can't be created by objects and methods only, right? Wrong! They can:

if (false) { } elsif (true) { } else { }
is equivalent with:
var condObj = if(false); # 'if' object condObj do { } elsif(true) do { } else { }
What? Yes, the above code is valid code. if(expr) returns an object which accepts methods like 'do', 'elsif' and 'else'.
This proves how flexible an OO language can be. The basic definition of Sidef is this: obj.method(obj), with minor exceptions.

Objects are:
  • strings
  • files
  • numbers
  • arrays
  • everything else
while methods are functions defined for that kind of object which returns other objects.

In Sidef, the numbers have a very special purpose. We see the language as a toy-language and recommend to be seen only this way, but still it can be used in simple home-made projects, especially in those involving number computation. Numbers, by default, are represented by Math::BigFloat objects, giving them a better precision at the cost of being somewhat slower than Perl's standard representation for numbers (-Nfast).

Perl related features:
  • any Sidef script can be compiled to a stand-alone Perl program (-c)
  • can load and use Perl modules (both OO and functional)
  • can evaluate arbitrary Perl code (Sys.eval(""))
  • supports memoization via Memoize (-M) (not enabled by default)
  • no CPAN module is required

The project is available at:
The documentation page:
The RosettaCode page:

The very basic concept of the language can be found at:

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://1082640]
Approved by rnewsham
Front-paged by Corion
[mxb]: Hi all.
[Discipulus]: Hi marto
Discipulus mmh .oO(perl data chess.. 8 scalar, 2 arrays, 2 hashes, 2 refernses, 1 typeglob and atied scalar)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-03-19 09:28 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (237 votes). Check out past polls.