Live data from Hacker News

Odin: Moving Towards a New "core:OS"

odin-lang.org

41–50 of 102 posts

Re: Odin: Moving Towards a New "core:OS"

#41
post #17

Earlier quoted context omitted.

I personally don't enjoy the MyObject? typing, because it leads to edge cases where you'd like to have MyObject??, but it's indistinguishable from MyObject?. E.g. if you have a list finding function that returns X?, then if you give it a list of MyObject?, you don't know if you found a null element or if you found nothing. It's still obviously way better than having all object types include the null value.

I like go’s approach on having default value, which for struct is nil. I don’t think I’ve ever cared between null result and no result, as they’re semantically the same thing (what I’m looking for doesn’t exist)

In Go, the default (zero) value for a struct is an empty struct.

Re: Odin: Moving Towards a New "core:OS"

#42
post #14

Anyone have a good comparison of Odin vs C/C++/Rust/Zig/Hare/etc? I'm particularly interested in how simple it is to implement a compiler in the given language.

Don't have a comparison, but I've written toy languages in a few of them.

I only really feel confident to talk about Rust, Rust stands out when it comes to parsing (functional bros unite), but does suffer when interpreting because of unsafe memory access - although for a compiler that shouldn't be an issue.

Odin is great, but I feel like it doesn't have enough syntax sugar to make languages easy to work on - that being said you can achieve most of what you want in a mostly comparable way if you're willing to write more ugly code. In this way it's very similar to C.

Re: Odin: Moving Towards a New "core:OS"

#43
post #17

Earlier quoted context omitted.

I personally don't enjoy the MyObject? typing, because it leads to edge cases where you'd like to have MyObject??, but it's indistinguishable from MyObject?. E.g. if you have a list finding function that returns X?, then if you give it a list of MyObject?, you don't know if you found a null element or if you found nothing. It's still obviously way better than having all object types include the null value.

I like go’s approach on having default value, which for struct is nil. I don’t think I’ve ever cared between null result and no result, as they’re semantically the same thing (what I’m looking for doesn’t exist)

Eh, it’s not uncommon to need this distinction. The Go convention is to return (res *MyStruct, ok bool).

An Option type is a cleaner representation.

Re: Odin: Moving Towards a New "core:OS"

#44

Earlier quoted context omitted.

That's a pretty heavyweight pattern. Wouldn't dynamic scope be better?

As another commenter wrote "how do you allocate memory without an allocator?" Even `malloc` has overhead. > Wouldn't dynamic scope be better? Dynamic scope would likely be heavier than what Odin has, since it'd require the language itself to keep track of this - and to an extent Odin does do this already with `context.allocator`, it just provides an escape hatch when you need something allocated in a specific way. Th…

> and to an extent Odin does do this already with `context.allocator`

It has a temporary allocator as well, which could track memory leaks. Not so much anymore though, IIRC.

> As another commenter wrote "how do you allocate memory without an allocator?

I would like to point out that this is basic knowledge. At first I was wondering if I have gone insane and it really is not the case anymore or something.

Re: Odin: Moving Towards a New "core:OS"

#45
post #37
post #26

Earlier quoted context omitted.

Your example produces very distinguishable results. e.g. if Array.first finds a nil value it returns Optional .some(.none), and if it doesn't find any value it returns Optional .none The two are not equal, and only the second one evaluates to true when compared to a naked nil.

What language is this? I'd expect a language with a ? -type would not use an Optional type at all. In languages such as OCaml, Haskell and Rust this of course works as you say.

This is Swift, where Type? is syntax sugar for Optional. Swift's Optional is a standard sum type, with a lot of syntax sugar and compiler niceties to make common cases easier and nicer to work with.

Re: Odin: Moving Towards a New "core:OS"

#46

Earlier quoted context omitted.

As another commenter wrote "how do you allocate memory without an allocator?" Even `malloc` has overhead. > Wouldn't dynamic scope be better? Dynamic scope would likely be heavier than what Odin has, since it'd require the language itself to keep track of this - and to an extent Odin does do this already with `context.allocator`, it just provides an escape hatch when you need something allocated in a specific way. Th…

