Live data from Hacker News

Odin, a pragmatic C alternative with a Go flavour

bitshifters.cc

71–80 of 131 posts

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

#71
post #5

A C alternative means a language that will last for 50 years, whereas this seems more like "whatever's popular by way of LLVM". I can see some real smart stuff coming out of languages like Zig and Rust, where Odin seems just to follow along.

Does Modula-2 count?

https://gcc.gnu.org/onlinedocs/gcc-15.1.0/gm2/

Or Ada,

https://gcc.gnu.org/onlinedocs/gcc-15.1.0/gnat_ugn

Maybe C++, given that the three main C compilers are written in it?

https://devblogs.microsoft.com/cppblog/the-great-c-runtime-c...

https://petereisentraut.blogspot.com/2013/05/moving-to-c.htm...

https://github.com/llvm/llvm-project/tree/main/clang/

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

#72
post #27

Earlier quoted context omitted.

Walter Bright, the creator of D, is an active commenter here. https://news.ycombinator.com/user?id=WalterBright Zig is also worth mentioning, and pops up frequently.

Once, on a previous account, he actually replied to me. It's like a kid going to guitar center and the guy who replaces your strings is Axl Rose. If you're on here, Walter, you're my hero. I also once interacted with Brendan Eich, who I admire as much for his role in web history as for his activism.

[flagged]

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

#73
post #70

Earlier quoted context omitted.

If you aim to be both a C alternative and C++ alternative, in reality you are just a C++ alternative because you haven't understood why people prefer C over C++. Therefore D is a C++ alternative and that's what it was always trying to be, even with "BetterC".

Only if they aren't using anything beyond C99, because after that C is basically turning into C++ without Classes .

Most C programmers I know pretty much do that. I use C11 just for the atomics and that is it. And I know many C programmers who still use C89/C90 exclusively.

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

#74

For me, I don't really look at Odin as a successor/fixer of C. There are other languages that can make a better case for that[1][2]. Instead, I look at it more like a successor/fixer of Pascal. It doesn't fall down the OO hole that so many others did. It has type casting, dynamic arrays, parametric polymorphism in both functions and data structures, is much less noisy (and in my opinion far more skimmable), more usef…

Thank you for the kind words regarding Odin! So Odin is in the family of Pascal _but_ I've tried my best to design it in such a way that it does "fix" most of the problems of C (since I am/was a C programmer), and make it _feel_ good to a C programmer when programming in the language. My view is that the core of Pascal was actually the correct place to start rather than the core of C. C won out of Pascal purely becau…

Where can I follow Odin's progress other than the blog? It doesn't seems to have any social media presence.

And what sort of time frame in terms of 1.0? I found Odin lacks the marketing push from Zig or Rust.

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

#75
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.

It certainly is, also known as D as C or Das C.

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

#76
post #74

Earlier quoted context omitted.

Thank you for the kind words regarding Odin! So Odin is in the family of Pascal _but_ I've tried my best to design it in such a way that it does "fix" most of the problems of C (since I am/was a C programmer), and make it _feel_ good to a C programmer when programming in the language. My view is that the core of Pascal was actually the correct place to start rather than the core of C. C won out of Pascal purely becau…

Where can I follow Odin's progress other than the blog? It doesn't seems to have any social media presence. And what sort of time frame in terms of 1.0? I found Odin lacks the marketing push from Zig or Rust.

So Odin the language in-itself is effectively done. But of course the core library, vendor library, tooling, etc are still very much being improved.

The reason for the lack of "social media presence" is because Odin is kind of weird to market for: https://www.gingerbill.org/article/2024/09/08/odin-weird-to-...

It's not "hypeable" like Zig or Rust mainly because it doesn't have any "killer features" but rather is a very pragmatic language by design. The people Odin attracts are also not the types of people to evangelize Odin either, since they are not there for the hype-train but to actually program.

So if you can help us find a way to market Odin itself without lying or exaggerating or overblowing minor features, then that would be very much obliged. It's a lot harder than you think.

As for "1.0", we have never worked to a timeframe for anything nor any sort of roadmap. The reason being is that we do not want to give false promises/hope about anything. Roadmaps are purely for advertisement, and the problem is, we don't even work to one so why present one? The other problem is that for "1.0", the language itself is well known: it's pretty much what you see today. But "1.0" for the general tooling? Now that's a harder question. We have plans but since everything is being worked on as we go (mostly volunteers), we cannot say when things will be finished. The biggest project at the moment is `core:os/os2`, the replacement for the `core:os` package. `core:os` was the first package ever written for Odin and it's absolutely dreadful and needs replacing. And that's what we've been doing with `core:os/os2`, slowly. And when it is ready, we will tell people many months in advance when we will make it the official one. This will be a breaking change, but probably the last biggest one for Odin.

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

#77
post #16

Odin seems to strike a really interesting balance between simplicity and practicality, especially for game development. I like the idea of having “batteries included” without too much abstraction getting in the way. For those who have used both Odin and Go, how do you feel about the differences in day-to-day development? Are there any features in Odin that you wish Go had, or vice versa? Would love to hear more real-…

