Live data from Hacker News

The Chaos Programming Language

chaos-lang.org

81–87 of 87 posts

Re: The Chaos Programming Language

#81
post #71

Having 2 to 3 keywords for the exact same purpose seems like a nightmare. Do we need `def`, `fun`, and `function`? Just pick one and only one. On another note, the docs are not so good. They're really missing a few real life examples with unit tests.

This alone made me stop reading. There is absolutely no reason for this. It's an extra thing I have to think about when reading/writing code with literally zero benefit. Now people new to the language have extra stuff to learn. Languages need less ways to do the same thing. Not more.

Re: The Chaos Programming Language

#82
post #56

Earlier quoted context omitted.

No, it only means that you can reassign the name `a` to a different value (i.e. it is a variable, not a constant). It would be mutable if it allowed something like this: > a = 5 > a.add(1) > print a 6 Note that numbers are immutable in most languages anyway. Arrays, hashmaps, and sometimes strings are the data types that are frequently mutable.

That's standard behavior for object oriented languages. A different example with functions: function add(x, y) { return x + y } a = 5 add(a, 1) print(a) A language printing 6 is pass by reference. A language printing 5 is pass by value. Both would print 6 for this code a = add(a, 1) print(a) However a language like Erlang would end with an error when trying to reassign a new value to a.

I correct myself. The function in the first example should be

  function add(x, y) {
    x = x + y
    return x
  }

Re: The Chaos Programming Language

#83

Earlier quoted context omitted.

Everyone says strings in java are immutable, yet you can still re-assign to string variables. It really is up for debate.

Java strings are immutable. Java variables with a string type are not. It's really not up for debate. You can't mutate a string in Java (you can in Ruby), but you can mutate a string variable by reassigning it.

Oh, I see the distinction now.

Re: The Chaos Programming Language

#85

Earlier quoted context omitted.

I have never worked with Haskell but admire it from afar, and I'm honestly astonished that the REPL works this way. I would assume this would error at the compiler for a normal program, and that the REPL runtime would enforce the same constraints.

I guess an argument can be made that forcing a restart of the REPL is a pretty harsh punishment, but I would expect Haskell (of all languages) to at least require some kind of tabula rasa.

If it makes you feel better node doesn't allow you to reassign const declarations in the REPL, which is actually very annoying if you forget about that behaviour and tend to default to writing const.

Re: The Chaos Programming Language

#86

As far as I understand after reading the docs for 5 minutes, this section is the core original idea behind the language: https://chaos-lang.org/docs/11_decision_making > Decision making(a.k.a. control structures) in Chaos language is only achievable on function returns for the sake of zero cyclomatic complexity. This looks as original and language-defining as Rust's borrow checker. I really wish authors changed their…

That doesn't seem possible. A function with no flow control statements has a cyclomatic complexity of 1. I.e. function retVal(x) { return x } has a cyclomatic complexity of 1 because there is 1 path through.

Even ignoring that issue, even if the control flow statement is in the return, it still has a cyclomatic complexity of 2. I.e. function isEqual(x, y) { return x == y } still has a cyclomatic complexity of 2, you're just hiding it. The actual logic flow in terms of nodes is

``` if (x == y) { return true } else { return false } ```

It's entirely possible for a single line to have a cyclomatic complexity of more than 1. Ternaries, for example, would have a cyclomatic complexity of 3.

Re: The Chaos Programming Language

#87
post #60

Earlier quoted context omitted.

I'm still not convinced it doesn't just sweep the complexity under the rug. Ultimately you still need to branch unless you only want the language to do pure mathematical computation or something like that. Only now every branch needs to be hidden in a function call.

I have a large Elixir project with less than 10 branches (if then else) and they were written by other developers. Conditional logic is done either in pattern matching in function definitions (and some guard) or case/cond or with/else. I guess case/cond can be implemented with the return mechanism of Chaos. Maybe it's going to feel weird, maybe not. There is no pattern matching and I got the feeling that's going to c…

Pattern matching is still branching. An elegant way of expressing it, but it is branching none the less.
Post reply on HN