> and to an extent Odin does do this already with `context.allocator` It has a temporary allocator as well, which could track memory leaks. Not so much anymore though, IIRC. > As another commenter wrote "how do you allocate memory without an allocator? I would like to point out that this is basic knowledge. At first I was wondering if I have gone insane and it really is not the case anymore or something.

[deleted]

Re: Odin: Moving Towards a New "core:OS"

#47
post #45
post #37

Earlier quoted context omitted.

What language is this? I'd expect a language with a ? -type would not use an Optional type at all. In languages such as OCaml, Haskell and Rust this of course works as you say.

This is Swift, where Type? is syntax sugar for Optional . Swift's Optional is a standard sum type, with a lot of syntax sugar and compiler niceties to make common cases easier and nicer to work with.

Right, so it's not like a union type Type | Null. Then naturally it works the same way as in the languages I listed.

Re: Odin: Moving Towards a New "core:OS"

#48

Earlier quoted context omitted.

I like to think about how many problems a feature solves to judge whether it's "worth it". I believe that the Sum types solve enough different problems that they're worth it, whereas nullability solves only one problem (the C-style or Java-style null object) the Sum types can solve that with Option and also provide error handling with Result and control flow with ControlFlow among others so that's already a better de…

Erased generics give parametricity, which most PL people think is fairly important. See https://en.wikipedia.org/wiki/Parametricity or https://www.cl.cam.ac.uk/teaching/1617/L28/parametricity.pdf

I mean, yeah, type erasure does give parametricity, but, you can instead design your language so that you monomorphize but insist on parametricity anyway. If you write stable Rust your implementations get monomorphized but you aren't allowed to specialize them - the stable language doesn't provide a way to write two distinct versions of the polymorphic function.

And if you only regard parametricity as valuable rather than essential then you can choose to relax that and say OK, you're allowed to specialize but if you do then you're no longer parametric and the resulting lovely consequences go away, leaving it to the programmers to decide whether parametricity is worth it here.

Re: Odin: Moving Towards a New "core:OS"

#49
post #29
post #23

Earlier quoted context omitted.

I think Odin should market itself for aforementioned games and graphics. Otherwise it will become very niche language. Even now, I think there is only about 5k Odin repositories on github while it is essentially a complete language. Contrast it with Zig, which is still evolving and has breaking changes, being still at 0.x without clear sight of 1.0, and it has over 27k repositories and big projects like Ghostty, Bunt…

> the language that inspired conception of both of these I haven’t heard this before. Do you have a source on this?

I do not, but John's old videos on the idea of making a language and addressing the modern problems of archaic languages has been cited many times.

Here is a list with his videos where he goes from conception to something tangible: https://www.youtube.com/watch?v=TH9VCN6UkyQ&list=PLmV5I2fxai...

The first video is from September 17, 2014.

Zig's first commit was Aug 5, 2015.

Odin has first commit in Jul 7, 2016.

Re: Odin: Moving Towards a New "core:OS"

#50
post #23

Earlier quoted context omitted.

I think Odin should market itself for aforementioned games and graphics. Otherwise it will become very niche language. Even now, I think there is only about 5k Odin repositories on github while it is essentially a complete language. Contrast it with Zig, which is still evolving and has breaking changes, being still at 0.x without clear sight of 1.0, and it has over 27k repositories and big projects like Ghostty, Bunt…

Did Jon state that he intends to release as open source? I am not sure he is the guy to the stressful route. If it all he would probably go long release cycles without considering public feedback too much. He also stated recently that he doesn't care too much about language design at a syntax level, or better said it's not his top focus as the overarching concepts are more important to him. I think there is a chance…

He said that for some period, the compiler will not be open source, the language will. Whether the compiler will become OS or not, I am not sure. But I think he just wants to get the spec done beforehand. I think he mentioned that the compiler code might be purchased via paid licence? I am not certain but as I am not a AAA studio, I do not care either way.
Post reply on HN