from Hacker News

Nature: Programming language to experience the joy of programming

by psxuaw on 10/13/23, 11:36 AM with 123 comments

  • by xwowsersx on 10/14/23, 12:18 AM

    The general negativity and tone of "tell me precisely what the point of this is right now!" in the comments here deviates so completely from the spirit of play, tinkering, and experimentation inherent in the hacker ethos, at least as I see it, and I'm really disappointed to see it here. You can have your qualms with this language, you might feel personally overloaded by languages at the current moment, maybe you even have legitimate questions about the intended audience of this language — fine. None of those feelings or questions justify the kind of rude, interrogatory "How dare you do this! Show me why I should care!" attitude reflected in many of the comments here.
  • by booleandilemma on 10/13/23, 2:54 PM

    I don't know. I feel like the language space is very crowded right now.

    While that's a great thing for everybody, it does mean if you're going to be pushing a new language, you need to be clear about what sets your language apart from the dozens of others clamoring for attention.

  • by donpdonp on 10/13/23, 4:42 PM

    The syntax choices are really nice here. It has a lot of what I would pick for a language. The one-liner test cases are awesome, <> for generics is comfortable since I use rust, sum types like elm are awesome. If I were to add something (well take it away really) its to use whitespace for array element separators. Eliminates the whole trailing comma issue and looks cleaner, though I admit it might create parsing ambiguities. 'try expr', returning (val,err) is curious and I think I like it better already than try {} catch {}.
  • by zoogeny on 10/13/23, 3:29 PM

    I like the feel of the syntax on first glance.

    I have been thinking recently that all of the new powerful features showing up in language (Typescrpt, Go, Rust, Elixir, Kotlin, etc.) have been exposing programmers to combinations of programming language features that were not widely available before. I mean, I grew up with Pascal, Basic, C/C++ and Lisp but kids these days are growing up with Python, Typescript, Rust, Go, Haskel, Kotlin, Dart, Swift, C#.

    Specifically I was thinking about how I avoid classes now for almost all of my code. I used to be a OOP first guy. Now I want value semantics and abstract data types. I have always hated exceptions (or any non-local control flow in general) and I love guards and defer-like semantics. I love the idea of CSP and Erlang but I also want full low-level control of bits. I want custom allocators and no GC, except maybe when I want a GC for some reason.

    I love that people are just experimenting by taking the bits and pieces they like from the multitude of available high-quality languages and they are mixing them up into strange new soups.

  • by johngossman on 10/14/23, 12:30 AM

    There is a 1963 RAND paper where they considered whether it was time to standardize on a programming language (Not yet, was their conclusion). It contains one of my favorite quotes: “About the same time, however, a further complicating factor arose--the designing of programming languages became fashionable. Now the proliferation of languages increased rapidly as almost every user who developed a minor variant on one of the early languages rushed into publication, with the resultant sharp increase in acronyms. In addition, some languages were designed practically in vacuo. They did not grow out of the needs of a particular user, but were designed as someone's "best guess" as to what the user needed (in some cases they appeared to be designed for the sake of designing).”

    Personally, I find nothing wrong with designing for the sake of designing.

  • by munro on 10/13/23, 2:53 PM

    A pleasant little language, it looks like weiwenhao started working on it back in 2021. It looks great!

    I couldn't find anything novel the programmer wanted to try out in this language-- seems like they just want to capture the zeitgeist, and condense it into a simpler form.

    It does make me wonder, how many other interesting languages are programmers toiling on out there? Wish there was a way to sort by newest repo, but this does start revealing some interesting underground langs:

    https://github.com/topics/programming-language?o=desc&s=upda...

  • by lifeisstillgood on 10/13/23, 11:44 PM

    I have a joy of programming in bash. Another language might be fun but the real joy lies in expressing oneself, solving a problem, getting the bon mot - its past bedtime and I have for the first time in a year found myself doing salaried work after hours for the fun of it
  • by dindobre on 10/13/23, 4:08 PM

    Allow me a shallow opinion since we are in "joy of programming" territory: after python anything with curly brackets feels "uh". Give me python with typescript typing
  • by twism on 10/13/23, 4:58 PM

    In the "Error Handle" example ...

      11 var t = test {
      ---------------------------------------------
    Should the variable `t` be `foo` here?

      ---------------------------------------------
      12     list = [1, 2, 3, 4, 5]
      13 }
      14 
      15 var (l, err) = foo.list[8]
  • by gsuuon on 10/13/23, 3:39 PM

    This is cool - it looks like there are a few languages developed targeting game development, like Odin and Jai. Are there others in this space? Really curious how these compare.

    It doesn't look like Nature has ADT's, is that true or just missing from the docs?

  • by Willamin on 10/13/23, 3:46 PM

    A bit of a nitpick on the language on the homepage:

    The description of the Fibonacci example seems incorrect, but I might be misunderstanding something about the language.

    > A fib evaluation function was defined using recursion.

    > The result of the function call was assigned to a variable named "result" and format the output using fmt.printf

        import fmt 
    
        fn fib(int n):int {
            if n <= 1 {
                return n
            }
            return fib(n - 1) + fib(n - 2)
        }
    
        fmt.printf('fib result is %d', fib(30))
    
    No variable named "result" is ever defined, right? Maybe the description is outdated from a time when an intermediate variable was present.
  • by agentultra on 10/13/23, 2:56 PM

    Depends on what brings you joy.

    Update: Ok, non-glib serious comment: the "joy" of programming is highly subjective and the author might want to consider a different byline to avoid confusion. A "creative" or "hobby" programming lanugage for "experimentation," might make the point better.

    Personally I don't find much joy in C-like languages as they're all approximately the same to me... and the "joy of programming," is less about syntax than semantics and form.

  • by billfruit on 10/13/23, 2:57 PM

    How exactly does it make someone experience the joy of programming?
  • by ejstembler on 10/13/23, 10:03 PM

    Congratulations weiwenhao! I like what I see so far and am looking forward to following the continued development of the language. Do you have any social media accounts set up for the language (e.g. X, Mastodon, Blue Sky, etc.) that people can follow?
  • by teo_zero on 10/15/23, 2:11 AM

    I find this promising. There are some weak points to highlight (not to criticize, but to help development).

    What I don't like is that there are more ways to declare what a name means. Variables:

      var x = ...
      int x = ...
    
    And even functions:

      fn f()...
      var f = fn()...
    
    It makes reading someone else's code difficult. When I want to know what an identifier is, I scan the code until I find its declaration. I might do it manually or via some macros of my editor, but the fact that such declaration can appear in different forms makes things difficult.

    Besides, looking for the first time at a piece of code it's not immediately clear if an identifier is a type or a variable. Especially in constructs where a variable and a type appear separated by a =, which suggests they are of the same kind:

      var box = rectangle {...
    
    My personal preference to solve the two issues in one go would be to use : to mark the type (which could be omitted in case of auto inference) and make 'var' mandatory:

      var x : u8 = 27
      var y : = 'hello'
      var f : fn(int)->int = {
    
    With : repurposed, it can't be used for the return type; I used -> as in other languages.

    Now a macro or reader looking for the declaration of x, y or f knows exactly what to look for. Now types can only appear after a : or the keywords 'type' and 'as' (unless the syntax of the latter elements is changed to 'type:' and 'as:').

    And talking about 'as', its priority must be clarified:

      z = a * -b as int
    
    Does 'as int' apply to b, to -b, to the whole product, or to z?

    I like how easy it is to declare union or sum types with '|', but the need to use 'as' and 'let' after an 'if ... is' makes it clumsy. Lazy programmers, the ones that wouldn't check for NULL in C, will simply add a 'let' here and there and perpetrate Tony hoare's billion-dollar mistake.

    Finally, I'd like to understand exactly how the parser handles new lines. It looks like they end a statement, but are ignored in other contexts.

  • by TeaDude on 10/13/23, 3:15 PM

    In-house non-llvm compiler? Ooh! This looks fun!

    Will definately give this a peruse.

  • by twism on 10/13/23, 5:05 PM

    Man i don't know ... if things are not strictly immutable (or at least by default) i'm not so sure about the joy part.
  • by dvektor on 10/14/23, 1:09 AM

    Looks like the love child of Python and Go.

    I like the syntax.

  • by joshbuckler on 10/13/23, 4:17 PM

    weiwenhao: The example in https://nature-lang.org/docs/the-basics/function#multiple-re... has `balance` and `product` swapped.
  • by spinal on 10/14/23, 10:01 AM

    I really like the syntax around error handling. It is similar to the usual try/catch, but looks a lot cleaner (at least to me, coming from Go).

    Was this inspired by another language? I don't recall seeing a language with the same (or very similar) syntax.

  • by endorphine on 10/14/23, 5:11 AM

    By reading the title, I expected this to be targeted towards newcomers to programming and hence be more close to Ruby (no types, reads like English etc)
  • by FrustratedMonky on 10/13/23, 2:58 PM

    Just quick take from the code examples.

    How is this more joyful than Rust Or Java or anything?

    What is the key difference here that is about adding 'joy'?

    Just not picking up on the sales case.

  • by hamdouni on 10/14/23, 10:35 AM

    Nice to see another language with different approaches... I will check it as it is always interesting to challenge its knowledge
  • by raytopia on 10/14/23, 1:50 AM

    I like it. I'm going to give it a try.
  • by klausnrooster on 10/14/23, 2:21 AM

    Glad to see things like this. Think Phix is contender in the space. 100% RosettaCode coverage in 2021.
  • by sjm on 10/13/23, 4:15 PM

    Sometimes I think we need more verbosity in programming languages. Imagine you're new to programming and come across this,

    - what the hell is fmt? - what the hell is fn? - int? - n? - printf? what is f? - what is %d?

    I know this probably isn't the crowd for this, but if my non-programmer friends curious about learning to code saw this they'd run for the hills. Sure this isn't a "learn to code" language, but a little verbosity is IMO not a bad thing: it is more humanist and can be self-documenting.

  • by fyzix on 10/14/23, 12:58 AM

    Any eta on a json module?
  • by mock-possum on 10/13/23, 5:12 PM

    Reminds me of typescript, less parenthesis, and prefix typing.
  • by pif on 10/13/23, 2:50 PM

    The question I didn't find answered in their documentation: why?
  • by riidom on 10/13/23, 7:49 PM

    Is Unicode support on the todo list?
  • by Vaslo on 10/13/23, 5:36 PM

    It just looks like another programming language that I would waste time on instead of learning languages with tons more support and user acceptance that don’t look much different.

    Let’s keep reinventing the wheel!