Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #9818
| From | BGB <cr88192@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: back to .Net? lesser of two evils? |
| Date | 2011-11-09 22:48 -0700 |
| Organization | albasani.net |
| Message-ID | <j9fojj$t25$1@news.albasani.net> (permalink) |
| References | (5 earlier) <4eb1bef4$0$286$14726298@news.sunsite.dk> <j8te92$3ms$1@news.albasani.net> <4eb33753$0$290$14726298@news.sunsite.dk> <j9e29t$uuh$1@news.albasani.net> <4ebb292c$0$287$14726298@news.sunsite.dk> |
On 11/9/2011 6:30 PM, Arne Vajhøj wrote:
> On 11/9/2011 9:21 AM, BGB wrote:
>> On 11/3/2011 5:52 PM, Arne Vajhøj wrote:
>>> On 11/3/2011 3:01 AM, BGB wrote:
>>>> On 11/2/2011 3:06 PM, Arne Vajhøj wrote:
>>>>> On 11/2/2011 10:58 AM, BGB wrote:
>>>>>> Mono also can't run C++/CLI code last I checked, which sort of screws
>>>>>> over my personal motivation to use it.
>>>>>
>>>>> It should be able to run pure code. Obviously not mixed code.
>>>>
>>>> yes, but banning mixed code sort of breaks C++/CLI's ability to...
>>>> actually work...
>>>>
>>>> even if one compiles the code itself as pure CIL, then Mono rejects it
>>>> due to things like "can't load MSVCR80.DLL" or similar.
>>>
>>> With:
>>>
>>> /clr:pure
>>>
>>> it should not.
>>>
>>> Are you sure that it does not work?
>>>
>>
>> I tested it.
>> the issue is, as soon as one uses and C or C++ runtime stuff, or calls
>> into C land, well, Mono is no longer happy.
>
> If one mixes in native code (not pure CIL) then then it is not portable.
>
> If one uses DllImport in C++/CLI or C# or VB.NET to load
> native modules then it is obviously not portable either.
>
> So if portability is a requirement then one should not do
> these things.
>
> I believe Mono has a little tool to examine code for
> portability.
>
ideally, though, it should "just work".
the example would be, say, if Mono would make it automatically redirect
dependencies to "MSVCRT" and friends to a glib-based wrapper (granted,
all this would mean faking parts of the Win32 API, in addition to all of
the .NET stuff...).
similarly, if the library is available on both targets, then ideally the
runtime can figure it out, and map to the appropriate library.
otherwise, something like C++/CLI is not nearly so useful, as its main
point is to, well, be C++ but with access to .NET stuff, in addition to
the normal C and C++ libraries. if Mono can't make this work, then this
is IMO a problem that ideally should be addressed somehow.
but, granted, Mono's deficiencies in this area generally led to me not
using .NET:
if the main (personally relevant) selling points for .NET only work on
Windows, why should I really bother with .NET?
I can make my own stuff work, and be portable across Windows and Linux,
which is IMO good enough (in the past, I was also working some on an
Android port, but this was not a high priority).
in my case (for my VM), I dealt with the issue partly by binding against
high-level "library names", which are sometimes named after the library
files in use (stripped-down DLL or shared-object names), and other times
after the headers.
at the moment it is a bit crufty, but in the future I may devise
"cleaner" ways of dealing with the issue.
note that the main (in language) import mechanism looks like:
"native import C.libname;"
note: the "C." is magic (it indicates the language target, and yes there
may later be a "CPP.").
where the VM will itself try to figure out what "libname" means to
import. it will check for "<libname>.dll", "<libname>.so",
"lib<libname>.so" as appropriate for the target OS, or may import the
associated metadata databases (loaded by the libname) and load any
libraries listed as dependencies (such as the physical library name).
thus far it works on both Windows and Linux, so it is generally good
enough (note: databases need to be rebuilt per-target though, but this
is not a big issue). technically the database-building tool is a
modified C compiler (with some annotations used to give special
information to the tool).
technically, these annotations are mostly "__declspec" attributes
wrapped in macros, with the macros being no-op to a standard C or C++
compiler.
in a header somewhere, there may be annotations like:
#ifdef _WIN32
dytlibdep("msvcrt");
dytlibdep("opengl32");
...
#endif
#ifdef linux
dytlibdep("glib");
dytlibdep("GL");
dytlibdep("GLX");
dytlibdep("GLu");
...
#endif
...
otherwise, it is left as the VM's responsibility to make it work.
this is much like gluing together the type-system and other things...
note: maybe I have it a little easier, as my language is somewhat
different (WRT semantics) than either Java or C# (the language is
late-bound, so the visibility or type of a declaration is not a huge
issue when producing bytecode, the compiler will "take it on faith" that
the declaration will be visible when the code runs).
maybe one could coin the term "eager late bound" (although semantically
late bound, the VM may try to avoid run-time lookups where possible,
such as by optimizing for known visibility).
yes, there is also a "native package" feature which allows exporting an
interface to C (basically, this involves a tool to spit out a header and
C source file containing a glue interface).
like (to export a package named "foo"):
"native package C.foo { ... }"
again a tool is needed as, sadly, C can't do late-binding...
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-01 22:18 -0400
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-01 22:35 -0700
Re: back to .Net? lesser of two evils? Cindy <c.thurston@frell.okb.uwa.edu> - 2011-11-02 03:17 -0400
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-02 07:58 -0700
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-02 18:06 -0400
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-03 00:01 -0700
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-03 20:48 -0400
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-03 20:52 -0400
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-09 07:21 -0700
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-09 20:30 -0500
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-09 22:48 -0700
Re: back to .Net? lesser of two evils? coder <j-code@speak.invalid> - 2011-11-02 17:36 -0400
Re: back to .Net? lesser of two evils? Lew <lewbloch@gmail.com> - 2011-11-02 17:13 -0700
Re: back to .Net? lesser of two evils? Cindy <c.thurston@frell.okb.uwa.edu> - 2011-11-03 00:49 -0400
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-03 00:10 -0700
Re: back to .Net? lesser of two evils? Cindy <c.thurston@frell.okb.uwa.edu> - 2011-11-03 04:41 -0400
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-03 05:36 -0700
Re: back to .Net? lesser of two evils? thoolen <tholen01@gmail.com> - 2011-11-02 23:13 -0700
Re: back to .Net? lesser of two evils? markspace <-@.> - 2011-11-02 08:28 -0700
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-02 10:04 -0700
Re: back to .Net? lesser of two evils? markspace <-@.> - 2011-11-02 10:19 -0700
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-02 14:32 -0700
Re: back to .Net? lesser of two evils? Lew <lewbloch@gmail.com> - 2011-11-02 17:20 -0700
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-02 21:34 -0700
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-03 20:57 -0400
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-09 09:25 -0700
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-09 20:25 -0500
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-09 23:05 -0700
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-02 17:26 -0400
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-02 15:01 -0700
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-02 18:18 -0400
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-02 18:20 -0400
Re: back to .Net? lesser of two evils? BGB <cr88192@hotmail.com> - 2011-11-02 22:30 -0700
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-03 21:30 -0400
Re: back to .Net? lesser of two evils? Arne Vajhøj <arne@vajhoej.dk> - 2011-11-03 21:40 -0400
csiph-web