Live data from Hacker News

Focus: A simple and fast text editor written in Jai

github.com

31–40 of 105 posts

Re: Focus: A simple and fast text editor written in Jai

#31
post #25
post #22

Earlier quoted context omitted.

Jai has a few unique features that are quite interesting. You can think of it as C with extremelly powerful metaprogramming, compile-time codegen and reflection, and strong template systems, plus a few extra niceties like native bump allocator support or things like easily creating custom iterators. There is nothing quite like it.

Thanks. I guess the "extremelly powerful metaprogramming", "compile-time codegen" and "strong template systems" are essentially the same thing. So the unique selling point of Jai from your perspective would be "C with generic metaprogramming, iterators and reflection"? Besides reflection, which is quite limited in C++, this would essentially be a subset of C++, isn't it?

Cpp goes nowhere to this level. Jai templates execute normal code (any code) at compile time, so there is no need for sfinae tricks or others, you just write code that directly deals with types.

You can do things like having structs remove or add members by just putting the member behind an if branch. You can also fully inspect any type and iterate members through reflection. There is a macro system that lets you manipulate and insert "code" objects, the iterator system works this way. you create a for loop operator overload where the for loop code is sent to the function as a parameter.

It also lets you convert a string (calculated compile time) into code. Either by adding it into the macro system, or just inserting it somewhere.

Some of the experiments ive done were implementing a full marc-sweep GC by generating reflection code that would implement the GC sweep logic, having a database system where it directly converts structs into table rows and codegens all the code relating to queries, automatic inspection of game objects by having a templated "inspect" type thing where it exposes the object into imgui or debug log output, fully automatic json serialization for everything, and an ECS engine where it directly codegens the optimal gather code and prepares the object model storage from whatever loops you use in the code.

All of those werent real projects, just experiments to play around with it, but they were done in just a few dozens/hundreds lines of code each. While in theory you could do those in Cpp, it would need serious levels of template abominations to write it. In jai you write your compile time templates as normal jai. And it all compiles quickly with optimal codegen (its not bloating your PDB like a million type definitions would do in cpp template metaprogramming).

The big downside of the language is that its still a closed private beta, so tooling leaves much to be desired. There is a syntax color system, but things like correct IDE autocomplete or a native debugger arent there. I use remedybg to debug things and vscode as text editor for it. Its also on relatively early stages even if its been a thing for years, so some of the features are still in flux between updates.

Re: Focus: A simple and fast text editor written in Jai

#32
post #27

Earlier quoted context omitted.

> how do you recognize that there are still not enough options One language that's still missing is a simple C-like language that offers Rust-style memory safety but without Rust's design philosophy of repeating every C++ mistake (that's not about memory safety) and high level type system wankery (or generally too much influence from functional languages). There are also many more areas still to explore when it comes…

> is a simple C-like language that offers Rust-style memory safety Ok, I see; but why then not just add this feature to C, or maybe Zig? > many more areas still to explore when it comes to memory safety that are less extreme than Rust's approach Such as memory arenas/pools (like Ada), or runtime automatic garbage collection?

> but why then not just add this feature to C

It would most likely need to 'break' C in a way that it wouldn't be recognisable as C anymore or at least break compatibility with existing C code (e.g. removing pointers, or at least pointer arithmetics, and the way pointers and arrays interact).

Re: Focus: A simple and fast text editor written in Jai

#33
post #12

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…

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

#34
post #27

Earlier quoted context omitted.

> is a simple C-like language that offers Rust-style memory safety Ok, I see; but why then not just add this feature to C, or maybe Zig? > many more areas still to explore when it comes to memory safety that are less extreme than Rust's approach Such as memory arenas/pools (like Ada), or runtime automatic garbage collection?

> but why then not just add this feature to C It would most likely need to 'break' C in a way that it wouldn't be recognisable as C anymore or at least break compatibility with existing C code (e.g. removing pointers, or at least pointer arithmetics, and the way pointers and arrays interact).

Not necessarily; the compiler has to trace ownership anyway and could also detect "legal" use of pointers and reject certain uses for objects under the "borrow checker regime", as Rust does it. But of course one could take a subset of C and augment it with the new features, as it was e.g. done in C++ in the eighties or Simula (with Algol) in the sixties; the obvious advantage is the similarity to the original language and (potential) reusability of a large existing code base.

Re: Focus: A simple and fast text editor written in Jai

#35
post #12

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…

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 wi…

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 -> part.velocity } )

