Skip to content

The Cosmos Initiative

cosmos-lang edited this page Jul 27, 2023 · 6 revisions

What? Why? How the Cosmos programming language?!

Cosmos is a general-purpose, multi-paradigm logic scripting language that's simple to use and focuses on high-level programming.

Among its goals are,

  • Usability. It's simple to use and easy to pick up.
  • High-level. It's optimized for high-level scripting. It's not a low-level language.
  • Multi-style. It is multi-paradigm and accepts multiple styles of programming.
  • Experimental. It experiments and lets the user experiment with multi-paradigm programming.

A Modern Logic Language

What would logic programming look like if designed today?

Cosmos is designed around the idea is that if one were to make a logic language today, it could make use of anything from commonly used syntax sugar, modules and higher-orderness to advances in logic programming itself (see Pure Logic Programming)--all without having to be bound about backwards-compatibility.

Although we tend to call Cosmos a logic programming language--this is because we use a relation as the main unit and function is a sub-type of it you would not be wrong whether you call it a logic, logic-functional or even multi-paradigm language. Paradigms provide convenient labels by which one can describe a language, however, they are they are not absolute. This is specially so for a multi-paradigm language.

Development

The parser of Cosmos is made in Cosmos. It's a bootstrapped language.

All you need to know to work on the code is Cosmos. Prolog/C are sometimes used as host languages.

The plan of development is roughly,

  • Improve Cosmos(pl). (Fixes, syntax sugar, etc.)
  • Use it as the basis to compile Cosmos(c). This is optional.

Cosmos(pl) is our proof-of-concept compiler that uses Prolog as a host language. This is what's most up-to-date. The compiler being as such is out of convenience. It's not out of question to make a standalone compiler in C. It would depend on whether contributors are interested in and decide that Cosmos(pl) is not enough. They can then move development to Cosmos(c). This uses C/C++ as the host. Incidentally, both use Cosmos for the parser. Therefore, development in Cosmos(pl) also helps Cosmos(c). Why is the parser bootstrapped? Doing it any other way would mean using languages that aren't Cosmos(tm).

Wam

If you want a standalone compiler, you'll likely need to know about the WAM.

"The WAM" is the VM used for Prolog-style languages. I don't think any register-based VM is going to look that different than a WAM aside from possible optimizations. It's a weird custom to call it "The WAM". It's like calling every stack-based VM a JVM.

I highly recommend the original paper[1]. It is actually surprisingly readable for a technical paper and anyone saying otherwise is trying to scam you.

[1] An Abstract Prolog Instruction Set.

CWam

You'll find Cosmos(c) uses a DSL that we call the CWam (Cosmic Wam).

The CWam is an intermediary language that compiles to low-level WAM instructions.

x=Put(Val(1), 2)

The above translates to,

put_val 1, 2

The CWam is very high-level. The WAM has no notion of 'unification' despite compiling to Prolog, while CWam is allowed to have an Eq(x, y) instruction.

Clone this wiki locally