PythonJSใฎgithubใ่ฆใฆใใใใ
PythonJS development has moved to Rusthon https://github.com/rusthon/Rusthon
ใจใใใพใใใฎใงใใใฃใจRusthonใPythonJSใฟใใใซไฝฟใใใใ ใใใ ใจๆใใๆฉ้ใใญใฅใกใณใใ่ชญใใงใฟใพใใใ
Windowsใใตใใผใใใใฆใญใ
ไปๆนใชใใฎใงๅฎ่กpythonในใฏใชใใใใใใ็ใซไฝฟใใพใใ
Tagใฎ0.9.8ใใrusthonใ็พใใใใไปฅๅใฏPythonJSใงใใ 0.9.8ใฎใณใใใใ2015ๅนด1ๆ17ๆฅใงใใใ็พๅจ(2016/1/23)ใซ่ณใใพใงใใญใฅใกใณใใๆฅๆฌ่ชใฏใใใๅ
ฌๅผใซใใ่ฆใคใใใชใใฎใงใใกใใฃใจ่ฉฆ่ก้ฏ่ชคใใฆใฟใพใใใ
็ต่ซใใ่จใใจใ็ฐกๅใชpython -> javascript็ฟป่จณๆฉใจใใฆไฝฟใใใใงใใ
Continue Reading
ใใฃใจใใญใฅใกใณใใ่ชญใใ ็ฐกๅใช็่งฃใใพใจใใพใใ
Python, C++, javascript, Go, rustใฎ็ธไบๅคๆใใงใใใใใใใพใใใ coffee scriptใrapydscriptใฎๅบๅใใงใใใจใใ
ๅบๆฌ็ใซmarkdownใใญใฅใกใณใไธญใซใใญใฐใฉใ ใๅผ็จใฎๅฝขใง่จ่ผใใๆฌไฝใฎpythonใใญใฐใฉใ rusthon.pyใซๆธกใใฆใใใฐๅคๆใใณใณใใคใซใๅฎ่กใใใฃใฆใใใใฟใใใงใใ
ใพใใๆธกใใใใกใคใซใmarkdownใงใฏใชใpythonใงใใใฐใๅ็ดใซไปใฎ่จ่ชใธใฎๅคๆๅจใจใใฆใๅใใใใงใใ
ใชใใpythonใซ้ขใใฆใฏpypyใใ้ใใฟใใใช่จไบใ่ฆใๆฐใใใใ
git clone https://github.com/rusthon/Rusthon.git
C++11ใไฝฟใใmingwใ็จๆใใใในใ้ใใฆใใใพใใ ้ฉๅฝใชใณใใณใใใญใณใใใใg++ -vใจๆใฃใฆใ4.8ใจใ4.9ใจใๅบใใฐใใใใจๆใใพใใ
ใใใฎใใใซใไพใใฐๅใฏใใคใฎ้ใซใใคใณในใใผใซใใฆใใgcc490ใฎmingwใฎใในใ้ใใๅใฎใใผใธใงใณใฎMinGWใจHaskell platformใซๅๆขฑใใใgccใฎใในใๆถใใพใใใ
ๆฉ้pythonใฎใฏใฉในใจ้
ๅใๆไฝใใใตใณใใซใC++ใซๅคๆใใฆ่ฉฆใใฆใฟใพใใ
cd \Path\to\Rusthon\examples python ../rusthon.py array_genetics.md
ใงใใใใฎใพใพใ ใจใจใฉใผใๅบใพใใ
d:/MinGW/gcc490/mingw32/bin/../lib/gcc/i686-w64-mingw32/4.9.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -ldl collect2.exe: error: ld returned 1 exit status Traceback (most recent call last): File "../rusthon.py", line 1951, in <module> main() File "../rusthon.py", line 1725, in main package = build(modules, base_path, datadirs=datadirs ) File "../rusthon.py", line 1398, in build subprocess.check_call( cmd ) File "c:\Python27\lib\subprocess.py", line 540, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['g++', '-O3', '-fprofile-generate', '-march=native', '-mtune=native', '-Ic:\\users\\xxxx\\appdata\\local\\temp', '-Wl,-rpath,/usr/local/lib/', '-Wl,-rpath,./', 'c:\\users\\xxxx\\appdata\\local\\temp/rusthon-c++-build.cpp', '-o', 'c:\\users\\xxxx\\appdata\\local\\temp\\rusthon-test-bin', '-pthread', '-std=c++11', '-ldl']' returned non-zero exit status 1
rusthon.pyใฎ1371่ก็ฎใใณใกใณใใขใฆใใ
## always link to libdl, external libraries may require dl_open, etc. # cmd.append('-ldl')
1330่ก็ฎใซ/usr/local/libใๅ ใใใชใใทใงใณใใใใพใใใๆฎใใฆใใใฆๅคงไธๅคซใงใใ ใใใจใใใงใใใใใ
> python ../rusthon.py array_generics.md ========== g++ : compile main ========== g++ -O3 -fprofile-generate -march=native -mtune=native -Ic:\users\xxxx\appdata\local\temp -Wl,-rpath,/usr/local/lib/ -Wl,-rpath,./ c:\users\xxxx\appdata\local\temp/rusthon-c++-build.cpp -o c:\users\xxxx\appdata\local\temp\rusthon-test-bin -pthread -std=c++11 c:\users\xxxx\appdata\local\temp/rusthon-c++-build.cpp: In function 'std::string* __pointer__(std::string)': c:\users\xxxx\appdata\local\temp/rusthon-c++-build.cpp:54:38: warning: address of local variable 'ob' returned [-Wreturn-local-addr] std::string* __pointer__(std::string ob) { ^ running: c:\users\xxxx\appdata\local\temp/rusthon-test-bin 1 200 220 3000 hi from C
ไธญ้ใณใผใใ่ฆใใพใใไธๆไฝๆฅญใใกใคใซ็ฝฎใๅ ดใซ็ฝฎใใใฆใใพใใ
Linuxใ ใจ/tmp/ใWindowsใซใฏ็ฐๅขๅคๆฐTEMPใซ่จญๅฎใใใฆใใพใใๅใฎ็ช10ใงใฏ %USERPROFILE%\AppData\Local\Temp ใงใใใ
ใใฉใใกใใก่ฆใซ่กใใฎใฏใใใฉใใใใฎใงใrusthon.pyใฎtarใๅใๅบใใชใใทใงใณใๅฉ็จใใพใใ
> python ../rusthon.py array_generics.md test.tar ========== g++ : compile main ========== g++ -O3 -fprofile-generate -march=native -mtune=native -Ic:\users\xxxx\appdata\local\temp -Wl,-rpath,/usr/local/lib/ -Wl,-rpath,./ c:\users\xxxx\appdata\local\temp/rusthon-c++-build.cpp -o c:\users\xxxx\appdata\local\temp\rusthon-test-bin -pthread -std=c++11 c:\users\xxxx\appdata\local\temp/rusthon-c++-build.cpp: In function 'std::string* __pointer__(std::string)': c:\users\xxxx\appdata\local\temp/rusthon-c++-build.cpp:54:38: warning: address of local variable 'ob' returned [-Wreturn-local-addr] std::string* __pointer__(std::string ob) { ^ Traceback (most recent call last): File "../rusthon.py", line 1951, in <module> main() File "../rusthon.py", line 1820, in main save_tar( package, output_tar ) File "../rusthon.py", line 1505, in save_tar s.write(open(info['binary'],'rb').read()) IOError: [Errno 2] No such file or directory: 'c:\\users\\xxxx\\appdata\\local\\temp/rusthon-test-bin'
ใใใฏใใณใณใใคใซๆg++ใซใฏrusthon-test-binใๅบๅใใใใใชใชใใทใงใณใๆธกใใฆใใใฎใซใWindows(ใฎg++)ใๅๆใซ.exeใไปใใใฎใงใใกใคใซใ่ฆใคใใใใชใใชใฃใฆใใใฎใๅๅ ใงใใ
ใชใฎใงใrusthon.pyใฎ1505่ก็ฎใซๆฌกใฎใใใซ่ฟฝ่จใใพใใ
elif 'binary' in info: info['binary'] = info['binary'] + '.exe' s.write(open(info['binary'],'rb').read())
ใใใงๆฌกใฎใใใซใใพใใใใพใใ
> python ../rusthon.py array_generics.md test.tar ========== g++ : compile main ========== g++ -O3 -fprofile-generate -march=native -mtune=native -Ic:\users\xxxx\appdata\local\temp -Wl,-rpath,/usr/local/lib/ -Wl,-rpath,./ c:\users\xxxx\appdata\local\temp/rusthon-c++-build.cpp -o c:\users\xxxx\appdata\local\temp\rusthon-test-bin -pthread -std=c++11 c:\users\xxxx\appdata\local\temp/rusthon-c++-build.cpp: In function 'std::string* __pointer__(std::string)': c:\users\xxxx\appdata\local\temp/rusthon-c++-build.cpp:54:38: warning: address of local variable 'ob' returned [-Wreturn-local-addr] std::string* __pointer__(std::string ob) { ^ saved build to: test.tar
ใใใงใงใใtarใใกใคใซใใปใฉใใพใใจใไธญใซrusthon-test-bin-source.cppใจใณใณใใคใซใใใrusthon-test-bin (.exeใชใ)ใใใใพใใ
cppใฏ300่ก่ฟใใฎใงใใใซใฏ่ผใใพใใใใ่ช่บซใฎ็ฎใง็ขบใใใฆใฟใใ
ใปใใฎHello worldใตใณใใซ
ใปใใซใjavascriptใฎใในใใ
> python ../rusthon.py hello_javascript.md ../rusthon.py:940: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal 'staticlib' : nuitka_compile( nsrc, nuitka_module_name ),
ใใใจ็ช็ถใใฉใฆใถใ็ซใกไธใใใพใใใใใใฆclickmeใจๆธใใใใใฟใณใใ ๆผใใจ"hi"ใจใ ใๆธใใใใขใฉใผใใๅบใพใใใ
ไปๅบฆใฏpythonใณใผใใใๅ็จฎ่จ่ชใธใฎๅคๆใ
> python ../rusthon.py helloworld.py --javascript hello world > python ../rusthon.py helloworld.py --c++ hello world > python ../rusthon.py helloworld.py --go WARNING: could not find go compiler only a single translation pass was performed (the generated code may not compile) > python ../rusthon.py helloworld.py --rust Traceback (most recent call last): File "../rusthon.py", line 1951, in <module> main() File "../rusthon.py", line 1725, in main package = build(modules, base_path, datadirs=datadirs ) File "../rusthon.py", line 830, in build rustcode = translate_to_rust( pyjs ) File "<string>", line 14220, in translate_to_rust RuntimeError: rustc not found in /usr/local/bin
Goใจrustใฏใคใณในใใผใซใใฆใชใใฎใงใใจใฉใผใๅบใพใใใ
pythonใฎ่ฆใจใใใใๆจๆบใขใธใฅใผใซใงใใใctypesใฏjavascriptๅฎ่กๆใซใจใฉใผใrandomใฏ
RuntimeError: can not find rapydscript stdlib source: /lib/node_modules/rapydscript/src/lib/random.pyj
ใใฏใinstall-dev.shใไฝฟใฃใฆใฎใคใณในใใผใซใใใLinuxใงใชใใจไฝฟใใใชใใฎใฏ้ฃใใใใใงใใ
ใใจใชใใjavascriptใใใฎใพใพๆธใใใcoffeescriptใไฝฟใใใจๆใใพใใใ
for i in range(1, 101): print (((i%3 == 0)and "fizz" or "") + ((i%5 == 0) and "buzz" or "")) or i
ใฟใใชๅคงๅฅฝใ1่กfizzbuzzใ
python /path/to/rusthon.py fizzbuzz_oneline.py fizzbuzz_oneline.tar
ใจใใฆ็ๆใใใjavascriptใฎไธญ่บซใ่ฆใใจใ
var __$UID$__=0; /*for var in range*/; var i; i = (1 - 1); while (++i < 101) { console.log(((((((i % 3)) === 0 && "fizz") || "") + ((((i % 5)) === 0 && "buzz") || "")) || i)); }
nodeใซๆธกใใฆใใใฐใใกใใใจๅใใพใใ
for i in [f(x) for x in range(100)]: print i
ใฟใใใชใใจใใใใจใไธญใฎrange็จใฎใซใผใๅคๆฐใใใฐใฃใฆx = 0ใฎๆใใ่ฉไพกใใใพใใใงใใใ
ใชใC++ใธใฎๅคๆใฏๅคฑๆใใพใใใ