2010/9/30 Andreas Raab <[hidden email]>: > > On 9/29/2010 6:48 PM, Igor Stasenko wrote: >> >> On 30 September 2010 04:30, Andreas Raab<[hidden email]> wrote: >>> >>> See, in my experience that claim is simply wrong. How can you say that >>> (for >>> example) a little test program like the one that I just wrote to >>> experiment >>> with a Windows function would be faster to write using the FFI? >>> >>> ------------------------------ CredTest.cpp ---------------------------- >>> >>> // CredTest.cpp : Defines the entry point for the console application. >>> // >>> >>> #include "stdafx.h" >>> #include<Windows.h> >>> #include<wincred.h> >>> >>> LPTSTR readCredential(LPTSTR targetName) { >>> CREDENTIAL *cred; >>> >>> if(CredRead(targetName, CRED_TYPE_GENERIC, 0,&cred)) { >>> LPTSTR result = (LPTSTR) >>> calloc(cred->CredentialBlobSize+1, >>> sizeof(TCHAR)); >>> memcpy(result, cred->CredentialBlob, >>> cred->CredentialBlobSize); >>> return result; >>> } >>> printf("CredRead failed: %d\n", GetLastError()); >>> return NULL; >>> } >>> >>> int _tmain(int argc, _TCHAR* argv[]) >>> { >>> LPTSTR credential = readCredential(L"TERMSRV/devmsapps01"); >>> printf("Credential: %s\n", credential); >>> return 0; >>> } >>> ---------------------------------------------------------------------- >>> >>> You can imagine that it took me some ten minutes or so (incl. firing up >>> Visual Studio, creating a new project etc) to write this. Now do that in >>> Squeak and keep in mind how much of your time you're wasting in the >>> overhead >>> of declaring the types, functions, defines. That's why I'm saying that >>> unless you can get the equivalent of #include<windows.h> you're not even >>> in >>> the same ballpark. >> >> Wait, in the above you forgot to show me the glue code which exposing >> this function >> via some primitive. And you forgot to write the list of steps (in >> addition to opening Visual studio), >> how you rebuilding VM using VMMaker , compiling and linking, and >> finally deploying VM with new plugin, >> and then telling others that they can download new version of VM, so >> they could try your new stuff. >> Now i doubt if you do that, it will take ten minutes or so. > > But now you're complaining about the integration APIs (with which I agree). > But there is stuff we can do to make this easier, *much* easier. If you've > ever looked at how Python deals with this stuff you'll get an idea about how > easy that can be - no slang, no VMMaker, no build files other than what is > already in Visual Studio. In effect, we should be providing a squeak.h and a > squeak.lib and the primitives should look like this: > > #include <windows.h> > #include <wincred.h> > #include "squeak.h" > > /* Read a credential from the Windows credential store */ > OOP primitiveCredRead(VM *vm, OOP rcvr, OOP args) { > Credentials *cred; > char *target; > > vm->parseArgs(1, "%s", &target); > if(!CredRead(targetName, CRED_TYPE_GENERIC, 0,&cred)) return > vm->fail(); > return vm->stringWithLength(cred->CredentialBlobSize+1, > cred->CredentialBlob); > } > > Voila, done. > >>>> <sarcasm> >>>> Why Croquet using FFI for OpenGL binding, why not writing a plugin? It >>>> would be much more 'stable' >>>> and 'robust' and secure. >>>> </sarcasm> >>> >>> Only one reason: The poor integration APIs. I couldn't figure out how to >>> generate proper plugin glue (and later I had lost the source for >>> generating >>> this stufF). And we *paid* for it. Weeks and weeks of obscure crash >>> reports >>> that we couldn't figure out until *finally* we realized that when using >>> client state operations a GC may occur if the rendering is interrupted >>> "just >>> so". We fixed this by (guess what) moving these operations into a plugin. >> >> No objections here. Shit happens. And its really don't matters where: >> either in language/FFI or in C. You still have to fix that. > > It's not so much that shit happens but rather that your sarcastic comment is > *completely* wrong and (I think) goes to show how little exposure to the > resulting problems you (and pretty much everybody else arguing for that kind > of stuff) really have. > > Cheers, > - Andreas > Agree with some of your arguments, but certainly not the last one: you can't presume of everybody else experience. >From my personnal experience, in the restricted case of simple types and no #include hell, my productivity did boost in VW with DLLCC compared to writing user primitives. Simply because I didn't have to deal with any C code at all... This may vary with applications for sure. Nicolas |
In reply to this post by Igor Stasenko
On 9/30/2010 1:43 AM, Igor Stasenko wrote: >> But now you're complaining about the integration APIs (with which I agree). >> But there is stuff we can do to make this easier, *much* easier. If you've >> ever looked at how Python deals with this stuff you'll get an idea about how >> easy that can be - no slang, no VMMaker, no build files other than what is >> already in Visual Studio. In effect, we should be providing a squeak.h and a >> squeak.lib and the primitives should look like this: >> >> #include<windows.h> >> #include<wincred.h> >> #include "squeak.h" >> >> /* Read a credential from the Windows credential store */ >> OOP primitiveCredRead(VM *vm, OOP rcvr, OOP args) { >> Credentials *cred; >> char *target; >> >> vm->parseArgs(1, "%s",&target); >> if(!CredRead(targetName, CRED_TYPE_GENERIC, 0,&cred)) return >> vm->fail(); >> return vm->stringWithLength(cred->CredentialBlobSize+1, >> cred->CredentialBlob); >> } >> >> Voila, done. >> > > Yep. Been there , did that :) > I had implemented own automatic code generator which generated > bindings for my abandoned smalltalk interpreter. > I used SWIG C++ compiler by writing own plugin to it. > So, what is stopping us from either use SWIG, or write own C/C++ > parser/compiler for automatic > generation of external library bindings? Someone needs to do it :-) >>> No objections here. Shit happens. And its really don't matters where: >>> either in language/FFI or in C. You still have to fix that. >> >> It's not so much that shit happens but rather that your sarcastic comment is >> *completely* wrong and (I think) goes to show how little exposure to the >> resulting problems you (and pretty much everybody else arguing for that kind >> of stuff) really have. >> > > Oh, please. I worked more than 2 years on single big C++ project, in > Visual Studio. > STL, templates, threads, 10 minutes of compilation time, incredibly > hard to move ahead, > incredibly hard to reproduce errors (since after 'fix' you were always > had to restart program and > repeat all steps which may possibly triggered bug). I am sick of C, really sick. > If it would be so easy to develop in C, then no one (including me) > would even look into smalltalk direction. This isn't my claim. My claim is that for *platform integration tasks* C is superior. Not for general software development. But for a plugin that reads and writes the windows credential store, for a plugin that reads and writes the Apple keychain, for a plugin that interfaces with sockets, for a plugin that deals with platform windows, C/C++/C#/ObjC are the better choices. Cheers, - Andreas |
On 30 September 2010 11:57, Andreas Raab <[hidden email]> wrote: > >>> >>> Voila, done. >>> >> >> Yep. Been there , did that :) >> I had implemented own automatic code generator which generated >> bindings for my abandoned smalltalk interpreter. >> I used SWIG C++ compiler by writing own plugin to it. >> So, what is stopping us from either use SWIG, or write own C/C++ >> parser/compiler for automatic >> generation of external library bindings? > > Someone needs to do it :-) > >>>> No objections here. Shit happens. And its really don't matters where: >>>> either in language/FFI or in C. You still have to fix that. >>> >>> It's not so much that shit happens but rather that your sarcastic comment >>> is >>> *completely* wrong and (I think) goes to show how little exposure to the >>> resulting problems you (and pretty much everybody else arguing for that >>> kind >>> of stuff) really have. >>> >> >> Oh, please. I worked more than 2 years on single big C++ project, in >> Visual Studio. >> STL, templates, threads, 10 minutes of compilation time, incredibly >> hard to move ahead, >> incredibly hard to reproduce errors (since after 'fix' you were always >> had to restart program and >> repeat all steps which may possibly triggered bug). I am sick of C, really >> sick. >> If it would be so easy to develop in C, then no one (including me) >> would even look into smalltalk direction. > > This isn't my claim. My claim is that for *platform integration tasks* C is > superior. Not for general software development. But for a plugin that reads > and writes the windows credential store, for a plugin that reads and writes > the Apple keychain, for a plugin that interfaces with sockets, for a plugin > that deals with platform windows, C/C++/C#/ObjC are the better choices. > How i could argue with that? Of course for interfacing with C, C is better than any other language. :) But its too late. My mind already tainted by smalltalk. I want to do it in smalltalk way. I want to evaluate simple doit and access computer's CMOS memory, as demoed by Gerardo Richarte under SqueakNOS on ESUG conference. I don't want to rebuild whole VM from scratch, each time i need to change something. And you are always need to change something, because we're not living in a perfect world and not running our programs under perfect OS, using perfect VM and libraries and so on. > Cheers, > - Andreas > -- Best regards, Igor Stasenko AKA sig. |
On 30 September 2010 12:11, Igor Stasenko <[hidden email]> wrote: > On 30 September 2010 11:57, Andreas Raab <[hidden email]> wrote: >> >>>> >>>> Voila, done. >>>> >>> >>> Yep. Been there , did that :) >>> I had implemented own automatic code generator which generated >>> bindings for my abandoned smalltalk interpreter. >>> I used SWIG C++ compiler by writing own plugin to it. >>> So, what is stopping us from either use SWIG, or write own C/C++ >>> parser/compiler for automatic >>> generation of external library bindings? >> >> Someone needs to do it :-) >> > Amen :) > >>>>> No objections here. Shit happens. And its really don't matters where: >>>>> either in language/FFI or in C. You still have to fix that. >>>> >>>> It's not so much that shit happens but rather that your sarcastic comment >>>> is >>>> *completely* wrong and (I think) goes to show how little exposure to the >>>> resulting problems you (and pretty much everybody else arguing for that >>>> kind >>>> of stuff) really have. >>>> >>> >>> Oh, please. I worked more than 2 years on single big C++ project, in >>> Visual Studio. >>> STL, templates, threads, 10 minutes of compilation time, incredibly >>> hard to move ahead, >>> incredibly hard to reproduce errors (since after 'fix' you were always >>> had to restart program and >>> repeat all steps which may possibly triggered bug). I am sick of C, really >>> sick. >>> If it would be so easy to develop in C, then no one (including me) >>> would even look into smalltalk direction. >> >> This isn't my claim. My claim is that for *platform integration tasks* C is >> superior. Not for general software development. But for a plugin that reads >> and writes the windows credential store, for a plugin that reads and writes >> the Apple keychain, for a plugin that interfaces with sockets, for a plugin >> that deals with platform windows, C/C++/C#/ObjC are the better choices. >> > > How i could argue with that? > Of course for interfacing with C, C is better than any other language. :) And yeah, but then you still will need to interface C with smalltalk. And here where fun starts (see VMMaker & slang voodo). So, no matter how much additional C code you write, it makes not a bit easier to use it from smalltalk :) Of course, automatic library bindings could help with it, but they are also having own limitations. For instance, how you suppose to reflect a C++ class with multiple inheritance in smalltalk? :) > But its too late. My mind already tainted by smalltalk. > I want to do it in smalltalk way. I want to evaluate simple doit and > access computer's CMOS > memory, as demoed by Gerardo Richarte under SqueakNOS on ESUG conference. > I don't want to rebuild whole VM from scratch, each time i need to > change something. > And you are always need to change something, because we're not living > in a perfect world > and not running our programs under perfect OS, using perfect VM and > libraries and so on. > > >> Cheers, >> - Andreas >> > > > > -- > Best regards, > Igor Stasenko AKA sig. > -- Best regards, Igor Stasenko AKA sig. |
In reply to this post by Andreas.Raab
On Thu, Sep 30, 2010 at 01:57:21AM -0700, Andreas Raab wrote: > > On 9/30/2010 1:43 AM, Igor Stasenko wrote: > >>But now you're complaining about the integration APIs (with which I > >>agree). > >>But there is stuff we can do to make this easier, *much* easier. If you've > >>ever looked at how Python deals with this stuff you'll get an idea about > >>how > >>easy that can be - no slang, no VMMaker, no build files other than what is > >>already in Visual Studio. In effect, we should be providing a squeak.h > >>and a > >>squeak.lib and the primitives should look like this: > >> > >>#include<windows.h> > >>#include<wincred.h> > >>#include "squeak.h" > >> > >>/* Read a credential from the Windows credential store */ > >>OOP primitiveCredRead(VM *vm, OOP rcvr, OOP args) { > >> Credentials *cred; > >> char *target; > >> > >> vm->parseArgs(1, "%s",&target); > >> if(!CredRead(targetName, CRED_TYPE_GENERIC, 0,&cred)) return > >>vm->fail(); > >> return vm->stringWithLength(cred->CredentialBlobSize+1, > >>cred->CredentialBlob); > >>} > >> > >>Voila, done. > >> > > > >Yep. Been there , did that :) > >I had implemented own automatic code generator which generated > >bindings for my abandoned smalltalk interpreter. > >I used SWIG C++ compiler by writing own plugin to it. > >So, what is stopping us from either use SWIG, or write own C/C++ > >parser/compiler for automatic > >generation of external library bindings? > > Someone needs to do it :-) > > >>>No objections here. Shit happens. And its really don't matters where: > >>>either in language/FFI or in C. You still have to fix that. > >> > >>It's not so much that shit happens but rather that your sarcastic comment > >>is > >>*completely* wrong and (I think) goes to show how little exposure to the > >>resulting problems you (and pretty much everybody else arguing for that > >>kind > >>of stuff) really have. > >> > > > >Oh, please. I worked more than 2 years on single big C++ project, in > >Visual Studio. > >STL, templates, threads, 10 minutes of compilation time, incredibly > >hard to move ahead, > >incredibly hard to reproduce errors (since after 'fix' you were always > >had to restart program and > >repeat all steps which may possibly triggered bug). I am sick of C, really > >sick. > >If it would be so easy to develop in C, then no one (including me) > >would even look into smalltalk direction. > > This isn't my claim. My claim is that for *platform integration tasks* C > is superior. Not for general software development. But for a plugin that > reads and writes the windows credential store, for a plugin that reads > and writes the Apple keychain, for a plugin that interfaces with > sockets, for a plugin that deals with platform windows, C/C++/C#/ObjC > are the better choices. There's a certain amount of personal preference involved here, which is a good thing IMHO. OSProcessPlugin, which is pure platform integration, is written entirely in Slang, with some embedded #cCode: but no external C sources. Why? Because I thought it was cool that it was possible to do it in Smalltalk. If I had it to do over again, would I do it the same way? Yes. Does that mean that this approach is better? No, it's just my personal preference. That said, I do think that there can be some unexpected benefits from writing platform glue code in Smalltalk. I wrote MemoryAccess as a Slang replacement for the low level C macros in the VM, and found to my amazement that the performance of the Slang version was identical to that of the cpp macros (on my system, YMMV). So I ended up thinking that the macros are a performance enhancement in C that actually do not improve performance, and that make the VM code harder to understand. Of course, at the time the macros were done, they were very much needed because the Slang inliner did not originally deliver this kind of performance. I like the SWIG idea a lot by the way. $0.02 Dave |
In reply to this post by Andreas.Raab
+1 ----- Original Message ---- From: Andreas Raab <[hidden email]> To: [hidden email] Sent: Wed, September 29, 2010 6:30:29 PM Subject: Re: [Vm-dev] Cog: A question about: setInterruptCheckChain() [Side note: Please don't quote entire posts if you're going to reply 2/3rds of the way down. I had to scroll three times through this post to even find what you replied to] +1 |
In reply to this post by Andreas.Raab
Hi Andreas, excuse me for flogging the odd limb of a dead horse... I agree with many of your points below but a few I still need to flail away at... On Wed, Sep 29, 2010 at 4:22 PM, Andreas Raab <[hidden email]> wrote:
I don't see that C provides any more or less memory safety than the FFI, unless the FFI can't access accurate type information for signatures and parameter types, and can't easily manage unmoving objects. I know this is an issue, requiring good header parsing a C compiler modelling tools, or use of things like gcc-xml, but it is possible, and there are clunky solutions to unmoving objects (ExternalData, Alien) and more elegant facilities in gestation (a pinning garbage collector). So if grant me that the FFI can access accurate type information and provide unmoving objects then there's no difference since C allows one to mismanage memory (e.g. free memory still in use, cast a pointer inappropriately, etc, etc) just as much, if not more than, the FFI. Memory safety errors in both C and Smalltalk domains can cause hard-to-dagnose crashes that happen long after the fact. The one advantage that C has is that one has to use only one domain while debugging, C, whereas if one is using the FFI it's likely one has to debug in both.
I don't see this in my specific example. One can provide a hack such as specifying a default response before the fact for the VM to respond with to WM_QUERYENDSESSION but that doesn't give the image a chance to act, e.g. to flush data or to query the user. So humour me, how would you solve this specific case without callbacks? The requirement is that the image gets a chance to query the user in response to WM_QUERYENDSESSION so that they can abort the reboot if desired.
But porting the FFI is /not/ harder than porting a JIT (believe me), and as an FFI grows in sophistication it gets easier to port because techniques and solutions used on one platform are applicable to others (again, I've been there and done that either with discarding the bulk of the assembler in an existing implementation or a new port in the VisualWorks FFI implementations on Alpha AXP, MIPS, PowerPC, SPARC (32-bit & 64-bit) and x86-64).
I don't agree that they don't exist in Smalltalk code. Well-written Smalltalk code that uses an FFI typically does provide an abstraction-boundary and manage memory behind it. The ODBC connect is a good example.
Two great advantages that Smalltalk has here are browsability and inheritance. It is straight-forward to use inheritance to group platform fan-out and the IDE supports comparing the various platform-specific implementations. Further, inheritance encourages code-sharing and keeping platform fan-out to a minimum. In contrast the platform tree in the Squeak VM has very little shared code and IME is quite badly organized.
That's a strong point. It was hard in VisualWorks to find the effort to keep the C preprocessor up-to-date. However, I can at least imagine a well-maintained interface to windows.h and know how I would implement it (I've discussed this a lot before; I won't bore you).
True. But it breaks my heart. I don't want to be embraced and then extended ;) They're playing catch-up and have probably caught up, but I would still like to compete.
Agreed.
There's plenty of examples of stable interfaces above the FFI. VisualWorks has depended on its database connects; they are its bread if not its butter and are implemented on the FFI. The Windows registry is accessed solely through the FFI, etc. These interfaces are certainly stable and have evolved.
best Eliot
|
Free forum by Nabble | Edit this page |