A programming language for Creators. Arini becomes Node.js.
A scope is any Arini file, or syntactically created using #(args){...}
. A Scope is divided into 3 parts:
- Optional name and/or arguments.
- Declarative code - declare public, protected, or private properties.
- construction code - invoke expressions, conditional statements, return statements, etc.
Construction code can be in the declarative section as values. Properties may not be declared outside of the declarative code.
Scopes are used for various forms of encapsulation. Scopes may be invoked, allowing the programmer to return a result of her choice, or to reveal the public properties. Scopes may be used by one-another, allowing the programmer to share protected properties.
You might notice I didn't mention methods. That's because Scopes are first-class values. Properties that have a Scope as their value, are methods. Conveniently, a creative amount of nesting is possible with Scopes, and each one may be as simple or complex as needed.
Using a single first-class encapsulation type makes Arini easy to learn and remember.
Before reading forward, all of the following content has been translated into an easy-to-take course that you can try in your web-browser for the cost of a free sign-up. https://www.katacoda.com/spn/scenarios/hello-world
How to create an Arini Project with npm.
mkdir project
{{execute}}
cd project
{{execute}}
npm init && npm i --save -g arini && npm i --save arini
{{execute}}
Follow the directions from npm to initialize your Node.JS prackage.
touch program.ari
{{execute}}
Now, in your editor, open the project
directory, and open up program.ari
Once opened, you can copy this code:
console.log("Sup?");
arini program.ari
{{execute}}
That's it!
In Arini, we have expressions, lists of expressions, identifiers, operators, and syntax used to craft those expressions. Control code (what you find in the root of an Arini program or in every scope) is a list of expressions seperated by semi-colons. Arini has a few basic types. These basic types may be used to implement more abstract types..
- A boolean is the token
true
orfalse
.
let foo = true or false; // true let bar = true and false; // false console.log(foo, bar);
arini program.ari
{{execute}}
- A string can be text surrounded by
""
, or''
, or backticks.
let foo = "I am a string."; let bar = 'I am a multiline string'; let baz = \` I am a multiline string containing 2 variables: foo: ${foo} bar: ${bar} And that is that. \`; console.log(baz);
arini program.ari
{{execute}}
- A number is simply a number like JavaScript's Number.
let a = 543; let b = 1.25; console.log(a + b);
arini program.ari
{{execute}}
- An array is a map of items. Arrays, if not named, use indices just like in most programming languages. Arini also supports named arrays. One big diference between Arini and JavaScript, is arrays. Arini takes JavaScript arrays and objects and consolidates their features. Interestingly, JavaScript already does this with the Array. So Arini builds on that.
let foo = [ question = "What is the answer to the universe and everything?", answer = 42 ]; console.log(foo["question"]); // "What is the..." console.log(foo.answer); // 42
let bar = ["cow", "pig", "sheep"]; bar.forEach(#(val) { console.log(val); });
arini program.ari
{{execute}}
- A tag is basically an XML tag- kinda like HTML. A Tag has a name and may contain attributes or children. Unlike XML/HTML, Tag children in Arini can be of any type or expression. Because of the first-class nature of Tag children, each child of a Tag must be followed by a semi-colon- just like everywhere else in the language.
let someVariable = "I'm some variable"; let someSwitch = true; let myComponent = <someTag with="attributes"> "I am some inner text."; <nestedTag> "This is a nested string in a nested tag."; someVariable; { if (someSwitch) { return <switch on=true />; } else { return <switch on=false />; }; }(); </nestedTag>; </someTag>; console.log("" + myComponent.nestedTag.switch);
arini program.ari
{{execute}}
- A scope is kind of like a function from other languages, but has support for
public
andprotected
properties. If nothing is returned, a scope does not returnvoid
when invoked, it instead returns the public properties available. When extended, the public and protected properties are made available to the scope that extends it.private
can be thought of as a synonym forlet
, but there are subtle differences. In essence,private
andlet
are stored exactly the same way, just in slightly different places. They both work anywhere in the language exactly the same way- so I suggest to pick one and stick with it.
let Guy { protected shared_secret = "it's a foo!"; public sayHi (name = "no name") { return "Hello, " + name; }; }; let someObj = Guy(); let GuysFriend { use Guy; public tellSecret() { console.log(shared_secret); }; }; let friend = GuysFriend(); friend.tellSecret();
arini program.ari
{{execute}}
For further information on primitive types, visit the wiki.
Node.js modules can be used with require. Arini and JavaScript are similar enough, it just works for the most part. Try it! express works, mongo-js works, socket.io works.
For more information on extensions, visit the wiki.
Scope comes with a base library necessary for basic programming. There are some constants under development right now, but the naming is not quite right yet, so please don't use them yet. I won't mention them for that purpose, but if you see __blah
don't rely on it yet.