Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gobengo/node-polyglot-fibonacci
experiment. bindings to fibonacci implementation in non-JavaScript languages (defaults to C++)
https://github.com/gobengo/node-polyglot-fibonacci
Last synced: 25 days ago
JSON representation
experiment. bindings to fibonacci implementation in non-JavaScript languages (defaults to C++)
- Host: GitHub
- URL: https://github.com/gobengo/node-polyglot-fibonacci
- Owner: gobengo
- Created: 2015-05-01T10:40:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-01T10:44:31.000Z (over 9 years ago)
- Last Synced: 2024-10-03T15:30:06.207Z (about 1 month ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-polyglot-fibonacci
An experiment in writing node.js bindings to other languages.
The bindings are to a function that calculates the Nth Fibonacci term.
## Implementations
* [C++](./lib/fibonacci.cc) - [bindings](./lib/fibonacci-cc.js) via [node-gyp](https://github.com/TooTallNate/node-gyp)
- recursive
- #TODO: recursive memoized
- iterative
* [JavaScript](../lib/fibonacci-js.js)
- recursive
- #TODO: recursive memoized
- iterative
* #TODO
- Rust - [example](https://github.com/alexcrichton/rust-ffi-examples/tree/master/node-to-rust/src)
- C++ via node-ffi. [example](https://github.com/node-ffi/node-ffi/blob/master/example/factorial/factorial.c)## Use it
```
⚡ FIBONACCI_IMPL=lib/fibonacci-cc.js node index.js 42
433494437
```
```
⚡ FIBONACCI_IMPL=lib/fibonacci-js.js node index.js 42
433494437
```## Compare Implementations
```
⚡ make compare N=42
node bin/compare.js
Comparing implementations of Fibonacci(42)
1148.6017629394532ms - C++.recursive
0.0134940185546875ms - C++.iterative
5944.805768920898ms - JavaScript.recursive
0.0868218994140625ms - JavaScript.iterativeThe fastest was C++.iterative
```