- Compiler throws warnings if you shadowed names.

Re: Focus: A simple and fast text editor written in Jai

#36
post #31
post #25

Earlier quoted context omitted.

Thanks. I guess the "extremelly powerful metaprogramming", "compile-time codegen" and "strong template systems" are essentially the same thing. So the unique selling point of Jai from your perspective would be "C with generic metaprogramming, iterators and reflection"? Besides reflection, which is quite limited in C++, this would essentially be a subset of C++, isn't it?

Cpp goes nowhere to this level. Jai templates execute normal code (any code) at compile time, so there is no need for sfinae tricks or others, you just write code that directly deals with types. You can do things like having structs remove or add members by just putting the member behind an if branch. You can also fully inspect any type and iterate members through reflection. There is a macro system that lets you man…

That sounds interesting; seems to be even more flexible than comptime in Zig, almost as powerful as Lisp and the MOP. How about compiler and runtime performance of these features?

EDIT: can you point to source locations in the referenced projects which demonstrate such features?

Re: Focus: A simple and fast text editor written in Jai

#37

This is meant as more of a general comment than to critisize this editor: I fail to see the selling point of an editor that "can't do much", but is performant - there is an abundance of these already. If you made an editor that does "everything" and is "fast", I may be interested. Regarding Jai: the idea about a "language for good programmers" is just about the worst thing ever to say about a language and it's commun…

GO was named a language for bad (not experienced) programmers by its creator. I don't see why doing the reverse of that automatically egregious

I mean sure, people are in general hesitant when someone calls himself good, and for a decent reason.

But pushing it to extreme and defaulting to reverse JUST BECAUSE someone dared to call himself good is also a pretty childish reaction. At the end of the day it is a fact that there are differences in skill between programmers and different languages expect from you different levels of understanding. Pretending it's only valid to acknowledge these differences in others but not in oneself is irrational.

Re: Focus: A simple and fast text editor written in Jai

#38
post #36
post #31

Earlier quoted context omitted.

Cpp goes nowhere to this level. Jai templates execute normal code (any code) at compile time, so there is no need for sfinae tricks or others, you just write code that directly deals with types. You can do things like having structs remove or add members by just putting the member behind an if branch. You can also fully inspect any type and iterate members through reflection. There is a macro system that lets you man…

That sounds interesting; seems to be even more flexible than comptime in Zig, almost as powerful as Lisp and the MOP. How about compiler and runtime performance of these features? EDIT: can you point to source locations in the referenced projects which demonstrate such features?

Dunno about runtime performance, but compiling speed is something that's regularly mentioned as an important aspect of Jai and I think it's not an exaggeration to name it as one of the fastest languages when it comes down to comp speed.

Re: Focus: A simple and fast text editor written in Jai

#39
post #5

Cool, an open source project in a language no one can use. Say what you will about V, at least it exists.

You can use Jai. You just have to ask. It’s in closed beta, but afik “closed” pretty much means “open to anyone who wants to be a beta tester”.

[flagged]

Re: Focus: A simple and fast text editor written in Jai

#40
post #10

Given that the compiler for this language is not publicly available, is this still open source, considering that you cannot easily modify and rebuild it to your liking, despite being GPL?

GPL (I'm not talking about AGPL) only forces you to publish the sources if the binary would be published. If you don't have the program you don't have a right to the source.

I think you're missing the point.

The source code to the program is available, but the compiler with which to compile that code isn't.

To the OP I would say this is opensource.

If you received an open source recipe, despite not having a kitchen you could still modify the recipe, pass it on etc.

You still have the right to modify this code and pass it on, which is what the opensource licenses generally guarantee, opensource software for the latest supercomputer doesn't guarantee you access to that supercomputer.

Post reply on HN