comparison unix-phil.ms @ 20:578d5c84e5c0

a lot about mh (ch04)
author meillo@marmaro.de
date Fri, 26 Feb 2010 00:57:37 +0100
parents d8f428cee0d1
children ca929b042039
comparison
equal deleted inserted replaced
19:d8f428cee0d1 20:578d5c84e5c0
743 %P Appendix B 743 %P Appendix B
744 %O Also available online: \f(CW\s-2http://rand-mh.sourceforge.net/book/\fP 744 %O Also available online: \f(CW\s-2http://rand-mh.sourceforge.net/book/\fP
745 .] 745 .]
746 746
747 .NH 2 747 .NH 2
748 Contrasts to similar software 748 Contrasts to monolithic mail systems
749 .LP 749 .LP
750 All \s-1MUA\s0s are monolithic, except \s-1MH\s0. 750 All \s-1MUA\s0s are monolithic, except \s-1MH\s0.
751 This might not be completely true, 751 This might not be true,
752 but it reflects the general situation pretty well. 752 but it reflects the situation pretty well.
753 .PP 753 .PP
754 While monolithic \s-1MUA\s0s gather all function in one program, 754 While monolithic \s-1MUA\s0s gather all function in one program,
755 \s-1MH\s0 is a toolchest of many small tools \(en one for each job. 755 \s-1MH\s0 is a toolchest of many small tools \(en one for each job.
756 Following is a list of important programs of \s-1MH\s0's toolchest: 756 Following is a list of important programs of \s-1MH\s0's toolchest:
757 .IP \(bu 757 .IP \(bu
799 \f(CWshow\fP is like \f(CWcat\fP, 799 \f(CWshow\fP is like \f(CWcat\fP,
800 \f(CWfolder\fP is like \f(CWcd\fP, 800 \f(CWfolder\fP is like \f(CWcd\fP,
801 \f(CWrefile\fP is like \f(CWmv\fP, 801 \f(CWrefile\fP is like \f(CWmv\fP,
802 and \f(CWrmm\fP is like \f(CWrm\fP. 802 and \f(CWrmm\fP is like \f(CWrm\fP.
803 .PP 803 .PP
804 The most important difference to Unix' toolchest is,
805 that \s-1MH\s0's tools have an own context.
806 The context of the Unix tools is mainly the current working directory, 804 The context of the Unix tools is mainly the current working directory,
807 the user identification, and the environment variables. 805 the user identification, and the environment variables.
808 \s-1MH\s0 extends this context by two more items: 806 \s-1MH\s0 extends this context by two more items:
809 A current mail folder, similar to the current working directory, 807 The current mail folder, similar to the current working directory,
810 is maintained; \f(CWfolder\fP provides the functionality 808 for which \f(CWfolder\fP provides the functionality of
811 of \f(CWpwd\fP and \f(CWcd\fP for it. 809 \f(CWpwd\fP and \f(CWcd\fP.
812 A current message, relative to the current folder, is maintained. 810 And the current message, relative to the current mail folder,
813 This enables commands like \f(CWnext\fP and \f(CWprev\fP. 811 which enables commands like \f(CWnext\fP and \f(CWprev\fP.
814 In contrast to Unix' context, which is chained to the shell session, 812 In contrast to Unix' context, which is chained to the shell session,
815 \s-1MH\s0's context is meant to be chained to a mail account. 813 \s-1MH\s0's context is meant to be chained to a mail account.
816 Actually, the current message is a property of the mail folder. 814 But actually, the current message is a property of the mail folder,
817 This is without problem as long as a mail folder belongs to one user. 815 which is mainly a legacy.
818 But when multiple users want to work on one mail folder simultaneously, 816 This will cause problems when multiple users work
819 it will cause problems. 817 in one mail folder simultaneously.
820 This is a legacy from a time when emailing was different.
821 .PP 818 .PP
822 Using a monolithic program with a captive user interface 819 Using a monolithic program with a captive user interface
823 means ``entering'' the program, using it, and ``leaving'' the program. 820 means ``entering'' the program, using it, and ``exiting'' the program.
824 Using a toolchest like \s-1MH\s0 means running programs, 821 Using toolchests like \s-1MH\s0 means running programs,
825 alone or in combinition with others, even from other toolchests, 822 alone or in combinition with others, even from other toolchests,
826 without leaving the shell. 823 without leaving the shell.
827 824
828 .NH 2 825
829 Gains of the design 826 .NH 2
830 .LP 827 Discussion of the design
828 .LP
829 The following paragraphs discuss \s-1MH\s0 in regard to the tenets
830 of the Unix Philosophy Gancarz identified.
831
832 .PP
833 .I "``Small is beautiful''
834 and
835 .I "``do one thing well''
836 are two design goals that are directly visible in \s-1MH\s0.
837 Gancarz actually presents \s-1MH\s0 as example under the headline
838 ``Making UNIX Do One Thing Well'':
839 .QP
840 [\s-1MH\s0] consists of a series of programs which
841 when combined give the user an enormous ability
842 to manipulate electronic mail messages.
843 A complex application, it shows that not only is it
844 possible to build large applications from smaller
845 components, but also that such designs are actually preferable.
846 .[
847 %A Mike Gancarz
848 %T unix-phil
849 %P 125
850 .]
851 .LP
852 The various small programs of \s-1MH\s0 were relatively easy
853 to write as each of them is small, limited to one function,
854 and has clear bounderies.
855 For the same reasons, they are also good to maintain.
856 Further more, the system can easily get extended.
857 One only needs to put a new program into the toolchest.
858 This was done when \s-1MIME\s0 support was added
859 (e.g. \f(CWmhbuild\fP).
860 Also, different programs can exist to do the basically same job
861 in different ways (e.g. in nmh: \f(CWshow\fP and \f(CWmhshow\fP).
862 If someone needs a mail system with some additionally
863 functions that are nowhere available yet, he best takes a
864 toolchest system like \s-1MH\s0 where he can add the
865 functionality with little work.
866
867 .PP
868 .I "Data storage.
869 How \s-1MH\s0 stores data was already mentioned.
870 Mail folders are directories (which contain a file
871 \&\f(CW.mh_sequences\fP) under the user's \s-1MH\s0 directory
872 (usually \f(CW$HOME/Mail\fP).
873 Mail messages are text files located in a mail folder.
874 The files contain the messages as they were received.
875 The messages are numbered in ascending order in each folder.
876 This mailbox format is called ``\s-1MH\s0'' after the \s-1MUA\s0.
877 Alternatives are \fImbox\fP and \fImaildir\fP.
878 In the mbox format all messages are stored within one file.
879 This was a good solution in the early days, when messages
880 were only a few lines of text and were deleted soon.
881 Today, when single messages often include several megabytes
882 of attachments, it is a bad solution.
883 Another disadvantage of the mbox format is that it is
884 more difficult to write tools that work on mail messages,
885 because it is always neccessary to first find and extract
886 the relevant message in the mbox file.
887 With \s-1MH\s0 mailboxes, each message is a self-standing item,
888 by definition.
889 Also, the problem of concurrent access to one mailbox is
890 reduced to the problem of concurrent access to one message.
891 However, the issue of the shared parts of the context,
892 as mentioned above, remains.
893 Maildir is generally similar to \s-1MH\s0's format,
894 but modified towards guaranteed reliability.
895 This involves some complexity, unfortunately.
896
897 .PP
898 .I "``Avoid captive user interfaces.''
831 \s-1MH\s0 is perfectly suited for non-interactive use. 899 \s-1MH\s0 is perfectly suited for non-interactive use.
832 It offers all functions directly and without captive user interfaces. 900 It offers all functions directly and without captive user interfaces.
833 If users want a graphical user interface, anyhow, 901 If users want a graphical user interface, anyhow,
834 they can have it with \fIxmh\fP or \fIexmh\fP. 902 they can have it with \fIxmh\fP or \fIexmh\fP, too.
835 These are graphical frontends for the \s-1MH\s0 toolchest. 903 These are graphical frontends for the \s-1MH\s0 toolchest.
836 This means, all email-related work is still done by \s-1MH\s0 tools, 904 This means, all email-related work is still done by \s-1MH\s0 tools,
837 but xmh issues the calls when the user clicks a button. 905 but the frontend issues the appropriate calls when the user
838 Providing easy-to-use user interfaces as frontends is a good 906 clicks on a button.
907 Providing easy-to-use user interfaces in form of frontends is a good
839 approach, because it does not limit the power of the backend itself. 908 approach, because it does not limit the power of the backend itself.
840 The frontend will anyways only be able to make a part of the 909 The frontend will anyway only be able to make a subset of the
841 backend's power and flexibility available. 910 backend's power and flexibility available.
842 If it is separate, then the missing parts can still be accessed 911 But if it is a separate program,
843 at the backend directly. 912 then the missing parts can still be accessed at the backend directly.
844 If it is integrated, then this will hardly be possible. 913 If it is integrated, then this will hardly be possible.
845 .PP 914
915 .PP
916 .I "``Choose portability over efficiency''
917 and
918 .I "``use shell scripts to increase leverage and portability'' .
919 These two tenets are indirectly, but nicely, demonstrated by
920 Bolsky and Korn in their book about the korn shell.
921 .[
922 %T The KornShell: command and programming language
923 %A Morris I. Bolsky
924 %A David G. Korn
925 %I Prentice Hall
926 %D 1989
927 %O \s-1ISBN\s0: 0-13-516972-0
928 .]
929 They demonstrated, in one chapter of the book, a basic implementation
930 of a subset of \s-1MH\s0 in ksh scripts.
931 Of course, this was just a demonstration, but a brilliant one.
932 It shows how quickly one can implement such a prototype with shell scripts,
933 and how readable they are.
934 The implementation in the scripting language may not be very fast,
935 but it can be fast enough though, and this is all that matters.
936 By having the code in an interpreted language, like the shell,
937 portability becomes a minor issue, if we assume the interpreter
938 to be widespread.
939 This demonstration also shows how easy it is to create single programs
940 of a toolchest software.
941 Most of the single programs comprise less than a hundred lines of
942 shell code.
943 Such small software is easy to write, easy to understand,
944 and thus easy to maintain.
945 Being a toolchest improved the possibility to only write some parts
946 and though create a working result.
947 Expanding the toolchest without global changes will likely be
948 possible, too.
949
950 .PP
951 .I "``Use software leverage to your advantage''
952 and the lesser tenet
953 .I "``allow the user to tailor the environment''
954 are ideally followed in the design of \s-1MH\s0.
955
956 .PP
957 filters: many tools provide basic FS operations (like mv, rm, ...)
958 prototypes: affect dev, but MH is very matured
959
960 .NH 2
961 Problems
962 .LP
963 modern emailing
964 MIME
965 encodings
966 largest problem: different feeling
967
968 .NH 2
969 Summary \s-1MH\s0
970 .LP
846 flexibility, no redundancy, use the shell 971 flexibility, no redundancy, use the shell
847
848 .PP
849 easy to write: see ksh-book
850
851 .NH 2
852 Problems
853 .LP
854 972
855 973
856 974
857 .NH 1 975 .NH 1
858 Case study: uzbl 976 Case study: uzbl