Live data from Hacker News

The C3 Programming Language

c3-lang.org

211–220 of 270 posts

Re: The C3 Programming Language

#211
post #118

Earlier quoted context omitted.

> dangling pointers to raw memory that [are not] cleaned How do you feel about building special constructs to automatically handle these ?

I totally can but my gripe is about not wanting to.

c3 has a @pool annotation that makes a block use an arena to allocate, that should help since all memory is freed upon exiting the block.

Re: The C3 Programming Language

#213

Earlier quoted context omitted.

That would be C# ?

I understood the sibling comment recommending Ocaml and to a lesser extent Borgo, but OP is looking for a high level functional programming language based on giving Gleam as the reference point. How does C# fit here. I do think the compilation speed and runtime is at least in the same ballpark, but C#, while a perfectly fine language, is definitely not a functional language in syntax or semantics.

[dead]

Re: The C3 Programming Language

#214

Earlier quoted context omitted.

Borgo could be your thing? https://borgo-lang.github.io

It looked really good! But seems kinda dead, and I don't know the Go ecosystem well enough to know if dead things can sort of keep working forever

There is also Dingo https://github.com/MadAppGang/dingo https://dingolang.com (heavy AI project)

Re: The C3 Programming Language

#215
post #188

This seems pretty neat! Still holding out for a language with Go's runtime and compilation and performance characteristics, but language syntax and semantics like Gleam... Maybe one day

Unfortunately the current trend among new languages seems to be eschewing GC; a clear mistake IMO — we don't really need yet another low-level systems programming language, but we badly need the go-to GC'd lang — one that'd take the faults of Java and Go into account.

There is lots of languages that already do that: Kotlin, Dart, typescript, OCaml, D, Haskell and the list goes on! Non GC languages OTOH are rare and we absolutely need more of them!

Re: The C3 Programming Language

#216

Earlier quoted context omitted.

That would be C# ?

I understood the sibling comment recommending Ocaml and to a lesser extent Borgo, but OP is looking for a high level functional programming language based on giving Gleam as the reference point. How does C# fit here. I do think the compilation speed and runtime is at least in the same ballpark, but C#, while a perfectly fine language, is definitely not a functional language in syntax or semantics.

They probably meant F#

Re: The C3 Programming Language

#217

Earlier quoted context omitted.

Contracts are a way to express invariants, "This shall always be true". There are three main things you could do with these invariants, the exact details of how to do them, and whether people should be allowed to specify which of these things to do, and if so whether they can pick only for a whole program, per-file, per-function, or whatever, is separate. 1. Ignore the invariants. You wrote them down, a human can rea…

I guess the reason I found it surprising is that I would only use 3 (ie risk introducing UB) for invariants that I was very certain were true, whereas I would mostly use 2 for invariants that I had reason to believe might not always be true. It struck me as odd that you'd use the same tool for scenario's that feel like opposites, especially when you can just switch between these modes with a compiler flag

It feels pretty clear to me that these Contracts should only be used for the “very certain” case. Writing code for a specific compiler flag seems very sketchy, so the programmer should assume the harshest interpretation.

The runtime check thing just sounds like a debugging feature.

Re: The C3 Programming Language

#218
post #73

Earlier quoted context omitted.

“However, violating either pre- or post-conditions is unspecified behaviour, and a compiler may optimize code as if they are always true – even if a potential bug may cause them to be violated” This implies that a compiler would be permitted to remove precisely that actual code that checks the condition in non-safe mode. Seems like a deliberately introduced footgun.

My understanding of this was that the UB starts only after the value is passed/returned. So if foo() has a contract to only return positive integers, the code within foo can check and ensure this, but if the calling code does it, the compiler might optimize it away.

Assuming that is correct, it's still exactly the same footgun. Checks like that are introduced to guard against bugs: you are strictly safer to not declare such a constraint.

Re: The C3 Programming Language

#219

Earlier quoted context omitted.

Which one specifically does ending a process not clean up the memory?

Any flat memory rtos. Not everything is *nix. For example microcontrollers or aerospace systems.

Tbh on such a bare bones system I would use my own trivial arena bump allocator and only do a single malloc at startup and a single free before shutdown (if at all, because why even use the C stdlib on embedded systems instead of talking directly to the OS or hardware)

Re: The C3 Programming Language

#220

I've been following C3 for sometime now, and I really appreciate the discipline in the design philosophy here. Neither does it force a new memory model on you, nor does it try to be C++. The killer feature for me is the full ABI compatibility. The fact that I no longer have to write bindings and can just mix C3 files into my existing C build system reduces the friction to near zero. Kudos to the maintainer for sticki…

Is full ABI compatibility important? I'm having a hard time seeing why. I mean… C isn't even an unsafe language. It's just that C implementations and ABIs are unsafe. Some fat pointers, less insanely unsafe varargs implementations, UBSan on by default, MTE… soon you're doing pretty well! (Exceptions apply.)

How would you integrate C3 with other programming languages (not just C), or even talk to operating systems if you don't implement a common ABI?

And the various system ABIs supported by C compilers are the defacto standards for that (contrary to popular belief there is no such thing as a "C ABI" - those ABIs are commonly defined by OS and CPU vendors, C compilers need to implement those ABIs just like any other compiler toolchain if they want to talk to operating system interfaces or call into libraries compiled with different compilers from different languages).

Post reply on HN