Live data from Hacker News

The C3 Programming Language

c3-lang.org

161–170 of 270 posts

Re: The C3 Programming Language

#161
post #157

The GitHub project has more details: https://github.com/c3lang/c3c Some ways C3 differs from C: - No mandatory header files - New semantic macro system - Module-based namespacing - Slices - Operator overloading - Compile-time reflection - Enhanced compile-time execution - Generics via generic modules - "Result"-based zero-overhead error handling - Defer - Value methods - Associated enum data - No preprocessor - Less…

So far so good. The feature set is bit random though. Things i personally miss is function overloading, default values in parameters and tuple returns.

> default values in parameters

C3 has you covered

https://c3-lang.org/language-fundamentals/functions/#functio...

It also has operator overloading and methods which you could use in place of function overloading I guess.

Re: The C3 Programming Language

#162
It's funny seeing the problems with C Niklaus Wirth pointed out originally still trying to be solved. He solved them with pascal and its OO successors, though for some reason it's not cool still.

I suppose it has less of the ability to blow your foot off and so isn't a very dangerous way to code, therefore not cool. If any of you younger folk haven't looked at it, I'd suggest having a look, there is Delphi - a cross platform dev environment that addresses all these problems and compiles in less than a second, or there's the free, open source alternative Lazarus. They also compile to mobile platforms and even the raspberry pi (Lazarus) or Arduino.

If you like contracts then ADA is the way to go, but I haven't used this for many years, so not sure what is the state of the compilers.

[1] https://www.embarcadero.com/products/delphi

[2] https://www.lazarus-ide.org

Re: The C3 Programming Language

#164

I see 'fn void main()'. There's probably a good reasson but why the 'fn'? It doesn't really add anything because 'void main()' already communicates it's a function. The main draw of C (to me) is it's terseness and it's avoidance of 'filler' syntax words. I admit I didn't (yet) look much further into it, but this first thing jumped out to me and slightly diminished my desire to look further into C3...

https://c3.handmade.network/blog/p/8886-why_does_c3_use_%252...

Re: The C3 Programming Language

#165

I've enjoyed using the C3 language to make some simple games [0] and found it really easy to pick up. The only thing that I got hung up on at first was the temporary memory arenas which I didn't know existed and ultimately really liked. [0] https://github.com/Syn-Nine/c3-mini-games

I took a look at your github and saw you implemented the same games in multiple languages, which one did you like the most and why?

Re: The C3 Programming Language

#166

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

It is called OCaml. Fast compilation and state of the art statically typed functional programming.

Sure it is a bit more complex than Gleam and the syntax is different but you can manage.

Re: The C3 Programming Language

#167
post #130

Was an interesting ready but sad to see that there is nothing special for matching or restructuring tagged unions (beyond the special cased optional type). That's one of the things from Rust I miss the most in my day to day work with C/C++.

Still looking for a good design: https://github.com/c3lang/c3c/issues/829

Did you manage to get more discussion on the Discord?

Re: The C3 Programming Language

#169

Delete "fn" and I might get onboard

The price of not requiring fn is mandatory forward declarations, header files, and a slower parser (because then the syntax requires knowing whether every symbol is a type or a function/variable to be parsed correctly)

I think that trade-off is absolutely not worth it. I'll take order-independent declarations and fast modules over strictly sticking to C syntax any day.

Re: The C3 Programming Language

#170

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…

You've described three different features with three different sets of semantics. Which set of semantics is honored? Unknown! This is not software engineering. This is an appeal to faith. Software engineering requires precise semantics, not whatever the compiler feels like doing. You can't even declare that this feature has no semantics, because it actually introduces a vector for UB. This is the sort of "feature" th…

> Which set of semantics is honored?

Typically it's configurable. For example C++ 26 seems to be intending you'll pick a compiler flag to say if you want its do-nothing semantics, or its "tell me about the problem and press on" semantics or just exit immediately and report that. They're not intending (in the standard at least) to have the assume semantic because that is, as you'd expect, controversial. Likewise more fine-grained configuration they're hoping will be taken up as a vendor extension.

My understanding is that C3 will likely offer the coarse configuration as part of their ordinary fast versus safe settings. Do I think that's a good idea? No, but that's definitely not "Unknown".

Post reply on HN