Live data from Hacker News

Odin, a pragmatic C alternative with a Go flavour

bitshifters.cc

81–90 of 131 posts

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

#81
post #65

Earlier quoted context omitted.

Odin itself does not care what naming conventions you use. Use whatever you prefer. For Odin native libraries, we usually for the convention of `snake_case` for variables and procedures and `Ada_Case` for types. However for anything that is third-party/foreign, we try to keep to the same convention as the original library to make it easier to people reference the original documentation, as well as not have any of the…

Sticking to an library style is a way to go. It's so much friction to use python library wrappers which try to hammer original style into a snake_case.

Nim has solved this in a very practical way, which works great - case insensitive except 1st letter, and underscore insensitive. So hello_world and helloWorld and hello___wOrlD are the same identifier, though HelloWorld and hello_world are not.

Many people complain that this is horrible, but not people who have actually tried it. It works very well, lets you bridge over differences in C++ library conventions, Unix C conventions and Microsoft conventions in a project that interfaces all of them, without getting users upset. (There’s more to it - consistency for some identifier can be enforced, there’s a smart source reformatted, and more)

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

#82

I don't understand the point of this. When I say "Go flavour" I thought it would have lightweight threads like Go, but there is no mention of that in the description page. So it's another uninteresting curly brace language as far as I can tell. I'd rather use one with more traction.

"go flavour" refers to the similarity in the design philosophy, and some of the features. That said, it's still not Go. For example, "errors as values" is a point that Odin makes, but it does make it in a slightly different light from Go. Whereas Go has an `error` type that encompasses all errors, Odin does not. Instead, it treats some types (booleans, enums, unions) as "special", in that they support things like `or…

I just don't see the surface syntax as mattering that much. When I see "Go", I think lightweight threads, channels, and GC. Stuff like the declaration syntax is way down the list. Thanks though.

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

#83
post #23
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.

Seems needlessly harsh and also misplaced in some way. Zig is super non-ergonomic to any C-developer, and its explicitness at all costs is also non-C-like (meaning a rather big shift for someone actually liking C). Rust is a completely different beast altogether. Odin is a rather simple, performant, pragmatic, procedural language, fixing especially things in C with regards to its type system and infrastructure (such…

I have long been aware of that particular user of Odin, after all the creators mention it frequently. The fact remains that the US government has warned against the use of languages such as Odin [1]. As such, it is competing in the extremely small niche of "languages best suited for embedded computing and operating systems". Suffice to say that most of its users likely do not use it for that. Finally there is the matter of trust. A while ago I was shopping around these new languages that have sprouted out of LLVM and watched a few talks from the creators of various languages. The Zig team were both ambitions and clear in their presentation. They gave me the impression of an experienced and motivated team. By contrast the Odin presentation I saw was utterly directionless and filled with fluff. I like to think I have a good nose for BS, and Odin trips it. That great wall of random corporate logos of companies which don't use Odin on their website doesn't help. Upon investigating, I find that the creator of the language is also a developer at JangaFX, so is either using the Odin website to advertise his own software, or hoping to obtain clout by mentioning large companies as if they used Odin when they do not. You might think I'm being overly critical, but I've learned the hard way to avoid things like this. It's a mighty pain depending on something which ends up abandoned or unused. The Zig compile supports multiple codegen backends, compiling C/C++ code, and easy cross-compilation. It is a considerable feat of engineering and shows a lot of dedication on the part of the creators. I can see nothing comparable on the Odin front.

Additionally, I don't think a C replacement should be immediately intuitive to someone who has only ever used C. To entice people away from on of the most popular and stable programming languages ever created, you must offer more than an incremental improvement. There needs to be a paradigm shift, which necessitates some degree of learning on the part of the developer.

[1] https://techtheworld.net/2024/03/06/the-nsa-list-of-memory-s...

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

#84

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…

snake_case is just more readable overall. PascalCase and/or camelCase are okay in moderation and add a kind of emphasis, which is why e.g. Rust uses PascalCase for types (other than core built-in ones) and enum case constructors. SCREAMING_SNAKE_CASE is ok for even rarer things that should stand out - C/C++ uses it for preprocessor macros, Rust for program constants and global variables. Ada_Case is rare and mostly shows up in languages with case-insensitive identifiers, like Ada itself.

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

#85

Can someone explain how Odin achieves memory safety? Eg how does it avoid use-after-free?

It's not. However it is safer than C by default due to things like bounds-checking on arrays, slices (ptr+len), tagged unions, distinct typing for many things, an actual enum type, numerous checks for things like missing switch cases, and my more. It's not trying to be memory safe, but rather try and catch many common mistakes that C does not catch easily. As for use-after-free, I'd argue that is more of a problem wi…

One of the things I like about ObjC is that ARC is really really well done. The only time I care about memory management in ObjC is with cyclic references (eg: A->B and B->A). Those are about as rare as hen's teeth, and memgraph points them out if they ever do raise their head.

ObjC is pretty much the sweet spot for me in terms of language complexity and cognitive load over C, while providing so much more. It's really a shame that a lot of people (and I'm not pointing any fingers at anyone specifically) can't get past the [..] syntax, which comes from making ObjC a pure superset of C.

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

