joe_the_user 5 days ago

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

  • nativeit 5 days ago

    It’s refreshing in its stripped down aesthetic, but I missed where it tells potential users what Cognate is especially good at, who it’s for, why it was developed, or why I should devote the time and effort to learning it?

    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.

nativeit 5 days ago

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/

  • nativeit 5 days ago

    I’m still baffled by the assertion that right-to-left evaluation of novel arithmetic syntax “enhance[s] readability”.

    • mcherm 5 days ago

      In a prefix language, I first learn what I'm going to be doing, then I learn what values I will be doing it to. This has the advantage that I understand the context in which things are going to be used. It helps in working from the top down.

      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.

    • epgui 5 days ago

      Beware the difference between familiarity and simplicity!

      To compare readability, you must first get used to the thing.

      • hallgrim 4 days ago

        I would disagree with this. The prefix notation isn’t hard to understand, but even if I am familiar with how it works, it still requires the reader to do conversion, whereas when I write “a + b” in most other languages, it is quite clear to anyone what it means without mental conversion.

        • brabel 4 days ago

          That's the opposite of the truth. With infix, you not only have to do conversions in your head, you need to keep track of which operator has precedence over another.

          You say you make no conversion when doing `a + b`, but that's exactly equivalent to `+ a b` or `a b +`, you're simply used to a particular order. In English, adjectives normally come in front of the subject, but in many other languages, it comes after. Same thing: the order is not really very relevant and either order "works".

          But where concatenative languages (and s-expression languages, e.g. Lisp) are superior is with complex expressions.

          In "usual" languages, you need to convert this:

              2 * 3 + 4 - 6
          
          to

              ((2 * 3) + 4) - 6
          
          To clearly determine the order of operations.

          In concatenative languages, you simply don't have to do anything, just apply the operators.

              * 2 3; + 4; - 6
          
          No conversion required, just do `* 2 3`, then `+ 4 <result>`, then `- 6 <result>`.

          Hence, if you really don't want to do conversions in your head, this is the way to go, not the conventional math notation!

          Notice how if the expression was instead:

              2 + 3 * 4 - 6
          
          Math notation would dictate you need to convert it to:

              (2 + (3 * 4)) - 6
          
          That is , the order of the operations is not even the one you read it (it's not just left to right, like normal English prose, and not right-to-left either, like Arabic prose would be).

          But in Cognate you MUST represent it pretty much the way you read:

              * 3 4; + 2; - 6
        • epgui 4 days ago

          In your argument you fell right into the trap of confounding simplicity and familiarity.

          Familiarity is when you say “look, this is like that other thing that I already do, neat”.

Kinrany 6 days ago

> 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?

emmanueloga_ 5 days ago

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.

  • rajandatta 5 days ago

    Yes - Concatenation Languages and stack-based languages refer to the same paradigm and group of languages. Forth is the original and oldest. I've looked at Factor and it's a really impressive piece of work. Well worth studying.

    • zsyllepsis 5 days ago

      I don’t think this is accurate. While most popular concatenative languages are stack-based, that is not a requirement for the paradigm. The Wikipedia article calls out a few alternatives, such as Om.

      Source: https://en.m.wikipedia.org/wiki/Concatenative_programming_la...

      • pxeger1 5 days ago

        APL-family languages are somewhat concatenative but not stack-based. They use grouping rules to form chains of composed functions.

purple-leafy 3 days ago

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

proneb1rd 5 days ago

A victim of its own simplicity. Such a mess with arithmetic operators being functions and everything being space separated.

  • kwhitefoot 4 days ago

    What's wrong with space separation?