← Back to team overview

ooc-dev team mailing list archive

Re: Fwd: OOC best practices

 

>         try
>         to program a Java to ooc translator (just to have some fun
>         trying to
>         port SWT to ooc language, like it was done with D) 
> 
> 
> That would be interesting - they really did it that way with D? Seems
> quite complicated. (Especially since the foreign interfaces of D/Java
> look different)
>         
In fact there were two or three different approaches to SWT in D. Java
translator was one of them. The problem with that approach is
translating semantics and libraries. Translating syntax can be automated
within relative ease, but whe you find something like:

StringBuilder s = new StringBuilder("foo"); s.add("bar");

You must change the type and it's methods in target language, so it
adheres to existing ones (in ooc you would declare a String type and
accumulate more strings into it with the appropiate method)... or else,
you create a compatibility layer, by adding types similar to those of
Java (implementing the interface part you are interested on) and making
their implementations employ target language's types (something like a
Bridge Pattern). A project that takes this approach is, at some extent,
is ikvm.net (although it implements jvm on .net runtime, some parts of
it are translated for the sake of efficiency).

Of course it's a hard hard work, but think on the benefits: by
translating java.lang functions, you could progresively incorporate java
libs into ooc (think on iText, hibernate or log4j). 

>          -- this is a comment 

> 
> Well - even though they look nice, why add them since we already have
> '//' ?

Of course. I read some discussion about one line comments previously and
I stated my preference here. Actually, I'm mainly a C# programmer,  so
'//' look just right for my eyes. 
>         
>         Sharp as macros are not (in my opinion) a good idea. ... 
> 
> That's true but it would be potentially easier to read/to understand
> like "what is it he's calling here? is it a function? a macro?"
> 
I don't believe that's a real problem. The great about macros (and just
to be sure about what's the topic here, I'm thinking in macros like in
scheme with higyene and all) is that you can forget about what they are
most of the time. That's not true with C #defines, where you must be
careful not to catch some variable, not to generate wrong syntax code). 
> 
> Yeah I'm not sure about pragmas - what would they really be used for?
> I mean, most settings can be controlled with compiler command-line
> flags, so.. I don't know.
> 
Of course, pragmas should not be used instead of compiler commands. It's
nonsense to think they're going to replace them. But think the useful it
would be to disable a warning in a point of the code, changing the byte
packing size on a single structure or even declaring directives for C
compiler (like if it should do C, pascal or stdcall calling styles on a
function)
> 

Greetings

> P.S: Hit 'Reply All' next time, your answer was only sent to me. 
> 
I'll try not to forget it, thank you.





Follow ups

References