[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [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


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: wut.png (91 KB, 589x535)
91 KB PNG
can someone smarter than me explain the significance of this
please
>>
>>109536187
It is probably the same as with Go, that if you have something like a channel that you just want to use as a signal, you send an empty struct of 0 bytes, so effectively only the sync primitive gets activated.
That is the only usecase that I can imagine for a type of 0 bytes in size
>>
idk maybe ask in the thread that already exists faggot nigger stupid idiot african black
>>109534245
>>
>>109536187
Here's a much simpler explanation of what that Jai code image shows:

## The Core Concept
This code is playing with two big ideas in programming:

**1. What's the "size" of nothing?**
- Think of `size_of(void)` like asking "how big is empty space?"
- The answer is **0 bytes** - nothing takes up zero space
- This is similar to asking "how many apples are in an empty basket?" the answer is 0

**2. Dereferencing null pointers**
- A "null pointer" is like a pointer that points to nowhere - it's set to null
- In most languages, trying to access what a null pointer points to crashes the program
- Think of it like trying to read from a closed book that doesn't exist

## Why This Jai Code is Special
The magic here is that Jai is intentionally designed to be **super safe**:

- When you try to dereference a null `void*` pointer, Jai safely reads **0 bytes** (nothing)
- Because `void` has size 0, reading nothing from nowhere doesn't hurt
- This is **different from C/C++**, where this would crash your program

## The Counter-Intuitive Part
Most programmers would expect:
- `null_pointer.something` program crashes
- `size_of(void)` should be 1 (to make sense in memory)

But Jai does the opposite - it's designed to prevent crashes even when programmers make mistakes like this.

## Why This Matters
This showcases how Jai tries to be **friendlier** than languages like C/C++:
- It catches mistakes that would otherwise crash programs
- It makes "unsafe" code safe by design
- It's like having a seatbelt that automatically clicks when you forget to buckle

The code is essentially showing how Jai protects you from one of programming's most dangerous bugs - null pointer dereferencing - by making it do nothing harmful instead of crashing your entire program.
>>
>>109536232
AI sloppa I'm not reading and i'm hiding this comment. bye.



[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.