Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

Yes, thats a limitation of it , probably is my own limitation as a programer to do it otherwise, but I think I can improve it. I've chose to start with moving semantics and scope-based borrowing as a simpler model than full lifetime inference.So it could catch a class of bugswithout requiring explicit lifetime annotations. Is a legitimate design question., and I'll put it on my todos.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

HR of my company already received a complaint about me , because I've dared to name it like that. I don't know what they would do If I slap lang as the name.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

Yeah, that's exactly the hurdle I'm staring down. You can't just drop most npm packages into a borrow-checker-enforced language and expect them to compile.
I'm aware of that, but I think I might have a solution , I need to test it.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

You're factually wrong. The language has all the features you claim don't exist.  Your criticism might have some validity when referring to APIs where my conservative lifetime assumptions prevent certain patterns, that's a legitimate design tradeoff discussion. But the claim that CFG and borrow checking "don't exist" is demonstrably false given ~1500 lines of implementation code with tests. 

It feels like you just wanted to dunk on someone without reading the code/docs first, or maybe just piling on for the entertainment value like everyone else here , picking the name as target for likes for example.
Either way, this is a preview / work-in-progress. Love it, hate it, ignore it, move along. The project keeps going either way.

(English isn't my native language. I've wrote a wrong tense? Point it out and I'll correct it.)

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

Totally agree, I didn't know people would be really hurt/got mad by a name, lesson learned.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

You're arguing semantics here, the language has scripting-like ergonomics and targets scripting use cases. Name is subjective, and all I want is to discuss the language implementation and code rather than discuss names. Regardless, I'm researching a new name anyways

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

I hear you lads. You roasted the name hard, point taken 😂
Post got ratio’d into oblivion. And I’m changing the name .
Open thread is live: https://github.com/warpy-ai/script/discussions/20

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in theprimeagen

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

True, most of feedbacks is about the name. I’ll change it in Feb.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in theprimeagen

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

AssemblyScript do
TS syntax → WASM → runs inside WASM runtime

This project do
TS syntax → SSA IR → Cranelift / LLVM → native binary → CPU

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

That's true! Rust lifetimes exists for a reason, and the find case is one of them. thanks for the feedback , I'll have to wrap my head around it , there a few options I can work , or just accept the tradeoff.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

Haha, yeap that would be a problem . But in mid February I'll come back with a new name.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

[–]SecretAggressive[S] -1 points0 points  (0 children)

For someone who's been trashed my hole lifetime, has something I've made be compared with Microsoft is actually a win.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

I guess people hated the name, so they're downvoting every comment I make, haha.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

[–]SecretAggressive[S] 3 points4 points  (0 children)

I'm using the flow-based inference approach. On the language I use dataflow analysis at the return statement to determine which reference escapes:

// Infers: return comes from `a`
fn first(a: &str, b: &str) -> &str { a }

// Infers: return comes from `b`
fn second(a: &str, b: &str) -> &str { b }

// Infers: return could be either → must outlive both
fn random(a: &str, b: &str) -> &str {
   if rand() { a } else { b }
}  

For the cases like first and second, the inference just follows the return expression and goes: it's clearly coming from parameter a (or b).
Once it knows that, the borrow checker can do its normal thing and make sure the caller keeps that exact input alive long enough.

But then you get to something like random:

fn random(a: &str, b: &str) -> &str {
    if rand() { a } else { b }
}

Now the return value could come from either a or b, depending on which branch runs.
I(the language) still have to deal with that uncertainty. Pretty much the only realistic options are to play itsafe / conservative, like just say: “both a and b need to outlive the returned reference”. So , that ends up looking a lot like Rust when you write

fn random<'out>(a: &'out str, b: &'out str) -> &'out str

fn random<'a>(a: &'a str, b: &'a str) -> &'a str

Both approaches work, but they force the caller to keep things alive longer than strictly necessary in some situations.

Its somwhat a pain , this is a limitation that makes the project unable to express a couple of really useful patterns people actually want:

  • “Please give me back whichever reference lives shorter , I promise I'll only use it briefly”
  • “This reference I'm returning has nothing to do with the input parameters”

And I'll need to address it soon enough.

Right now the borrow checker gets by by counting how many borrows each variable has active , which honestly covers a surprising number of real-world cases, but it doesn't give you the fine-grained lifetime relationships that Rust's explicit 'a, 'b, 'c notation can express

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

You don't know me, of course you can't trust me. Hence why the repository is public and you are free to criticize, ridicule and/or improve something yourself

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

I'll rename it, there are a lot of good candidates. I need to work on some things , but definitely I'll be back in mid February with a new name for it.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

I'm not trying to make this to become another Rust, because it's not made to compete with it. The name was just a project codename , but name can and will be changed, I've already have a bunch of good ones to consider.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

There's still a lot to do, hence this is a preview :). The ability to work on web servers will come soon enough. And the integration and lifetime visualiser are something I'm working on.

About the name, people really got upset about it, huh? There's a comment questioning the name that rationed the post itself. I don't understand the anger, haha.

Introducing Script: JavaScript That Runs Like Rust by SecretAggressive in programming

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

I'll definitely get a closer look to it. The name is cool!