Skip to content

Commit 0aa3331

Browse files
Add link to Cogni, rework list of implementations
1 parent ab57e74 commit 0aa3331

File tree

13 files changed

+593
-797
lines changed

13 files changed

+593
-797
lines changed

content/_index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Def Primes (
7474
Print Primes up to 1000;
7575
```
7676

77+
7778
Cognate borrows from other concatenative languages, but also adds unique features of its own.
7879

7980
- Point-free functions
@@ -84,5 +85,8 @@ Cognate borrows from other concatenative languages, but also adds unique feature
8485
- Natural language programming
8586

8687

87-
Interested? Read the [tutorial](/learn/), check out the [interactive web playground](https://cognate-playground.hedy.dev/), or visit our [GitHub repository](https://github.com/cognate-lang/cognate).
88+
Interested? Read the [tutorial](/learn/), and check out one of Cognate's implementations:
8889

90+
- [CognaC](https://github.com/cognate-lang/cognate) is the original compiler -- it performs type inference and produces efficient binaries.
91+
- [Cognate Playground](https://cognate-playground.hedy.dev/) (developed by [hedyhli](https://github.com/hedyhli)) runs Cognate programs in a web browser.
92+
- [Cogni](https://github.com/dragoncoder047/cogni) (developed by [dragoncoder047](https://github.com/dragoncoder047)) interprets Cognate programs and is optimised to run on microcontrollers.

content/learn.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,23 @@ title = 'Learn Cognate'
88
## A brief introduction to the language
99

1010

11-
## Install
11+
## Setup
1212

13+
First get hold of one of Cognate's implementations; installation and invocation instructions are on the respective pages.
1314

14-
First install `CognaC` the Cognate Compiler from here using the provided instructions. Currently `CognaC` will run on recent Linux or Mac systems. Windows users can install it onto the Windows Subsystem for Linux -- native Windows support is planned.
15-
16-
Invoking `CognaC` is simple. If you have a file named `foo.cog` containing a Cognate program, it can be compiled into an executable named `foo` with the following command.
17-
15+
- [CognaC](https://github.com/cognate-lang/cognate) is the original compiler -- it performs type inference and produces efficient binaries.
16+
- [Cognate Playground](https://cognate-playground.hedy.dev/) (developed by [hedyhli](https://github.com/hedyhli)) runs Cognate programs in a web browser, requiring no installation.
17+
- [Cogni](https://github.com/dragoncoder047/cogni) (developed by [dragoncoder047](https://github.com/dragoncoder047)) interprets Cognate programs and is optimised to run on microcontrollers.
1818

19+
If you're using `CognaC`, you can compile a Cognate file named `foo.cog` into an executable named `foo` with the following command.
1920
```
2021
cognac foo.cog
2122
```
2223

23-
2424
To compile a debug executable, which will run slower but give a nice backtrace if there's an error, you can use the `-debug` flag.
2525

26-
Alternatively, you can use the interactive web playground [here](https://cognate-playground.hedy.dev/) which runs Cognate programs client-side in the browser. It also has intelligent syntax highlighting, code folding, and error reporting in the editor
27-
28-
2926
## First Programs
3027

31-
3228
```cognate
3329
Print "Hello world!";
3430
```

public/categories/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
<!doctype html>
33
<html>
4-
<head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>
4+
<head>
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<link rel="stylesheet" href="/main.min.css" />

public/categories/index.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
33
<channel>
44
<title>Categories on Cognate: Readable and concise concatenative programming</title>
5-
<link>http://localhost:1313/categories/</link>
5+
<link>https://cognate-lang.github.io/categories/</link>
66
<description>Recent content in Categories on Cognate: Readable and concise concatenative programming</description>
77
<generator>Hugo</generator>
88
<language>en-us</language>
9-
<atom:link href="http://localhost:1313/categories/index.xml" rel="self" type="application/rss+xml" />
9+
<atom:link href="https://cognate-lang.github.io/categories/index.xml" rel="self" type="application/rss+xml" />
1010
</channel>
1111
</rss>

public/index.html

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!doctype html>
33
<html>
44
<head>
5-
<meta name="generator" content="Hugo 0.130.0"><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>
5+
<meta name="generator" content="Hugo 0.131.0">
66
<meta charset="UTF-8" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<link rel="stylesheet" href="/main.min.css" />
@@ -17,68 +17,60 @@
1717

1818
<h1 id="cognate">Cognate</h1>
1919
<h2 id="readable-and-concise-concatenative-programming">Readable and concise concatenative programming</h2>
20-
<!--cognate--><div class="code"><pre><code>
21-
~~ Fizzbuzz in Cognate
20+
<div class="code"><pre><code><span style='font-style: italic;color: #969896'>~~ Fizzbuzz in Cognate</span>
2221

23-
Def Fizzbuzz (
24-
Let N be Of (Integer?);
25-
Def Multiple as (Zero? Modulo Swap N);
22+
<span style='color: #0086b3'>Def</span> <span style='color: #795da3'>Fizzbuzz</span> <span style='color: #4e4e4e'>(</span>
23+
<span style='color: #0086b3'>Let</span> <span style='color: #795da3'>N</span> <span style='color: #333333'>be</span> <span style='color: #183691'>Of</span> <span style='color: #4e4e4e'>(</span><span style='color: #183691'>Integer?</span><span style='color: #4e4e4e'>)</span>;
24+
<span style='color: #0086b3'>Def</span> <span style='color: #795da3'>Multiple</span> <span style='color: #333333'>as</span> <span style='color: #4e4e4e'>(</span><span style='color: #183691'>Zero?</span> <span style='color: #183691'>Modulo</span> <span style='color: #183691'>Swap</span> <span style='color: #795da3'>N</span><span style='color: #4e4e4e'>)</span>;
2625

27-
If Multiple of 15 then "fizzbuzz"
28-
If Multiple of 3 then "fizz"
29-
If Multiple of 5 then "buzz"
30-
else N
31-
);
26+
<span style='color: #a71d5d'>If</span> <span style='color: #795da3'>Multiple</span> <span style='color: #333333'>of</span> <span style='color: #0086b3'>15</span> <span style='color: #333333'>then</span> <span style='color: #183691'>&quot;fizzbuzz&quot;</span>
27+
<span style='color: #a71d5d'>If</span> <span style='color: #795da3'>Multiple</span> <span style='color: #333333'>of</span> <span style='color: #0086b3'>3</span> <span style='color: #333333'>then</span> <span style='color: #183691'>&quot;fizz&quot;</span>
28+
<span style='color: #a71d5d'>If</span> <span style='color: #795da3'>Multiple</span> <span style='color: #333333'>of</span> <span style='color: #0086b3'>5</span> <span style='color: #333333'>then</span> <span style='color: #183691'>&quot;buzz&quot;</span>
29+
<span style='color: #333333'>else</span> <span style='color: #795da3'>N</span>
30+
<span style='color: #4e4e4e'>)</span>;
3231

33-
For each in Range 1 to 100 (Print Fizzbuzz);
34-
</code></pre></div>
35-
<p>Cognate is a project aiming to create a human readable programming language with as little syntax as possible. Where natural language programming usually uses many complex syntax rules, instead Cognate takes them away. What it adds is simple, a way to embed comments into statements.</p>
36-
<!--cognate--><div class="code"><pre><code>
37-
~~ Towers of Hanoi in Cognate
32+
<span style='color: #a71d5d'>For</span> <span style='color: #333333'>each</span> <span style='color: #333333'>in</span> <span style='color: #183691'>Range</span> <span style='color: #0086b3'>1</span> <span style='color: #333333'>to</span> <span style='color: #0086b3'>100</span> <span style='color: #4e4e4e'>(</span><span style='color: #183691'>Print</span> <span style='color: #795da3'>Fizzbuzz</span><span style='color: #4e4e4e'>)</span>;
33+
</code></pre></div><p>Cognate is a project aiming to create a human readable programming language with as little syntax as possible. Where natural language programming usually uses many complex syntax rules, instead Cognate takes them away. What it adds is simple, a way to embed comments into statements.</p>
34+
<div class="code"><pre><code><span style='font-style: italic;color: #969896'>~~ Towers of Hanoi in Cognate</span>
3835

39-
Def Move discs as (
36+
<span style='color: #0086b3'>Def</span> <span style='color: #795da3'>Move</span> <span style='color: #333333'>discs</span> <span style='color: #333333'>as</span> <span style='color: #4e4e4e'>(</span>
4037

41-
Let N be number of discs;
42-
Let A be first rod;
43-
Let B be second rod;
44-
Let C be third rod;
38+
<span style='color: #0086b3'>Let</span> <span style='color: #795da3'>N</span> <span style='color: #333333'>be</span> <span style='color: #333333'>number</span> <span style='color: #333333'>of</span> <span style='color: #333333'>discs</span>;
39+
<span style='color: #0086b3'>Let</span> <span style='color: #795da3'>A</span> <span style='color: #333333'>be</span> <span style='color: #333333'>first</span> <span style='color: #333333'>rod</span>;
40+
<span style='color: #0086b3'>Let</span> <span style='color: #795da3'>B</span> <span style='color: #333333'>be</span> <span style='color: #333333'>second</span> <span style='color: #333333'>rod</span>;
41+
<span style='color: #0086b3'>Let</span> <span style='color: #795da3'>C</span> <span style='color: #333333'>be</span> <span style='color: #333333'>third</span> <span style='color: #333333'>rod</span>;
4542

46-
Unless Zero? N (
47-
Move - 1 N discs from A via C to B;
48-
Prints ("Move disc " N " from " A " to " C);
49-
Move - 1 N discs from B via A to C;
50-
)
51-
);
43+
<span style='color: #a71d5d'>Unless</span> <span style='color: #183691'>Zero?</span> <span style='color: #795da3'>N</span> <span style='color: #4e4e4e'>(</span>
44+
<span style='color: #795da3'>Move</span> <span style='font-weight: bold;color: #4e4e4e'>-</span> <span style='color: #0086b3'>1</span> <span style='color: #795da3'>N</span> <span style='color: #333333'>discs</span> <span style='color: #333333'>from</span> <span style='color: #795da3'>A</span> <span style='color: #333333'>via</span> <span style='color: #795da3'>C</span> <span style='color: #333333'>to</span> <span style='color: #795da3'>B</span>;
45+
<span style='color: #183691'>Prints</span> <span style='color: #4e4e4e'>(</span><span style='color: #183691'>&quot;Move disc &quot;</span> <span style='color: #795da3'>N</span> <span style='color: #183691'>&quot; from &quot;</span> <span style='color: #795da3'>A</span> <span style='color: #183691'>&quot; to &quot;</span> <span style='color: #795da3'>C</span><span style='color: #4e4e4e'>)</span>;
46+
<span style='color: #795da3'>Move</span> <span style='font-weight: bold;color: #4e4e4e'>-</span> <span style='color: #0086b3'>1</span> <span style='color: #795da3'>N</span> <span style='color: #333333'>discs</span> <span style='color: #333333'>from</span> <span style='color: #795da3'>B</span> <span style='color: #333333'>via</span> <span style='color: #795da3'>A</span> <span style='color: #333333'>to</span> <span style='color: #795da3'>C</span>;
47+
<span style='color: #4e4e4e'>)</span>
48+
<span style='color: #4e4e4e'>)</span>;
5249

53-
Move 5 discs from "a" via "b" to "c";
54-
</code></pre></div>
55-
<p>As you can see, Cognate ignores words starting with lowercase letters, allowing them to be used to describe functionality and enhance readability. This makes Cognate codebases intuitive and maintainable.</p>
56-
<!--cognate--><div class="code"><pre><code>
57-
~~ Square numbers in Cognate
50+
<span style='color: #795da3'>Move</span> <span style='color: #0086b3'>5</span> <span style='color: #333333'>discs</span> <span style='color: #333333'>from</span> <span style='color: #183691'>&quot;a&quot;</span> <span style='color: #333333'>via</span> <span style='color: #183691'>&quot;b&quot;</span> <span style='color: #333333'>to</span> <span style='color: #183691'>&quot;c&quot;</span>;
51+
</code></pre></div><p>As you can see, Cognate ignores words starting with lowercase letters, allowing them to be used to describe functionality and enhance readability. This makes Cognate codebases intuitive and maintainable.</p>
52+
<div class="code"><pre><code><span style='font-style: italic;color: #969896'>~~ Square numbers in Cognate</span>
5853

59-
Def Square as (* Twin);
60-
Map (Square) over Range 1 to 10;
61-
Print;
62-
</code></pre></div>
63-
<p>Cognate is a stack-oriented programming language similar to Forth or Factor, except statements are evaluated right to left. This gives the expressiveness of concatenative programming as well as the readability of prefix notation. Statements can be delimited at arbitrary points, allowing them to read as sentences would in English.</p>
64-
<!--cognate--><div class="code"><pre><code>
65-
~~ Prime numbers in Cognate
54+
<span style='color: #0086b3'>Def</span> <span style='color: #795da3'>Square</span> <span style='color: #333333'>as</span> <span style='color: #4e4e4e'>(</span><span style='font-weight: bold;color: #4e4e4e'>*</span> <span style='color: #183691'>Twin</span><span style='color: #4e4e4e'>)</span>;
55+
<span style='color: #183691'>Map</span> <span style='color: #4e4e4e'>(</span><span style='color: #795da3'>Square</span><span style='color: #4e4e4e'>)</span> <span style='color: #333333'>over</span> <span style='color: #183691'>Range</span> <span style='color: #0086b3'>1</span> <span style='color: #333333'>to</span> <span style='color: #0086b3'>10</span>;
56+
<span style='color: #183691'>Print</span>;
57+
</code></pre></div><p>Cognate is a stack-oriented programming language similar to Forth or Factor, except statements are evaluated right to left. This gives the expressiveness of concatenative programming as well as the readability of prefix notation. Statements can be delimited at arbitrary points, allowing them to read as sentences would in English.</p>
58+
<div class="code"><pre><code><span style='font-style: italic;color: #969896'>~~ Prime numbers in Cognate</span>
6659

67-
Def Factor (Zero? Modulo Swap);
60+
<span style='color: #0086b3'>Def</span> <span style='color: #795da3'>Factor</span> <span style='color: #4e4e4e'>(</span><span style='color: #183691'>Zero?</span> <span style='color: #183691'>Modulo</span> <span style='color: #183691'>Swap</span><span style='color: #4e4e4e'>)</span>;
6861

69-
Def Primes (
70-
Fold (
71-
Let I be our potential prime;
72-
Let Primes are the found primes;
73-
Let To-check be Take-while (<= Sqrt I) Primes;
74-
When None (Factor of I) To-check
75-
(Append List (I)) to Primes;
76-
) from List () over Range from 2
77-
);
62+
<span style='color: #0086b3'>Def</span> <span style='color: #795da3'>Primes</span> <span style='color: #4e4e4e'>(</span>
63+
<span style='color: #183691'>Fold</span> <span style='color: #4e4e4e'>(</span>
64+
<span style='color: #0086b3'>Let</span> <span style='color: #795da3'>I</span> <span style='color: #333333'>be</span> <span style='color: #333333'>our</span> <span style='color: #333333'>potential</span> <span style='color: #333333'>prime</span>;
65+
<span style='color: #0086b3'>Let</span> <span style='color: #795da3'>Primes</span> <span style='color: #333333'>are</span> <span style='color: #333333'>the</span> <span style='color: #333333'>found</span> <span style='color: #333333'>primes</span>;
66+
<span style='color: #0086b3'>Let</span> <span style='color: #795da3'>To-check</span> <span style='color: #333333'>be</span> <span style='color: #a71d5d'>Take-while</span> <span style='color: #4e4e4e'>(</span><span style='font-weight: bold;color: #4e4e4e'>&lt;=</span> <span style='color: #183691'>Sqrt</span> <span style='color: #795da3'>I</span><span style='color: #4e4e4e'>)</span> <span style='color: #795da3'>Primes</span>;
67+
<span style='color: #a71d5d'>When</span> <span style='color: #183691'>None</span> <span style='color: #4e4e4e'>(</span><span style='color: #795da3'>Factor</span> <span style='color: #333333'>of</span> <span style='color: #795da3'>I</span><span style='color: #4e4e4e'>)</span> <span style='color: #795da3'>To-check</span>
68+
<span style='color: #4e4e4e'>(</span><span style='color: #183691'>Append</span> <span style='color: #794da3'>List</span> <span style='color: #4e4e4e'>(</span><span style='color: #795da3'>I</span><span style='color: #4e4e4e'>)</span><span style='color: #4e4e4e'>)</span> <span style='color: #333333'>to</span> <span style='color: #795da3'>Primes</span>;
69+
<span style='color: #4e4e4e'>)</span> <span style='color: #333333'>from</span> <span style='color: #794da3'>List</span> <span style='color: #4e4e4e'>(</span><span style='color: #4e4e4e'>)</span> <span style='color: #333333'>over</span> <span style='color: #183691'>Range</span> <span style='color: #333333'>from</span> <span style='color: #0086b3'>2</span>
70+
<span style='color: #4e4e4e'>)</span>;
7871

79-
Print Primes up to 1000;
80-
</code></pre></div>
81-
<p>Cognate borrows from other concatenative languages, but also adds unique features of its own.</p>
72+
<span style='color: #183691'>Print</span> <span style='color: #795da3'>Primes</span> <span style='color: #333333'>up</span> <span style='color: #333333'>to</span> <span style='color: #0086b3'>1000</span>;
73+
</code></pre></div><p>Cognate borrows from other concatenative languages, but also adds unique features of its own.</p>
8274
<ul>
8375
<li>Point-free functions</li>
8476
<li>Operation chaining</li>
@@ -87,7 +79,12 @@ <h2 id="readable-and-concise-concatenative-programming">Readable and concise con
8779
<li>Predicate pattern matching</li>
8880
<li>Natural language programming</li>
8981
</ul>
90-
<p>Interested? Read the <a href="/learn/">tutorial</a>, check out the <a href="https://cognate-playground.hedy.dev/">interactive web playground</a>, or visit our <a href="https://github.com/cognate-lang/cognate">GitHub repository</a>.</p>
82+
<p>Interested? Read the <a href="/learn/">tutorial</a>, and check out one of Cognate&rsquo;s implementations:</p>
83+
<ul>
84+
<li><a href="https://github.com/cognate-lang/cognate">CognaC</a> is the original compiler &ndash; it performs type inference and produces efficient binaries.</li>
85+
<li><a href="https://cognate-playground.hedy.dev/">Cognate Playground</a> (developed by <a href="https://github.com/hedyhli">hedyhli</a>) runs Cognate programs in a web browser.</li>
86+
<li><a href="https://github.com/dragoncoder047/cogni">Cogni</a> (developed by <a href="https://github.com/dragoncoder047">dragoncoder047</a>) interprets Cognate programs, and is optimised to run on microcontrollers.</li>
87+
</ul>
9188

9289

9390
</main>

0 commit comments

Comments
 (0)