I'd recommend going through https://odin-lang.org/docs/overview, as most of my points will be directly from there. Keep in mind it doesn't show _every_ feature (for instance, there are more built-in comptime procedures than shown https://odin-lang.org/docs/overview/#built-in-procedures-1), but does do a good job at displaying most.

Odin has all the features Go has (even struct tags https://odin-lang.org/docs/overview/#struct-field-tags), but adds:

- proper enums

- unions https://odin-lang.org/docs/overview/#unions

- built-in optional https://odin-lang.org/docs/overview/#maybet

- or_else/or_return/or_continue/or_break https://odin-lang.org/docs/overview/#or_else-expression (scroll down for the others)

- distinct types https://odin-lang.org/docs/overview/#distinct-types

- named arguments https://odin-lang.org/docs/overview/#named-arguments

- built-in matrix type https://odin-lang.org/docs/overview/#matrix-type

- built-in quaternions

- ternary operator, but you can use `bar := 1 if condition else 42` instead of ? and : if you'd like https://odin-lang.org/docs/overview/#ternary-operator

- default parameter values https://odin-lang.org/docs/overview/#default-values

- fantastic C integration

- forced in/exclusive range operators ..https://odin-lang.org/docs/overview/#range-based-for-loop

- can get the zero value of any type using `{}` https://odin-lang.org/docs/overview/#zero-values

- defer if https://odin-lang.org/docs/overview/#defer-if

- explicit procedure overloading https://odin-lang.org/docs/overview/#explicit-procedure-over...

- bunch of vendored libraries https://pkg.odin-lang.org/vendor

- bit_set/bit_field https://odin-lang.org/docs/overview/#bit-sets https://odin-lang.org/docs/overview/#bit-fields

- proper slices (not the Go monster which combines a dynamic array along with slices) https://odin-lang.org/docs/overview/#slices

- `for x in xs` instead of `for _, x := range xs`, and `for &x in xs` if you want `x` to be addressable

- implicit selector expressions `.Member_Name` https://odin-lang.org/docs/overview/#implicit-selector-expre...

- parametric polymorphism with a ton of intrinsics https://odin-lang.org/docs/overview/#parametric-polymorphism

- - along with `where` clauses (similar to Rust) https://odin-lang.org/docs/overview/#where-clauses

Language cohesion has been _incredibly_ well thought out.

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

#78

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!

I'm kinda curious, you mind sharing some of the things you thought you didn't like?

I took a good hard look at everywhere I may have stored it, but I believe I lost the original list after formatting.

I remember believing these were important:

- methods (turned out I mainly wanted working intellisense, which Odin does even without methods)

- a package manager (still a gripe, but git submodules do the trick somewhat)

- expressions (so I could assign the result from a `switch` statement to a variable for instance, but I can use an #inline proc if I _really_ want to)

- private by default (I had forgotten how many times I wanted to use something private from a library, and had to fork it instead)

- - although possible to make something private in Odin, nowadays I'd rather things be prefixed with underscores instead

Also, here are my list of things I'd still prefer changed, but are less important: https://forum.odin-lang.org/t/what-features-of-odin-do-you-d...

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

#79

I like odin a lot, however, there are two things that just don't stick with me, and i ended up quitting: - RTTI: just give me compile time type introspection and let me disable RTTI without making the language unusable - when/import: just let me wrap an import inside a when block, being forced to split my file in 3 made me quit the language

You should be able to import everything, then use `when` to generate a unified constant name:

@(require) import "x_a"

@(require) import "x_b"

when ODIN_OS == .Windows { x :: x_a } else when ODIN_OS == .Linux { x :: x_b }

x.do_thing()

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

#80

> This is the polar opposite of Zig’s embracing of metaprogramming for as much as possible. I found this claim a bit strange. do people actually use metaprogramming in Zig a lot?

I haven't read the article yet, but this seems to conflate compile time evaluation with metaprogramming. Not all comptime evaluation is metaprogramming. I would argue the majority of comptime programming as it is used in Zig isn't even metaprogramming. Metaprogramming is a paradigm where there source or target data structure is primarily the language you're programming in. comptime evaluation of expressions that could be runtime evaluated is not that. I would argue that comptime evaluation of expressions that return comptime only values (like types) is not even inherently that.

Where you start to see actual metaprogramming in Zig is in functions like @typeInfo, @alignOf, @offsetOf, which actually let you operate on language constructs (ie: looping over the fields of a struct). This is not extremely out of the ordinary, but it's not done "as much as possible".

Another place that metaprogramming shows up in Zig is code generation using the build system. I've never done this, and I would argue this is usually recommended to be done as little as possible, rather than as often as possible.

Edit: I read the article, and while I think that the author was wrong about Zig pushing metaprogramming "as much as possible", they were fairly accurate in how it is used in the rest of the article, like for serialization. The thing is, most of my programs are not serialization. I use serialization as a means to do other things.

Post reply on HN