Re: [LAD] Looking for an introduction to rt programming with a gui

From: torbenh <torbenh@email-addr-hidden>
Date: Mon May 24 2010 - 14:47:31 EEST

On Mon, May 24, 2010 at 12:36:43PM +0200, Olivier Guilyardi wrote:

> > then you need to manage most memory yourself again....
>
> Which may results in choosing a simplified memory model, and thus optimization.
>
> > could you explain your reasons a bit more ?
>
> First, it's not all about reasons, it's also a matter of taste. But what I like

taste is one of the strongest reasons in my opinion.

> about C is that, for the reasons outlined above, it's closer to doing what it
> says than C++, the price being verbosity. And when I work with some low level
> audio routines, where things have to be as optimized and stable as possible, I
> like this clarity. Yes, your must manage memory and other things yourself, but
> it's all there in front of your eyes.
>
> That said, in the past I chose to write a GUI using pure C with Gtk, and this
> was really a mistake I think. Adding simple features is really heavy now.

yes. thats what i referred to.
you cant simply derive from GtkWidget in C ... you need to write 50 locs
of boilerplate to do that.

>
> >> But maybe that, with experience and methodology, one can get as productive in C
> >> as in C++? I suppose the guys at Gnome would agree with that..
> >
> > there is a reason why gob2 and vala emerged.
> > writing a GObject in C is a pretty big PITA.
>
> Indeed, and that's why I don't use Vala. To make any real use of it, you need to
> write GObjects wrappers for the libraries or low level C/C++ routines that you
> need, before you can bind them into Vala.

hmm... i actually view it from the other side.
if i want to derive from GtkWidget or somthing this is a huge PITA in C.
in vala this is easy and streight forward. and the vala code compiles to C
so i can go ahead and use my vala widget from my C code.

you dont need to write GObject wrappers. but vala can generate bindings
automatically through GObject introspection.

a vala .vapi file looks like this:
---------------------------------------------------------------------------------
[CCode (cprefix = "", lower_case_cprefix = "",cheader_filename="time.h")]
namespace Time {
        [CCode (cname="struct tm", cprefix="")]
    public class TimeStruct {
      [CCode (cname="tm_sec")] public int second;
      [CCode (cname="tm_min")] public int minute;
      [CCode (cname="tm_hour")] public int hour;
      [CCode (cname="tm_mday")] public int day_of_month;
      [CCode (cname="tm_mon")] public int month;
      [CCode (cname="tm_year")] public int year;
      [CCode (cname="tm_wday")] public int day_of_week;
      [CCode (cname="tm_yday")] public int day_of_year;
      [CCode (cname="tm_isdst")] public bool daylight_saving_time;
    }
    [CCode (cheader_filename = "time.h")]
    public static int time (pointer int_ref);
    public static weak TimeStruct localtime(ref int time);
}
---------------------------------------------------------------------------------

>
> Nevertheless, Vala looks promising. But I don't like the GObject model. I made
> my own OO constructs in C with inheritance and such, but if you want the whole
> thing, with interfaces etc.., I think that C just isn't the way to go.

your own OO constructs dont really help you when you want to derive from a GObject.
and thats the whole point, i think.

gtkmm makes deriving easy. but the resulting object cant be wrapped with pygtk
or other stuff. you lock yourself into the c++ domain.
or write your own wrappers.

>
> > its probably possible to create the boilerplate out of some kind of
> > template.
> > but i am not aware of some rails/paster like framework to create this
> > boilerplate with a single command.
>
> Actually, I'm currently thinking about some very clever IDE and intellisense
> features for C. When I look at this Eclipse IDE, and all that it understands,
> and thus automatically proposes, I think that similar aids could really be
> useful in C.

hmm... when it comes to C i dont miss anything from vim. its pretty much smart enough.
c++ is another story. since the tags system isnt smart enought to
resolve x->write() to the right write() method of all those classes that support that interface.

if your still into vim you might want to have a look at http://eclim.org/
thats pretty awesome :)

-- 
torben Hohn
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Mon May 24 16:15:04 2010

This archive was generated by hypermail 2.1.8 : Mon May 24 2010 - 16:15:04 EEST