|
Post by tkorrovi on Nov 9, 2006 14:42:44 GMT -5
Maybe this is something which most already know, then at least nothing wrong about writing it here again. The most important set is the POSIX, which is the standard for operating system (supposed to be for *any* operating system, though some proprietary ones differ from that). It is written in Single Unix Specification, I used to read the version 2, as it is somewhat easier to access opengroup.org/onlinepubs/007908799/index.html though version 3 is also available www.opengroup.org/onlinepubs/009695399 Among the rest there are system libraries and function calls, and some utilities, like vi text editor. The scripting languages are there almost only the shell scripting language, and awk, which is very good and simple scripting language written by the author of C. It is that scripting language must be simple, and all the rest should be done with programming language, but nevertheless, arguably based on awk, they developed Perl, which has become very complicated now, and aims to be a universal programming language, though is not good as such, in spite that it is a good scripting language for simple scripts, Perl is not POSIX, neither is it GNU. The only programming language is c89 in version 2, and c99 in version 3, but, say, linux kernel main tools are still written in c89, and programmers of these really don't like to see c99 programs, with c++-like comments in them. Therefore, if possible, it's better to write programs in c89, these are also compatible with c99. Abot C, I think the people who know it best are at freenode c channel site www.iso-9899.info/wiki/Main_Page where surprisingly also still remains a link to my c89 description tkorrovi.sourceforge.net/c89.txt Guess all the links provided on that c channel site are the best for learning c, well, I can answer whatever questions as well. Then next important set is GNU directory.fsf.org/GNU GNU also provides most of the POSIX tools, like bash shell for sh and gawk for awk, and compiler gcc for c89 and c99, but doesn't provide some, like no vi-like editor (if you search for vim in GNU site, then all you get is a song "Vim send me an angel"). Somewhat it seems that GNU wants to create its own POSIX standard, as it also defines Scheme and Guile as the only official scripting language, which likely also means then using Scheme shell instead of Unix Bash shell. This is likely because the hairy chairman of the Free Software Foundation, the copyright owner of GNU, was also the author of emacs, a text editor which uses Lisp for its numerous macros. And this is of course also why there is no vi-like editor in GNU, but emacs instead. Why I don't use emacs is that I don't need a text editor which contains another operating system. He was also a leading Lisp developer, especially in developing Lisp computers. And in addition to Scheme and Guile, GNU also contains Lisp programs and compilers, the best I think is GCL. But then, only a very few use Guile as scripting language, and most likely GNU would never replace POSIX, so that all the numerous bash scripts in linux should also be then rewritten in Guile, which is equal of creating a completely new operating system, different from Unix. The only GUI which GNU provides, is GTK, though for example GCL also uses tcl/tk for GUI. Tk is very different from GTK, maybe somewhat more simple, it can also be used in Windows, but then installing tcl/tk in Windows is by far not so standard than installing GTK, which can be considered as a kind of necessary evil in Windows, as many necessary programs use GTK. Tk can also be used in C, using tcl/tk C bindings, but for that, of course, the tcl/tk must be installed. Most of the GNU tools work in Windows, and also the autotools work in msys, which is a part of mingw, which uses the gcc compiler. In fact, tcl/tk was intended to be GNU scripting language, tcl is a C-like scripting language, which is the development of what was once known as C shell, which was known to be unreliable then, but this cannot be said about tcl. But there was a big war for using Guile instead. Then, I don't know whether you have Linux, for other purposes it may be good to have only Windows, but for programming Linux is almost indispensable. As it is that there are not so many free tools for Windows, and also obtaining, installing, and upgrading software in Windows is kind of very difficult. If you compare with the Debian package system where, say, I can install all certain kind of software, with one push of the button, with all dependencies and configuration, so everything simply starts to work after that, and then it upgrades them all the time, so you all the time have the newest version. Like, for me it was very difficult to try all these Lisp programs, but with my Debian Etch it took no time at all, including finding all the Lisp programs which there are. If you don't have Linux, install one in parallel with Windows, I use lilo boot manager, which is more reliable than anything, and today Debian installs without you having to do anything, and everything, the graphics, sound, whatever, works after that. The most widely used Linux today is Ubuntu, which is slightly modified Debian, with Gnome, but it's better to get Debian www.debian.org as it has more packages, is more free and even a bit more reliable, and not more difficult to install and use at all. And certainly it must be testing version, which is in fact very stable, but stable version likely has no support for "newer" harware, like these not even so new things like pci-e and sata raid interfaces. But then, if you have Windows installed in the whole hard disk, Linux needs its own partition, and its too risky to split particion, and too much work to backup all your data to cd-rom. So the best likely would be to buy a second hard disk, which is a good thing anyway, and enables also somewhat protect against hard disk failures. And then, I even thought that maybe ADS-AC can be even only Linux project, rather than cross-platform, as at least all who understand something about such software and such, almost certainly also have Linux installed, as all the better software experts have. It is that way different from the applications, say like games, which should be in Windows for much wider audience. But geass only smarter people who know more about software, would ever run things like ADS-AC.
|
|
|
Post by tkorrovi on Nov 11, 2006 16:01:05 GMT -5
I now really think that it's better to try to create any GUI with tk. It would not much harm to install tcl/tk in Windows (it's almost always installed in Linux) either, tcl/tk is after all a useful thing. Yes it can be considered a bad programming language, I had an impression that it doesn't have function pointers, structures, array initialisation, it has lists and hash arrays though, and it's very simple. A simple scripting language with its own GUI. It also has been used quite often in science, it is otherwise very well done and very reliable, so I even kind of like it. What to do when Guile is not very widely used, and also far from mature. And also, the GUI for Lisp and Scheme compilers and interpreters, something like LTK, is mostly provided by tcl/tk bindings, so tcl must be installed anyway. And in C the tk GUI can also be provided by tcl/tk bindings. Tk is really much simpler than GTK, and GTK is often too complex for most needs. The GUI would usually be made by writing an empty front end first, and then adding the back end, like library, it would become too complicated for complex programs to write them both together. I think it would be reasonable by now to consider tk as a GUI, both for Lisp and C. It's not GNU, but then all the Lisps and Schemes and other programs use it, which are GNU, GNU is really in many ways not entirely consistent. And then, it's also not very reasonable to use Guile bindings in C, which use tcl/tk bindings for GUI, it's much more reasonable to use tcl/tk bindings directly for C.
|
|
|
Post by tkorrovi on Nov 22, 2006 2:19:26 GMT -5
Just for some idea what is gtk. It's even not so very complicated, just impossible to put an elephant in a matchbox, and running gui through some other language interpreter like in tk is still kind of strange... And tk is also by far not the best gui, and not standard at all, gtk is the most standard of all gui-s, as it's gnu, it's also the gui of the gnome desktop, and the latest versions have quite high quality, nice antialiased fonts at least. This mantra runs at least with tcc. Yes there is no tcc for mac, should not be difficult to port though, it's so small and nice... But there is gcc, it's a part of os x. But gtk is not a part of os x, it should be installed, well, the same as tk as much as I know is not a part of os x. There should be some xlib maybe. To compile with gcc, in any shell which there should be, write gcc something.c -o executablename #include <gtk/gtk.h> #include <string.h> #define W 25
GtkWidget *window, *fixed, *entry; GdkColor white = {0, 0xffff, 0xffff, 0xffff}, black = {0, 0, 0, 0}, blue = {0, 0, 0, 0xffff}; gboolean quit = FALSE;
gint delete_event (GtkWidget *widget, gpointer data) { widget = widget; data = data; return FALSE; /* returning false generates destroy event */ }
void destroy (GtkWidget *widget, gpointer data) { widget = widget; /* because c89 demands that we should use it */ data = data; quit = TRUE; }
int main (int argc, char **argv) { char s [FILENAME_MAX], banner [] = "That is whole, whole is " "this; from invisible whole comes forth the visible whole yet " "the whole remains unaltered. AUM! Peace! Peace! Peace! "; gint j = 0; /* automatic variable, no implicit initialization */
gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (window, 640, 200); gtk_window_set_title (GTK_WINDOW (window), "GTK Entry"); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); g_signal_connect (window, "delete_event", G_CALLBACK (delete_event), NULL); g_signal_connect (window, "destroy", G_CALLBACK (destroy), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &white); /* fixed container to put widgets into certain x, y */ fixed = gtk_fixed_new (); gtk_container_add (GTK_CONTAINER (window), fixed); entry = gtk_entry_new (); /* entry is an edit box */ gtk_fixed_put (GTK_FIXED (fixed), entry, 15, 50); gtk_widget_modify_bg (entry, GTK_STATE_NORMAL, &black); /* just write font name, as it appears in font selection, and size */ gtk_widget_modify_font (entry, pango_font_description_from_string ("dejavu sans mono 36")); /* set fixed width, as getfontmetrics doesn't work well anyway */ gtk_widget_set_size_request (entry, 588, 60); gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE); /* no one can remember that modify text means change text color */ gtk_widget_modify_text (entry, GTK_STATE_NORMAL, &blue); GTK_WIDGET_SET_FLAGS (window, GTK_CAN_FOCUS); gtk_widget_grab_focus (window); /* no nasty cursors in edit box */ gtk_widget_show_all (window);
while (!quit) { strncpy (s, banner + j, W); while (strlen (s) < W) strncat (s, banner, W - strlen (s)); /* and we can also get text */ gtk_entry_set_text (GTK_ENTRY (entry), s); if (++j == (int) strlen (banner)) j = 0; g_usleep (200000); /* in microseconds */ while (g_main_context_iteration (NULL, FALSE)); } return 0; }
|
|
|
Post by tkorrovi on Nov 22, 2006 2:28:35 GMT -5
Sorry, for compiling gtk you should run something like gcc `pkg-config gtk+-2.0 --cflags --libs` something.c -o execytablename If this shell supports these backquotes, or something else which the shell supports, or the worst case run pkg-config separately, and copy the results anywhere in the command line...
|
|
|
Post by tkorrovi on Nov 22, 2006 17:35:17 GMT -5
This is another one gtk, enables to write text, like in console, not so very well, but still possible. And all is done with gtk label widget. #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <string.h> #define MY 12 #define MX 40 #define MK 100
GtkWidget *window, *label; GdkColor white = {0, 0xffff, 0xffff, 0xffff}, blue = {0, 0, 0, 0xffff}; char s [MY] [MX + 1]; unsigned int keyb [MK + 1], quit, y, x;
gint key_press_event (GtkWidget *widget, GdkEventKey *event) { int i;
if (event->keyval && !keyb [MK - 1]) { for (i = MK; i; i--) keyb = keyb ; keyb [0] = event->keyval; } return TRUE; }
gint delete_event (GtkWidget *widget, gpointer data) { widget = widget; data = data; return FALSE; }
void destroy (GtkWidget *widget, gpointer data) { widget = widget; data = data; quit = TRUE; }
int main (int argc, char **argv) { unsigned int key, i, j;
gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (window, 640, 420); gtk_window_set_title (GTK_WINDOW (window), "GTK Label"); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); gtk_container_set_border_width (GTK_CONTAINER (window), 10); gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &white); g_signal_connect (window, "delete_event", G_CALLBACK (delete_event), NULL); g_signal_connect (window, "destroy", G_CALLBACK (destroy), NULL); gtk_widget_set_events (window, GDK_KEY_PRESS_MASK); g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (key_press_event), NULL); label = gtk_label_new (""); gtk_container_add (GTK_CONTAINER (window), label); gtk_widget_modify_font (label, pango_font_description_from_string ("dejavu sans mono 19")); gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &blue); gtk_widget_show_all (window); for (i = 0; i < MY; i++) { for (j = 0; j < MX; j++) s [j] = ' '; s [MX] = '\n'; } s [MY - 1] [MX] = 0; s [0] [0] = '_'; gtk_label_set_text (GTK_LABEL (label), s [0]);
while (!quit) { if (keyb [0]) { for (i = 0; keyb && i < MK; i++); key = keyb ; keyb = 0; if (key >= 0x020 && key < 0x0b0) { s [y] [x] = key; if (x < MX - 1) x++; } switch (key) { case GDK_Left: if (x > 0) x--; break; case GDK_Right: if (x < MX - 1) x++; break; case GDK_Up: if (y > 0) y--; break; case GDK_Return: x = 0; case GDK_Down: if (y < MY - 1) y++; break; } s [y] [x] = '_'; gtk_label_set_text (GTK_LABEL (label), s [0]); } g_usleep (100000l); while (g_main_context_iteration (NULL, FALSE)); } return 0; }
|
|
|
Post by tkorrovi on Nov 27, 2006 9:48:43 GMT -5
About lisp, tk-based gui is not the only one, especially the newer implementations have also gtk. Like there is something called lgtk, and there is lambda gtk, this at least works with steel bank common lisp. Steel bank common lisp also enables to compile to binary code, though the code is somewhat slower than that of gcl, and it also supposed to work in os x. Guess in the future they would use more and more gtk instead of tk, because for some things tk is simply not enough, is slower, and not so standard either. There is also gtk for java. Tk is simpler, but this is only the first impression. It really can, say, display a label with two functions, but then the first thing which I would like to do, is to change this small and ugly font to something more nice, and so with every little thing there would be additional functions and options. So much about that. One really nice thing which I recently found is the xfe file manager, this also supposed to work in os x. It's like windows exlporer, but simpler and extremely fast, nautilus is really so terribly slow that it's almost useless. It's though not based on gtk, but fox toolkit, which is very rare and complicated, but then it produces incredibly good gui, in no time at all I could change all the fonts to nice and clear freesans. It also has an incredible thing, you can execute a program inside the file manager, and it runs in the directory in which you are in file manager at the moment. This is something really innovative, for some strange reasons the file managers mostly don't change the default directory to the one which you browse at the moment, this is also terribly counter-intuitive. So it was difficult to run, say, compilers, in the current directory, I usually did it inside vim while editing some file there, strange that something so simple has been so difficult to implement before.
|
|
|
Post by tkorrovi on Dec 23, 2006 17:41:33 GMT -5
Ohh just nothing else to do, than to write my random thoughts here, that time is in the remote future when we may do some coding, together with someone... One may certainly wonder, what mean there the things like GTK_CONTAINER (window). It's a kind of magic, but almost the only such in GTK... This function mainly only casts a pointer to a structure, to pointer to some "parent" structure, like GTK_Container, which represents some GTK object, like widget. But the problem is that what this casting really does, is not documented in the C standard. And what it does is kind of surprising, and not like other type casts at all. What this cast does, is that it replaces the pointer to a structure, to the pointer to the first member of this structure. And this is the way how the inheritance has been built in into C from the beginning, though this is mostly unknown. Inheritance happens so that in the child structure, the parent structure would be included as the first member, and the cast is made in a way that it enables to cast from child to parent. This means that C was made from the beginning as an object-oriented language, it is a wrong undertanding that C++ is object-orjented, and C is not. C is object-orjented, only this is largely unknown. As we have inheritance, and we can have function pointers as members of the structures, such structure is nothing else than an object, in the OOP sense. Though it is not so very often necessary to have function pointers in structures, but there is such possibility in case it will be necessary. So C is a high-level programming language, which lacks no major features, but is at that just simply simpler than languages like C++. And in fact, any procedural programming language which has both structures and function pointers, like Lisp, is really object-oriented. guess anyone who knows a bit more about programming, understands that... But are there many of these? And, Merry Christmas!
|
|
|
Post by zouze on Mar 25, 2008 6:37:22 GMT -5
this topic is really interesting. I wish I have the time to review...I will do so in the near future. www.accounting.zouze.com
|
|