News for hackers. Stuff that matters.
Re:Focus: A simple and fast text editor written in Jai by konsuko on Sunday September 03, 2023 @03:40AM (#37368488)
Jai is an amazing language to work with, I highly recommend checking it out once it becomes publicly released. It's elegant, simple, performant, takes all the best parts of Zig minus the annoying parts (like errors on unused local variables) and adds a bunch of super useful game development libraries as well as a built-in string type (which I really missed in Zig).

Oh, and the compile times are just a joy, almost no other language even comes close to the speed of iteration that's possible with Jai, which is another great reason to use it for games and prototyping in general.

Re:Focus: A simple and fast text editor written in Jai by flohofwoe on Sunday September 03, 2023 @03:57AM (#37368564)
If Jai can only be judged once it's public, Zig should only be judged once it hits 1.0 though. Personally I put a lot more trust into Zig than Jai.
Re:Focus: A simple and fast text editor written in Jai by ReleaseCandidat on Sunday September 03, 2023 @05:23AM (#37368950)
I'd have preferred a `fun` (or `fn, if you insist on 2 characters) instead of the Haskell-esque double colon `::` in function definitions to make parsing them easier. And the semicolon after `case` is irritating for me too. But `foo := bar` for a type-less `foo: TYPE = bar` is too much parser-friendly syntax and inconsistent with using a double colon `::` for function types and struct definitions. And inconsistent with using just the colon in `foo: TYPE`.

How do nested for-loops work, if `it` names the current iterator?

     for particles {
        // Inside for loops the "it" object is the iterator for the current object.
        particle_left := view_left \* it.particle_size;
     }
Re:Focus: A simple and fast text editor written in Jai by ohgodplsno on Sunday September 03, 2023 @05:36AM (#37369003)
Just like every language that implicitly names the current value of the iterator:

- It's the innermost iterator that takes priority

- You are encouraged to name your iterators if you do so (for particles { part -> )

- Compiler throws warnings if you shadowed names.

Re:Focus: A simple and fast text editor written in Jai by ReleaseCandidat on Sunday September 03, 2023 @06:01AM (#37369114)
> Just like every language that implicitly names the current value of the iterator

Oh, i didn't know that there are any.

It would be a good idea to add the naming explicitly to the Wiki entry of loops: https://jai.community/t/loops/147, I've just found it buried in the `remove` section.

Btw. in for-loops the colon `:` is used inconsistently again, this time for naming the iterator (`foo` in this example:) `for foo: VALUES { ... }`.

Re:Focus: A simple and fast text editor written in Jai by ohgodplsno on Sunday September 03, 2023 @06:22AM (#37369208)
>Oh, i didn't know that there are any.

Plenty! Although, it's not limited to iterators: most languages that have first class lambdas/closures behave this way. Kotlin has `it` as the default parameter of any lambda (but only accepts it for single parameter lambdas, two parameters and you need to name them:

`fun <T, U> Collection<T>.map(block: (T) -> U): Collection<U>`

is called like so:

`listOf(1, 2, 3).map { it * it }`

Swift has $0, $1

>Btw. in for-loops the colon `:` is used inconsistently again, this time for naming the iterator (`foo` in this example:) `for foo: VALUES { ... }`.

Sorry, Jonathan Blow doesn't believe in such silly things as "compiler research" nor "programming language research". Jai gets built by piling up crap on top of crap.

Re:Focus: A simple and fast text editor written in Jai by ReleaseCandidat on Sunday September 03, 2023 @06:40AM (#37369281)
Thanks, and yes, I didn't think about closures.

Talking about closures, I also don't know why Jai needs explicit capture lists. In C++ and Rust I understand the need for them, because you have various ways to pass them into the lambda, but Jai doesn't seem to care, at least in the examples at https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md.... To be honest, I also don't see how this is different from just writing the function definition by hand, just in more than one step and you have to throw away the intermediate versions?

Btw. I just replied to say that I really like your username, I have noticed it just now :)

Re:Focus: A simple and fast text editor written in Jai by iml7 on Wednesday September 06, 2023 @08:13AM (#37403947)
+1,fun, fn, have obvious visual effects
Re:Focus: A simple and fast text editor written in Jai by ngrilly on Sunday September 03, 2023 @06:03AM (#37369120)
What is annoying with errors in Zig?
Re:Focus: A simple and fast text editor written in Jai by metaltyphoon on Sunday September 03, 2023 @07:28AM (#37369528)
I don't think they can carry information.
Re:Focus: A simple and fast text editor written in Jai by alwaysbeconsing on Sunday September 03, 2023 @12:57PM (#37371945)
They seem to be specifically referring to the compiler error (as in, prevents compilation) for unused local variables. See discussion here: https://github.com/ziglang/zig/issues/335#issuecomment-10011...
Re:Focus: A simple and fast text editor written in Jai by Modified3019 on Sunday September 03, 2023 @03:11PM (#37373358)
Yeesh, that's good to know. With the dev response basically doubling down on ideology and ignoring reasonable protest, that's definitely an ecosystem to not sink time into.
Re:Focus: A simple and fast text editor written in Jai by Gibbon1 on Sunday September 03, 2023 @07:09PM (#37375499)
My thought about unused variable is the compiler should assume someones trying to debug something and not optimize them out.
Re:Focus: A simple and fast text editor written in Jai by ngrilly on Sunday September 03, 2023 @03:28PM (#37373516)
You're right. I read too fast. Coming from Go, I'm used to errors on unused local variables, and like that Zig does the same.