← Back to context

Comment by baq

10 hours ago

It isn't, v8 will have anywhere between 2-1000x performance depending on the exact code it's jitting. Boa absolutely destroys v8 here though:

    use boa_engine::{Context, Source, JsResult};
    
    fn main() -> JsResult<()> {
      let js_code = r#"
          let two = 1 + 1;
          let definitely_not_four = two + "2";
    
          definitely_not_four
      "#;
    
      // Instantiate the execution context
      let mut context = Context::default();
    
      // Parse the source code
      let result = context.eval(Source::from_bytes(js_code))?;
    
      println!("{}", result.display());
    
      Ok(())
    }

Huh, I just noticed thanks to this that the comment needs to be updated in the example lol it should probably say "Parse and evaluate the source code".

Oh my god, that's so easy to embed.

I have to check this out.

This is awesome. You literally just sold me on it.

> anywhere between 2-1000x performance depending on the exact code it's jitting

That is useful information! Benchmarks can show you this useful information.