comp.lang.ada
 help / color / mirror / Atom feed
* Binding or not binding
@ 2007-01-31 12:33 Ali Bendriss
  2007-01-31 13:21 ` Jeffrey Creem
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Ali Bendriss @ 2007-01-31 12:33 UTC (permalink / raw)
  To: comp.lang.ada

Hello,

Could you please first excuse me if my past and maybe future posting in this 
group were (will be) sometimes awkward. But I will really like to be more 
active using and promoting Ada.

I was really interested by the thread about "How come Ada isn't more popular?"

I would like to have your opinion about the best way to go in the future, 
and in particular if binding a C library is really the way to go.
  
When we talk about reuse does it mean reusing the libraries done in an other 
language ? 
Re-implementing zlib in Ada for example. Is it a waist of time ?
How to choose ? where to start writing in Ada ?
 
If I need some compression lib like jpeg2k for example which way to go ?
I would love to be able to manipulate some DICOM image format in Ada for 
example. Most of the actual project implementing the DICOM standard are in 
C++ and java. Is it only a question of money (project funding) ? 

Thanks for your feedback in the professional and the hobbyist side.

-- 
Ali 



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

* Re: Binding or not binding
  2007-01-31 12:33 Binding or not binding Ali Bendriss
@ 2007-01-31 13:21 ` Jeffrey Creem
  2007-01-31 13:25 ` Pascal Obry
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Jeffrey Creem @ 2007-01-31 13:21 UTC (permalink / raw)


Ali Bendriss wrote:
> Hello,
> 
> Could you please first excuse me if my past and maybe future posting in this 
> group were (will be) sometimes awkward. But I will really like to be more 
> active using and promoting Ada.
> 
> I was really interested by the thread about "How come Ada isn't more popular?"
> 
> I would like to have your opinion about the best way to go in the future, 
> and in particular if binding a C library is really the way to go.
>   
> When we talk about reuse does it mean reusing the libraries done in an other 
> language ? 
> Re-implementing zlib in Ada for example. Is it a waist of time ?
> How to choose ? where to start writing in Ada ?
>  
> If I need some compression lib like jpeg2k for example which way to go ?
> I would love to be able to manipulate some DICOM image format in Ada for 
> example. Most of the actual project implementing the DICOM standard are in 
> C++ and java. Is it only a question of money (project funding) ? 
> 
> Thanks for your feedback in the professional and the hobbyist side.
> 

It depends on your goals. In general, the conventional wisdom is that 
you should simply bind to existing libraries and as a general rule, this 
usually makes sense. However, having said that, the net is full of 
libraries in a variety of languages implemented natively in that 
language and the existence of these native libraries is sometimes what 
makes people call those languages "good".

So, if my goal is to just get some work done, and I need the 
functionality of some library, and the functionality is non-trivial, 
I'll usually go the binding route.

If I want functionality and existing libraries don't provide it and/or 
provide it in a manner that is not really what I want, I start to 
consider writing a native version.

Sometimes dealing with either the build process, license terms, compiler 
requirements of an existing library is nearly as much work as just 
writing and maintaining a native version. Finding this tipping point 
will depend on a lot of factors but certainly for functionality <~ 100 
lines of code, the intellectual overhead of a binding and another 
language is usually not worth it.

Having something like SWIG working and well understood for Ada would 
certainly help bring bindings along.

Work is progressing in that area but I have not really looked at 
progress recently.

http://gnuada.svn.sourceforge.net/viewvc/gnuada/trunk/projects/swig-1.3.29/



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

* Re: Binding or not binding
  2007-01-31 12:33 Binding or not binding Ali Bendriss
  2007-01-31 13:21 ` Jeffrey Creem
