Live data from Hacker News

Odin, a pragmatic C alternative with a Go flavour

bitshifters.cc

31–40 of 131 posts

Re: Odin, a pragmatic C alternative with a Go flavour

#31
post #24

FWIW, another take on "C Alternative" is the D programming language: https://wiki.dlang.org/Tutorials Comparatively mature, there's even a freeware book which is quite good: http://www.ddili.org/ders/d.en/index.html

D was never a C alternative, it was a C++ alternative.

Doesn't having a whole subset of the language called "Better C" qualify?

Re: Odin, a pragmatic C alternative with a Go flavour

#32

Earlier quoted context omitted.

IMO it's one of Zig's advantages over C (text substitution macros are both too powerful and not powerful enough). If you're using Zig without metaprogramming, you're leaving a useful (if advanced) tool on the table.

C's preprocessor not being powerful enough is less a problem with text-substitution macros, more that they're not allowed to expand recursively which was an intentional design choice. There are some hacks you can do to get around it, and people have done cool things[1] within the limited space those hacks grant you, but there's a reason many C projects with extensive metaprogramming just use an external macro languag…

Debugging complex Lisp metaprogramming is a piece of cake in the overall debugging landscape.

- It is not distributed across machines. No distributed fault tolerance issues.

- It doesn't run on a resource constrained embedded system, with poor visibility, but in your dev environment.

- It runs in a single thread; no flaky race conditions or deadlocks to debug.

- Its expansion-time performance rarely matters; and it is rarely bogged down with machine dependencies or other low-level stuff.

- It is unit-testable with cases does construct X expanding to construct Y.

I would rather debug a macro than any number of other things I've also debugged.

Re: Odin, a pragmatic C alternative with a Go flavour

#33
post #24

FWIW, another take on "C Alternative" is the D programming language: https://wiki.dlang.org/Tutorials Comparatively mature, there's even a freeware book which is quite good: http://www.ddili.org/ders/d.en/index.html

D was never a C alternative, it was a C++ alternative.

Do you realize that D has betterC and now it also supports C compilation natively? [1] [2]

[1] D as a C Replacement (187 comments):

https://news.ycombinator.com/item?id=20323114

[2] Adding ANSI C11 C compiler to D so it can import and compile C files directly (105 comments):

https://news.ycombinator.com/item?id=27102584

Re: Odin, a pragmatic C alternative with a Go flavour

#34
post #24

Earlier quoted context omitted.

D was never a C alternative, it was a C++ alternative.

Doesn't having a whole subset of the language called "Better C" qualify?

C is liked particularly, even considering all its shortcomings, for being a relatively limited language in scope, being raw but flexible.

D's scope seems to go far beyond what your average C programmer would want in a language; "use only 15% of the language and you'll be fine" (paraphrasing: "use only the 'better-C' subset", if that is what you meant, and it does seem to be a subset of D) seems a weird proposition; it still complicates things, as in collaboration, idiomatic feel and look of code, the amount of knowledge required to be competent in the language, complexity of a compiler implementation, portability of code etc... and by that logic you'd have to prefer C++ over C as well (since a lot of C is valid C++), or prefer C plus one safety feature added over C; but the "rawness"/limited scope/small size/procedural nature of C is what's appealing for many to begin with.

I for one think that a proper C replacement (C's strength also being the simplicity in which to implement a compiler for example, being the reason it's so ubiquitous in the embedded world) will be a much more limited proposition than D is.

Edit: And having been curious, even "Better-C" still has things many C-programmers wouldn't particularly like. Going by things listed here https://en.wikipedia.org/wiki/D_(programming_language)

  RAII
  Full metaprogramming
  Nested functions, nested structs, delegates and lambdas
  Member functions, constructors, destructors, operating overloading, etc.
  ...
Where to draw the line will be different person to person, but D doesn't seem to be a language "in the spirit of C", or a "modern version of it", at all.

Viewing it as a C++ alternative makes much more sense. A `Better-C` "limit yourself to a subset of the language" compiler flag doesn't change that much.

Re: Odin, a pragmatic C alternative with a Go flavour

#35
post #24

Earlier quoted context omitted.

D was never a C alternative, it was a C++ alternative.

Doesn't having a whole subset of the language called "Better C" qualify?

It was introduced in 2017, and not part of the original direction of D (it’s neither in 1.0 nor the 2.0 revision of the language)

That D exposes a curated subset of D doesn’t make it a C alternative, even though the ”betterC” aims to target people looking for a C alternative

Re: Odin, a pragmatic C alternative with a Go flavour

#36
post #24

Earlier quoted context omitted.

D was never a C alternative, it was a C++ alternative.

Do you realize that D has betterC and now it also supports C compilation natively? [1] [2] [1] D as a C Replacement (187 comments): https://news.ycombinator.com/item?id=20323114 [2] Adding ANSI C11 C compiler to D so it can import and compile C files directly (105 comments): https://news.ycombinator.com/item?id=27102584

Yes, I am quite aware. But it doesn’t make D any less a C++ alternative.

Re: Odin, a pragmatic C alternative with a Go flavour

#37
post #36

Earlier quoted context omitted.

Do you realize that D has betterC and now it also supports C compilation natively? [1] [2] [1] D as a C Replacement (187 comments): https://news.ycombinator.com/item?id=20323114 [2] Adding ANSI C11 C compiler to D so it can import and compile C files directly (105 comments): https://news.ycombinator.com/item?id=27102584

Yes, I am quite aware. But it doesn’t make D any less a C++ alternative.

Safe to say that D is both C and C++ alternative, never say never.

Re: Odin, a pragmatic C alternative with a Go flavour

#38

As a completely incidental observation (and maybe related to the article from a few days ago considering the importance of language skills compared to math skills for software development), I'm interested in what people choose to capitalize when developing languages. With c, lowercase seems to be the default, signifying variables or function calls. Adding inheritance in c++ leads to Proper Nouns like classes being ca…

That's a method from Raylib, a C library which has Odin bindings. For all libraries, Odin follows the original library's style.

The Odin convention is Pascal case (lower_case_procedures, Capitalized_Enums_And_Structs).

Re: Odin, a pragmatic C alternative with a Go flavour

#39
When I first saw Odin, I wrote down a list of everything I didn't think I'd like.

After several thousand lines, it proved all of my major worries incorrect, and has been an absolute pleasure.

It has since replaced my usage of Go, which I had been using since release.

I would highly recommend giving it a proper shot!

Post reply on HN