[clean-list] Dynamic typing for communication with non-cleanprograms

Groenouwe, C. c.groenouwe at vu.nl
Wed Nov 30 16:06:46 MET 2011


Dear Pieter,

This sounds as what I was looking for (but I'll keep the good tip of
Erik and Bas in mind if I have to exchange more OO oriented messages,
which I undoubtedly going to do in the near future...) Going to
experiment with generics then!

However, where can I find this slightly extended TCP interface from
Clean (and is it also available for linux?), you say it is in the
distribution, but in what file (there are quite some TCP related files
in the lib directory). Moreover, it would be great if you have an
example application showing such a test.

________________________________
Van: clean-list-bounces at science.ru.nl [clean-list-bounces at science.ru.nl] namens Pieter Koopman [pieter at cs.ru.nl]
Verzonden: maandag 21 november 2011 16:05
Aan: clean-list at science.ru.nl
Onderwerp: Re: [clean-list] Dynamic typing for communication with non-cleanprograms

Dear Chide,

In order to test programs written in Java with Gast I use a slightly extended TCP interface from Clean. There is a TCP interface in distribution (or rather two of them). The messages are arbitrary data types that are encode en decode on the Clean side by some generic functions. On the Java side the user has to do some work on encoding decoding manually. This works fine for the rather simple messages used by Gast..

Maybe the JSON stuff works even better since there is a better interface on the Java side. On the Clean side there is also a generic interface, you can just derive the needed conversions. I have no experience with this JSON library (apart from using it in iTasks).

Dynamics would not be my choice since they contain unevaluated Clean expressions and (references to) Clean code. You would need too much machinery to handle this in any other language.

Best, Pieter

On 21/11/2011 3:02 PM, Bas Lijnse wrote:
The JSON libraries that Erik mentions are available from:
https://svn.cs.ru.nl/repos/clean-platform/trunk/src/libraries/OS-Independent/Text/

I always use this when I want to do simple data exchange between Clean and another language (I may be biased as author/maintainer of the library though :) )

Best,
Bas

On 21-11-11 14:52, zuurb078 at planet.nl<mailto:zuurb078 at planet.nl> wrote:

And dump all the hard work on Java? Dynamics are a proprietary Clean format and likely more complex/liberal than you need. Maybe JSON is easier to use: probably available in your JAVA implementation already and under the hood JSON converters are already available in Clean iTasks.


-----Oorspronkelijk bericht-----
Van: clean-list-bounces at science.ru.nl<mailto:clean-list-bounces at science.ru.nl> namens Groenouwe, C.
Verzonden: ma 21-11-2011 13:39
Aan: pieter at cs.ru.nl<mailto:pieter at cs.ru.nl>
CC: clean-list at science.ru.nl<mailto:clean-list at science.ru.nl>
Onderwerp: [clean-list] Dynamic typing for communication with non-cleanprograms

Dear Pieter (and others),

Then another question:

If you want to send information from one programming language (e.g. Java) to Clean, a typical way to go would be the following. First define an intermediate representation (for example in XML, or your own format). Then write a generator on the sender's side (in this case in Java), which converts a Java value or object into a file in the intermediate representation. Finally, write a parser on the receiver's side (Clean) which parses file holding the intermediate representation into a Clean value (with a Clean type). This is a labourious process during which you have the feeling you are are doing a lot of unnecessary work. As if you are repackaging the same sandwich three times in a row, first in a Java structure, then in the intermediate structure, and then again in a Clean structure... Waste of time (and the environment...) ;-)

However, I had an idea: is it possible to use Clean's dynamic types for this purpose? Instead of generating some arbitrary intermediate type on the sender's side, immediately generate a value that can be read by Clean's dynamic type system. This would cut your work in half: you don't have to write a parser on Clean's side any more.

I don't have any experience using Clean's dynamic typing yet, therefore I decided to first ask whether it is a fruitful approach before exploring it. Thus, is this possible and is it a good idea? Of course, I'm also open to other suggestions.

Thanks in advance,

Chide







_______________________________________________
clean-list mailing list
clean-list at science.ru.nl<mailto:clean-list at science.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/clean-list





_______________________________________________
clean-list mailing list
clean-list at science.ru.nl<mailto:clean-list at science.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/clean-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/clean-list/attachments/20111130/3fb743ce/attachment.html>


More information about the clean-list mailing list