CJIT - C, Just In Time! (dyne.org) 28
Long-time Slashdot reader jaromil writes:
As a fun project, we hacked together a C interpreter (based on Tiny C Compiler) that compiles C code in-memory and runs it live.
CJIT today is a 2MB executable that can do a lot, including call functions from any installed library on Linux, Windows, and MacOSX.
Slashdot reader oliwer points out "they are also including a REPL, which could be interesting." And the CJIT web page promises there's "no EULA to sign, no IDE to install... 100% Free and open source!"
It also says the project was inspired by Terry Davis (TempleOS) and Fabrice Bellard (Tiny C Compiler).
CJIT today is a 2MB executable that can do a lot, including call functions from any installed library on Linux, Windows, and MacOSX.
Slashdot reader oliwer points out "they are also including a REPL, which could be interesting." And the CJIT web page promises there's "no EULA to sign, no IDE to install... 100% Free and open source!"
It also says the project was inspired by Terry Davis (TempleOS) and Fabrice Bellard (Tiny C Compiler).
My favourite (Score:4, Funny)
Re: (Score:3)
C interpreters aren't new.
I first used one back in the 1980s.
They don't work very well. C isn't designed to be an interpreted language.
Re: My favourite (Score:2)
It's compiled "in-memory." It is not "interpreted" per se.
Re: My favourite (Score:4, Insightful)
It's compiled "in-memory." It is not "interpreted" per se.
The problem is that small changes, such as tweaking a header file, can have global effects.
So, incremental compilation doesn't work very well.
You can kinda sorta make it work most of the time but with lots of limitations.
Languages designed for interpretation, such as Python, or for incremental compilation, such as Java, don't have the same problems (although they have different problems).
Re: (Score:2)
But t's value-add is presumably interactive development because it is used like an interpreter. It's a modified interpreter with better performance, something of value to no one these days.
Re: My favourite (Score:1)
Re: (Score:3)
Many interpreted languages are compiled in memory. Python, for example, isn't executed line by line, but compiled for a virtual machine bytecode and that bytecode is executed.
But it's still considered an interpreted language because you just run the code directly even though there's an implicit compile and link step that happens when you run the code.
It's a very fine distinction these days
Re: (Score:3)
We often use the term 'compile' informally to refer to programs that translate programs to a machine code, but, strictly speaking, a compiler is a program that translates a program written in one language into another. An interpreted language that didn't use some intermediate representation would be very odd. The only one I could come up with off-hand was Lisp, but it seems silly to draw a distinction on that basis when all we could say is "we have compiled languages and an interpreted language called Lis
Re: (Score:2)
Even those old BASIC interpreters in ROM on your home micro used an intermediate form, generated as you typed, to save memory and improve performance.
I wouldn't call that either compiling or interpreting. That's front-end lexical analysis and parsing, which for BASIC was not exactly a conventional parse tree, but close. It remained in memory, and that's what was read when you typed RUN. I'd have to fire up my old Apple ][ to be able to tell you for certain what the on-disk format of a saved BASIC program looked like, but it was probably stored in some hybrid of the tokenized format plus the REM comments. (I probably knew the answer to that 45 years ago.)
Re: (Score:3)
I wouldn't call that either ...
That's my whole point, really. It's silly to try to draw a hard line. The claim that there is "a very fine distinction" is equally silly, for the same reasons.
The rest of this is wildly off-topic, but I feel compelled to reply anyway:
not exactly a conventional parse tree, but close
Not even remotely close, as it happens. Quite a few, at least of those I'm familiar with, were little more than a tokenization, not even bothering to do so much as evaluating constant expressions or converting infix expressions to postfix, I assume to simplify the conversion
Re: (Score:3)
Re: (Score:2)
Would you consider typescript a compiler since it converts it to javascript?
Re:My favourite (Score:4, Funny)
The hair on all the Java people's backs just went up and now they're hissing at you.
Re: (Score:2)
C is the worst language available, except for all others that have been tried.
Well, not quite. But essentially all programming languages suck. The right tool for the right task makes them suck a bit less and for many tasks, C is it.
Re:My favourite (Score:5, Informative)
all programming languages suck.
"There are only two kinds of languages: the ones people complain about and the ones nobody uses." -- Bjarne Stroustrup
Re:My favourite (Score:5, Funny)
There are only 10 kinds of computer languages: those that write numbers in binary, those that don't, and those with off-by-one errors.
("there's two hard problems in computer science: we only have one joke and it's not funny." - Phillip Bowden [x.com])
Gimple c-terp anyone? (Score:1)
2MB? (Score:2)
Flappy Bird is bigger than that...
Anyway, great job! It's fun to see news about a good old-fashioned "we did it because we could" open-source nerd project.
Dr. Dobb's 1989 (Score:5, Informative)
Re: (Score:2)
Ah, good old Dr. Dobb's. I do miss that magazine!
Run/C from 1985 still works too. (Score:3)
Javascript? (Score:3)
Where is the Javascript version so it can run in the browser window?
Re: Javascript? (Score:3)
It's somewhere. I believe it's an emergent property of a sufficiently large number of GET requests to jquery.org.
Tiny C.. (Score:3)
Damn... (Score:2)
I could have used this when I was writing a lot of C...