June 20th, 2024

Cognate: Readable and concise concatenative programming

Cognate is a concise, readable concatenative programming language emphasizing simplicity and flexibility. It supports operators as functions, stack evaluation, control flow statements, list manipulation, recursion, and mutable variables through boxes.

Read original articleLink Icon
Cognate: Readable and concise concatenative programming

Cognate is a concise and readable concatenative programming language. It runs on Linux or Mac systems and can be installed using CognaC. In Cognate, operators like + and - are functions, and programs are evaluated right to left using a stack. Functions and variables are defined using Def and Let respectively. Control flow includes When, Unless, While, and If statements. Lists are created using the List function and manipulated with Push, First, Rest, For, Map, and Filter functions. Cognate also supports recursion and mutable variables through boxes. The language emphasizes simplicity and flexibility, allowing for concise and expressive code.

Related

F (2006)

F (2006)

F is a functional concatenative language with K3 list operations and Joy's dip combinator. It enforces one-time assignment, supports floating-point and symbolic datatypes, and emphasizes function-valence and -charge theories. The language is purely functional, prohibiting side-effects and reassignment, with various primitives for arithmetic, logic, and list operations. F also provides interactive commands for debugging and manipulation, focusing on simplicity, efficiency, and functional programming paradigms.

Trealla Prolog: Compact and efficient Prolog interpreter

Trealla Prolog: Compact and efficient Prolog interpreter

Trealla Prolog is a compact interpreter written in C, compliant with ISO Prolog. It supports unbounded integers, UTF-8 atoms, efficient strings, and runs on Linux, Android, and WebAssembly. It offers C integration, SQLite access, concurrency features, and experimental functionalities. The project is open source under the MIT license.

As you learn Forth, it learns from you (1981)

As you learn Forth, it learns from you (1981)

The Forth programming language is highlighted for its unique features like extensibility, speed, and efficiency. Contrasted with Basic, Forth's threaded code system and data handling methods make it versatile.

Cosmopolitan v3.5

Cosmopolitan v3.5

Cosmopolitan Libc transforms C into a universal language by modifying GCC and Clang to create a POSIX-compliant polyglot format. Users can compile programs using the `cosmocc` compiler and access debugging techniques. The project provides platform notes, a Discord chatroom, and funding acknowledgments.

Gren 0.4: New Foundations

Gren 0.4: New Foundations

Gren 0.4 updates its functional language with enhanced core packages, a new compiler, revamped FileSystem API, improved functions, and a community shift to Discord. These updates aim to boost usability and community engagement.

Link Icon 9 comments
By @joe_the_user - 5 months
I have to say that as a page presenting a new programming, this is the best I've seen in long time.

Yes, give simple examples demonstrating the language!

Yes, explain the syntax and structure from these!

There are many languages posted HN. Many of them sound interesting but the linked page often gives no example code at all, weirdly enough. Or it gives the code for fibonacci sequence with no explanation (nth fibonacci number code is embarrassing just cause if you ever wrote a naive routine for the nth fibonacci number in production, you would be doing it way wrong).

By @nativeit - 5 months
If anyone else is as lost as I was, here’s a primer[1]:

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.

…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.

Cognate is a stack-oriented programming language similar to Forth or Factor, except expressions are evaluated right to left. This gives the expressiveness of concatenative programming as well as the readability of prefix notation. Expressions can be delimited at arbitrary points, allowing them to read as sentences would in English.

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

—- 1. https://cognate-lang.github.io/

By @Kinrany - 5 months
> Cognate ignores words starting with lowercase letters, allowing them to be used as comments. This lets us write:

> Print the Square of 8;

At first sight I really disliked this. I thought it'd become repetitive. But... no more repetitive than just writing prose I guess?

By @dang - 5 months
Related:

Show HN: Cognate – Stack oriented programming in English prose - https://news.ycombinator.com/item?id=31312815 - May 2022 (6 comments)

By @emmanueloga_ - 5 months
HN often submits articles about Forth and derivatives. Are concatenative and stack-based languages kind of the same thing? (for example, Wikipedia classifies both "Forth" and "Factor" as "concatenative (stack-based)" programming languages.
By @purple-leafy - 5 months
I quite like the idea that you can write code as sentences, and they casing dictates what runs and what is ignored.

Id probably take it further and use a marker to better distinguish code from ignored comments eg

_my_variable is #equal to 3

Something to tell variables apart from functions. Let user use whatever casing they desire

By @proneb1rd - 5 months
A victim of its own simplicity. Such a mess with arithmetic operators being functions and everything being space separated.