Esbuild: Posibility to port another languages ?

Created on 20 Jun 2020  路  10Comments  路  Source: evanw/esbuild

Its possible to port that library to c#.
It could work without node dependency ?

I see its using golang !

There have some roadmap or list of testability ?

Very ambigious to make it work without nodejs dependecy !

Most helpful comment

That's very interesting. Did C++ and Rust not perform as well as Go? Or is Go more succinct? Or was there another reason for switching?

I wrote up some thoughts about Rust vs. Go in a reply to someone about swc, a project similar to esbuild but written in Rust: https://news.ycombinator.com/item?id=22336119. Long story short: I was by far the most productive in Go vs. Rust and C++. Go lets me iterate much quicker, easily use the full power of my machine with parallelism, and makes cross-platform deployment trivial.

I've also been told that esbuild is faster than swc even though it's written in Rust because esbuild uses better algorithms. So just writing something in Rust doesn't necessarily make it the fastest. I'm sure a bundler written in C++ or Rust could be faster than esbuild with enough effort because of LLVM's optimization passes, but I'm not sure it's worth the effort since it probably wouldn't be that much faster. Perhaps if there's ever an LLVM backend for Go it could be interesting to see what effect that has on esbuild's performance.

On a related note, I recently tried building swc and it took 10 minutes to build on my 6-core 2019 MacBook Pro. 10 minutes! The Go compiler builds esbuild in 0.6 seconds. It was a good reminder for me about why I stopped using Rust :)

All 10 comments

Its possible to port that library to c#.

Yes, it's possible to port this to other languages. It actually used to be written in C++, and then in Rust, before I switched to Go. But I will not be porting it from Go.

It could work without node dependency ?

This is already the case. Node is not required to use esbuild. One of the nice things about Go is that Go code can be built as a single cross-platform executable that runs without anything needing to be installed. The reason esbuild is hosted on npm is because the entire web development community uses it, not because esbuild requires node to work.

If you don't want to install npm to install esbuild, you can just download the binary straight from npm over HTTP:

  • For Linux (the binary will be ./package/bin/esbuild):

    curl -O https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.5.5.tgz
    tar xf ./esbuild-linux-64-0.5.5.tgz
    
  • For macOS (the binary will be ./package/bin/esbuild):

    curl -O https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.5.5.tgz
    tar xf ./esbuild-darwin-64-0.5.5.tgz
    
  • For Windows (the binary will be ./package/esbuild.exe):

    curl -O https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.5.5.tgz
    tar xf ./esbuild-windows-64-0.5.5.tgz
    

Obviously you'd want to substitute 0.5.5 for the version of esbuild that you want to install. Does this work for you? What platform are you on?

Also go get github.com/evanw/esbuild/cmd/esbuild if you have the Go toolchain installed.

Could add something to the README on that.

I just added alternate installation methods to the readme, which should hopefully address this.

I assume you mean using go get github.com/evanw/esbuild/cmd/esbuild to install esbuild globally? There's no way to install a specific version with that command, so I don't want to recommend that method. Not pinning esbuild to a specific version is asking for trouble because a future version may introduce a backwards-incompatible change.

Yes, I did mean global install. However, you are mistaken regarding the version pinning, good sir:

$ GO111MODULE=on go get github.com/evanw/esbuild/cmd/[email protected]
go: downloading github.com/evanw/esbuild v0.5.6
go: found github.com/evanw/esbuild/cmd/esbuild in github.com/evanw/esbuild v0.5.6
$ esbuild --version
0.5.6

Ah, thanks for showing how to do it. I will add that to the readme as well then.

It actually used to be written in C++, and then in Rust, before I switched to Go.

@evanw That's very interesting. Did C++ and Rust not perform as well as Go? Or is Go more succinct? Or was there another reason for switching?

That's very interesting. Did C++ and Rust not perform as well as Go? Or is Go more succinct? Or was there another reason for switching?

I wrote up some thoughts about Rust vs. Go in a reply to someone about swc, a project similar to esbuild but written in Rust: https://news.ycombinator.com/item?id=22336119. Long story short: I was by far the most productive in Go vs. Rust and C++. Go lets me iterate much quicker, easily use the full power of my machine with parallelism, and makes cross-platform deployment trivial.

I've also been told that esbuild is faster than swc even though it's written in Rust because esbuild uses better algorithms. So just writing something in Rust doesn't necessarily make it the fastest. I'm sure a bundler written in C++ or Rust could be faster than esbuild with enough effort because of LLVM's optimization passes, but I'm not sure it's worth the effort since it probably wouldn't be that much faster. Perhaps if there's ever an LLVM backend for Go it could be interesting to see what effect that has on esbuild's performance.

On a related note, I recently tried building swc and it took 10 minutes to build on my 6-core 2019 MacBook Pro. 10 minutes! The Go compiler builds esbuild in 0.6 seconds. It was a good reminder for me about why I stopped using Rust :)

Very interesting thoughts!
In my opinion the main problem of js is tooling !

By the way golang is more efficient and more simple than c++ and rust!
Google madeit golang because pain of c++ kills many developrrs in google!

Brcause of golang simplicity it easy to mantain code base !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ayox picture ayox  路  4Comments

vforsh picture vforsh  路  3Comments

a7ul picture a7ul  路  3Comments

egoist picture egoist  路  3Comments

tonyhb picture tonyhb  路  3Comments