#87

Can someone explain how Odin achieves memory safety? Eg how does it avoid use-after-free?

The language creator strongly suggests using arenas and zero-is-initialization. That's a programming paradigm that completely avoids having to keep track of zillions of small memory allocations, so the mechanisms needed to manage that are less important.

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

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

I feel like the lack of marketing push is for two reasons. One is that it feels like Odin simply doesn't desire the kind of attention the other two languages have. Two is...I can't speak for Rust, but I feel like Zig punches well above its weight because of comptime, privileged support for Result in the form of error unions, and having a realistic roadmap for porting C code thanks to translate-c and its build system.

From what little I've seen of Odin, it doesn't have anything in particular that's especially headline-grabbing. However, Odin does have one thing that Zig doesn't, and it's that the language is considered "complete" despite its git repository being newer than Zig by a year. When it comes to programming languages, I do feel like there's something to be said for ease-of-implementation, and although Zig _feels_ simple from a feature-set point of view, I imagine it has a much higher bar to clear in terms of implementation complexity.

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

#89

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…

> Odin isn't a C++ alternative by any stretch

Perhaps not modern C++, but I would absolutely place it in the same weightclass as CFront and C++98 (albeit with less bugs and more ergonomics than those). I know you've placed the language adjacent to gamedev, so an appropriate metaphor, I feel like Odin is up to the task of making something with the complexity of a Goldsrc game, or a Dreamcast game. I feel like I could churn out half a million lines of high density soft real-time code quite happily.

Excited to see how it evolves through the years. Keep up the good work!

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

#90
Related. Others?

Understanding the Odin Programming Language - https://news.ycombinator.com/item?id=42348655 - Dec 2024 (97 comments)

Moving my game project from C to the Odin language - https://news.ycombinator.com/item?id=42030704 - Nov 2024 (19 comments)

Golang developers should try Odin - https://news.ycombinator.com/item?id=41969839 - Oct 2024 (7 comments)

Marketing the Odin programming language is weird - https://news.ycombinator.com/item?id=41913319 - Oct 2024 (101 comments)

Odin isn't getting more features. The syntax is done - https://news.ycombinator.com/item?id=40873431 - July 2024 (3 comments)

Introduction to the Odin Programming Language - https://news.ycombinator.com/item?id=40688899 - June 2024 (60 comments)

Odin Programming Language - https://news.ycombinator.com/item?id=38836512 - Jan 2024 (102 comments)

Small joys of programming in Odin - https://news.ycombinator.com/item?id=36812175 - July 2023 (61 comments)

A Review of the Odin Programming Language - https://news.ycombinator.com/item?id=32799499 - Sept 2022 (140 comments)

I like Odin - https://news.ycombinator.com/item?id=32626543 - Aug 2022 (204 comments)

Odin Programming Language - https://news.ycombinator.com/item?id=30394000 - Feb 2022 (42 comments)

The Odin Programming Language - https://news.ycombinator.com/item?id=22199942 - Jan 2020 (141 comments)

The Odin Programming Language - https://news.ycombinator.com/item?id=20075638 - June 2019 (3 comments)

Post reply on HN