DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Cover image for Introducing Howl and Cosmo
Tea
Tea

Posted on

Introducing Howl and Cosmo

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.

โ€’ฬฅ โ”ˆ Main(ใ„น[] args){
    ๐Ÿฐ "Howl CLI v0.0.8\n";
    โคด (argsโ™ โ˜ฐ 0) (โ•ฏยฐโ–กยฐ)โ•ฏ
                       โŒข Ex("โ˜†*:.๏ฝกo(โ‰งโ–ฝโ‰ฆ)o.๏ฝก.:*โ˜†");
    โŒข CLI().Parse(args);
}
Enter fullscreen mode Exit fullscreen mode

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:

โ€’ public
โ—  protected,
๏ธฒ internal,
โ–ฐ private
...
Enter fullscreen mode Exit fullscreen mode

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

โ€’ฬฅ public static
๏ธฒฬฅฬ‘ protected internal static
Enter fullscreen mode Exit fullscreen mode

Control flow

Cosmo notations for control flow are endearing:

โˆ˜ ใ…‡ IsModifier(ใ„น x) {
    โคด (howlTemplate โ˜ฐ null) โคฌ
    โคต โˆ€ (โˆ™ k โˆˆ howlTemplate) โคด (k โ˜ฐ x) ใ†‘ โคฌ
}
Enter fullscreen mode Exit fullscreen mode

C#

static bool IsModifier(string x) {
    if (howlTemplate == null) return false;
    else foreach (var k in howlTemplate) 
        if (k == x) return true; 
    return false;
}
Enter fullscreen mode Exit fullscreen mode

(Screaming anathema at ใ†‘ and โคฌ? They may of course be written as โฎ โœ“; and โฎ โœ—;)

Linq expressions:

โ€’ฬฅ ใ„น[] FilesOver(ใ„น ฯ€, แ†ž n, ใ„น pattern)
โ†’ (โ€– x โˆˆ FileSystem.Paths(ฯ€, pattern)
   ยฟ x.NumberOfLines() > n
   โข x.NumberOfLines() โ—บ
   แฅ x.FileName().Replace(".howl", ""))เงด;
Enter fullscreen mode Exit fullscreen mode

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) );
}

Enter fullscreen mode Exit fullscreen mode

C#

[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) );
}
Enter fullscreen mode Exit fullscreen mode

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

Top comments (3)

Collapse
kamo profile image
KAIDI

Hey,
are there resources of the project?

Collapse
eelstork profile image
Tea Author

As hinted, resources up on Github later this week. Unity Asset store later this month after approval and some additional screening/testing on my end.

Collapse
kamo profile image
KAIDI

Thanks, my fault, I didn't see !!

๐Ÿค” Did you know?

ย 
๐ŸŒš Dark mode is available in Settings.