Skip to content

Commit

Permalink
[js] work-in-progress JS version test
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Apr 6, 2024
1 parent d14fa19 commit cfd4d4a
Show file tree
Hide file tree
Showing 25 changed files with 7,683 additions and 20 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Javascript

on:
push:
branches:
- master
paths:
- 'js/**'
- '.github/workflows/js.yml'
pull_request:
paths:
- 'js/**'
- '.github/workflows/js.yml'
workflow_dispatch:

jobs:
common:
name: Common
uses: ./.github/workflows/common.yml
with:
workdir: js
format-pkgs: nodejs libsdl2-dev
build-pkgs: nodejs libsdl2-dev libc-bin
cache-paths: |
js/node_modules
cache-file: '**/package-lock.json'
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,24 @@ each compiler, with standard "release mode" flags (see each language's

```
$ ./all.py bench | ./utils/sort.py
nim / lto : Emulated 16438 frames in 10.00s (1643fps)
rs / lto : Emulated 16029 frames in 10.00s (1603fps)
cpp / lto : Emulated 15064 frames in 10.00s (1506fps)
c / lto : Emulated 15054 frames in 10.00s (1505fps)
rs / release: Emulated 13904 frames in 10.00s (1390fps)
c / release: Emulated 13368 frames in 10.00s (1337fps)
cpp / release: Emulated 12967 frames in 10.00s (1297fps)
nim / release: Emulated 11860 frames in 10.00s (1185fps)
zig / release: Emulated 8844 frames in 10.00s (884fps)
zig / safe : Emulated 7206 frames in 10.00s (721fps)
c / debug : Emulated 5914 frames in 10.00s (591fps)
cpp / debug : Emulated 5663 frames in 10.00s (566fps)
go / release: Emulated 5029 frames in 10.00s (503fps)
pxd / release: Emulated 3610 frames in 10.00s (361fps)
nim / debug : Emulated 2587 frames in 10.00s (258fps)
rs / debug : Emulated 1808 frames in 10.01s (181fps)
py / mypyc : Emulated 789 frames in 10.01s (79fps)
php / opcache: Emulated 655 frames in 10.00s (65fps)
php / release: Emulated 257 frames in 10.02s (26fps)
py / release: Emulated 165 frames in 10.02s (16fps)
rs / lto : Emulated 15763 frames in 10.00s (1576fps)
cpp / lto : Emulated 14737 frames in 10.00s (1474fps)
rs / release: Emulated 13183 frames in 10.00s (1318fps)
cpp / release: Emulated 12966 frames in 10.00s (1297fps)
zig / release: Emulated 8792 frames in 10.00s (879fps)
nim / speed : Emulated 8127 frames in 10.00s (812fps)
nim / release: Emulated 6161 frames in 10.00s (616fps)
cpp / debug : Emulated 5693 frames in 10.00s (569fps)
go / release: Emulated 5040 frames in 10.00s (504fps)
pxd / release: Emulated 3792 frames in 10.00s (379fps)
js / release: Emulated 2436 frames in 10.00s (243fps) # missing GPU
nim / debug : Emulated 1968 frames in 10.00s (196fps)
rs / debug : Emulated 1676 frames in 10.00s (168fps)
py / mypyc : Emulated 887 frames in 10.01s (89fps)
php / opcache: Emulated 613 frames in 10.01s (61fps)
php / release: Emulated 255 frames in 10.01s (25fps)
py / release: Emulated 101 frames in 10.06s (10fps)
zig / safe : Emulated 40 frames in 10.00s (4fps)
```

Also if you spot some bit of code that is weirdly slow and making your favourite
Expand Down
3 changes: 3 additions & 0 deletions js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.parcel-cache
dist
19 changes: 19 additions & 0 deletions js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
RosettaBoy - JavaScript (TypeScript (Node)) Version
===================================================

Thoughts on JS / TS / Node
--------------------------

On TypeScript vs JavaScript:
* TypeScript seems better in every way, except that it requires a build step :(

On the state of NPM libraries:
* Try one SDL library, it doesn't compile
* Try another SDL library, realise it hasn't been updated in 8 years and doesn't work with current Node
* Try a third SDL library, realise that it makes a lot of assumptions and has its own API that's very different from SDL
* Find some modern, supported, well-behaved libraries... which _exclusively_ cover the audio interface and nothing else
* Give up on SDL libraries, try the FFI library instead to build my own
* Find that there's no official FFI library, so I try the FFI library on NPM
* Find that the FFI library on NPM was abandoned several years ago
* Seems like somebody forked the above to make a stable version and _has_ kept it up to date, so let's try that...
* The up-to-date FFI library links to the abandoned library's docs
16 changes: 16 additions & 0 deletions js/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -eu

cd $(dirname $0)
if [ ! -d node_modules ] ; then
npm install
fi
npm run build

cat >rosettaboy-release <<EOD
#!/usr/bin/env bash
set -eu
# gdb -batch -ex "run" -ex "bt" --args
node --enable-source-maps "\$(dirname \$0)/dist/index.js" \$*
EOD
chmod +x rosettaboy-release
7 changes: 7 additions & 0 deletions js/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -eu

if [ ! -d node_modules ] ; then
npm install
fi
npm run format
Loading

0 comments on commit cfd4d4a

Please sign in to comment.