@ 2007-01-31 13:25 ` Pascal Obry
  2007-01-31 15:56   ` Dmitry A. Kazakov
  2007-01-31 13:25 ` Pascal Obry
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Pascal Obry @ 2007-01-31 13:25 UTC (permalink / raw)
  To: Ali Bendriss; +Cc: comp.lang.ada

Ali,

I don't think there is a definite answer to this. It all depends on the
size of the library. An one-day-work rewriting in Ada is probably fine,
but when the work done on the C side is years ? For example in AWS we
bind to the Zlib, and OpenSSL libraries, it would be a waste of time to
recode both of them in Ada.

Another example, do you think it would have been wise to recode the Gtk+
library in Ada... certainly not :)

> If I need some compression lib like jpeg2k for example which way to go ?

For such library I would bind to the C library.

> I would love to be able to manipulate some DICOM image format in Ada for 
> example. Most of the actual project implementing the DICOM standard are in 
> C++ and java. Is it only a question of money (project funding) ?

Note that recent GNAT versions are now using the same object layout as
G++. It means that a GNAT tagged type can be mapped to a C++ class. This
will probably easy binding to C++ based libraries.

> Thanks for your feedback in the professional and the hobbyist side.

You're welcome :)

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



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

* Re: Binding or not binding
  2007-01-31 12:33 Binding or not binding Ali Bendriss
  2007-01-31 13:21 ` Jeffrey Creem
  2007-01-31 13:25 ` Pascal Obry
@ 2007-01-31 13:25 ` Pascal Obry
  2007-01-31 18:44 ` Jeffrey R. Carter
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Pascal Obry @ 2007-01-31 13:25 UTC (permalink / raw)
  To: Ali Bendriss; +Cc: comp.lang.ada

Ali,

I don't think there is a definite answer to this. It all depends on the
size of the library. An one-day-work rewriting in Ada is probably fine,
but when the work done on the C side is years ? For example in AWS we
bind to the Zlib, and OpenSSL libraries, it would be a waste of time to
recode both of them in Ada.

Another example, do you think it would have been wise to recode the Gtk+
library in Ada... certainly not :)

> If I need some compression lib like jpeg2k for example which way to go ?

For such library I would bind to the C library.

> I would love to be able to manipulate some DICOM image format in Ada for 
> example. Most of the actual project implementing the DICOM standard are in 
> C++ and java. Is it only a question of money (project funding) ?

Note that recent GNAT versions are now using the same object layout as
G++. It means that a GNAT tagged type can be mapped to a C++ class. This
will probably easy binding to C++ based libraries.

> Thanks for your feedback in the professional and the hobbyist side.

You're welcome :)

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595




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

* Re: Binding or not binding
  2007-01-31 13:25 ` Pascal Obry
@ 2007-01-31 15:56   ` Dmitry A. Kazakov
  2007-01-31 18:31     ` tmoran
  2007-02-05 20:41     ` Björn Persson
  0 siblings, 2 replies; 15+ messages in thread
From: Dmitry A. Kazakov @ 2007-01-31 15:56 UTC (permalink / raw)


On Wed, 31 Jan 2007 14:25:50 +0100, Pascal Obry wrote:

> Another example, do you think it would have been wise to recode the Gtk+
> library in Ada... certainly not :)

I wouldn't be so sure. In a long term perspective it certainly makes sense.
Fighting GTK+ costs too much time. GUI libraries have too much influence on
software design to leave them outside Ada. If Ada only had a quasi-standard
GUI library, portable, task-safe, designed for and in Ada...

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Binding or not binding
  2007-01-31 15:56   ` Dmitry A. Kazakov
@ 2007-01-31 18:31     ` tmoran
  2007-02-05 20:41     ` Björn Persson
  1 sibling, 0 replies; 15+ messages in thread
From: tmoran @ 2007-01-31 18:31 UTC (permalink / raw)


> > Another example, do you think it would have been wise to recode the Gtk+
> > library in Ada... certainly not :)
>
> I wouldn't be so sure. In a long term perspective it certainly makes sense.

  In addition to the "how easy is it to rewrite in Ada or to write a
thin binding in Ada" questions mentioned:
  Is the underlying library subject to important iplementation change
(efficiency, for instance), so that you would have to modify an all-Ada
version to keep up?
  Is there a question of thick/thin binding?  Do you want the Ada binding
to be type-safe, use exceptions, avoid pointers, etc, or just to be
a thin set of pragma imports?
  How good is the library you are looking at?  Do the routines actually
act as their documentation says?  If not, do you want your binding to
expose those problems to its users, or to internally work around, and
thus hide, them?
  Just a few considerations.



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

* Re: Binding or not binding
  2007-01-31 12:33 Binding or not binding Ali Bendriss
                   ` (2 preceding siblings ...)
  2007-01-31 13:25 ` Pascal Obry
