Reason 1: Rush support similar Python syntax without braces, and is compatible with 60% of the C++ syntax, Rush itself using standard C++ compiler to compile or self compiled.
Reason 2: Rush can be interpreted or compiled, it dominated statically typed, no GC, and support translated into C++, so can be nearly achieved C++'s efficiency.
Reason 3: It using Lisp as intermediate layer, support mixin, macro, meta-programming and a variety of dynamic characteristics, and supports call by name, call by need and call by value.
Reason 4: Rush's design goal is simple, fast, stable, fully open source, it's source code structure is much simpler than lua, but it's ability is not less than lua.
Rush overall design:
define ← =
void insertion_sort(rstr& a):
for j ← 1; j<a.count; j ← j+1
key ← a[j]
i ← j-1
while i>=0 && a[i]>key
a[i+1] ← a[i]
i ← i-1
a[i+1] ← key
bool next_permutation<T>(rbuf<T>& v):
if v.count<=1
return false
next=v.count-1
for
temp=next
next--
if v[next]<v[temp]
mid=v.count-1
for !(v[next]<v[mid])
mid--
swap<T>(v[next],v[mid])
reverse<T>(v,temp)
return true
if next==0
reverse<T>(v,0)
return false
void main():
int a
int b
[int,=,[a,1]]
[int,=,[b,2]]
[rf,print,[[int,+,[a,b]]]]
Rush coding style 4: (This is the standard C++ syntax, this section of code can be compiled with VC++, G++ or Rush)
static rbool inherit_proc(tsh& sh,tclass& tci,int level=0)
{
if(level++>c_rs_deep)
return false;
if(tci.vfather.empty())
return true;
rbuf<tword> v;
for(int i=0;i<tci.vfather.count();i++)
{
rstr cname=tci.vfather[i].vword.get(0).val;
tclass* ptci=zfind::class_search(sh,cname);
if(ptci==null)
{
ptci=zfind::classtl_search(sh,cname);
if(ptci==null)
return false;
}
if(!inherit_proc(sh,*ptci,level))
return false;
v+=ptci->vword;
}
v+=tci.vword;
tci.vword=v;
return true;
}
Rush supports multiple operation modes, as follows:
- cd to the bin directory
- Command line typing: rush -jit ..\src\example\test\1.rs
- cd to the bin directory
- Command line typing: rush ..\src\example\test\1.rs
- cd to the bin directory
- Command line typing: rnasm ..\src\example\test\1.rs
- cd to the bin directory
- Command line typing: gpp ..\src\example\test\1.rs
- Run ext\ide\SciTE.exe
- Click File -> Open
- Select the ..\src\example\test\1.rs, click 'Open'
- Press F5 to run the program (or F7 generate EXE)
HTML5 online interpretation runs (currently only supports chrome, EM++ function pointer conversion support for seemingly a problem):
- Click http://roundsheep.github.io/rush/
- Click the 'run' button and wait a few seconds will show operating results
- Make sure the clang (3.5 or higher) or g++ (4.8 or higher)
- cd to the bin directory
- Command line typing: g++ ../src/rush.cxx -o rush -w -m32 -std=c++11
- Command line typing: ./rush ../src/example/test/50.rs
- cd to the bin directory
- Command line typing: rush -gpp ..\src\example\test\1.rs
- The resulting src\example\test\1.cpp and ext\mingw\gpp.h two files into xcode
- Modify the main function as required, comment out the header files 'windows.h'
- Ensure that the compiled environment is windows with 64 bit
- Download a key android toolkit and unzip to a path without space or Chinese (1.1G) http://pan.baidu.com/s/1c0oc3Ws
- Click create_proj.bat
- Enter the project name such as 'test', waiting for the end of the command window
- Click proj\test\build_cpp.bat
- Wait a few minutes, command window appears "Press any key to continue."
- Press 'Enter' and wait for the end of the command window
- Get proj\test\proj.android\bin\xxx.apk after successfully
- If need, use 'rush -gpp' command to translate Rush to CPP and include it into the proj\test\Classes\HelloWorldScene.cpp
- cd to the bin directory
- Command line typing: rush -gpp64 ..\src\example\64bit_test.rs
- Import the resulting file src\example\test\64bit_test.cpp with Visual Studio (or using 64 of G++)
- Select x64, Press F7
##### Rush re-compiled to JS:
- Be sure to install the emscripten
- Open 'Emscripten Command Prompt'
- cd to Rush home directory
- Command line typing: em++ -O3 src\rush.cxx -o rush.html -w --preload-file src -s TOTAL_MEMORY=156777216 -s EXPORTED_FUNCTIONS="['_ js_main']"
- Be sure to install the VS2012 update4 or VS2013
- Open src\proj\rush.sln
- Select 'Release' mode (not support 'Debug' because of JIT)
- Press F7, will generate bin\rush.exe after successfully
- Double-click self_test_nasm.bat
- Wait a few minutes will generate bin\rush_nasm.exe (Rush actually complete self compiled requires only five seconds, the bottleneck in NASM, reportedly Chez Scheme self compiled is 5 seconds)
- Note that only NASM mode and GPP mode are available after self compiled
- Double-click self_test_gpp.bat
- Wait a few minutes will be generated bin\rush_gpp.exe
- Note that only NASM mode and GPP mode are available after self compiled
- cd to the bin directory
- Command line typing: rush -gpp ..\src\example\test\1.rs
- Using gdb or Visual Studio to debugging the src\example\test\1.cpp
- Double-click the bin\example_test.bat
Rush don't have license, anyone can freely use, copy, distribute, modify, rename.
QQ group: 34269848
E-mail: 287848066@qq.com