public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [Announce] GCCSharp - libgccjit bindings for C#
  2015-01-01  0:00 ` David Malcolm
@ 2015-01-01  0:00   ` Mukul Sabharwal
  0 siblings, 0 replies; 3+ messages in thread
From: Mukul Sabharwal @ 2015-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm; +Cc: jit

I did not know libgccjit had a C++ API as well, I suppose I can model
the C# API to look like that.

Thanks for the feedback, I agree it'll make the API less-verbose.

For folks who do like the verbosity, I'll keep the C-ish API around,
but the OOP approach will make it cleaner.

On Fri, Apr 24, 2015 at 8:09 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> On Thu, 2015-04-23 at 12:29 -0700, Mukul Sabharwal wrote:
>> I'd like to introduce GCCSharp [ http://github.com/mjsabby/GCCSharp ]
>> - libgccjit bindings for C# that are are modeled after the C Bindings,
>> but improve type-safety by strongly typing the different pointers used
>> (i.e. gcc_jit_context* is different from gcc_jit_result*, etc.); this
>> also improves productivity in a C# IDE.
>>
>> My primary use case for libgccjit is actually not using it is as JIT
>> but as an AOT for a toy-but-turing-complete language, hence the
>> project name GCCSharp which does not include the term JIT.
>>
>> The bindings have only been tested on Linux (which is where I need
>> this for my language port), I suppose for completeness I will work on
>> testing this on Windows, but that will likely require a source build
>> of GCC that I haven't gotten to yet.
>>
>> Feedback and patches are welcome.
>
> Hi Mukul; thanks for working on this!
>
> I've added a link to your project to the wiki page at:
> https://gcc.gnu.org/wiki/JIT
>
> On the subject of feedback, libgccjit's C API is rather verbose, but in
> an object-oriented language it's possible to greatly simplify the client
> code by using methods and namespaces.
>
> (Caveat: I have zero C# experience, and am relying on the syntax
> similarity with Java, with which I have close-to-but-not-zero
> experience)
>
> So rather than e.g.
>       GCCJITTypeRef voidType = GCC.JITContextGetType(ctxt,
>                                                      GCC_JIT_TYPES.GCC_JIT_TYPE_VOID);
>
> would it be possible to have something like:
>
>       TypeRef voidType = ctxt.GetType(TYPES.VOID);
>
> where "TypeRef" would be a namespaced-lookup of
>
>    "GCCSharp.TypeRef"
>
> and "TYPES" would be (after namespace lookup) be "GCCSharp.TYPES", with
> the GetType being a method of the
> GCCSharp.Context class?
>
> I did something like this for the C++ bindings, and for the Python
> bindings.  The Python bindings do it by using two layers: a low-level
> layer that binds the C API into the Python world, and then a
> higher-level layer that adds an object-oriented approach to the API.
>
> I hope that this would still work well within IDEs, and I think it looks
> more elegant.
>
> Hope this is constructive (and please forgive me if I'm missing
> something)
>
> Dave
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Announce] GCCSharp - libgccjit bindings for C#
  2015-01-01  0:00 [Announce] GCCSharp - libgccjit bindings for C# Mukul Sabharwal
@ 2015-01-01  0:00 ` David Malcolm
  2015-01-01  0:00   ` Mukul Sabharwal
  0 siblings, 1 reply; 3+ messages in thread
From: David Malcolm @ 2015-01-01  0:00 UTC (permalink / raw)
  To: Mukul Sabharwal; +Cc: jit

On Thu, 2015-04-23 at 12:29 -0700, Mukul Sabharwal wrote:
> I'd like to introduce GCCSharp [ http://github.com/mjsabby/GCCSharp ]
> - libgccjit bindings for C# that are are modeled after the C Bindings,
> but improve type-safety by strongly typing the different pointers used
> (i.e. gcc_jit_context* is different from gcc_jit_result*, etc.); this
> also improves productivity in a C# IDE.
> 
> My primary use case for libgccjit is actually not using it is as JIT
> but as an AOT for a toy-but-turing-complete language, hence the
> project name GCCSharp which does not include the term JIT.
> 
> The bindings have only been tested on Linux (which is where I need
> this for my language port), I suppose for completeness I will work on
> testing this on Windows, but that will likely require a source build
> of GCC that I haven't gotten to yet.
> 
> Feedback and patches are welcome.

Hi Mukul; thanks for working on this!

I've added a link to your project to the wiki page at:
https://gcc.gnu.org/wiki/JIT

On the subject of feedback, libgccjit's C API is rather verbose, but in
an object-oriented language it's possible to greatly simplify the client
code by using methods and namespaces.

(Caveat: I have zero C# experience, and am relying on the syntax
similarity with Java, with which I have close-to-but-not-zero
experience)

So rather than e.g.
      GCCJITTypeRef voidType = GCC.JITContextGetType(ctxt,
                                                     GCC_JIT_TYPES.GCC_JIT_TYPE_VOID);

would it be possible to have something like:

      TypeRef voidType = ctxt.GetType(TYPES.VOID);

where "TypeRef" would be a namespaced-lookup of

   "GCCSharp.TypeRef"

and "TYPES" would be (after namespace lookup) be "GCCSharp.TYPES", with
the GetType being a method of the
GCCSharp.Context class?

I did something like this for the C++ bindings, and for the Python
bindings.  The Python bindings do it by using two layers: a low-level
layer that binds the C API into the Python world, and then a
higher-level layer that adds an object-oriented approach to the API.

I hope that this would still work well within IDEs, and I think it looks
more elegant.

Hope this is constructive (and please forgive me if I'm missing
something)

Dave


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Announce] GCCSharp - libgccjit bindings for C#
@ 2015-01-01  0:00 Mukul Sabharwal
  2015-01-01  0:00 ` David Malcolm
  0 siblings, 1 reply; 3+ messages in thread
From: Mukul Sabharwal @ 2015-01-01  0:00 UTC (permalink / raw)
  To: jit

I'd like to introduce GCCSharp [ http://github.com/mjsabby/GCCSharp ]
- libgccjit bindings for C# that are are modeled after the C Bindings,
but improve type-safety by strongly typing the different pointers used
(i.e. gcc_jit_context* is different from gcc_jit_result*, etc.); this
also improves productivity in a C# IDE.

My primary use case for libgccjit is actually not using it is as JIT
but as an AOT for a toy-but-turing-complete language, hence the
project name GCCSharp which does not include the term JIT.

The bindings have only been tested on Linux (which is where I need
this for my language port), I suppose for completeness I will work on
testing this on Windows, but that will likely require a source build
of GCC that I haven't gotten to yet.

Feedback and patches are welcome.

Mukul

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-24 17:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-01  0:00 [Announce] GCCSharp - libgccjit bindings for C# Mukul Sabharwal
2015-01-01  0:00 ` David Malcolm
2015-01-01  0:00   ` Mukul Sabharwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).