@ 2007-01-31 18:44 ` Jeffrey R. Carter
  2007-01-31 21:31 ` gautier_niouzes
  2007-02-01  8:16 ` Maciej Sobczak
  5 siblings, 0 replies; 15+ messages in thread
From: Jeffrey R. Carter @ 2007-01-31 18:44 UTC (permalink / raw)


Ali Bendriss wrote:
> 
> I would like to have your opinion about the best way to go in the future, 
> and in particular if binding a C library is really the way to go.
>   
> When we talk about reuse does it mean reusing the libraries done in an other 
> language ? 
> Re-implementing zlib in Ada for example. Is it a waist of time ?
> How to choose ? where to start writing in Ada ?

As others have said, there's no single answer.

Bindings are quicker and cheaper, so that's often the reason bindings 
are used. There's also the valid argument that one should not duplicate 
the effort that's already gone into the library in another language. So 
those are arguments for a binding.

Both bindings and Ada versions have to be modified when the original 
version changes, so that's probably not a major issue, but modifying a 
binding may be easier than modifying an Ada version.

On the other hand, Ada has tasking, and libraries in other languages 
don't take tasking into account, so an Ada version can be designed to 
handle tasking, sometimes better than a thick binding can. Added to the 
impression that languages with extensive native libraries are better, 
those are arguments for an Ada version.

So you need to consider how much effort you're willing to put into the 
matter, both upfront and in the future, and how well the existing 
library meets your needs, and make your choice accordingly.

-- 
Jeff Carter
"Alms for an ex-leper!"
Monty Python's Life of Brian
75



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

* Re: Binding or not binding
  2007-01-31 12:33 Binding or not binding Ali Bendriss
                   ` (3 preceding siblings ...)
  2007-01-31 18:44 ` Jeffrey R. Carter
@ 2007-01-31 21:31 ` gautier_niouzes
  2007-02-01  0:13   ` Jeffrey R. Carter
  2007-02-01  8:16 ` Maciej Sobczak
  5 siblings, 1 reply; 15+ messages in thread
From: gautier_niouzes @ 2007-01-31 21:31 UTC (permalink / raw)


Hullo!
It is a very fundamental question and not akward at all.
An Ada version is worth because you get an a priori portability, when,
with a binding, you have to follow each version/compiler/OS/option set
of the original library. But it cost effort and time.
I think the value of this effort depends on:
 1/ simplicity of input - output
 2/ degree of fossilisation
1: if the input and output are relatively basic, abstract and stable
over time (like files, memory), it is more worth to have an Ada
version: you can take time to build it, it will still work
2: the more the library is fossilized, the more the effort of both
(Ada version, Ada binding) is worth
Examples:
- zlib is perfect in the 1 and 2 criteria; in addition, the code for
decompression is already done (Unzip-Ada); there are better
compressors for the "inflate" format than zlib, so translating zlib
compression would perhaps not be the best idea (for a _worse_
compression, there are two quick solutions :-) )...
- OpenGL: the output is a graphics card; it would be silly to make an
Ada version for each one...; the criterium 2 is advanced, so
maintaining a binding is worth the effort IHMO.
My point of view is rather hobbyist - but you never know with
software... E.g. Unzip-Ada is reportedly used in at least two
professional programs (one is embedded).
______________________________________________________________
Gautier         -- http://www.mysunrise.ch/users/gdm/index.htm
Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm




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

* Re: Binding or not binding
  2007-01-31 21:31 ` gautier_niouzes
@ 2007-02-01  0:13   ` Jeffrey R. Carter
  0 siblings, 0 replies; 15+ messages in thread
From: Jeffrey R. Carter @ 2007-02-01  0:13 UTC (permalink / raw)


gautier_niouzes@hotmail.com wrote:
> My point of view is rather hobbyist - but you never know with
> software... E.g. Unzip-Ada is reportedly used in at least two
> professional programs (one is embedded).

I know of an embedded project that uses your LZH decompression routine, 
translated into Ada 83 and modified to work on small groups of bytes as 
they are received. (The compression, I think, is done on a PC in Ada 95 
with an unaltered version of the package.)

-- 
Jeff Carter
"Alms for an ex-leper!"
Monty Python's Life of Brian
75



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

* Re: Binding or not binding
  2007-01-31 12:33 Binding or not binding Ali Bendriss
                   ` (4 preceding siblings ...)
  2007-01-31 21:31 ` gautier_niouzes
