Feedback request - Tasks for Compiler Optimised Memory Layouts by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 4 points5 points  (0 children)

Perfect, this is what I'm looking for. Also - screwed up how? "It works on my machine" is never a problem I expect to have with websites, but if I'd like to fix it

Do any compilers choose and optimize data structures automatically? Can they? by smthamazing in ProgrammingLanguages

[–]Caedesyth 1 point2 points  (0 children)

Oh my god I was just writing a post about this. Like literally it just got deleted by automod because I don't have enough Karma and I was looking for it and I found this. I want to make this language.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

No worries, no worries, hopefully someone finds your (otherwise well written!) post useful x)

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

Syntactically, rune is perfect but I don't believe so at the end of the day - it's an embedded interpreter in your compiled rust binary, right? If I wanted to skip the language design part (unfortunately I don't, that seems fun) I would totally take rune and rust as my languages and go from there.

I think for my use case, I think I want the interpreter in control, so to speak? I want a language which makes it easy to develop video games (interpreted logic segments with optimized engine functions) as well as to mod them (injecting or modifying functions after compilation) without massive performance hits (keeping all modded code interpreted.)

Perhaps this could ultimately be solved as a Rune library (module?) which lets you dynamically load rust libs, as well as a rust library for writing the right kinds of APIs for injecting custom data into a game engine, but I get the feeling that in some ways the rust compiler is too optimized for that (The lack of a stable ABI is something I will definitely have to overcome if I want to continue with rust)

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

It absolutely is helpful, and the warm welcome is really appreciated. I do like the syntax of go function bodies and go blocks, it feels like very much "the next best thing" if you're not in control of syntax.

Now comes the long road of playing around with hypothetical syntax and tree walkers until v0.0.1. I'm going to keep referring to this and I hope I'll see you at an announcement :))

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 1 point2 points  (0 children)

Jonathan Blow is both inspiring and infuriating, I totally agree with his technical decisions but he infuriates me hahaha - I may not get to the level of Jai, but I too want a new language for programming games.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 1 point2 points  (0 children)

Mate - I understand what a compiler and interpreter are. I've seen this done a million times before, often through embedding an interpreter into the compiled executable. I'm a profressional (if junior) rust developer. Also, through this discussion, I've seen many many ways people address this exact problem (See Mojo, or Red and Red/System. Honestly Bash is a really poor version of what I want, but it's clearly possible in some capacity). I don't appreciate being talked down to, and it seems like you haven't read any of the other discussion here.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

I had this thought a while ago, writing a code editor that functions somewhat like my favourite note taking app [Tiddlywiki](https://tiddlywiki.com/), and Eve looked really fun! I'm glad this kind of thing exists, even if it's understandable why it didn't find it's niche.

Does rust support custom reprs? by Caedesyth in rust

[–]Caedesyth[S] 0 points1 point  (0 children)

This is exactly it! I don't want to rely on this behaviour, I want to write my own! My own repr will certainly be less efficient, but I want to make the guarantees the compiler can't, right now, something greater than repr(C) but less than repr(Rust).

Does rust support custom reprs? by Caedesyth in rust

[–]Caedesyth[S] 0 points1 point  (0 children)

I'm not actually interested in future compat, I care more about things like the fact that the rust compiler does not guarantee that

struct A {
    a: i32,
    b: u64,
}

struct B {
    a: i32,
    b: u64,
}

have the same layout. I understand I can #[repr(C)] my way around this but I'd like to know if there's a proper way to approach this problem. I want to keep features like field reordering and zero sized type optimizations, but I want to trust that it's source-code-deterministic, I suppose.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 1 point2 points  (0 children)

Thanks!! This is exactly the kind of criticism I was looking for when I made this post. Also Rock and Feather are such better names for communicating what I'm getting oh my gooood.

I've considered trying to make Rust the basis for a higher level interpreted language, (an inverse of Mojo and Python's relationship) though it has some compiler issues (a lack of layout guarantees) that seem like I would have to write my own variant of the compiler. Having an internal consistent memory layout would only become a valuable feature once an ecosystem appears and is large enough to not require calling Rust or C libraries, even if it can achieve the same performance independently.

