[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

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]


Janitor acceptance emails will be sent out over the coming weeks. Make sure to check your spam folder!


[Advertise on 4chan]


File: HPfQLXjWsAAKDUO[1].png (60 KB, 1038x755)
60 KB PNG
In Jai size of void is zero. Which means it is safe to dereference null because it reads 0 bytes from memory.
Is this good or bad?
>>
>>109534245
>jai
He finished it ?!, It's not even 2050 !

gpt bro, what's the code doin' ?
>>
Buy an ad
>>
Iz dat you, mista zozin?
>>
>>109534245
i think bad.
dereferencing null means something went wrong somewhere, but the error isnt handled properly, so the program should crash immediately and loudly in my book
>>
>>109534245
>>109536228 cont.
yeah, if the program doesnt crash immediately, it will crash somewhere else
and then its another step removed from the actual cause of the crash

also, debuggers, no?
with a stack trace dereferencing a null acts like a breakpoint in a way, no?
>>
>including void in a language in 2026
yikes
>>
>>109534245
retarded, null pointer is not to be dereferenced
this jaishit simply means do nothing, like 'pass' in python
>>
>>109534245
>>109536274
in odin doing
    i :^int= nil 
fmt.println(i^)
> ./main
<nil>

works however doing i^ = 42 crashes. It takes 20s for it to return control idk why.
>>
>>109534245
ok...?
>>
>>109536497
This thread is stolen intellectual property from tsoding
>>109536187
apparently necrobumping a stolen tweet is better than starting a new thread that properly attributes the intellectual work
>>
>>109536529
I see....?
I still don't understand what the big deal is. any modern language should have zero sized types. the fact that C++ and other boomer shitlangs doesn't isn't really newsworthy.
>>
>>109536629
>0 sized types
whatfor?
>>
>>109536652
classic example is a hashmap<K, V> where the hashset impl is just hashmap<K, V = ZST_HERE>
>>
>>109536476
i, um, dont speak odin
but from what i gleamed from the code, fmt.println is probably an inbuilt that checks the validity of i before dereferencing it. or maybe its a macro, i have no idea
that would explain why doing i^ = 42 crashes, because there you dont have the conditional that checks wether i is null

i have no idea why it takes 20s to return though
maybe some internal logging system
>>
>>109536692
20s seems to be something due to my system idk why maybe just unrolling takes long. Odin has special formatters done by runtime type inspection I assume nil just has <nil> . Anyway my point is that jai does something similar pretty sure c++ prints 0 as well.
>>
>>109534245
One problem with zero sized types is generic object allocators are going to have troubles handling them.
An object allocator must provide different addresses for each object, even if its size is 0, so they still use at least 1 byte per object.
>>
>>109536681
>classic example is a hashmap<K, V> where the hashset impl is just hashmap<K, V = ZST_HERE>
i had to look this shit up

i think you can do something just like that in c elegantly enough
you define a structure, this is your primitive for both the version where you have an actual value or a zero value
like zo:

typedef struct{
char *key;
}key_t;


and thats what you build your hashmap system around, and so it returns a pointer or a null for when you just want to maintain a list of keys
and if you need to have an actual value you then cast the resulting pointer into this:

typedef struct{
key_t key; // note its not behind a pointer
char *key; // or it could be a vla
}full_t;


obviously provided you have the right memory layout behind the pointer

id rather have this than to have increase the complexity of the language im using
>>
File: oldman-shrug.jpg (9 KB, 250x203)
9 KB JPG
>>109536784
nah yeah, even in c printf does that too.
like i said, its just an additional conditional
in the code, or in a macro, or whatever exotic solution odin might have theres a line like
if (pointer == NULL)
print("<nil>")

its not black magic
>>
>>109536794
You are so retarded lmao
>>
>>109536794
tfu
im distracted

typedef struct{
key_t key; // note its not behind a pointer
char *value; // or it could be a vla
}full_t;


its value for the second item, not key
>>
>>109536883
nice insults, high level trany
but what are your arguments, then?
>>
>>109534245
Usecase?
>>
>>109534245
Bad. It can lead to potencial errors, the compiler should assist the users in finding errors and avoiding that kind of stuff, by allowing it you can no longer determine were the posible error occurs.
Think about the consequences if this.
>>
>>109536629
>any modern language should have zero sized types
Do you know it’s possible to eliminate null from any language? Also, sum types IMHO are better for doing generics and other things without using a ‘void’ type. So, if we remove null explicitly through better error handling and use sum types, then none of this shit is required anymore.
>>
File: file.png (73 KB, 1482x438)
73 KB PNG
>>109536835
seems like you are right https://grep.app/search?f.repo=odin-lang%2FOdin&f.repo.pattern=odin&q=%3Cnil%3E
and github is down again
>>
>>109537217
null bad, but I'm talking about zero sized types.
yes, I am aware of sum types and conditional type narrowing, but this is a case of the OP's post.
>>
>>109536907
>muh macros
>>
>>109534245
>Is this good or bad?
It's very dumb. The type system shouldn't authorize to dereference a null pointer type.
>>
>>109538152
>to dereference a null pointer type.
meant to say void pointer type

