Alternative use of JS and Shell

by Ricardo Fernández Serrata

Version 1 (September 8, 2021)

Download (4 downloads)

Shows that processing can be done in JS and SH instead of AM, which decreases the block count dramatically.

The default expression to evaluate is 3x + 1 (where x is input), but you can change it to anything valid depending on language.

JS and MirBSD Korn Shell (MKSH) are very different languages, some expressions will have different valid syntax or the same syntax but different interpretation. In this example I show you something they have in common, for the sake of simplicity.

The result of some arithmetic can be vastly different, because MKSH uses 32bit integers that do wrap-around on overflow.

Text processing can be done in both, but JS is extremely better at it than AM and MKSH combined. Math is faster in MKSH, but there are no pow() nor log() functions.

The shell can do more things than just processing, it can do file operations like creating, editing, deleting, renaming, and moving files and directories. With curl command, you can do HTTP requests. With root (or ADB), it can also change any system setting and install more cmds.

Dialogs have more latency than shell, but the shell has more latency than AM even though some computations are faster in the shell.


MirBSD Korn Shell Manual: www.mirbsd.org/htman/i386/man1/mksh.htm

List of installed executable files and symlink binaries for each Android version: chromium.googlesource.com/aosp/platform/system/core/+/refs/heads/upstream/shell_and_utilities

developer.android.com/studio/command-line/adb#shellcommands

JS documentation can be found in the official Mozilla Developer Network: developer.mozilla.org/en-US/docs/Web/JavaScript

4.7 average rating from 3 reviews

5 stars
2
4 stars
1
3 stars
0
2 stars
0
1 star
0
Reports
0

Rate and review within the app in the Community section.