Initial commit
[platform/upstream/glib2.0.git] / docs / reference / gobject / html / chapter-intro.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Background</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
7 <link rel="home" href="index.html" title="GObject Reference Manual">
8 <link rel="up" href="pt01.html" title="Part I. Concepts">
9 <link rel="prev" href="pt01.html" title="Part I. Concepts">
10 <link rel="next" href="ch01s02.html" title="Exporting a C API">
11 <meta name="generator" content="GTK-Doc V1.13 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 <link rel="preface" href="pr01.html" title="Introduction">
14 <link rel="part" href="pt01.html" title="Part I. Concepts">
15 <link rel="chapter" href="chapter-intro.html" title="Background">
16 <link rel="chapter" href="chapter-gtype.html" title="The GLib Dynamic Type System">
17 <link rel="chapter" href="chapter-gobject.html" title="The GObject base class">
18 <link rel="chapter" href="chapter-signal.html" title="The GObject messaging system">
19 <link rel="reference" href="rn01.html" title="API Reference">
20 <link rel="reference" href="rn02.html" title="Tools Reference">
21 <link rel="part" href="pt02.html" title="Part IV. Tutorial">
22 <link rel="chapter" href="howto-gobject.html" title="How to define and implement a new GObject">
23 <link rel="chapter" href="howto-interface.html" title="How to define and implement interfaces">
24 <link rel="chapter" href="howto-signals.html" title="How to create and use signals">
25 <link rel="part" href="pt03.html" title="Part V. Related Tools">
26 <link rel="chapter" href="tools-vala.html" title="Vala">
27 <link rel="chapter" href="tools-gob.html" title="GObject builder">
28 <link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of GObjects">
29 <link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems">
30 <link rel="chapter" href="tools-gtkdoc.html" title="Writing API docs">
31 <link rel="index" href="api-index-full.html" title="Index">
32 <link rel="index" href="api-index-deprecated.html" title="Index of deprecated symbols">
33 <link rel="index" href="api-index-2-2.html" title="Index of new symbols in 2.2">
34 <link rel="index" href="api-index-2-4.html" title="Index of new symbols in 2.4">
35 <link rel="index" href="api-index-2-6.html" title="Index of new symbols in 2.6">
36 <link rel="index" href="api-index-2-8.html" title="Index of new symbols in 2.8">
37 <link rel="index" href="api-index-2-10.html" title="Index of new symbols in 2.10">
38 <link rel="index" href="api-index-2-12.html" title="Index of new symbols in 2.12">
39 <link rel="index" href="api-index-2-14.html" title="Index of new symbols in 2.14">
40 <link rel="index" href="api-index-2-18.html" title="Index of new symbols in 2.18">
41 <link rel="index" href="api-index-2-22.html" title="Index of new symbols in 2.22">
42 <link rel="index" href="api-index-2-24.html" title="Index of new symbols in 2.24">
43 </head>
44 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
45 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
46 <td><a accesskey="p" href="pt01.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
47 <td><a accesskey="u" href="pt01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
48 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
49 <th width="100%" align="center">GObject Reference Manual</th>
50 <td><a accesskey="n" href="ch01s02.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
51 </tr></table>
52 <div class="chapter" title="Background">
53 <div class="titlepage"><div><div><h2 class="title">
54 <a name="chapter-intro"></a>Background</h2></div></div></div>
55 <div class="toc"><dl>
56 <dt><span class="sect1"><a href="chapter-intro.html#id589065">Data types and programming</a></span></dt>
57 <dt><span class="sect1"><a href="ch01s02.html">Exporting a C API</a></span></dt>
58 </dl></div>
59 <p>
60     GObject, and its lower-level type system, GType, are used by GTK+ and most GNOME libraries to
61     provide:
62     </p>
63 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
64 <li class="listitem"><p>object-oriented C-based APIs and</p></li>
65 <li class="listitem"><p>automatic transparent API bindings to other compiled 
66       or interpreted languages.</p></li>
67 </ul></div>
68 <p>
69   </p>
70 <p>
71     A lot of programmers are used to working with compiled-only or dynamically interpreted-only
72     languages and do not understand the challenges associated with cross-language interoperability.
73     This introduction tries to provide an insight into these challenges and briefly describes
74     the solution chosen by GLib.
75   </p>
76 <p>
77     The following chapters go into greater detail into how GType and GObject work and
78     how you can use them as a C programmer. It is useful to keep in mind that
79     allowing access to C objects from other interpreted languages was one of the major design
80     goals: this can often explain the sometimes rather convoluted APIs and features present
81     in this library.
82   </p>
83 <div class="sect1" title="Data types and programming">
84 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
85 <a name="id589065"></a>Data types and programming</h2></div></div></div>
86 <p>
87       One could say (I have seen such definitions used in some textbooks on programming language theory)
88       that a programming language is merely a way to create data types and manipulate them. Most languages
89       provide a number of language-native types and a few primitives to create more complex types based
90       on these primitive types.
91     </p>
92 <p>
93       In C, the language provides types such as <span class="emphasis"><em>char</em></span>, <span class="emphasis"><em>long</em></span>, 
94       <span class="emphasis"><em>pointer</em></span>. During compilation of C code, the compiler maps these
95       language types to the compiler's target architecture machine types. If you are using a C interpreter
96       (I have never seen one myself but it is possible :), the interpreter (the program which interprets 
97       the source code and executes it) maps the language types to the machine types of the target machine at 
98       runtime, during the program execution (or just before execution if it uses a Just In Time compiler engine).
99     </p>
100 <p>
101       Perl and Python are interpreted languages which do not really provide type definitions similar
102       to those used by C. Perl and Python programmers manipulate variables and the type of the variables
103       is decided only upon the first assignment or upon the first use which forces a type on the variable.
104       The interpreter also often provides a lot of automatic conversions from one type to the other. For example,
105       in Perl, a variable which holds an integer can be automatically converted to a string given the
106       required context:
107 </p>
108 <pre class="programlisting">
109 my $tmp = 10;
110 print "this is an integer converted to a string:" . $tmp . "\n";
111 </pre>
112 <p>
113       Of course, it is also often possible to explicitly specify conversions when the default conversions provided
114       by the language are not intuitive.
115     </p>
116 </div>
117 </div>
118 <div class="footer">
119 <hr>
120           Generated by GTK-Doc V1.13</div>
121 </body>
122 </html>