Recently, I talked to a friend about some of the features of the programming language. his remarks made me think a little bit: "REPL is not a waste ". Of course, this point of view is a bit radical, but we can explore which programming languages support REPL, which do not support it, and some REPL overview. In general scripting languages, REPL is the norm, because REPL is very convenient.
Recently, I talked to a friend about some of the features of the programming language. his remarks made me think a little bit: "REPL is not a waste ". Of course, this point of view is a bit radical, but we can explore which programming languages support REPL, which do not support it, and some REPL overview.
In general scripting languages, REPL is the norm, because REPL is very convenient. Programming term REPL (Read-Eval-Print Loop) can be translated into "interactive interpreter" or "interactive programming environment. However, I don't think it is enough to translate the REPL directly. this term is more difficult for readers to understand after being translated into Chinese. The following is an explanation of REPL:
A Read-Eval-Print-Loop (REPL) is available both as a standalone program and easily includable in other programs. REPL provides a way to interactively run JavaScript and see the results. it can be used for debugging, testing, or just trying things out.
The interactive interpreter (REPL) can be used as an independent program or easily included in other programs as part of the overall program. REPL provides an interactive way to run JavaScript scripts and view running results. generally, REPL interactive methods can be used for debugging, testing, and experimenting with certain ideas.
Below are some common programming languages that provide native support for REPL:
- The native has the REPL language.
- Common Lisp
- Ruby
- Python
- Lua
- Native language without REPL
- JavaScript
- PHP
- JAVA
- C #
- C ++
- Haxe
The native has the REPL language.
1. Common Lisp
General Common Lisp implementations all have REPL, such as Clozure CL for Mac, which even has the version of Mac App Store.
2. Ruby
The official implementation involves REPL, but the command is irb, which means Interactive Ruby Shell instead of ruby. The exit () and quit () commands can all exit. At the same time, there is also a webpage version of tryruby (and it is also an online tutorial of ruby). If you are interested, please take a look.
3. Python
The official implementation of the REPL command directly uses the python command to enter the REPL environment without parameters and exit with exit.
4. Lua
Use the lua command to implement REPL.
Native language without REPL
1. JavaScript
A script language similar to JavaScript should have REPL, But JavaScript is a language generally run in a browser, so it is special. However, some implementations, such as Mozilla's Rhino, can be implemented by Google.
In addition, I recommend using the recently popular node. js for REPL, although node. js is generally considered as a server-side script environment, but it is a very good REPL environment. It also comes with some common javascript library environments and supports npm, it is more powerful than Rhnio. In Mac, the node. js method is simply brew, although the version may be somewhat old.
2. PHP
PHP, as a common scripting language on the server, is designed as an apache mod language, so it does not contain REPL. although it should be of its language type, but does Facebook implement a php repl for us? Phpsh. Interestingly, this implementation was actually installed using Python...
3. JAVA
JAVA, as a traditional static language, does not have a REPL environment, but BeanShell exists.
After downloading BeanShell, place the. jar file in the library directory that can be found in JAVA, such ~ /Library/Java/Extension directory, run the command java bsh. Interpreter, and exit with the exit () command.
Generally, alias ijava = 'Java bsh. interpreter' is used in. bash_profile to simplify it into ijava commands.
Some people also recommend Closure ,? Groovy ,? Scala and other jvm language environments with REPL (generally compatible with JAVA) for REPL. it has never been tried and is not evaluated.
4. C #
It is said that there will be officially implemented REPL in the future. At present, there are some third-party implementations, such as Mono's built-in REPL. After installing Mono, run the csharp command to enter the REPL of C.
5. C ++
Cling, which has a Mac version for direct download, but the running method is a bit strange, that is, running in the decompressed directory. /bin/root (running in the bin directory does not work). you must first install the X environment under the Mac XQuartz and exit with exit.
It is a surprise to find that C ++ can have REPL, although C ++ is not a language suitable for REPL in essence. Cling, the REPL, cannot even easily define a function.
6. Haxe
Ihx, which can be directly installed through haxelib install ihx and then run through haxelib run ihx. There is also a webpage running version http://try.haxe.org/, in ~ /. Add alias ihx = 'haxelib run ihx 'to the bash_profile and execute ihx to access the REPL of Haxe.
Others
Repl. it
I don't know how to classify it ,? Repl. it itself supports multiple languages and runs on web pages. although it seems that some versions are relatively old (such as Ruby or 1.8.x), they can be used as web services and support multiple languages, saving time. the supported languages are as follows:
- Classic)
- QBasic: Structured programming for beginners.
- Forth: An interactive stack-oriented language.
- Practical language (Practical)
- Ruby (beta): A natural dynamic object-oriented language.
- Python: A dynamic language emphasizing readability.
- Lua: A lightweight multi-paradigm scripting language.
- Scheme: An elegant dynamic dialect of Lisp.
- Strange Language (Esoteric)
- Emoticon: Programming with an extra dose of smile.
- Brainfuck: A pure Turing machine controller.
- LOLCODE: The basic language of lolcats.
- Unlambda: Functional purity given form.
- Bloop: Nothing but bounded loops.
- Web language (Web)
- JavaScript: The de facto language of the Web.
- Javascript. next: The JavaScript of tomorrow.
- Move: The easy way to program the web.
- Kaffeine: Extended JavaScript for pros.
- CoffeeScript: Unfancy JavaScript.
- Roy: Small functional language that compiles to JavaScript.
Codepad
Codepad is not a REPL, but it allows you to run many languages on the webpage without installing any compiler, so it is sometimes quite convenient. Especially when you want to give some simple code snippets so that others can quickly get the results. Codepad automatically generates an address, which you can share directly, such as the Python fragment. anyone clicking submit can quickly see the results. this method of sharing code snippets is more advanced than snipplr and github gist.
The supported languages are as follows:
- C
- C ++
- D
- Haskell
- Lua
- OCaml
- PHP
- Perl
- Plain Text
- Python
- Ruby
- Scheme
- Tcl
WIKI list
WIKI list is also quite detailed: http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop
Address of this article: http://www.nowamagic.net/librarys/veda/detail/2462,welcome.