>>109536228
this isn't what it is at all. a null pointer of a type other than void pointer WILL get deferenced and segfaults which is fine for a C-like language like that, there is no unhandled error.
>>
>>109534245
bad, programs should crash on obvious errors like null dereference.
Same reason why zero initialization is bad.
>>
>>109536887
yeah, that's how it's implemented usually.
google's abeseil implements hash maps by using a hash set with a key-value key type and a custom key extract/hash that only looks at the key
>>
what is the usecase of void and nullptr and null and none?
>>
>>109534245
I'll tell you if it's good or bad once I'll try it out for myself.
which might take a long time because that jai thing is not public.
>>
>>109538841
>void
explicit stand-in for a lack of any return (languages used to make this distinction by calling the functions "procedures")
>nullptr
languages that don't have or use Option types need a way to say a pointer has no value
>none
typically an Option type value that's a "safer" version nullptr, either you have
Some(T)
or
None(T)
>>
>>109538841
There is no use case
Data is data, typing is a lie people use to make themselves feel better about their own incompetence
>>
>>109538641
>this isn't what it is at all. a null pointer of a type other than void pointer WILL get deferenced and segfaults which is fine for a C-like language like that, there is no unhandled error.
Right, it seems like there are too many retards in this thread. Deferencing null directly isn't the same as dereferencing an int pointer with value "null" for example
>>
>>109538891
>explicit stand-in for a lack of any return (languages used to make this distinction by calling the functions "procedures")
In some languages (probably in jai too?) void isn't just a lack of return type, it's a zero sized type. So you can have a variable of type void. The reason for this is for example a hash map implementation. If the value type if void, then it functions as a hash set without needing a separate hash set implementation.
>>
>>109534245
Doesn't Jai just completely mog and dab on every other programming language? It feels like it was designed by an intellectual but who also cares about fun in using it.
>>
>>109534245
Rust fixed this problem ages ago chud. This coping needs to stop.
>>
>>109536476
Odin is a joke language made by a fool.
>>
>>109539504
its actually very pleasent and coherent in the limited time Ive been using it
>>
>>109539746
It's lacking way too many important things: gotos, sum types, namespaces, classes, metaprogramming, because Bill is a contrarian idiot.
>>
>>109539831
>gotos
lol, you have tagged loops if you want to double break
>sum types
sure, but tagged unions get you most of the way there
>namespaces
packages are better
>>
>>109539890
>lol, you have tagged loops if you want to double break
that's retarded. the code is going to be a mess for absolutely no reason
>inb4 muh end of scope
retarded semantics, if I liked this end of scope garbage I'd use C++
>>
>>109534245
In Jai the number of useful programs is zero
>>
>>109539890
>sure, but tagged unions get you most of the way there
Sum types are not tagged onions.
>>
>>109540248
not even his game?
>>
The problem I have with Ginger and Johnny Blow is that they seem to be very egalitarian, and in their full-of-farts mindset, they think they're correct. They’re not selling you a language or compiler, they’re selling a kind of retarded programming philosophy that was proven to be wrong.
Both programming languages (Jai and Odin) are regressive and not innovative. By saying this, I’m not even claiming that Rust is better. There's a reason for Rust to exist, even if you dislike it, and we can say the same for other programming languages
>>
Claude, vibe code me up a working jai compiler. Make no mistakes
>>
>>109540339
do you mean this lol
https://github.com/withlang-dev/open-jai
>>
>>109534401
wtf is he saying at each stream start with "something something zozin" ?
>>
>>109540248
Focus is pretty good.
https://focus-editor.dev/
>>
>>109541124
welcome to another recreational programming session, with a who? with the mistah zozin
>>
I still can't believe that Jai is shilled as this ultimate metaprogramming language while it makes you generate strings for compile time program generation. What's worst, no one seems to have a problem it's that.
It's also supposed by a no bullshit low level language and yet it doesn't have gotos because "you can just inline assembly jump bro". No one seems to have a problem with that either.
>>
>>109541162
mmm, I thought he was saying in russian
>>
>>109534245
Dereferencing a void reference seems of dubious usefulness, even if you can torture yourself into thinking it makes sense. Dereferencing null never makes sense since null is the absence of anything to dereference. It doesn't matter what size the type is since there is no object in the first place.
>>
>>109539890
unbelievable cope. meme language hipsters should be banned from posting here.
>>
I like the dereference syntax.
>>
>>109536791
>An object allocator must provide different addresses for each object, even if its size is 0
Why?
>>
>>109541592
same, it's kind of genius actually. It makes it consistent with struct and array deference chains that are placed in the order the dereferences are done and remove the need of parentheses if pointer dereference is mixed in with them.

what do you think of the "size_of" operator compared to C's "sizeof" ?
>>
File: GVVqrkzWkAAh8-f.jpg (82 KB, 736x849)
82 KB JPG
jai doesn't exist until i try it out

until then i use odin
>>
How does pointer arithmetic work in Jai? In GCC C, void has size == 1 so you can do arithmetic on void pointers as if they were char pointers, since the stride is determined by the pointed-to type's size
>>
>>109541793
I'm going to try based on the version that has been linked.
Already found a bug on jai-linux. When you do jai-linux -help and redirect stdout, the output only contains 4096 bytes as if a flush is missing.
>>
>>109541793
    print("%\n", (cast(* void) 0) + 1);
print("%\n", (cast(* u8) 0) + 1);
print("%\n", (cast(* u32) 0) + 1);

Stats for Workspace 2 ("Target Program"):
Lexer lines processed: 10304 (17151 including blank lines, comments.)
Front-end time: 0.088853 seconds.
llvm time: 0.140783 seconds.

Compiler time: 0.229636 seconds.
Link time: 0.000350 seconds.
Total time: 0.229985 seconds.
1
1
4



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