70 points · by PaulHoule · 2y ago · 18 comments
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).
Rather, it makes cute remarks about how little it cares for how math works…well if it doesn’t care, why reinvent basic mathematical syntax? It goes out of its way to be confusing, and then flips you off for asking why. I must be missing the larger point of this project.
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.
In a postfix language, I first learn about how the values are constructed, then afterward I learn what I am going to do with them. This has the advantage that I am reading through things in the same order in which they happen. It helps me to think from bottom up.
To compare readability, you must first get used to the thing.
> 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?
Show HN: Cognate – Stack oriented programming in English prose - https://news.ycombinator.com/item?id=31312815 - May 2022 (6 comments)
Source: https://en.m.wikipedia.org/wiki/Concatenative_programming_la...
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