Live data from Hacker News

Zen-C: Write like a high-level language, run like C

github.com

81–90 of 159 posts

Re: Zen-C: Write like a high-level language, run like C

#81
post #49

> Mutability > By default, variables are mutable. You can enable Immutable by Default mode using a directive. > //> immutable-by-default > var x = 10; > // x = 20; // Error: x is immutable > var mut y = 10; > y = 20; // OK Wait, but this means that if I’m reading somebody’s code, I won’t know if variables are mutable or not unless I read the whole file looking for such directive. Imagine if someone even defined custo…

Given an option that is configurable, why would the default setting be the one that increases probability of errors? For some niches the answer is "because the convenience is worth it" (e.g. game jams). But I personally think the error prone option should be opt in for such cases. Or to be blunt: correctness should not be opt-in. It should be opt-out. I have considered such a flag for my future language, which I name…

But why put it as a global metaswitcher instead of having different type infered from initial assignation qualifier?

Example:

    let integer answer be 42 — this is a constant
    set integer temperature be 37.2 — this is a mutable

Or with the more esoglyphomaniac fashion

    cst ↦ 123 // a constant is just a trivial map
    st ← 29.5 // initial assignment inferring float

Re: Zen-C: Write like a high-level language, run like C

#82

Earlier quoted context omitted.

Odin and Jai are others.

Does Odin compile to C? I thought it only uses LLVM as a backend

No, Odin does not compile to C. It is a standalone programming language that compiles directly to machine code. It primarily uses LLVM as its backend for compiling to machine code, like you said.

Re: Zen-C: Write like a high-level language, run like C

#84

Earlier quoted context omitted.

It’s not, it’s just how hackernews works. You’ll see new projects hit 1k-10k stars in a matter of a day. You can have the best project, best article to you but if everyone else doesn’t think so it’ll always be at the bottom. Some luck involved too. Bots upvoting a post not organically I doubt is gonna live long on first page.

The stars are on GitHub, they can come from somewhere else, e.g. the author himself buying stars.

Hi, I'm the developer's father. Trust me, he hasn't bought a single star in his life—not even in Super Mario :p

Re: Zen-C: Write like a high-level language, run like C

#85
post #76
post #70

Earlier quoted context omitted.

chicken scheme compiles to c as well. it's a pretty convenient compilation target, you get to use all the compilers and tool chains out there and you don't add a dependency on llvm

I love CHICKEN Scheme! Nice to see it mentioned. Though I think it's worth pointing out it compiles to something pretty far from handwritten C, to my understanding. I think this is true of both performance and semantics; for example you can return a pointer to a stack allocated struct from a foreign lambda (this is because chicken's generated C code here doesn't really "return", I think. Not an expert). Of course you…

Chicken indeed interoperates with C quite easily and productively. You're right that the generated C code is mostly incomprehensible to humans, but compiles without difficulty.

The Chicken C API has functions/macros that return values and those that don't return. The former include the fabulous embedded API (crunch is an altogether different beast) which I've used in "mixed language" programming to good effect. In such cases Scheme is rather like the essential "glue" that enables the parts written in other languages to work as a whole.

Of course becoming proficient in Scheme programming takes time and effort. I believe it's true that some brains have an affinity for Lispy languages while others don't. Fortunately, there are many ways to write programs to accomplish a given task.

Re: Zen-C: Write like a high-level language, run like C

#86
post #59

Syntax aside, how does this compare to Nim? Nim does similar, I think Crystal does as well? Not entirely sure about Crystal tbh. I guess Nim and Vala, since I believe both transpile to C, so you really get "like C" output from both.

I was also going to mention this reminds me of Vala, which I haven't seen or heard from in 10+ years.

Surprisingly theres a shocking number of GUI programs for Linux made with Vala, and ElementaryOS is built using Vala, and all their custom software uses Vala. So it's not dead, just a little known interesting language. :)

Re: Zen-C: Write like a high-level language, run like C

#88

> Mutability > By default, variables are mutable. You can enable Immutable by Default mode using a directive. > //> immutable-by-default > var x = 10; > // x = 20; // Error: x is immutable > var mut y = 10; > y = 20; // OK Wait, but this means that if I’m reading somebody’s code, I won’t know if variables are mutable or not unless I read the whole file looking for such directive. Imagine if someone even defined custo…

Yeah, immutability should probably use a `let` keyword and compiler analysis should enforce value semantics on those declarations.

Agreed, using `var` keyword for something that is non-var-ying (aka immutable) is not very intuitive.

Re: Zen-C: Write like a high-level language, run like C

#89
post #27

That's a very nice project. List of remarks: > var ints: int[5] = {1, 2, 3, 4, 5}; > var zeros: [int; 5]; // Zero-initialized The zero initialized array is not intuitive IMO. > // Bitfields If it's deterministically packed. > Tagged unions Same, is the memory layout deterministic (and optimized)? > 2 | 3 => print("Two or Three") Any reason not to use "2 || 3"? > Traits What if I want to remove or override the "trait…

C uses `|` for bitwise OR and `||` for logical OR. I'm assuming this inherited the same operator paradigm since it compiles to C.
Post reply on HN