Live data from Hacker News

The Chaos Programming Language

chaos-lang.org

71–80 of 87 posts

Re: The Chaos Programming Language

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

Re: The Chaos Programming Language

#72
post #58

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.

You're just shadowing the previous binding with a new one, not actually mutating anything[1]: λ> let foo = 1 λ> let foo = 2 λ> foo => 2 could be rewritten[2] as λ> let foo = 1 in ( let foo = 2 in foo ) => 2 which makes the semantics more clear. This idiom is also quite common in Clojure, another famously immutable-first language: (let [foo 1 foo 2] foo) ;; => 2 In my opinion (predominantly informed by my experience w…

> the benefit of immutability isn't what's happening in your own local scope, since it's typically quite easy to track what your immediate context is doing to a variable.

From my experience any sufficiently badly written code is hard to understand even in the local scope. The bar for hard to understand code isn't that high because the complexity of well written code is very close to zero.

Most code that avoids reassignment can be read from top to bottom. Code with local mutation can require backtracking and then the complexity can start exploding but that doesn't necessarily apply to code with mutation across functions. A simple list.add() doesn't cause anyone's brain to melt.

A classic is that someone writes a for loop like this: for(;i All that meaningless complexity has no reason to exist. It doesn't provide any value and it doesn't cost anything to avoid it.

Re: The Chaos Programming Language

#73
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…

I am now wondering what the benefit of Chaos' approach is. Chaos is making some pretty substantial tradeoffs. Going with conventional pattern matching (as part of the declaration) isn't such a big leap.

Re: The Chaos Programming Language

#74

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.

Numbers are literally never immutable in any language that isn't designed intentionally for comedy. Variables of a number type may be mutable, but the numbers themselves never mutate. Strings are typically immutable in most languages, but that does vary some (generally surprising people who expect primitives to be immutable).

Pythons numbers aren't as immutable as you think ;)

https://kate.io/blog/2017/08/22/weird-python-integers/

Re: The Chaos Programming Language

#75

I started going through the docs. This language starts off with some heft sells - prevent errors, increase test coverage, etc. Then the docs mostly cover things like "you can call an array an array or a list" and stuff that isn't very interesting to me. It doesn't even show methods or things like that. I think 90% of the docs I've read so far should have just been a single page with one liners one after the other, an…

It would work if you somehow could get the value of `z` (the "return" value of `add` in the example). Then you have a unit test for `add` on its own, and if you also unit test `f1`, `f2` and `f3` (which it calls depending on the value of `z`), you'd have almost full unit test coverage.

(You're not testing the conditions that lead to calling one of the `f` functions. Maybe it's chalked up to integration testing?)

But yeah, I share much of your frustration. The Decision making section should be the first thing, and it should have a test example. Longer non-trivial programs examples should be contrived to reassure people that this not utterly impractical.

Re: The Chaos Programming Language

#76

Earlier quoted context omitted.

Numbers are literally never immutable in any language that isn't designed intentionally for comedy. Variables of a number type may be mutable, but the numbers themselves never mutate. Strings are typically immutable in most languages, but that does vary some (generally surprising people who expect primitives to be immutable).

For a moment I started imagining what a mutable number would be like: > 3 = 5 > print 3 5 The end

You can kind of do that in Java by manipulating the integer cache

Re: The Chaos Programming Language

#77

Earlier quoted context omitted.

Yet it says [1]: > Arrays and the elements of arrays are also immutable I guess the docs need a bit of rewording. Forcing a deep-copy on variable assignment does not mean the variable itself is immutable. [1] https://chaos-lang.org/docs/07_immutability

Ah, I did not dive that deep. Now I am curious what the impact of deep copies on performance is, and if the language employs any clever optimizations to improve performance.

Turns out that immutable data structures can share a lot of structure safely.

https://www.amazon.com/Purely-Functional-Structures-Chris-Ok...

Re: The Chaos Programming Language

#78
> Decision making(a.k.a. control structures) in Chaos language is only achievable on function returns for the sake of zero cyclomatic complexity.

This is just moving the control flow to the end of the function right? Switch-case statements also have cyclomatic complexity, right?

Re: The Chaos Programming Language

#79
I appreciate the minor insight provided by seeing a language where control structures can only happen upon function return. I've had to teach recursion to many beginning students, and I have a feeling that seeing something like the Chaos language would help the concept of recursion gel with them. I'm very unsure that the language itself is useful or good, but I was certainly delighted by that small bit of insight.

Maybe some unix pros here can tell me, why the occultist package manager not installed via sudo, but the language itself is? It seems like an unnecessary security risk to run sudo on a random download.

Re: The Chaos Programming Language

#80
I think the concept of having conditionals at the end of functions is more interesting than people here are giving credit. It could go a long way to getting rid of incomprehensible nested if statements.

But all the aliases need to go. What's the point of having three aliases for an import statement other than to confuse new programmers. It seems like one of those ideas that seems good on paper, to include words from first languages, but in the end it'll just end up confusing everybody.

Post reply on HN