Compilation vs Interpretation 
Author Message
 Compilation vs Interpretation

Does anyone have an opinion as to whether or not it is appropriate to
use dynamic compilation in a deployed application. That is, deploy
your application with the compiler classes that are used to convert
strings of text entered by users into compiled code.

Example: I need to write an application that includes filtering or
testing. The filtering consists of complex boolean logic.
I have three options (that I can think of):

        1. Devise a custom script language and interpret it at runtime

        2. Allow users to write Smalltalk code that gets compiled
           and executed (i.e a block)

        3. Take my custom script language and convert it into
           Smalltalk code that is then compiled and executed.

The followings are the points that I can see with the three options:

1.      Obviously it is more work and will perform more slowly.
        I will have to build a parser and a scheme to 'run' the
        resulting objects.

        It does not require the compiler classes and is thus safe.

2.      This is the least amount of work but it could be dangerous
        as it opens up the system. However, I believe the users will
        not have the knowledge to do any harm. It may also be the
        most powerful where extremely compilcated processing may be
        initiated by an expert (Smalltalk programmer) for specific
        needs.

3.      This seems like a good compromise, although the scripting
        language may not be powerful enough to do very complicated
        processing.

        But why build a custom language when you already have
        Smalltalk. From a syntactical perspective Smalltalk is easy
        to use (after all it was built to allow children
        to program).

        It would be nice to leverage the exisiting Smalltalk
        parser/compiler while ensuring no harm can be done.

Are there any 'patterns' that address this issue?

Thanks in advance.

Faisal Waris
Trecom Business System
Consultant at BellSouth Technologies
(205) 977-7985 (Sorry no email yet)



Tue, 07 Oct 1997 03:00:00 GMT  
 Compilation vs Interpretation
It's entirely possible - not the world's easiest job, but *possible* -
to protect the ObjectWorks image so that it's 'safe' - ie. the user
can only subclass, see, change or reference classes and methods that
you want them to.

I've done this as a contract for a company who deploy applications
written in Smalltalk that *need* the Compiler, Decompiler and De{*filter*}
available, but who don't want users to see or change some of their
code. This is probably a more complex requirement than you have.

I'm thinking of clean-room rewriting the code and marketing it
(at the moment, this company have rights over the code, so I'd have
to re-write it from scratch). Would anyone out there be interested in
such a system?

                - Peter
--
Peter Crowther, Medical Informatics Group, Dept. of Computer Science,
        University of Manchester, Manchester M13 9PL, England.

"Every day you're getting older, never seem to find the time.
Plans that either come to nought or half a page of scribbled lines."



Fri, 10 Oct 1997 03:00:00 GMT  
 Compilation vs Interpretation
I am having a similar problem and I chose to implement your option 3.

My problem: I want to read conditions while the application is running and test these
conditions subsequently.
My solution: I devised a limited set of expressions that allow a user to specify the conditions.
The expressions are parsed and generate string that is evaluated by the Compiler. This way
if someone writes 'self halt' it will not pass the interpretation and raise an error. By keeping it
as an evaluated string rather than a compiled method, I have the compilation step to check
for non-sense alterations of the code and do not blindly execute code from the data space.

I guess there is only so much you can do: if someone really tries to{*filter*}up, s/he should be
able to destroy her/his image.

Regards,

        Manfred

|> Does anyone have an opinion as to whether or not it is appropriate to
|> use dynamic compilation in a deployed application. That is, deploy
|> your application with the compiler classes that are used to convert
|> strings of text entered by users into compiled code.
|>
|> Example: I need to write an application that includes filtering or
|> testing. The filtering consists of complex boolean logic.
|> I have three options (that I can think of):
|>
|>   1. Devise a custom script language and interpret it at runtime
|>
|>   2. Allow users to write Smalltalk code that gets compiled
|>      and executed (i.e a block)
|>
|>   3. Take my custom script language and convert it into
|>      Smalltalk code that is then compiled and executed.
|>
|>   ------ stuff deleted --------
|>
|> Are there any 'patterns' that address this issue?
|>
|>
|> Thanks in advance.
|>
|>
|> Faisal Waris
|> Trecom Business System
|> Consultant at BellSouth Technologies
|> (205) 977-7985 (Sorry no email yet)
|>



Fri, 10 Oct 1997 03:00:00 GMT  
 Compilation vs Interpretation


Quote:
>I am having a similar problem and I chose to implement your option 3.

>My problem: I want to read conditions while the application is running and test these
>conditions subsequently.
>My solution: I devised a limited set of expressions that allow a user to specify the conditions.
>The expressions are parsed and generate string that is evaluated by the Compiler. This way
>if someone writes 'self halt' it will not pass the interpretation and raise an error. By keeping it
>as an evaluated string rather than a compiled method, I have the compilation step to check
>for non-sense alterations of the code and do not blindly execute code from the data space.

One problem with this is that most dialects of Smalltalk remove the
compiler from packaged applications.  This makes it very difficult to
deploy your application.

If what you want is a simple expression evaluation (i.e., unary,
binary, and keyword messages with parentheses and a handful of simple
literals), it's relatively easy to write a recursive descent parser to
create a parse tree that can then be evaluated.  I wrote such a parser
in one evening recently.  If you need blocks, loops, conditionals,
etc, then things get more complicated.

David Buck

_________________________________
| David K. Buck                 |

| The Object People             |
|_______________________________|



Sat, 11 Oct 1997 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Compilation vs. Interpretation

2. HW compilation vs SW compilation

3. RFI: compilation semantics in interpretation state

4. Articles about Prolog's compilation/interpretation

5. Arbitrary combinations of compilation and interpretation semantics: Implementation

6. RFI: different routines for compilation & interpretation

7. immediate vs. compilation semantics

8. conditional compilation (was C++ vs Modula-2)

9. Filenames vs Compilation Names

10. Filenames vs Compilation Unit Names

11. f95 vs. F compilation question

12. Special compilation action for defalut compilation sematics

 

 
Powered by phpBB® Forum Software