Home

Awesome

Onyx - pragmatic, get-shit-done, beautiful, fast & stable programming

Enjoy writing apps that runs with trustworthy solid stability at speeds nearing C/C++ with the feeling of simply pseudo coding!

Onyx is / has Goal of

What Do You Mean With Scientific Approach?

Well, there aren't that many studies concerning coding directly. So admittedly the statement could be seen as kind of vague. The focus is on the actual process of a human being reading, writing and reasoning on code to accomplish a task, including prototyping, refining, re-factoring, etc.

What is not meant is "highly abstract functional lambda theory proofs from outer space when the cat is and isn't in the cradle and/or you give a shit".

Run Down

Relation to Crystal

Onyx is built upon the AST, most semantics and IR generation of Crystal. There are some additional semantics for more fine-grained control in some contexts. The syntax is entirely different. The actual machine code generation is done by LLVM, a god sent to language loving mankind! Currently, by internally flagging AST-nodes, Onyx can compile both Onyx and Crystal sources within the same program. Therefore great praise and credit goes out to the efforts of the Crystal team and the LLVM team, whom without Onyx would not be in this stage.

About Oscar Campbell

I've always loved linguistics, programming and manipulation of text (kind of a weird interest when you think about it). And a whole lot of other stuff not relevant to this. I coded my first language 25 years ago (when I was twelve). Well, it was called "CP Torsk 0.2", so not that serious. For the Amiga or Commodore 64 if I remember correctly.

Onyx is where the accumulated interest and experiences will distill to the optimal brew.

Inspiration

Most of Onyx is accumulated ideas with no basis in any of the modern languages. Fortunately, many concepts have ended up in similar ways as other new languages (we all have the same languages as reference, so we're bound to come up with similar ideas). I've then looked at the newer languages to see if they have some better ideas to steal from. Amateurs borrow - pros steal. So, inspiration has been taken from languages as diverse as LiveScript, Haskell, Nim, Go, Rust, Erlang, Python, Lisp, Swift, Scala, C++, LLVM-IR(!), etc. Sometimes syntax, sometimes semantics, sometimes just an idea inspired by some concept.

What does it look like currently?

GitHub doesn't accept highlighters until there are hundreds of repositories using it, so to view these with highlighting you currently have to resort to Sublime Text or Atom.

For Crystalers, the front page example in Onyx will be very familiar (lent the examples):

-- A very basic HTTP server
require "http/server"

server = HTTP.Server 8080, (request) ~>
  HTTP.Response.ok "text/plain", "Hello world! You called me on {request.path} at {Time.now}!"

say "Listening on http://0.0.0.0:8080"
server.listen

A rather contrived example, just to show some basic constructs:

type Greeter
   @greeting–phrase = "Greetings,"

   init() ->
   init(@greeting–phrase) ->

   greet(who–or–what) ->!
      say make–greeting who–or–what

   make–greeting(who–or–what) ->
      "{@greeting–phrase} {who–or–what}"
end

type HelloWorldishGreeter < Greeter
   @greeting–phrase = "Hello"
end

ext HelloWorldishGreeter
   greet(who-or-what) ->
      previous-def(who-or-what).red

greeter = HelloWorldishGreeter "Goodbye cruel"
greeter.greet "world"  -- => "Goodbye cruel world"

And with some added explanations:


-- Comments are started with two dashes - rather natural.
-- Types inherits `Reference` by default if nothing else specified.
-- All types begin with a capital

type Greeter
   @greeting–phrase = "Greetings,"  -- member-vars are prefixed with `@`
   -- separator (-|–|_) completely interchangeable so above can be referred
   -- to as @greeting_phrase, @greeting-phrase etc. from _your_ code - should
   -- you prefer a different style than a lib-author

   init() ->      -- init does nothing - just keep defaults

   init(@greeting–phrase) ->
      -- does nothing in body. Sugar for assigning a member in the parameter
      -- did all we need! (the `@` prefix to parameter name)

   -- above could have been written more verbose; in many different levels.
   -- init(greeting–phrase Str) ->
   --    @greeting–phrase = greeting–phrase
   -- end     -- ending expressions blocks, is implicit, but can be done
              -- explicitly.

   -- define a method that greets someone
   greet(who–or–what) ->!  -- `!` is sugar notation for methods that returns
                           -- "nothing", it's ensured that ret val is nil
      say make–greeting who–or–what
      -- say(make–greeting(who–or–what)) -- parentheses or "juxtapos-calls"

   -- a method that constructs the message
   make–greeting(who–or–what) ->
      -- interpolation of exprs within strings is done with simple braces
      "{@greeting–phrase} {who–or–what}"  -- last expression is returned

   -- All on one line works too of course:
   -- make–greeting(who–or–what) -> "{@greeting–phrase} {who–or–what}"

end  -- as already mentioned, you can explicitly end code block at will

-- another type, inheriting Greeter
type HelloWorldishGreeter < Greeter
   @greeting–phrase = "Hello"
end

-- re-open the type! Here using nest-token instead of indent (colon here)
ext HelloWorldishGreeter: greet(who-or-what) -> previous-def(who-or-what).red

greeter = HelloWorldishGreeter "Goodbye cruel"
-- Some variations for instantiating: (call syntax on a type is sugar
-- for calling a `new` function defined on the type):
-- greeter = HelloWorldishGreeter("Goodbye cruel")
-- greeter = HelloWorldishGreeter.new("Goodbye cruel")
-- greeter = HelloWorldishGreeter.new "Goodbye cruel"

greeter.greet "world" --  => "Goodbye cruel world"

Status

Roadmap

See it's own issue.

Installing

Documentation

Onyx Project Code of Conduct

Whatever you think promotes and helps the language forward is enough for code of conduct for now. Cursing is fucking allowed, but not necessarily decreed. If someone is offended - you've probably been an asshole; acknowledge it and apologize. We can all stumble down that road some times. Apologizing is a strong and proud act.

Everyone with an interest is welcome, no matter where you come from linguistically or otherwise (creed, religion, sexual configuration or even musical taste). In fact different backgrounds are essential for a good project!

Community

Use "issues" for now. Add RFC's or ideas already if you feel like it!

There is also an IRC-channel now on freenode #onyx-lang, I'll try to remember to login.

Read the general Contributing guide, (it's very terse, you will get through it!)

Contributing

Read the general Contributing guide, (it's very terse, you will get through it!):