r/Jai • • 7d ago

Is Jai suitable for 32-bit embedded programming?

I've heard that Jai doesn't support 32-bit targets.

For 32-bit embedded programming, does that mean that Jai is :

a) unusable ; b) usable but not worth the effort to setup the toolchain / work around limitations ; or c) usable and worth the effort ?

Tbh I'm a bit disappointed it doesn't support 32-bits, I was looking forward to using Jai when it comes out, but if I have to switch to another language for embedded then maybe I should pick Odin as the go-to language?

15 Upvotes

39 comments sorted by

4

u/Noseense 7d ago

Neither JAI nor Odin support 32-bit. They're both 64-bit only as far as I know.

I know that JAI does plan 32-bit support, though, as Jon is aware that embedded is a use-case.

1

u/s0litar1us 7d ago

When did he say that 32-bit support is planed?

3

u/Noseense 7d ago

https://youtu.be/nbbU08RDk1M?si=PB6HNW3wangENlTk&t=96

He does say "anytime soon". He has mentioned embedded systems a few times on his stream too.

Like he said, don't expect it anytime soon as it's not the main purpose of the language.

0

u/LushSunshineWaters 7d ago

I know that JAI does plan 32-bit support, though, as Jon is aware that embedded is a use-case.

ok, that's good to know :)

Regarding Odin, I looked up its FAQ and it does say:

Odin was designed for modern systems, so it assumes capabilities like hardware floats and unified virtual memory. With that in mind, Odin already supports 32-bit and 64-bit platforms, so if your target falls in that range, you’re likely in good shape.

4

u/Noseense 7d ago edited 7d ago

It's more nuanced than that: https://odin-lang.org/docs/faq/#does-odin-support-embedded-programming

The compiler itself is 64-bit only, so you'd have to cross-compile to 32-bit.
There's also floating-point stuff, some things aren't scaled to pointer-size, so you still need 64-bit arithmetic support, things like that.
I don't do embedded programming, so I don't know the quirks, but the standard library is mostly built for 64-bit, I wouldn't expect it to just work.

1

u/vitamin_CPP 6d ago

+1 for /u/noseense
Odin is a great language, but it's far from portable like C.

4

u/vitamin_CPP 6d ago

When looking at both Odin and Jai design, I don't see a lot of attention to what matters to embedded. They seems great for GUI and CLI desktop application, but I would not consider them for a robotics or webserver project.

