comparison unix-phil.ms @ 47:b6ae4a8ab1d3

improved references and some minor design issues
author meillo@marmaro.de
date Mon, 12 Apr 2010 14:11:39 +0200
parents 98a1446744c7
children 40caeb9e9b25
comparison
equal deleted inserted replaced
46:98a1446744c7 47:b6ae4a8ab1d3
1 .nr PS 11 1 .nr PS 11
2 .nr VS 13 2 .nr VS 13
3 .nr lu 0 3 .nr lu 0
4
4 .de CW 5 .de CW
5 .nr PQ \\n(.f 6 .nr PQ \\n(.f
6 .if t .ft CW 7 .if t .ft CW
7 .ie ^\\$1^^ .if n .ul 999 8 .ie ^\\$1^^ .if n .ul 999
8 .el .if n .ul 1 9 .el .if n .ul 1
9 .if t .if !^\\$1^^ \&\\$1\f\\n(PQ\\$2 10 .if t .if !^\\$1^^ \&\\$1\f\\n(PQ\\$2
10 .if n .if \\n(.$=1 \&\\$1 11 .if n .if \\n(.$=1 \&\\$1
11 .if n .if \\n(.$>1 \&\\$1\c 12 .if n .if \\n(.$>1 \&\\$1\c
12 .if n .if \\n(.$>1 \&\\$2 13 .if n .if \\n(.$>1 \&\\$2
13 .. 14 ..
15
14 .ds [. \ [ 16 .ds [. \ [
15 .ds .] ] 17 .ds .] ]
16 18
17 .rn NH _N 19 .rn NH _N
18 .de NH 20 .de NH
21 ._N \\$1 23 ._N \\$1
22 .if '\\$1'1' .nr PS -2 24 .if '\\$1'1' .nr PS -2
23 .. 25 ..
24 26
25 .am QP 27 .am QP
28 .ps -1
29 ..
30
31 .am DS
32 .CW
26 .ps -1 33 .ps -1
27 .. 34 ..
28 35
29 .\"---------------------------------------- 36 .\"----------------------------------------
30 37
43 .AE 50 .AE
44 51
45 .FS 52 .FS
46 .ps -1 53 .ps -1
47 This paper was prepared for the ``Software Analysis'' seminar at University Ulm. 54 This paper was prepared for the ``Software Analysis'' seminar at University Ulm.
48 Mentor was professor Schweiggert. 2010-04-05 55 Mentor was professor Franz Schweiggert.
49 .br 56 Handed in on 2010-04-12.
50 You may retrieve this document from 57 You may retrieve this document from
51 .CW \s-1http://marmaro.de/docs \ . 58 .CW \s-1http://marmaro.de/docs \ .
52 .FE 59 .FE
53 60
54 .NH 1 61 .NH 1
55 Introduction 62 Introduction
56 .XS 63 .XS
64 .sp .5v
65 .B
57 \*(SN Introduction 66 \*(SN Introduction
58 .XE 67 .XE
59 .LP 68 .LP
60 The Unix Philosophy is the essence of how the Unix operating system, 69 The Unix Philosophy is the essence of how the Unix operating system,
61 especially its toolchest, was designed. 70 especially its toolchest, was designed.
128 137
129 .NH 1 138 .NH 1
130 Importance of software design in general 139 Importance of software design in general
131 .XS 140 .XS
132 .sp .5v 141 .sp .5v
142 .B
133 \*(SN Importance of software design in general 143 \*(SN Importance of software design in general
134 .XE 144 .XE
135 .LP 145 .LP
136 Software design is the planning of how the internal structure 146 Software design is the planning of how the internal structure
137 and external interfaces of a software should look like. 147 and external interfaces of a software should look like.
243 253
244 .NH 1 254 .NH 1
245 The Unix Philosophy 255 The Unix Philosophy
246 .XS 256 .XS
247 .sp .5v 257 .sp .5v
258 .B
248 \*(SN The Unix Philosophy 259 \*(SN The Unix Philosophy
249 .XE 260 .XE
250 .LP 261 .LP
251 The origins of the Unix Philosophy were already introduced. 262 The origins of the Unix Philosophy were already introduced.
252 This chapter explains the philosophy, oriented on Gancarz, 263 This chapter explains the philosophy, oriented on Gancarz,
261 Following are some examples to demonstrate how applied Unix Philosophy feels like. 272 Following are some examples to demonstrate how applied Unix Philosophy feels like.
262 Knowledge of using the Unix shell is assumed. 273 Knowledge of using the Unix shell is assumed.
263 .PP 274 .PP
264 Counting the number of files in the current directory: 275 Counting the number of files in the current directory:
265 .DS 276 .DS
266 .CW
267 .ps -1
268 ls | wc -l 277 ls | wc -l
269 .DE 278 .DE
270 The 279 The
271 .CW ls 280 .CW ls
272 command lists all files in the current directory, one per line, 281 command lists all files in the current directory, one per line,
274 .CW "wc -l 283 .CW "wc -l
275 counts the number of lines. 284 counts the number of lines.
276 .PP 285 .PP
277 Counting the number of files that do not contain ``foo'' in their name: 286 Counting the number of files that do not contain ``foo'' in their name:
278 .DS 287 .DS
279 .CW
280 .ps -1
281 ls | grep -v foo | wc -l 288 ls | grep -v foo | wc -l
282 .DE 289 .DE
283 Here, the list of files is filtered by 290 Here, the list of files is filtered by
284 .CW grep 291 .CW grep
285 to remove all lines that contain ``foo''. 292 to remove all lines that contain ``foo''.
286 The rest equals the previous example. 293 The rest equals the previous example.
287 .PP 294 .PP
288 Finding the five largest entries in the current directory. 295 Finding the five largest entries in the current directory.
289 .DS 296 .DS
290 .CW
291 .ps -1
292 du -s * | sort -nr | sed 5q 297 du -s * | sort -nr | sed 5q
293 .DE 298 .DE
294 .CW "du -s * 299 .CW "du -s *
295 returns the recursively summed sizes of all files in the current directory 300 returns the recursively summed sizes of all files in the current directory
296 \(en no matter if they are regular files or directories. 301 \(en no matter if they are regular files or directories.
440 But new programs can get created out of existing one with very low effort. 445 But new programs can get created out of existing one with very low effort.
441 .PP 446 .PP
442 A wrapper script for finding the five largest entries in the current directory 447 A wrapper script for finding the five largest entries in the current directory
443 could look like this: 448 could look like this:
444 .DS 449 .DS
445 .CW
446 .ps -1
447 #!/bin/sh 450 #!/bin/sh
448 du -s * | sort -nr | sed 5q 451 du -s * | sort -nr | sed 5q
449 .DE 452 .DE
450 The script itself is just a text file that calls the command line, 453 The script itself is just a text file that calls the command line,
451 which a professional user would type in directly. 454 which a professional user would type in directly.
452 It is probably worth to make the program flexible on the number of 455 It is probably worth to make the program flexible on the number of
453 entries it prints: 456 entries it prints:
454 .DS 457 .DS
455 .CW
456 .ps -1
457 #!/bin/sh 458 #!/bin/sh
458 num=5 459 num=5
459 [ $# -eq 1 ] && num="$1" 460 [ $# -eq 1 ] && num="$1"
460 du -sh * | sort -nr | sed "${num}q" 461 du -sh * | sort -nr | sed "${num}q"
461 .DE 462 .DE
511 No other part of the work so cripples the resulting system if done wrong. 512 No other part of the work so cripples the resulting system if done wrong.
512 No other part is more difficult to rectify later. 513 No other part is more difficult to rectify later.
513 .PP 514 .PP
514 Writing a prototype is a great method for becoming familiar with the requirements 515 Writing a prototype is a great method for becoming familiar with the requirements
515 and to run into real problems early. 516 and to run into real problems early.
517 .[ [
518 gancarz
519 unix philosophy
520 .], page 28 f.]
516 .PP 521 .PP
517 Prototyping is often seen as a first step in building a software. 522 Prototyping is often seen as a first step in building a software.
518 This is, of course, good. 523 This is, of course, good.
519 However, the Unix Philosophy has an \fIadditional\fP perspective on prototyping: 524 However, the Unix Philosophy has an \fIadditional\fP perspective on prototyping:
520 After having built the prototype, one might notice, that the prototype is already 525 After having built the prototype, one might notice, that the prototype is already
532 \*(SN Worse is better 537 \*(SN Worse is better
533 .XE 538 .XE
534 .LP 539 .LP
535 The Unix Philosophy aims for the 90% solution; 540 The Unix Philosophy aims for the 90% solution;
536 others call it the ``Worse is better'' approach. 541 others call it the ``Worse is better'' approach.
537 Practical experience shows, that: 542 Experience from real life projects shows:
538 .PP 543 .PP
539 (1) It is almost never possible to define the 544 (1) It is almost never possible to define the
540 requirements completely and correctly the first time. 545 requirements completely and correctly the first time.
541 Hence one should not try to; one will fail anyway. 546 Hence one should not try to; one will fail anyway.
542 .PP 547 .PP
549 (3) Maintenance work is hard work. 554 (3) Maintenance work is hard work.
550 Hence, one should keep the amount of code as small as possible; 555 Hence, one should keep the amount of code as small as possible;
551 it should just fulfill the \fIcurrent\fP requirements. 556 it should just fulfill the \fIcurrent\fP requirements.
552 Software parts that will be written in future, 557 Software parts that will be written in future,
553 do not need maintenance till then. 558 do not need maintenance till then.
559 .PP
560 See Brooks' ``The Mythical Man-Month'' for reference.
561 .[ [
562 brooks
563 mythical man-month
564 .], page 115 ff.]
554 .PP 565 .PP
555 Starting with a prototype in a scripting language has several advantages: 566 Starting with a prototype in a scripting language has several advantages:
556 .IP \(bu 567 .IP \(bu
557 As the initial effort is low, one will likely start right away. 568 As the initial effort is low, one will likely start right away.
558 .IP \(bu 569 .IP \(bu
606 Transferred to software: The most successful software, is the fittest, 617 Transferred to software: The most successful software, is the fittest,
607 is the one that survives. 618 is the one that survives.
608 (This may be at the level of one creature, or at the level of one species.) 619 (This may be at the level of one creature, or at the level of one species.)
609 The fitness of software is affected mainly by four properties: 620 The fitness of software is affected mainly by four properties:
610 portability of code, portability of data, range of usability, and reusability of parts. 621 portability of code, portability of data, range of usability, and reusability of parts.
611 .\" .IP \(bu
612 .\" portability of code
613 .\" .IP \(bu
614 .\" portability of data
615 .\" .IP \(bu
616 .\" range of usability
617 .\" .IP \(bu
618 .\" reuseability of parts
619 .PP 622 .PP
620 (1) 623 (1)
621 .I "Portability of code 624 .I "Portability of code
622 means, using high-level programming languages, 625 means, using high-level programming languages,
623 sticking to the standard, 626 sticking to the standard,
627 .[ [
628 kernighan pike
629 practice of programming
630 .], chapter\|8]
624 and avoiding optimizations that introduce dependencies on specific hardware. 631 and avoiding optimizations that introduce dependencies on specific hardware.
625 Hardware has a much lower lifetime than software. 632 Hardware has a much lower lifetime than software.
626 By chaining software to a specific hardware, 633 By chaining software to a specific hardware,
627 the software's lifetime gets shortened to that of this hardware. 634 the software's lifetime gets shortened to that of this hardware.
628 In contrast, software should be easy to port \(en 635 In contrast, software should be easy to port \(en
629 adaptation is the key to success. 636 adaptation is the key to success.
630 .\" cf. practice of prog: ch08
631 .PP 637 .PP
632 (2) 638 (2)
633 .I "Portability of data 639 .I "Portability of data
634 is best achieved by avoiding binary representations 640 is best achieved by avoiding binary representations
635 to store data, because binary representations differ from machine to machine. 641 to store data, because binary representations differ from machine to machine.
639 Important is that it is a plain text representation in a 645 Important is that it is a plain text representation in a
640 very common charset encoding. 646 very common charset encoding.
641 Apart from being able to transfer data between machines, 647 Apart from being able to transfer data between machines,
642 readable data has the great advantage, that humans are able to directly 648 readable data has the great advantage, that humans are able to directly
643 read and edit it with text editors and other tools from the Unix toolchest. 649 read and edit it with text editors and other tools from the Unix toolchest.
644 .\" gancarz tenet 5 650 .[ [
651 gancarz
652 unix philosophy
653 .], page 56 ff.]
645 .PP 654 .PP
646 (3) 655 (3)
647 A large 656 A large
648 .I "range of usability 657 .I "range of usability
649 ensures good adaptation, and thus good survival. 658 ensures good adaptation, and thus good survival.
703 712
704 .NH 1 713 .NH 1
705 Case study: \s-1MH\s0 714 Case study: \s-1MH\s0
706 .XS 715 .XS
707 .sp .5v 716 .sp .5v
717 .B
708 \*(SN Case study: \s-1MH\s0 718 \*(SN Case study: \s-1MH\s0
709 .XE 719 .XE
710 .LP 720 .LP
711 The previous chapter introduced and explained the Unix Philosophy 721 The previous chapter introduced and explained the Unix Philosophy
712 from a general point of view. 722 from a general point of view.
716 the driving force in the discussion. 726 the driving force in the discussion.
717 .PP 727 .PP
718 This first case study is about the mail user agents (\s-1MUA\s0) 728 This first case study is about the mail user agents (\s-1MUA\s0)
719 \s-1MH\s0 (``mail handler'') and its descendent \fInmh\fP 729 \s-1MH\s0 (``mail handler'') and its descendent \fInmh\fP
720 (``new mail handler''). 730 (``new mail handler'').
731 .[
732 nmh website
733 .]
721 \s-1MUA\s0s provide functions to read, compose, and organize mail, 734 \s-1MUA\s0s provide functions to read, compose, and organize mail,
722 but (ideally) not to transfer it. 735 but (ideally) not to transfer it.
723 In this document, the name \s-1MH\s0 will be used to include nmh. 736 In this document, the name \s-1MH\s0 will be used to include nmh.
724 A distinction will only be made if differences between 737 A distinction will only be made if differences between
725 \s-1MH\s0 and nmh are described. 738 \s-1MH\s0 and nmh are described.
1050 It is possible to take one of the distributed format files 1063 It is possible to take one of the distributed format files
1051 or to write one yourself. 1064 or to write one yourself.
1052 To use the format as default for \f(CWscan\fP, a single line, 1065 To use the format as default for \f(CWscan\fP, a single line,
1053 reading 1066 reading
1054 .DS 1067 .DS
1055 .CW
1056 scan: -form FORMATFILE 1068 scan: -form FORMATFILE
1057 .DE 1069 .DE
1058 must be added to \f(CW.mh_profile\fP. 1070 must be added to \f(CW.mh_profile\fP.
1059 If one wants this different format as an additional command, 1071 If one wants this different format as an additional command,
1060 instead of changing the default, he needs to create a link to 1072 instead of changing the default, he needs to create a link to
1166 1178
1167 .NH 1 1179 .NH 1
1168 Case study: uzbl 1180 Case study: uzbl
1169 .XS 1181 .XS
1170 .sp .5v 1182 .sp .5v
1183 .B
1171 \*(SN Case study: uzbl 1184 \*(SN Case study: uzbl
1172 .XE 1185 .XE
1173 .LP 1186 .LP
1174 The last chapter took a look on the \s-1MUA\s0 \s-1MH\s0, 1187 The last chapter took a look on the \s-1MUA\s0 \s-1MH\s0,
1175 which is an old and established software. 1188 which is an old and established software.
1198 ``Maybe, if I find the time ;-)''. 1211 ``Maybe, if I find the time ;-)''.
1199 .PP 1212 .PP
1200 Fortunately, he found the time. 1213 Fortunately, he found the time.
1201 One day later, the first prototype was out. 1214 One day later, the first prototype was out.
1202 One week later, uzbl had an own website. 1215 One week later, uzbl had an own website.
1216 .[
1217 uzbl website
1218 .]
1203 One month after the first code showed up, 1219 One month after the first code showed up,
1204 a mailing list was installed to coordinate and discuss further development. 1220 a mailing list was installed to coordinate and discuss further development,
1205 Then a wiki followed to store documentation and scripts that showed up on the 1221 and a wiki was added to store documentation and scripts that showed up on the
1206 mailing list and elsewhere. 1222 mailing list and elsewhere.
1207 .PP 1223 .PP
1208 In the, now, one year of uzbl's existence, it was heavily developed on various branches. 1224 In the, now, one year of uzbl's existence, it was heavily developed on various branches.
1209 Plaetinck's task became more and more to only merge the best code from the 1225 Plaetinck's task became more and more to only merge the best code from the
1210 different branches into his main branch, and to apply patches. 1226 different branches into his main branch, and to apply patches.
1227 .[
1228 lwn uzbl
1229 .]
1211 About once a month, Plaetinck released a new version. 1230 About once a month, Plaetinck released a new version.
1212 In September 2009, he presented several forks of uzbl. 1231 In September 2009, he presented several forks of uzbl.
1232 .[ [
1233 uzbl website
1234 .], news archive]
1213 Uzbl, actually, opened the field for a whole family of web browsers with similar shape. 1235 Uzbl, actually, opened the field for a whole family of web browsers with similar shape.
1214 .PP 1236 .PP
1215 In July 2009, \fILinux Weekly News\fP published an interview with Plaetinck about uzbl. 1237 In July 2009, \fILinux Weekly News\fP published an interview with Plaetinck about uzbl.
1238 .[
1239 lwn uzbl
1240 .]
1216 In September 2009, the uzbl web browser was on \fISlashdot\fP. 1241 In September 2009, the uzbl web browser was on \fISlashdot\fP.
1242 .[
1243 slashdot uzbl
1244 .]
1217 1245
1218 .NH 2 1246 .NH 2
1219 Contrasts to other web browsers 1247 Contrasts to other web browsers
1220 .XS 1248 .XS
1221 \*(SN Contrasts to other web browsers 1249 \*(SN Contrasts to other web browsers
1238 various tools that cover single jobs. 1266 various tools that cover single jobs.
1239 Therefore, uzbl listens for commands on a named pipe (fifo), a Unix socket, 1267 Therefore, uzbl listens for commands on a named pipe (fifo), a Unix socket,
1240 and on stdin, and it writes events to a Unix socket and to stdout. 1268 and on stdin, and it writes events to a Unix socket and to stdout.
1241 Loading a webpage in a running uzbl instance requires only: 1269 Loading a webpage in a running uzbl instance requires only:
1242 .DS 1270 .DS
1243 .CW
1244 echo 'uri http://example.org' >/path/to/uzbl-fifo 1271 echo 'uri http://example.org' >/path/to/uzbl-fifo
1245 .DE 1272 .DE
1246 The graphical rendering of the webpage is done by webkit, 1273 The graphical rendering of the webpage is done by webkit,
1247 a web content engine. 1274 a web content engine.
1248 Uzbl-core is built around libwebkit. 1275 Uzbl-core is built around libwebkit.
1338 The history mechanism of uzbl shall be presented as an example. 1365 The history mechanism of uzbl shall be presented as an example.
1339 Uzbl is configured to spawn a script to append an entry to the history 1366 Uzbl is configured to spawn a script to append an entry to the history
1340 whenever the event of a fully loaded page occurs. 1367 whenever the event of a fully loaded page occurs.
1341 The script to append the entry to the history is not much more than: 1368 The script to append the entry to the history is not much more than:
1342 .DS 1369 .DS
1343 .CW
1344 #!/bin/sh 1370 #!/bin/sh
1345 file=/path/to/uzbl-history 1371 file=/path/to/uzbl-history
1346 echo `date +'%Y-%m-%d %H:%M:%S'`" $6 $7" >> $file 1372 echo `date +'%Y-%m-%d %H:%M:%S'`" $6 $7" >> $file
1347 .DE 1373 .DE
1348 \f(CW$6\fP and \f(CW$7\fP expand to the \s-1URL\s0 and the page title. 1374 \f(CW$6\fP and \f(CW$7\fP expand to the \s-1URL\s0 and the page title.
1352 then displays \fIdmenu\fP to let the user select an item, 1378 then displays \fIdmenu\fP to let the user select an item,
1353 and afterwards writes the selected \s-1URL\s0 into uzbl's command input pipe. 1379 and afterwards writes the selected \s-1URL\s0 into uzbl's command input pipe.
1354 With error checking and corner case handling removed, 1380 With error checking and corner case handling removed,
1355 the script looks like this: 1381 the script looks like this:
1356 .DS 1382 .DS
1357 .CW
1358 #!/bin/sh 1383 #!/bin/sh
1359 file=/path/to/uzbl-history 1384 file=/path/to/uzbl-history
1360 goto=`tac $file | dmenu | cut -d' ' -f 3` 1385 goto=`tac $file | dmenu | cut -d' ' -f 3`
1361 echo "uri $goto" > $4 1386 echo "uri $goto" > $4
1362 .DE 1387 .DE
1494 1519
1495 .NH 1 1520 .NH 1
1496 Final thoughts 1521 Final thoughts
1497 .XS 1522 .XS
1498 .sp .5v 1523 .sp .5v
1524 .B
1499 \*(SN Final thoughts 1525 \*(SN Final thoughts
1500 .XE 1526 .XE
1501 1527
1502 .NH 2 1528 .NH 2
1503 Quick summary 1529 Quick summary
1517 \*(SN Why people should choose 1543 \*(SN Why people should choose
1518 .XE 1544 .XE
1519 .LP 1545 .LP
1520 Make the right choice! 1546 Make the right choice!
1521 1547
1522 .nr PI .3i 1548
1549 .bp
1550 .TL
1551 References
1552 .LP
1553 .XS
1554 .sp .5v
1555 .B
1556 References
1557 .XE
1558 .ev r
1523 .rm ]< 1559 .rm ]<
1524 .de ]< 1560 .de ]<
1525 .LP 1561 .LP
1526 .de FP 1562 .de FP
1527 .IP \\\\$1. 1563 .IP \\\\$1.
1528 \\.. 1564 \\..
1529 .rm FS FE 1565 .rm FS FE
1530 .. 1566 ..
1531 .ds CH "
1532 .bp
1533 .rs
1534 .sp .3i
1535 .TL
1536 References
1537 .LP
1538 .XS
1539 .sp .5v
1540 References
1541 .XE
1542 .sp 2v
1543 .nr PS -1 1567 .nr PS -1
1544 .nr VS -1 1568 .nr VS -1
1545 .[ 1569 .[
1546 $LIST$ 1570 $LIST$
1547 .] 1571 .]
1548 .\".wh -1p 1572 .nr PS +1
1573 .nr VS +1
1574 .ev
1575
1549 .bp 1576 .bp
1550 .PX 1577 .TL
1578 Table of Contents
1579 .LP
1580 .PX no