Login  Register

Re: Compiling Pharo to C++

Posted by kilon.alios on Feb 16, 2016; 2:02pm
URL: https://forum.world.st/Compiling-Pharo-to-C-tp4877775p4877898.html

"Then I guess you can do something like Slang, which is used for the VM. Slang is a restrictive Smalltalk compiling to C. "

I dont think Slang is close to what I am trying to do, last time I checked Slang out it appeared to me that Slang is trying to create as much smalltalk syntax as possible. My goal is the other way around to create C++ code by sticking as close to C++ syntax as possible but still using syntax that will make porting pharo code easier.

"
The slang compiler parses the code using the Smalltalk Compiler parser, then translate the Smalltalk AST to its own AST, "

Yeap thats the approach I am interested into as well. Take the Smalltalk AST and translate to an AST very close to C++. I am not interested into creating an in between language.

"I am not saying that slang is a nice language and that you should do something similar. Slang is horrible. "

Why Slang is horrible according to you ?

"But in the case of the VM is has some significant advantages over C++ and method templates."

Indeed the VM is awesome but as I said my main goal is not to keep the pharo features but rather to produce very readable C++ code. So I have little problem sacrificing those features.

I probably end up making my own variant of the Pharo language that can happily coexist with the existing pharo language.

"Not entirely true [1]....
[1] https://forums.unrealengine.com/showthread.php?3958-Scripting-Language-extensions-via-plugins
"

Still Pharo is no Lua and it cannot embed itself. What I meant was that its not actively supported. Also its not that simple because one has to expose C++ to the scripting language. I rather have something that produces C++ and I can easily integrate. Or maybe there is something I am missing here and its far easier than I assume.  Even without your link embeding lua and python in existing C++ executable is not that hard. Those language offer good support for this and they are heavily used for this task.

I also spoke with Esteban about embedding pharo and he told me that pharo has a long way to go before it is able to do this.

So for the time being I will start playing around with the Pharo AST and see if I can start generate super simple C++ code out of it and see how hard really it is and move step by step, thank you all for the suggestions.