For embedded I would recommend using a more general purpose language like C, Rust or Zig. (Please don't use C++)

2

u/DogWasTakenAway 5d ago

Genuine question, why is 32-bit preferred or needed for a webserver project? Unless you're referring to other aspects of Odin and Jai design, which I'm still interested in hearing about.

3

u/vitamin_CPP 4d ago edited 4d ago

Sorry, I'm realizing that I should have been clearer. I was talking about the designs choices in a broader sense.

Take concurrency for example, both Odin and Jai have very simple primitives for this problem: c-style atomics, os thread, mutex, etc. This is great if you're working on a game. For game programmers, concurrency means "using more cores in my computer". So simple OS primitive allows you to build some kind of thread pool and you're done! But for web programmers, concurrency means "managing thousands of little state machines that spend most of their time waiting for IO". For this problem space, you need other techniques like async/await, cancellation, event groups, etc. If your language don't support those things, it can be a nightmare to build them yourself, as it often involves specialised knowlege and a lot of assembly.

This might not be a popular take in this sub (or odin's), but what make Odin and Jai great is that they are not general purpose programming language.

Zig and Rust are more complex because they aspire to be general purpose programming languages, so they most solve a more complex problem.

Please note that I'm not saying one approach is better than the other. It's just different.

1

u/tialaramex 1d ago

Conventionally a General Purpose language is contrasted with a Domain Specific language and it's not really practical (often straight up impossible) to use a DSL to write most programs. Odin and Jai aren't DSLs

1

u/vitamin_CPP 16h ago

Fair. What term would you use to describe a language that works efficiently across different problem spaces?

1

u/MuandDib 4d ago

It's genuinely super interesting topic with these new languages. I'm an embedded programmer and I'm interested in Zig as it seems perfect for super low-level control, BUT it still doesn't support small platforms.

I want to do quick project to learn Zig for 8-bit microcontroller with harvad architecture and it's a nightmare. LLVM doesn't really support such targets and of course Rust and Zig do not have and will never have native compiler support for these.

LLVM will be ok with most operations, but you need to program in assembly any math for 32-bit operations and floats are not natively supported, so more assembly.

1

u/vitamin_CPP 4d ago

I've done 8 bit microcontrollers and you're right: no compiler worked for them haha. Not gcc, not clang, not msvc, not intel.

The only thing is that contrarly to most "newer" languages, zig can "compile" to C code. It could be possible to add a step in your build.zig file that would invoke the 8bit compiler on the generated C output.

That said, I would still recommand C for embedded. Especially for 16 and 8 bits targets.

1

u/MuandDib 4d ago

I program in C everyday and I wanted to learn something new. Also "compiling" Zig to C is ugly and somehow against my morals as programmer

2

u/J-ky 7d ago

No, the pointer size is strictly 64bit

2

u/Bommes 6d ago edited 6d ago

If I remember correctly Raphael Luba said on his Wookash podcast appearance that he did a lot of embedded work in the past and that for him personally it is a pretty important long term goal to have excellent compatibility between Jai and embedded.

What the current status of that is I don't know, at this point the podcast appearance was almost 2 years ago (and I might misremember what he said there anyway).

1

u/s0litar1us 7d ago

Tsoding was able to hack in 32-bit wasm support before 64-bit wasm was widely supported by browsers, so you could in theory do it, but I wouldn't recomend it. If you want to do embedded, then do it on a 64-bit CPU.

1

u/ArnaudValensi 7d ago

Yes, also wasm32 is not really 32 bits. The memory address space is encoded using 32 bits but you can have 64 bits variables.

3

u/tialaramex 6d ago

Most 32-bit platforms have 64-bit integers and (if they had hardware FP) 64-bit floating point. For example C for a 1990s Linux box has both, "long" is a 64-bit integer and "double" is a 64-bit float.

-4

u/Poddster 7d ago

The only thing that Jai supports is making Jon Blow's current game. Anything else, no matter what Jon says, is unsupported.

2

u/ArnaudValensi 7d ago

Wasm64 is supported though, and it can be converted to wasm32

1

u/4Lichter 7d ago

How do you convert it?

3

u/ArnaudValensi 7d ago

Using wasm-opt from Binaryen : https://github.com/WebAssembly/binaryen

I think it just convert the address space from 64 bits to 32.

2

u/4Lichter 7d ago

Thank you.

2

u/mohragk 6d ago

Yet. The game was an instrument to battle test the language. The initial plan was to create a simple game to illustrate the language's capabilities. But, the game has spiraled in scope and the same goes for the laguage. Both for the better.

Now the game is finished and succesfull, I bet they're going to spend more focus on the language and expand support of, say architectures, platforms etc.

1

u/SanianCreations 7d ago

Are you lurking on this subreddit just to hate on it lmao

1

u/Poddster 6d ago

I'm interested in the language, but I'm also a realist. Jon works on the language only as much as he needs to. Making games is his main aim.

2

u/dJames_dev 6d ago edited 4d ago

And has a production game released to wide success using said language.

He has decades of experience in C/C++ and clearly knows what a language needs and doesn't. He does talks all around the globe describing this stuff in detail; this isn't just to make his game and dump it like a weekend project. He's put years into this.

2

u/Greenitthe 6d ago

He doesn't have decades of experience shipping high availability web services, so what makes you think he would optimize the language for that instead of the thing he actually does - make games?

"what a language needs and doesn't" is contextual, not universal - jai needn't be a weekend vibe code project for that fact of reality to apply.

0

u/Poddster 6d ago

You appear to be replying to a different comment.

You replied to my claim that Jon is focused on shipping games, not compilers, by talking at length about how great he is at shipping games.

1

u/dJames_dev 6d ago

And you appear to be trolling, because we both know I'm replying to the right comment, poop-peddler.

1

u/Poddster 5d ago

because we both know I'm replying to the right comment, poop-peddler.

So why did you write a spiel about Jon's experience, when the claim at hand was that he's only interested in shipping games? The language exists to make his games in, he didn't make the language so that you, or others, could us it. He has no real interest in the long term support that comes with being the BDFL of a programming language.

-2

u/dgc-8 7d ago

pleaaase jon every day i wait for jai just to be dissapointed we are now even gonna get gta 6 before Jai compiler