[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


3-Year duration 4chan Passes are now available for $45

[Advertise on 4chan]


File: favicon.png (107 KB, 813x813)
107 KB
107 KB PNG
Programming Done Right

Odin is a general-purpose programming language with distinct typing built for high performance, modern systems and data-oriented programming.

Odin is the C alternative for the Joy of Programming.

website : https://odin-lang.org/
FAQ : https://odin-lang.org/docs/faq/
overview : https://odin-lang.org/docs/overview/
packages : https://pkg.odin-lang.org/
>>
>>102273820
>Joy of Programming
literally even this catchphrase is stolen from Jai lol
>>
File: _yes.jpg (36 KB, 474x632)
36 KB
36 KB JPG
>>102273853
if we are to look at it that way then then forget the catchphrase, the name of the language itself was stolen from the Norsemen
>>
>>102273955
It's not just about names though. Bill used to sit in Blow's chat and ask him detailed questions about his language. A while later, and surprise, Odin now has a bunch of features stolen from an unreleased language. I respect the hustle, but I also would feel quite hurt if someone was hanging out in my stream and asking me about my thing so that he can steal it and beat me to market.
>>
>>102274062
>Odin now has a bunch of features stolen from an unreleased language.
>stolen
are you retarded?
the "features" present in Odin can be found in 100 different languages from 20 years ago. Odin is a school project.
>>
>>102274180
where is the context feature from? not to mention straight-up ripping off the syntax...
>>
>Does Odin have closures? #
>Odin only has non-capturing lambda procedures. For closures to work correctly would require a form of automatic memory management which will never be implemented into Odin.
thanks, i'll just stick with javascript
>>
>>102274062
>an unreleased language.
then maybe Blowjob should hurry the fuck up and release his language that he's been working on for what, 15 years now? A programming language doesn't take that long to create, by the way. You can get it done in a few weekends.
>>
>>102274258
good, polished things take time. you would know this if you were a creative person.
it's more like <10 years anyway.
>>
>>102274062
>be so slow to release your language that someone in your chat has a production ready version of your language in 3 years
>cry like a bitch just like when soulja boy didn't like briad
>>
>>102274062
>I respect the hustle, but I also would feel quite hurt if someone was hanging out in my stream and asking me about my thing so that he can steal it and beat me to market.
this is where you are absolutely mistaken about one thing. Language like Jai and Odin are totally different from corporate language like Rust, Zig, Go, etc.,
Corporate languages have a need to put tremendous to make sure that grab hold of majority of the market. Odin and Jai are nothing like that. The creators of both the languages created the language primarily for themselves. Both Jon and Bill don't give a fuck about what the situation of the market. The fact that both of them hardly put any effort into marketing their language is the proof of it. Heck yeah, Jon Blow would have made Jai public by now if he actually cared about the market at all in the first place. The only thing they both care about is their vision to create a modern C like language so they both ended up with their own version of it. You might be butt hurt about the situation but I'm sure Jon Blow is totally cool with it and would love to answer even more question if Bill were to ask him.
Also, go ahead and use Jai if you have issues with Odin. Oh, wait... nvm. COPE.

>thanks, i'll just stick with javascript
please do. I'd do the same if I were to write web pages. Not necessarily for web applications though.

>>102274331
en.wikipedia.org/wiki/Jonathan_Blow
>In 2014, Blow began designing the language, which is codenamed Jai,
its been over ten years by now, bruh. Either Jon Blow is that bad or the language is good to go but Mr. Blow intentionally didn't make it public. We all know its the later so COPE hardurrr.
>>
>>102275201
*Corporate languages have a need to put tremendous effort into marketing to make sure that they grab hold of majority of the market. The creators of both the languages created their language primarily for themselves. Both Jon and Bill don't give a fuck about the situation of the market.
>>
https://x.com/BonesaiDev/status/1832088640157319629
>>
>>102273853
He stole it from Alex Comfort (lol) who wrote "The Joy of Sex," who stole it from Julia Child who wrote "The Joy of Cooking"
>>
>>102273820
Odin should be used in the Linux Kernel > Rust. Change my mind.
>>
>>102274331
2 more weeks, trust the plan.
>>
>>102274331
the saturn v rocket took 10 years. a language should take a few months at maximum to finish
>>
>>102274062
After the 70s we’ve collectively invented like two new language features. PL design is just a puzzle of arranging the pieces such that it’s as nice to use as possible.
>>
>>102273853
The Jai of Programming
>>
File: Cope-Cry.webm (2.43 MB, 640x464)
2.43 MB
2.43 MB WEBM
>>102277351
been seeing this on every Odin thread till now since. Not gonna lie, dumb me got excited the first time I saw this joke and seriously looked forward to it. But now, all I'm gonna say is COPE.
>>
File: 1704779127540126.jpg (265 KB, 1200x675)
265 KB
265 KB JPG
>>102277346
This is such a very sensible statement.
Using a language that doesn't allow you to manually manage memory or requires lots of work to be able to do it is not a good choice for Kernel development and the fact that there are people who think it is, is way beyond me.
>>
i like odin
>>
>>102278971
good thing Rust allows you to manually manage memory
>>
>>102279085
it would be actually good if manually managing memory in Rust is as simple as 'malloc()' in C and doesn't require any unsafe.
If unsafe is necessary for that, there is absolutely no point in using Rust other than having to do several folds more work.
>>
File: ha_gay.jpg (70 KB, 795x809)
70 KB
70 KB JPG
>>102279068
>>
>>102273820
Seems the Guru overlay got rid of the ebuild for this.

Language must be pretty lame then. Even Hare has an ebuild.
>>
Non-coder here.

What is the difference between "i32" and "int" in Odin?

Why would I use "i32" over "int" or "int" over "i32"?

Similarly, why is there "bool", "b8", "b16", "b32", and "b64", if all bools are is true or false?

What would be a situation where you wouldn't just use "bool" and instead use "b*"?
>>
>>102281344
google it
>>
>>102273820
Bump. Unrelated.
>>
>>102281344
books are more than one bit, sometimes they can have a lot, for alignment
>>
>>102281881
I'm not even sure how I would word the question for google, and even then how many pages to get to a relevant result?

I have a feeling you don't know, but felt the need to be an ass. I sincerely hope you live forever.

>>102281985
What do you mean by "alignment"?
>>
>>102282419
>What do you mean by "alignment"?
you should really go back to basics and read the greeks
I mean learn C
>>
>>102282453
I'm not a coder. Just a guy who ate some gummies a few hours ago and is browsing *chans while listening to flyleaf.
>>
>>102274062
Jai is vaporware, it's a good thing someone stole it.

Also less is stolen from Jai than you think, Jon didn't come up with the syntax for example, even though they are similar
>>
>>102274225
Syntax is taken from Newsqueak
>>
>>102282549
you can learn c in like an hour
itll take 30 years to be "good" with c, but still.
>>
>>102281931
Forgot the name, was browsing pol...
>>102282549
(I'm not one of the Anons who replied to you previously...)
Alignment exists for the most part because of the languages that support the concept of structures (struct in C, record in Ada...).
Also it's useful sometimes for the compiler to know the size of certain variables, so it can do optimizations on them in calls.
void draw (u8 r, u8 g, u8 b, u8 a);

Pseudo code, compiler would rather push 1 u32 on the stack then 4 u8s, but it should know the size, similar to structure alignment.
>>
>>102282549
>>102282593
Continuation: Things get more complex, some functions can be inlined, some can't, global variables affect it etc.
In the most dumb-case scenario, when you're pushing values on the stack and performing call instruction, it's that above.
Also, on 64-bit CISC architecture you can only push 16 or 64 bit values on the stack (AFAIK), so some compilers prefer mov.
Some compilers such as gcc and clang will recognize that something doesn't fuck up the state and will mov to registers.
--
Topic is more complex that you think...
>>
>>102280721
no build system eliminates shit ton of headache. one 'odin run .' to rule them all. There is also less chance of accidentally pulling GPL version library.

>>102281344
>What is the difference between "i32" and "int" in Odin?
i32 is a 32 bit signed integer that is exactly 4 bytes in size.
int on the other hand are register sized. Which means the depending on the instruction set architecture, the size of an 'int' would be 64 bit on 64 bit system 32 bit on 32 etc

>Why would I use "i32" over "int" or "int" over "i32"?
'int' on x86_64 is i64 by default. So if you want to make sure that your integer is occupying exactly 4 bytes, its better to use i32 instead of int. This is what you usually do when you need to send data to GPU as glsl or hlsl's 'int' type is of 4 bytes.
https://odin-lang.org/docs/overview/#basic-types

>Similarly, why is there "bool", "b8", "b16", "b32", and "b64", if all bools are is true or false?
this is not something odin specific. This had to be there because a lot of C libraries did use bool differently. WIndows for example, used an integer for bool. So to provide different sizes of boolean types is why there are so many bools.

>What would be a situation where you wouldn't just use "bool" and instead use "b*"?
bool and b8 are basically the same thing. Rest of the types can come in handy when a particular alignment is needed.
>>
Been doing a little Odin game project where I call lua scripts to control bots, man it's been so simple... using C libraries in general is so damn easy in Odin.

it has also replaced Python/Bash for some scripts I write, maybe just because I want to become more and more familiar with the language but it's honestly pretty fast to write Odin code.
>>
File: IMG_20240908_082450_905.jpg (3.84 MB, 3120x4160)
3.84 MB
3.84 MB JPG
>>102282549
I'm feeling lazy so I'll just share pics from the book I learned about them from.
Just know that allocating data types one after the other linearly is bad for performance. The CPU can only read one WORD at a time and its reading becomes more efficient if data is organized as per the size alignment.
>>
File: IMG_20240908_082624.jpg (3.25 MB, 3000x4000)
3.25 MB
3.25 MB JPG
>>102282837
>>
File: this.gif (1003 KB, 300x186)
1003 KB
1003 KB GIF
>>102282677
>it's honestly pretty fast to write Odin code.
>>
>>102273820
Also OP, you got me interested. I might check out Odin when I finish some XCB/Vulkan stuff I'm writing in ANSI C.
General questions from hobbyist:
> How fast is the compilation of average 3k sloc program?
> What are some improvements that "C programmers" should notice?
> Is the binding system complex? Is binding to Raylib easy?
> If I wanted to make bindings for my own C libraries, is it too verbose?
> Are final executables bloated like with C3 and Pust or not?
I'm way over my head with current project, you'll save me some time to look things up. Thanks in advance if you respond.
>>
I wanted to bootstrap Odin code like a kernel but the Odin compiler is producing code that is modifying memory off by one byte.

Compiling this Odin
entry :: proc() {
p := ([^]u8)(uintptr(0xB8000))
p[0] = '!'
}


Produces this assembly:
entry:
.cfi_startproc
movl $753664, %eax
movq %rax, -8(%rsp)
movq -8(%rsp), %rax
movb $33, (%rax)
retq


It doesn't modify the byte at 0xB8000 (start of VGA text buffer), but rather the byte before it. What stood out to me was the 32 bit movl, so I modified the assembly manually, pushing the address to the stack directly, which made it work correctly. Any ideas as to why? I'm not familiar with low level stuff.

entry:
.cfi_startproc
movq $753664, -8(%rsp)
movq -8(%rsp), %rax
movb $33, (%rax)
retq


Compiling a similar function in C produced this asm, which also works correctly:
entry:
push %rbp
mov %rsp,%rbp
movq $0xb8000,-0x8(%rbp)
mov -0x8(%rbp),%rax
movb $0x21,(%rax)
pop %rbp
ret
>>
>>102273820
> \v - vertical tab (VT)

Stopped reading right there.
>>
>>102283097
> How fast is the compilation of average 3k sloc program?
3k lines is nothing so it would take a second or two, I guess. My current project has over 15k loc in Odin and it doesn't even takes around 3 seconds. I mean, building the language itself on my 5 years old potato laptop takes around 11 seconds.

> What are some improvements that "C programmers" should notice?
better iterators, shorter data type names and an implicit context system like go. The standard library comes with different memory allocators and logger out of the box. You can use them or write and use your own as they all are just helper functions. Debugging Odin program is the same as C. Unlike C, Odin does bound checks by default so anytime you go out of bounds, you'll know. The compile will point out what is going out of bounds and there is also a tracking allocator to detect any leaks. The main different that gives C programmers a huge pleasure is the concept of no build system.
In Odin, the directory is the library. This design eliminates circular dependency hell. Just a single "odin build ." is enough to build your project and "odin run ." to build and run your project. Odin also makes it easy to do testing. The language has several features for testing as well.

> Is the binding system complex? Is binding to Raylib easy?
binding is so simple that it can't even be called binding. All it takes is just defining the function signature and the library name. Don't bother with having to write any bindings for Raylib. The language devs are supporting it and all you have to do is add " import "vendor:raylib" " to use it and that's it.
Here is a stream where the creator of the language uses raylib - www.youtube.com/watch?v=B9kSV2TaKpw
>>
>>102283268
Okay, compilation time matters to me because I have 2012 CPU and GPU on some old ThinkPad.
Image related, when I finish this Vulkan monster in C, I'll probably play around with Odin...
Also, major factor for me would be if the main developer doesn't give-in to tr*nnies, seriously.
--
I mainly use C for real stuff, Ada for pleasure, Fortran for torture and assembly for knowledge.
And C3 is too fucking slow to compile, in general it's a sloppy language, but it's WIP, oh well...
>>
>>102283097
>>102283268
cont.

> If I wanted to make bindings for my own C libraries, is it too verbose?
for static linking - https://odin-lang.org/docs/overview/#foreign-system
for dynaimc linking, you'll have to load the dll at runtime just like you would in C. "core:dynlib" package comes in handy. You can either load each function pointer manually yourself or use a handy "initialize_symbols" to get the job done
https://github.com/odin-lang/Odin/pull/3071

> Are final executables bloated like with C3 and Pust or not?
I can't say anything for certainly about this. Its all LLVM underneath. This is something that is on the programmer.
>>
>>102283339
Thanks, language looks more like Fortran then C, might be fun to try it out later.
>>
>>102283305
vulkan triangle in Odin sample codes for you to take a look at
https://gist.github.com/terickson001/bdaa52ce621a6c7f4120abba8959ffe6
https://gist.github.com/laytan/ba57af3e5a59ab5cb2fca9e25bcfe262



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.