Introducing Howl and Cosmo
Tags: csharp, productivity
Published: 2020-08-17 11:43:20


Cosmo is a modern shorthand for object oriented programming; Howl is a symbolic notation engine. 

Howl and Cosmo conspire towards helping you write short and delightfully expressive OOP programs.

- Muting language semantics (and very common words/idioms) *feels* good. 
- Learning isn't hard since all typing goes via snippets (still typing C#) and a little nitpicking.
- Cosmo leans over a 100 notations; you need not adopt every notation; be it when generating/using snippets, or importing C# source.

Writing a new language is hard, adopting a new language is harder.

A notation (vs a whole new language) is easier and safer; bidirectional conversions between classic and abbreviated sources ensure we do not silo ourselves in shmancy new paradigms with uncertain futures.

Without further ado, a Hello Howl program.

```howl
‒̥ ┈ Main(ㄹ[] args){
    🐰 "Howl CLI v0.0.8\n";
    ⤴ (args❙ ☰ 0) (╯°□°)╯
                       ⌢ Ex("☆*:.｡o(≧▽≦)o.｡.:*☆");
    ⌢ CLI().Parse(args);
}
```

Chances are, you can read this - reason being: strongly typed, object oriented programming is verbose and pedantic.

Ahead of Github and Unity asset store releases I will share a few samples and design decisions.

## Modifiers and primitives

`public` is the most common word in most C# programs. Modifiers take up space and aren't often what we are looking for when reading sources.

Howl condenses and compacts modifier blocks, like so:

```howl
‒ public
◠ protected,
︲ internal,
▰ private
...
```

One goal with modifier blocks was fitting a one character span; combining characters are used for this:

```howl
‒̥ public static
︲̥̑ protected internal static
```

## Control flow

Cosmo notations for control flow are endearing:

```howl
∘ ㅇ IsModifier(ㄹ x) {
    ⤴ (howlTemplate ☰ null) ⤬
    ⤵ ∀ (∙ k ∈ howlTemplate) ⤴ (k ☰ x) ㆑ ⤬
}
```

C#

```cs
static bool IsModifier(string x) {
    if (howlTemplate == null) return false;
    else foreach (var k in howlTemplate) 
        if (k == x) return true; 
    return false;
}
```

(Screaming anathema at `㆑` and `⤬`? They may of course be written as `⮐ ✓;` and `⮐ ✗;`)

Linq expressions:

```howl
‒̥ ㄹ[] FilesOver(ㄹ π, ᆞ n, ㄹ pattern)
→ (‖ x ∈ FileSystem.Paths(π, pattern)
   ¿ x.NumberOfLines() > n
   ⏢ x.NumberOfLines() ◺
   ፥ x.FileName().Replace(".howl", ""))৴;
```

Cosmo targets language keywords, semantics (𝕃 for List) and idioms (`৴` → `.ToArray()`).

## Testing

A few notations geared towards NUnit are included.

```
؟ Nits() → o( ω.nits.∋(ω.Rule(">=")) );

؟ Inject_Failed(){
    ∙ g = "These (__Bo__) are operators";
    ㄹ @out;
    ಠᴗಠ<InvOp>( ⎚ @out = TreeSitter.Inject(g, map) );
}

```

C#

```cs
[Test] public void Nits() => o( ω.nits.Contains(ω.Rule(">=")) );

[Test] public void Inject_Failed(){
    var g = "These (__Bo__) are operators";
    string @out;
    Assert.Throws<InvOp>( () => @out = TreeSitter.Inject(g, map) );
}
```

## Parting words

Be it language or notation, a programming tool does not exist without a toolchain:
- Full featured Unity integration
- CLI; still very new, this is for the benefit of .net coders beyond Unity (also: build system integrations *et caetera*)
- Input support (VS code, Atom) and syntax coloring (Atom).

The release will be announced here, or follow me on Twitter (@eelstork).

NOTE: *bunny face* 🐰 *not formally partaking the spec*