On Fri, May 6, 2011 at 4:01 PM, Igor Stasenko <siguctua@gmail.com> wrote:
On 6 May 2011 07:11, laurent laffont <laurent.laffont@gmail.com> wrote:
On Fri, May 6, 2011 at 3:19 AM, Igor Stasenko <siguctua@gmail.com>
wrote:
On 6 May 2011 01:03, Jimmie Houchin <jlhouchin@gmail.com> wrote:
On 5/5/2011 4:25 PM, Igor Stasenko wrote:
On 5 May 2011 21:39, Jimmie Houchin <jlhouchin@gmail.com> wrote:
On 5/5/2011 12:21 PM, Igor Stasenko wrote:
On 5 May 2011 18:57, Jimmie Houchin<jlhouchin@gmail.com> wrote:
[Big Snip]
Well said. Except that i'm not sharing your view that its hard to interface with foreign libraries. Its not hard at all. Of course to connect two different worlds, you need to have knowledge in both of them. But this requirement not a bit different when you take any other pair of languages and try to connect them.
Thanks,
I have no knowledge of either the knowledge or the challenges involved in using external libraries in Pharo or Squeak. I have no knowledge of FFI/Alien or using C/C++/C# or compilers.
So, read about it. It doesn't bites. :)
As I said, I am totally unaware of the limitations of the system, but that it did what I need, and would have liked to do that from Pharo/Squeak.
I
know Dolphin has/had certain capabilities. But I don't prefer to use non-open source software if at all possible for development. I also am very preferential towards cross-platform software. Dolphin fails on all accounts. I would choose my Python/Pharo blend over Dolphin any day. I know it introduces some pain, but I am willing to accept the pain. I like tools that allow me to use them where ever I am and whatever I am doing.
However, that said, when I look at the facilities Python offers for such capabilities it on appearances looks quite impressive.
http://docs.python.org/library/ctypes.html
""" ctypes is a foreign function library for Python. It provides C compatible data types, and allows calling functions in DLLs or shared libraries. It can be used to wrap these libraries in pure Python.
15.18.1.1. Loading dynamic link libraries
ctypes exports the cdll, and on Windows windll and oledll objects, for loading dynamic link libraries.
You load libraries by accessing them as attributes of these objects. cdll loads libraries which export functions using the standard cdecl calling convention, while windll libraries call functions using the stdcall calling convention. oledll also uses the stdcall calling convention, and assumes the functions return a Windows HRESULT error code. The error code is used to automatically raise a WindowsError exception when the function call fails.
Here are some examples for Windows. Note that msvcrt is the MS standard C library containing most standard C functions, and uses the cdecl calling convention:
from ctypes import * print windll.kernel32 # doctest: +WINDOWS <WinDLL 'kernel32', handle ... at ...> print cdll.msvcrt # doctest: +WINDOWS <CDLL 'msvcrt', handle ... at ...> libc = cdll.msvcrt # doctest: +WINDOWS
So? Why do you think that you cannot do the same in Pharo? Have you digested what is available before doing it in Python?
"""
It has examples for windows and linux.
I feel that you are seriously under-informed. Just try googling for:
Squeak + FFI Alien
NativeBoost
and just check what you can do using it:
http://www.squeaksource.com/NBOpenGL/
also check mail archives.
Forgive me, but i really can't understand , why you can't just look for what you need by yourself? Are google.com banned by your ISP?
For me this subject is interested in aspect, why this information (while being available openly) didn't catch your attention , so you using python instead. (Okay, you might miss some functionality like being able to automatically generate bindings to COM interfaces). But again, i am sure that if you surf the net or ask right questions on mailing list, you will probably discover that there is already work being done in that direction.
Indeed, one thing FFI / Alien / NB don't have is a documentation as nice as http://docs.python.org/library/ctypes.html in http://book.pharo-project.org/ FFI / Alien / NB may be powerful, it seems I've never managed to do what I want, even with all mailing lists support (search mails on yaz / z3950 or id3taglib). In Python it works on OSX out of the box (I've just tried :)
Is it works because someone already provided a bindings for libraries you mention, or you did it by yourself?
Have just used ctypes:
import ctypes import ctypes.util ctypes.util.find_library("yaz") '/usr/local/lib/libyaz.dylib' yaz = ctypes.cdll.LoadLibrary("libyaz.dylib") con = yaz.ZOOM_connection_new("z3950.loc.gov", 7090);
Laurent
Here a first hit from google search:
http://lists.indexdata.dk/pipermail/yazlist/2002-May/000269.html
<quote> I wrote these files for more than 2 years ago to play with SWIG and PERL, they are far from being used, but I have just done a fast perl test and the results were just fine.
zclient.c zclient.h zclinet.i swig interface file
The zclient_wrap.c will be created as
swig -python zclient.i
which should be compiled and linked with the rest </quote>
So? Do you think it was easy in first place to a guy who did it from scratch? Now you can easily use it (and its just works out of the box). But it is because someone did it before you!
And if you gonna repeat same from scratch, then you will have to learn: - C - SWIG - Python
so, do you still think that it easier to do that in Python than in Smalltalk?
But when I was working with Python and Ruby several years ago things was easy (for my needs), I think because of documentation. Laurent
-- Best regards, Igor Stasenko AKA sig.