[scala] F# code

View: New views
13 Messages — Rating Filter:   Alert me  

[scala] F# code

by SALEH AL-SHADLY :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear all,

how can I use codes of other languages (such F#) in Scala?

Saleh

Re: [scala] F# code

by Ricky Clarkson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You cannot.  Scala only implements the Scala programming language, not F#.

2009/7/7 SALEH AL-SHADLY <alshadly09@...>:
> Dear all,
>
> how can I use codes of other languages (such F#) in Scala?
>
> Saleh
>



--
Ricky Clarkson
Java Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...

Re: [scala] F# code

by Onorio Catenacci :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Tue, Jul 7, 2009 at 4:11 AM, Ricky Clarkson <ricky.clarkson@...> wrote:
You cannot.  Scala only implements the Scala programming language, not F#.

2009/7/7 SALEH AL-SHADLY <alshadly09@...>:
> Dear all,
>
> how can I use codes of other languages (such F#) in Scala?
>
> Saleh
>



--
Ricky Clarkson
Java Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...

You can't directly but it would be possible (as far as I know) to create a F# COM object and then use something like Jacob to call the COM object from Scala code.  But it'd be kind of a hack so I'd really think long and hard about the necessity to code part of the solution in F#.  If part of your solution is already coded in F#, then that might be a way for you to reuse the code but, as I said, I'd really have to give such a solution a lot of thought before I went that way.  And, of course, using COM ties you to Windows if that's a consideration.


--
Onorio

It is the greatest of all mistakes to do nothing because you can only do a little. -Sydney Smith, writer and clergyman (1771-1845)


Re: [scala] F# code

by Ricky Clarkson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Or you could do it directly by using the Scala .NET distribution.  I
don't know if Scala.NET and F# can actually run on the same version of
.NET as each other though (Scala.NET won't work past .NET 1.0, afaik,
and F# is so new it probably won't work on something that old).

2009/7/7 Onorio Catenacci <Catenacci@...>:

>
>
> On Tue, Jul 7, 2009 at 4:11 AM, Ricky Clarkson <ricky.clarkson@...>
> wrote:
>>
>> You cannot.  Scala only implements the Scala programming language, not F#.
>>
>> 2009/7/7 SALEH AL-SHADLY <alshadly09@...>:
>> > Dear all,
>> >
>> > how can I use codes of other languages (such F#) in Scala?
>> >
>> > Saleh
>> >
>>
>>
>>
>> --
>> Ricky Clarkson
>> Java Programmer, AD Holdings
>> +44 1565 770804
>> Skype: ricky_clarkson
>> Google Talk: ricky.clarkson@...
>
> You can't directly but it would be possible (as far as I know) to create a
> F# COM object and then use something like Jacob to call the COM object from
> Scala code.  But it'd be kind of a hack so I'd really think long and hard
> about the necessity to code part of the solution in F#.  If part of your
> solution is already coded in F#, then that might be a way for you to reuse
> the code but, as I said, I'd really have to give such a solution a lot of
> thought before I went that way.  And, of course, using COM ties you to
> Windows if that's a consideration.
>
>
> --
> Onorio
>
> It is the greatest of all mistakes to do nothing because you can only do a
> little. -Sydney Smith, writer and clergyman (1771-1845)
>
>



--
Ricky Clarkson
Java Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...

Re: [scala] F# code

by Kevin Wright-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

How about SOAP?

(quickly ducking...)


On Tue, Jul 7, 2009 at 10:29 AM, Ricky Clarkson <ricky.clarkson@...> wrote:
Or you could do it directly by using the Scala .NET distribution.  I
don't know if Scala.NET and F# can actually run on the same version of
.NET as each other though (Scala.NET won't work past .NET 1.0, afaik,
and F# is so new it probably won't work on something that old).

2009/7/7 Onorio Catenacci <Catenacci@...>:
>
>
> On Tue, Jul 7, 2009 at 4:11 AM, Ricky Clarkson <ricky.clarkson@...>
> wrote:
>>
>> You cannot.  Scala only implements the Scala programming language, not F#.
>>
>> 2009/7/7 SALEH AL-SHADLY <alshadly09@...>:
>> > Dear all,
>> >
>> > how can I use codes of other languages (such F#) in Scala?
>> >
>> > Saleh
>> >
>>
>>
>>
>> --
>> Ricky Clarkson
>> Java Programmer, AD Holdings
>> +44 1565 770804
>> Skype: ricky_clarkson
>> Google Talk: ricky.clarkson@...
>
> You can't directly but it would be possible (as far as I know) to create a
> F# COM object and then use something like Jacob to call the COM object from
> Scala code.  But it'd be kind of a hack so I'd really think long and hard
> about the necessity to code part of the solution in F#.  If part of your
> solution is already coded in F#, then that might be a way for you to reuse
> the code but, as I said, I'd really have to give such a solution a lot of
> thought before I went that way.  And, of course, using COM ties you to
> Windows if that's a consideration.
>
>
> --
> Onorio
>
> It is the greatest of all mistakes to do nothing because you can only do a
> little. -Sydney Smith, writer and clergyman (1771-1845)
>
>



--
Ricky Clarkson
Java Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...


Re: [scala] F# code

by Michael Songy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You could use JNI to call into a native library, and use .NET interop in that native library to call back into your F# code.  It makes me queasy just thinking about it, but you should be able to do it.

-Mike

Onorio Catenacci wrote:


On Tue, Jul 7, 2009 at 4:11 AM, Ricky Clarkson <ricky.clarkson@...> wrote:
You cannot.  Scala only implements the Scala programming language, not F#.

2009/7/7 SALEH AL-SHADLY <alshadly09@...>:
> Dear all,
>
> how can I use codes of other languages (such F#) in Scala?
>
> Saleh
>



--
Ricky Clarkson
Java Programmer, AD Holdings
+44 1565 770804
Skype: ricky_clarkson
Google Talk: ricky.clarkson@...

You can't directly but it would be possible (as far as I know) to create a F# COM object and then use something like Jacob to call the COM object from Scala code.  But it'd be kind of a hack so I'd really think long and hard about the necessity to code part of the solution in F#.  If part of your solution is already coded in F#, then that might be a way for you to reuse the code but, as I said, I'd really have to give such a solution a lot of thought before I went that way.  And, of course, using COM ties you to Windows if that's a consideration.


--
Onorio

It is the greatest of all mistakes to do nothing because you can only do a little. -Sydney Smith, writer and clergyman (1771-1845)



[scala] Re: F# code

by Jimmie Houchin-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

<snip>
> You can't directly but it would be possible (as far as I know) to create
> a F# COM object and then use something like Jacob to call the COM object
> from Scala code.  But it'd be kind of a hack so I'd really think long
> and hard about the necessity to code part of the solution in F#.  If
> part of your solution is already coded in F#, then that might be a way
> for you to reuse the code but, as I said, I'd really have to give such a
> solution a lot of thought before I went that way.  And, of course, using
> COM ties you to Windows if that's a consideration.

I am writing an app which requires interfacing with a commercial COM
library? I haven't gotten to that part of my Scala education yet. But
since it is mentioned here. How does one from Scala interface and use a
COM dll?  I just figured I would possibly or probably have use .NET and
an interop to interface the COM dll. If I could do it directly without
.NET, that would be even better.

Thanks for any insight and wisdom.

Jimmie


Re: [scala] Re: F# code

by Miles Sabin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jul 7, 2009 at 8:27 PM, Jimmie Houchin<jlhouchin@...> wrote:
> I am writing an app which requires interfacing with a commercial COM
> library? I haven't gotten to that part of my Scala education yet. But since
> it is mentioned here. How does one from Scala interface and use a COM dll?
>  I just figured I would possibly or probably have use .NET and an interop to
> interface the COM dll. If I could do it directly without .NET, that would be
> even better.

You could use a Java-COM bridge. JACOB,

  http://www.danadler.com/jacob/

is one that was mentioned earlier in the thread and there are many others.

It's a long time time since I looked at that sort of thing, but I
recall that the APIs were all very ugly and verbose. Is that still the
case? Would a generic COM wrapper written in Scala look any nicer than
one written in Java?

Cheers,


Miles

--
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin

[scala] Re: F# code

by Jimmie Houchin-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Miles Sabin wrote:
 > On Tue, Jul 7, 2009 at 8:27 PM, Jimmie Houchin<jlhouchin@...>
wrote:
 >> I am writing an app which requires interfacing with a commercial COM
 >> library? I haven't gotten to that part of my Scala education yet.
But since
 >> it is mentioned here. How does one from Scala interface and use a
COM dll?
 >>  I just figured I would possibly or probably have use .NET and an
interop to
 >> interface the COM dll. If I could do it directly without .NET, that
would be
 >> even better.
 >
 > You could use a Java-COM bridge. JACOB,
 >
 >   http://www.danadler.com/jacob/
 >
 > is one that was mentioned earlier in the thread and there are many
others.
 >
 > It's a long time time since I looked at that sort of thing, but I
 > recall that the APIs were all very ugly and verbose. Is that still the
 > case? Would a generic COM wrapper written in Scala look any nicer than
 > one written in Java?

Cool, thanks.

I saw the reference to JACOB but don't remember a link. I may have
missed it. Thanks for the link. It looks like it should do exactly what
I want.

I hope to not have to live in this situation for long. I hope to be in a
position to migrate to a completely Java/Scala solution soon.

Thanks.

Jimmie


Re: [scala] Re: F# code

by Johannes Rudolph-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jul 7, 2009 at 9:27 PM, Jimmie Houchin<jlhouchin@...> wrote:
> I am writing an app which requires interfacing with a commercial COM
> library? I haven't gotten to that part of my Scala education yet. But since
> it is mentioned here. How does one from Scala interface and use a COM dll?
>  I just figured I would possibly or probably have use .NET and an interop to
> interface the COM dll. If I could do it directly without .NET, that would be
> even better.

If the COM object supports IDispatch ("OLE Automation") you may use
Eclipse SWT to access it. Resulting code is quite verbose but it does
work well. Back in the times I wrote a wrapper generator, which could
generate Java wrapper classes for easy access from the metadata
retrieved with SWT from the OLE Automation metadata.

--
Johannes

-----------------------------------------------
Johannes Rudolph
http://virtual-void.net

RE: [scala] Re: F# code

by Ted Neward :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ping me off-list if you can't find an elegant solution to what you need;
I've been living and breathing the Java/.NET interop space for six years,
and I've been actively pursuing and writing/speaking about F# for two years.
;-)

Ted Neward
Java, .NET, XML Services
Consulting, Teaching, Speaking, Writing
http://www.tedneward.com

> -----Original Message-----
> From: news [mailto:news@...] On Behalf Of Jimmie Houchin
> Sent: Tuesday, July 07, 2009 1:50 PM
> To: scala@...
> Cc: scala@...
> Subject: [scala] Re: F# code
>
> Miles Sabin wrote:
>  > On Tue, Jul 7, 2009 at 8:27 PM, Jimmie Houchin<jlhouchin@...>
> wrote:
>  >> I am writing an app which requires interfacing with a commercial
> COM
>  >> library? I haven't gotten to that part of my Scala education yet.
> But since
>  >> it is mentioned here. How does one from Scala interface and use a
> COM dll?
>  >>  I just figured I would possibly or probably have use .NET and an
> interop to
>  >> interface the COM dll. If I could do it directly without .NET, that
> would be
>  >> even better.
>  >
>  > You could use a Java-COM bridge. JACOB,
>  >
>  >   http://www.danadler.com/jacob/
>  >
>  > is one that was mentioned earlier in the thread and there are many
> others.
>  >
>  > It's a long time time since I looked at that sort of thing, but I
>  > recall that the APIs were all very ugly and verbose. Is that still
> the
>  > case? Would a generic COM wrapper written in Scala look any nicer
> than
>  > one written in Java?
>
> Cool, thanks.
>
> I saw the reference to JACOB but don't remember a link. I may have
> missed it. Thanks for the link. It looks like it should do exactly what
> I want.
>
> I hope to not have to live in this situation for long. I hope to be in
> a
> position to migrate to a completely Java/Scala solution soon.
>
> Thanks.
>
> Jimmie


RE: [scala] F# code

by Ted Neward :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

F# requires generics, which means .NET 2.0 and beyond.

Scala-msil as far as I know has been deprecated and left to bit-rot. I wouldn't trust it as a viable solution.

To get F# and Scala to talk to one another you'd need something to bridge between the JVM and CLR.

Other languages will depend on their details; Haskell, example, could be reached through Scala -> JNI/JNA -> natively-bound Haskell functions/FFI. And so on.

Ted Neward
Java, .NET, XML Services
Consulting, Teaching, Speaking, Writing
http://www.tedneward.com

> -----Original Message-----
> From: Ricky Clarkson [mailto:ricky.clarkson@...]
> Sent: Tuesday, July 07, 2009 2:30 AM
> To: Onorio Catenacci
> Cc: SALEH AL-SHADLY; scala@...
> Subject: Re: [scala] F# code
>
> Or you could do it directly by using the Scala .NET distribution.  I
> don't know if Scala.NET and F# can actually run on the same version of
> .NET as each other though (Scala.NET won't work past .NET 1.0, afaik,
> and F# is so new it probably won't work on something that old).
>
> 2009/7/7 Onorio Catenacci <Catenacci@...>:
> >
> >
> > On Tue, Jul 7, 2009 at 4:11 AM, Ricky Clarkson
> <ricky.clarkson@...>
> > wrote:
> >>
> >> You cannot.  Scala only implements the Scala programming language,
> not F#.
> >>
> >> 2009/7/7 SALEH AL-SHADLY <alshadly09@...>:
> >> > Dear all,
> >> >
> >> > how can I use codes of other languages (such F#) in Scala?
> >> >
> >> > Saleh
> >> >
> >>
> >>
> >>
> >> --
> >> Ricky Clarkson
> >> Java Programmer, AD Holdings
> >> +44 1565 770804
> >> Skype: ricky_clarkson
> >> Google Talk: ricky.clarkson@...
> >
> > You can't directly but it would be possible (as far as I know) to
> create a
> > F# COM object and then use something like Jacob to call the COM
> object from
> > Scala code.  But it'd be kind of a hack so I'd really think long and
> hard
> > about the necessity to code part of the solution in F#.  If part of
> your
> > solution is already coded in F#, then that might be a way for you to
> reuse
> > the code but, as I said, I'd really have to give such a solution a
> lot of
> > thought before I went that way.  And, of course, using COM ties you
> to
> > Windows if that's a consideration.
> >
> >
> > --
> > Onorio
> >
> > It is the greatest of all mistakes to do nothing because you can only
> do a
> > little. -Sydney Smith, writer and clergyman (1771-1845)
> >
> >
>
>
>
> --
> Ricky Clarkson
> Java Programmer, AD Holdings
> +44 1565 770804
> Skype: ricky_clarkson
> Google Talk: ricky.clarkson@...


[scala] Re: F# code

by Andy Czerwonka :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

what for? curious as to your use case

"SALEH AL-SHADLY" <alshadly09@...> wrote in message
news:4A530225.4050206@......
> Dear all,
>
> how can I use codes of other languages (such F#) in Scala?
>
> Saleh
>