https://blog.kyubuns.dev/entry/2020/07/12/150546
I shared it.
Compiling is explosive, no null, Immutable variables by default , Pure functions by default and V language with lots of features you like .
Such V language supports js and wasm output! !! !!
However, the output method is not yet in the document .
Well I will get on soon.
I will introduce the build method based on the information collected from the discord of vlang.
Sample code
We will compile the code that enumerates the official Fibonacci sequence.
fibonacci.v
Try to run normally
v fibonacci.v
Compiling is about this speed. (Hereafter, all are tried at MBP2018.)0.25s user 0.04s system 97% cpu 0.301 total
./fibonacci
Execution is about this speed.0.00s user 0.00s system 56% cpu 0.004 total
js
v -b js -w -o fibonacci fibonacci.v
This will generate fibonacci.js. 0.00s user 0.00s system 73% cpu 0.008 total
It's stupid.
0.04s user 0.01s system 91% cpu 0.060 total
To test the execution speed, the number of trials is not enough by about 2 digits, so it is for reference only.
But isn't this faster than building and running as it is with v? ??
The converted code looks like this.
You can see that it is converted very honestly.
wasm
No, v is just converted to c!
Well, that being said, v-> c is as fast as js, but
c-> wasm takes 2.15s user 0.72s system 224% cpu 1.277 total
about a while.
This fibonacci.c swells to a whopping 9559 lines.
Converting to C is like when you want execution speed instead of compilation speed.
0 コメント:
コメントを投稿