@ 2007-02-01  8:16 ` Maciej Sobczak
  5 siblings, 0 replies; 15+ messages in thread
From: Maciej Sobczak @ 2007-02-01  8:16 UTC (permalink / raw)


Ali Bendriss wrote:

> I would like to have your opinion about the best way to go in the future, 
> and in particular if binding a C library is really the way to go.
>   
> When we talk about reuse does it mean reusing the libraries done in an other 
> language ? 
> Re-implementing zlib in Ada for example. Is it a waist of time ?
> How to choose ? where to start writing in Ada ?

One more thing (apart from those already mentioned) that you sometimes 
have to take into account is that some C libraries cannot be easily 
rewritten, because their internal working is either not documented, or 
even not exposed to public at all.

There are many projects that provide C API as part of the package and 
they don't document anything but the interface. In such a case the C 
library is just a black box and there is nothing really to rewrite.

A simple example that I have recently exercised on my own is a C client 
API to some database server. You don't know how it works internally (and 
you probably don't want to know), so it's not even clear what "rewriting 
in Ada" is supposed to mean. If it's open source then you can try to 
learn the details by reading the code (waste of time anyway), but what 
would you do if the source is closed? You have C API and nothing else. 
Bind to it.


-- 
Maciej Sobczak : http://www.msobczak.com/
Programming    : http://www.msobczak.com/prog/



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

* Re: Binding or not binding
  2007-01-31 15:56   ` Dmitry A. Kazakov
  2007-01-31 18:31     ` tmoran
@ 2007-02-05 20:41     ` Björn Persson
  2007-02-06  1:58       ` Randy Brukardt
                         ` (2 more replies)
  1 sibling, 3 replies; 15+ messages in thread
From: Björn Persson @ 2007-02-05 20:41 UTC (permalink / raw)


Dmitry A. Kazakov wrote:

> On Wed, 31 Jan 2007 14:25:50 +0100, Pascal Obry wrote:
> 
>> Another example, do you think it would have been wise to recode the Gtk+
>> library in Ada... certainly not :)
> 
> I wouldn't be so sure. In a long term perspective it certainly makes
> sense. Fighting GTK+ costs too much time. GUI libraries have too much
> influence on software design to leave them outside Ada. If Ada only had a
> quasi-standard GUI library, portable, task-safe, designed for and in
> Ada...

I wonder if it would make sense to make a hybrid, or maybe I should call it
an ultra-thick binding. That is, to design an API that makes sense for Ada,
and write the specifications without regard to any other library, but then
internally use a portable library like GTK+, QT or WXwidgets – or low-level
parts of it – to put things on the screen and take care of the
cross-platform issues.

But I know very little about GUI libraries so I should probably shut up.

-- 
Björn Persson                              PGP key A88682FD
                   omb jor ers @sv ge.
                   r o.b n.p son eri nu



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

* Re: Binding or not binding
  2007-02-05 20:41     ` Björn Persson
@ 2007-02-06  1:58       ` Randy Brukardt
  2007-02-06  8:38       ` Dmitry A. Kazakov
  2007-02-06  9:11       ` Ludovic Brenta
  2 siblings, 0 replies; 15+ messages in thread
From: Randy Brukardt @ 2007-02-06  1:58 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 886 bytes --]

"Bj�rn Persson" <spam-away@nowhere.nil> wrote in message
news:DDMxh.31243$E02.12620@newsb.telia.net...
...
> I wonder if it would make sense to make a hybrid, or maybe I should call
it
> an ultra-thick binding. That is, to design an API that makes sense for
Ada,
> and write the specifications without regard to any other library, but then
> internally use a portable library like GTK+, QT or WXwidgets - or
low-level
> parts of it - to put things on the screen and take care of the
> cross-platform issues.

That's vaguely what we were trying to do with Claw, except that we were only
trying to target Windows. (We were worried about a
"least-common-denominator" approach.) I certainly agree that that is the
best idea, but it might be difficult to actually do because of the great
differences in the design of the underlying libraries.

                                  Randy.





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

* Re: Binding or not binding
  2007-02-05 20:41     ` Björn Persson
  2007-02-06  1:58       ` Randy Brukardt
@ 2007-02-06  8:38       ` Dmitry A. Kazakov
  2007-02-06  9:14         ` Alex R. Mosteo
  2007-02-06  9:11       ` Ludovic Brenta
  2 siblings, 1 reply; 15+ messages in thread
From: Dmitry A. Kazakov @ 2007-02-06  8:38 UTC (permalink / raw)


On Mon, 05 Feb 2007 20:41:07 GMT, Björn Persson wrote:

> Dmitry A. Kazakov wrote:
> 
>> On Wed, 31 Jan 2007 14:25:50 +0100, Pascal Obry wrote:
>> 
>>> Another example, do you think it would have been wise to recode the Gtk+
>>> library in Ada... certainly not :)
>> 
>> I wouldn't be so sure. In a long term perspective it certainly makes
>> sense. Fighting GTK+ costs too much time. GUI libraries have too much
>> influence on software design to leave them outside Ada. If Ada only had a
>> quasi-standard GUI library, portable, task-safe, designed for and in
>> Ada...
> 
> I wonder if it would make sense to make a hybrid, or maybe I should call it
> an ultra-thick binding. That is, to design an API that makes sense for Ada,
> and write the specifications without regard to any other library, but then
> internally use a portable library like GTK+, QT or WXwidgets – or low-level
> parts of it – to put things on the screen and take care of the
> cross-platform issues.

It could turn even more difficult than to design, say, GTK+ from scratch.
At this level we will have to abstract widgets, styles, resources rather
than events, drawing contexts, pixels, fonts, pens of the lover level.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Binding or not binding
  2007-02-05 20:41     ` Björn Persson
  2007-02-06  1:58       ` Randy Brukardt
  2007-02-06  8:38       ` Dmitry A. Kazakov
