interpreter

Compiler Vs Interpreter Vs Transpiler

穿精又带淫゛_ 提交于 2019-12-03 03:30:31
问题 During a reactJs session that I was attending, the presenter used a term transpiler for some code conversion/porting happening. I've always used and heard the terms compiler and interpreter when it comes to converting a language code to a runnable form on a computer system/machine. Transpiler is completely new to me. Can someone help me to understand how a Transpiler is different from a compiler or an interpreter and why it is really needed? 回答1: As is mentioned in this Wiki article, it is a

Why does the Interpreter Pattern suck?

百般思念 提交于 2019-12-03 03:13:08
In Steve Yegge's review of Design Patterns , he calls the Interpreter Pattern an "in-joke". He goes on to talk about how the perception of compilers have changed, yet how interpreted languages are still s*** on, although I can't see how this ties into the pattern. Anyone want to enlighten this ignorant student? vava That was irony :) Everybody loves interpreted languages nowadays but 10 years earlier people just thought they are too slow for anything practical. Much like today most of people thinks about static vs. dynamic typing. The INTERPRETER pattern sucks because it's a codification of

Measure and Benchmark Time for Ruby Methods

放肆的年华 提交于 2019-12-03 03:05:00
问题 How can i measure the time taken by a method and the individual statements in that method in Ruby. If you see the below method i want to measure the total time taken by the method and the time taken for database access and redis access. I do not want to write Benchmark.measure before every statement. Does the ruby interpreter gives us any hooks for doing this ? def foo # code to access database # code to access redis. end 回答1: You could use the Time object. (Time Docs) For example, start =

What does PyPy have to offer over CPython, Jython, and IronPython?

百般思念 提交于 2019-12-03 02:42:37
问题 From what I have seen and read on blogs, PyPy is a very ambitious project. What are some advantages it will bring to the table over its siblings (CPython, Jython, and IronPython)? Is it speed, cross-platform compatibility (including mobile platforms), the ability to use c-extensions without the GIL, or is this more of a technical exercise on what can be done? 回答1: PyPy is really two projects: An interpreter compiler toolchain allowing you to write interpreters in RPython (a static subset of

Compiling and using Groovy classes from Java at runtime?

佐手、 提交于 2019-12-03 02:39:12
I have an app which I'd like to make extensible by letting users define classes in Groovy, eventually implementing some interfaces. The key aspect is that it should be interpreted/compiled at runtime. I.e. I need my app to take the .groovy and compile it. Doing it during boot is ok. Then, of course, my app should be able to instantiate that class. I see two solutions: 1) Compile while the app runs, put the classes somewhere on classpath, and then just load the classes, pretending they were always there. 2) Some smarter way - calling a compiler API and some classloading magic to let my system

How would I go about writing an interpreter in C? [closed]

蓝咒 提交于 2019-12-03 02:10:48
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I'd love some references, or tips, possibly an e-book or two. I'm not looking to write a compiler, just looking for a tutorial I could follow along and modify as I go. Thank you for being understanding! BTW: It must be C. Any more replies would be appreciated. 回答1: A great way to

JIT code generation techniques

蓝咒 提交于 2019-12-03 01:37:16
How does a virtual machine generate native machine code on the fly and execute it? Assuming you can figure out what are the native machine op-codes you want to emit, how do you go about actually running it? Is it something as hacky as mapping the mnemonic instructions to binary codes, stuffing it into an char* pointer and casting it as a function and executing? Or would you generate a temporary shared library (.dll or .so or whatever) and load it into memory using standard functions like LoadLibrary ? You can just make the program counter point to the code you want to execute. Remember that

How to call the scala interpreter in a Simple Build Tool project?

被刻印的时光 ゝ 提交于 2019-12-03 01:29:26
my scala program is using the compiler interface from scala.tools.nsc.interpreter.IMain. When I am compiling with scalac, everything works as expected. But when I compile with sbt it still compiles, but on execution it throws the following error message in the call of the interpret-method from the IMain instance: Failed to initialize compiler: object scala not found. ** Note that as of 2.8 scala does not assume use of the java classpath. ** For the old behavior pass -usejavacp to scala, or if using a Settings ** object programatically, settings.usejavacp.value = true. If I use settings

Access the Abstract Syntax Tree of V8 Engine

自闭症网瘾萝莉.ら 提交于 2019-12-03 00:21:22
Is it possible to access the AST of the v8 engine, for a given JavaScript code? I'm working on a JavaScript Static Analyzer using V8 engine. This is pretty old but maybe the answer helps someone stumbling upon this. The answer is yes, assuming you are willing to modify V8 and compile your own version of it. If so, then in compiler.cc you find a spot where MakeCode is called throughout MakeFunctionInfo which transforms the AST that is stored in the passed in CompilationInfo object into native code. You need to write a class that inherits from AstVisitor then you can inspect the AST by inserting

Detecting infinite loop in brainfuck program

给你一囗甜甜゛ 提交于 2019-12-02 23:54:54
I have written a simple brainfuck interpreter in MATLAB script language. It is fed random bf programs to execute (as part of a genetic algorithm project). The problem I face is, the program turns out to have an infinite loop in a sizeable number of cases, and hence the GA gets stuck at the point. So, I need a mechanism to detect infinite loops and avoid executing that code in bf. One obvious (trivial) case is when I have [] I can detect this and refuse to run that program. For the non-trivial cases, I figured out that the basic idea is: to determine how one iteration of the loop changes the