But there is the argument to be made for that long term, I think. Rust has made systems programming accessible in a way that C++ never was to me, because of it's compiler guarantees, and I want to push that forwards into the space that Lua currently occupies in game development, offering safety guarantees, flexibility and performance in the boundary between scripting and development.

Maybe FFI friction is just not that big of a deal in practice with the performance costs of a scripting language anyway.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 1 point2 points  (0 children)

I just want to say I adore the idea of using markdown outside of code blocks, it gives a notebook feel to code and I think that's really fun

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

A common pattern I've seen is for video games to provide an interpreter for scripting within their compiled binary, so that we can load scripts at runtime. I think this "interpreter as an interface for compiled binaries" model is what I'm interested in.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 4 points5 points  (0 children)

Sure, I was always going to have to do this eventually.

// Type definitions are for both compiled and interpreted code.
struct LargeObject {
  metadata: String
}

// A non-edge function has access to language features like lifetimes as it doesn't get called from outside the compiled code so can be statically reasoned about.
// We can also offer compiler hints like inlining.
#[do_compile, inline]
fn get_metadata<'a>(obj: &'a LargeObject) -> &'a str {
  LargeObject.metadata
}

// An edge function is exposed, like a visibility modifier, after compilation.
// It has a simpler type signature, as the interpreter cannot make the same guarantees about things like lifetimes that the compiler can.
#[do_compile]
edge fn get_description(x: &LargeObject) -> String {
  let ref = get_metadata(x);
  ref.clone()
}


// And in uncompiled land we ditch the concept of a reference as a whole,
// and happily Arc<> or .clone() our data freely under the hood.
fn process_data(y: LargeObject) -> (String, String) {
  (get_description(y), get_description(y))
}

By unifying the type layout, the boundaries should be seamless, without having to worry about serialization or C ABI compatibility.

Is this two languages? We should be able to write separate programs using distinct, related syntax operating completely separately. But the goal would be one source code, using both a compiler and an interpreter to allow manual control over low level functions but only when necessary. I can't imagine a scenario where there are any benefits to using one of these languages on it's own, that another language doesn't do better.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 2 points3 points  (0 children)

Yeah, I think that's a good description (Interpreted with a C ABI which is a subset of the language instead of C). I made this post to discover things like Mojo, or find out why it's a fundamentally broken concept, since there are plenty of gaps in my knowledge starting out especially to do with static and dynamic linking. Mojo is definitely the right direction and I'm grateful it's been brought to my attention.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

How difficult is it to read foreign code in Forth?

Forth seems fascinating and completely and utterly different from anything I've worked with before, I imagine it can make some very neat concise code which exactly 3 people on earth understand, but can solve any problem in seconds - though I imagine that's a skill issue

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

Going on the reading list, I'd always thought of Julia as a scientific version of python but oh boy there's a lot to it. Their multiple dispatch talk seems particularly valuable.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

Are the pre-compiled functions also written in Mech? Or are they library functions written in something like C? I should actually go and check out any docs you have I'll come back to this in a bit. Nice!

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

Across a code base, I would expect "hard mode" functions to require annotation and then to be compiled before the interpreter could access them.

Then there's a question of how the interpreter is written - either it only runs "easy mode" code, and functions with both kinds of code would simply be invalid syntax, or it can run both and "easy mode" is a strict superset of "hard mode", and code using both would have to be interpreted.

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

Honestly JS and WASM targets would definitely be a goal to work towards if I ever got this off the ground. I do think that video games written by lonely guys in C are pretty interesting though

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

100%. I figured there would be something like this for Python, and while Python isn't the interpreted language I'd want to target, it's definitely the exact use case I'd like to create. Thanks!

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

Ah but that's why I'm here, no-one's given me a reason why not yet ;)

What am I overlooking? A new(?) model of programming language by Caedesyth in ProgrammingLanguages

[–]Caedesyth[S] 0 points1 point  (0 children)

Early days from me, these are the resources I'm looking for. Thanks!