The threading story here is what grabbed my attention. Pass-by-value with copy-on-write means you get data-race immunity without any locks or channels. You just pass data to a thread and mutations stay local. That's a genuinely useful property. I've worked on systems where we spent more time reasoning about shared state than writing actual logic. The typical answer is "just make everything immutable" but then you los…
Show HN: A small programming language where everything is pass-by-value
61–64 of 64 posts
Re: Show HN: A small programming language where everything is pass-by-value
#62Syntax comment: in your control structures you use a keyword ("do", "then") to start a block as well as wrapping the block in parentheses. This feels superfluous. I suggest sticking with either keywords or parens to delineate blocks, not both.
This is a little bit tricky because the parser has to distinguish between: for x in arr (something ()) \ /-- function call and for x in arr (something ()) \ /-- loop body This is consequence of combining "blocks" and "precedence" into the same construct (). A more fitting example would be to support: for x in arr do set z += x; for x in arr do something x; IIRC these both currently require an explicit block in my par…
Re: Show HN: A small programming language where everything is pass-by-value
#63Earlier quoted context omitted.
I'm not sure if I understand the question? There are two ways to define a variable binding: x = 1; // declares x as immutable var y = 2; // declares y as mutable The "default" behaviour (if no keyword is used) is to define a new immutable variable.
I'm asking if the reality wouldn't be that "everything" is set as mutable by default and the non mutable part is ignored.
This is why the syntax "encourages" immutability by making it the easiest option (similar to e.g. Rust, F#). On the other hand, if it was an extra keyword nobody would use it (e.g. like Java).
Re: Show HN: A small programming language where everything is pass-by-value
#64Nim has a similar, strong preference for value semantics. However, its dynamic heap types (strings, seqs, tables) are all implemented as wrappers that hide the internal references and behave with value semantics by default, unless explicitly escape hatched. It makes it incredibly easy to manipulate almost any data in a functional, expression-oriented manner, while preserving the speed and efficiency of being backed b…