@ 2007-02-06  9:11       ` Ludovic Brenta
  2 siblings, 0 replies; 15+ messages in thread
From: Ludovic Brenta @ 2007-02-06  9:11 UTC (permalink / raw)


On Feb 5, 9:41 pm, Björn Persson wrote:
> I wonder if it would make sense to make a hybrid, or maybe I should call it
> an ultra-thick binding. That is, to design an API that makes sense for Ada,
> and write the specifications without regard to any other library, but then
> internally use a portable library like GTK+, QT or WXwidgets - or low-level
> parts of it - to put things on the screen and take care of the
> cross-platform issues.
>
> But I know very little about GUI libraries so I should probably shut up.

There once was a flurry of such libraries in C++. One that I liked
particularly was YACL (Yet Another Component Libraryu or some such).
It had containers and an abstract GUI toolkit with 3 implementations:
OS/2, Windows, and Motif. I liked its design, but that was before C++
had templates, so now I know better than to like a design where
everything is a descendant of Object :)

Writing such a library is not trivial.

--
Ludovic Brenta.




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

* Re: Binding or not binding
  2007-02-06  8:38       ` Dmitry A. Kazakov
@ 2007-02-06  9:14         ` Alex R. Mosteo
  0 siblings, 0 replies; 15+ messages in thread
From: Alex R. Mosteo @ 2007-02-06  9:14 UTC (permalink / raw)


Dmitry A. Kazakov wrote:

> On Mon, 05 Feb 2007 20:41:07 GMT, Bj�rn Persson wrote:
> 
>> Dmitry A. Kazakov wrote:
>> 
>>> On Wed, 31 Jan 2007 14:25:50 +0100, Pascal Obry wrote:
>>> 
>>>> Another example, do you think it would have been wise to recode the
>>>> Gtk+ library in Ada... certainly not :)
>>> 
>>> I wouldn't be so sure. In a long term perspective it certainly makes
>>> sense. Fighting GTK+ costs too much time. GUI libraries have too much
>>> influence on software design to leave them outside Ada. If Ada only had
>>> a quasi-standard GUI library, portable, task-safe, designed for and in
>>> Ada...
>> 
>> I wonder if it would make sense to make a hybrid, or maybe I should call
>> it an ultra-thick binding. That is, to design an API that makes sense for
>> Ada, and write the specifications without regard to any other library,
>> but then internally use a portable library like GTK+, QT or WXwidgets ?
>> or low-level parts of it ? to put things on the screen and take care of
>> the cross-platform issues.
> 
> It could turn even more difficult than to design, say, GTK+ from scratch.
> At this level we will have to abstract widgets, styles, resources rather
> than events, drawing contexts, pixels, fonts, pens of the lover level.
 
Perhaps the history of java AWT, JWT, Swing is relevant here.



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

end of thread, other threads:[~2007-02-06  9:14 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-31 12:33 Binding or not binding Ali Bendriss
2007-01-31 13:21 ` Jeffrey Creem
2007-01-31 13:25 ` Pascal Obry
2007-01-31 15:56   ` Dmitry A. Kazakov
2007-01-31 18:31     ` tmoran
2007-02-05 20:41     ` Björn Persson
2007-02-06  1:58       ` Randy Brukardt
2007-02-06  8:38       ` Dmitry A. Kazakov
2007-02-06  9:14         ` Alex R. Mosteo
2007-02-06  9:11       ` Ludovic Brenta
2007-01-31 13:25 ` Pascal Obry
2007-01-31 18:44 ` Jeffrey R. Carter
2007-01-31 21:31 ` gautier_niouzes
2007-02-01  0:13   ` Jeffrey R. Carter
2007-02-01  8:16 ` Maciej Sobczak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox