C: A Humbling Language

511
-1

Published on

OSDC 2007 opening keynote. Not sure it makes sense if you weren't there, but someone asked for slides.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
511
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

C: A Humbling Language

  1. 1. OSDC 2007 A Humbling Language Rusty Russell
  2. 2. Time Better Spent tcmalloc ● http://goog-perftools.sourceforge.net/doc/tcmalloc.html – tdb ● – ftp://ftp.samba.org/pub/unpacked/tdb lguest ● http://lguest.ozlabs.org –
  3. 3. ABCDEFG HIJKLM NOPQRST UVWXYZ
  4. 4. BCD G LM NOP RS UVW Z
  5. 5. C LM NO S VW Z
  6. 6. C O S
  7. 7. C O S
  8. 8. C S
  9. 9. C S
  10. 10. C
  11. 11. C
  12. 12. C
  13. 13. C: A Historic Language
  14. 14. http://www.thorstenkoerner.de/uploads/thompson_ritchie.jpg
  15. 15. += register entry
  16. 16. foo.c
  17. 17. foo.c preprocessor
  18. 18. foo.c #define FOO 17 preprocessor
  19. 19. foo.c #define FOO(x) (17*(x)) preprocessor
  20. 20. foo.c #ifdef LINUX ... #else preprocessor ... #endif
  21. 21. foo.c #include quot;foo.hquot; preprocessor
  22. 22. foo.c #include quot;foo.hquot; foo.h preprocessor
  23. 23. foo.c #include quot;foo.hquot; foo.h preprocessor #include <stdio.h>
  24. 24. foo.c #include quot;foo.hquot; foo.h preprocessor #include <stdio.h> stdio.h
  25. 25. foo.c #include quot;foo.hquot; foo.h preprocessor #include <stdio.h> stdio.h # include <features.h> # include <stddef.h> # include <bits/types.h> #include <libio.h> # include <stdarg.h> #include <bits/stdio_lim.h> #include <bits/sys_errlist.h> # include <getopt.h> # include <bits/stdio.h> # include <bits/stdio2.h> # include <bits/stdio-ldbl.h>
  26. 26. foo.c preprocessor
  27. 27. foo.c preprocessor
  28. 28. foo.c preprocessor foo.i
  29. 29. foo.c preprocessor compiler
  30. 30. foo.c preprocessor compiler
  31. 31. foo.c preprocessor compiler foo.s
  32. 32. foo.c preprocessor compiler assembler
  33. 33. foo.c bar.c baz.c preprocessor compiler assembler
  34. 34. foo.c bar.c baz.c preprocessor compiler assembler linker
  35. 35. foo.c bar.c baz.c preprocessor compiler assembler linker foobarbaz
  36. 36. foo.c bar.c baz.c make preprocessor compiler assembler linker foobarbaz
  37. 37. foo.c bar.c baz.c make preprocessor compiler ccache assembler linker foobarbaz
  38. 38. foo.c bar.c baz.c make preprocessor compiler ccache distcc assembler linker foobarbaz
  39. 39. foo.c bar.c baz.c make preprocessor ccontrol compiler ccache distcc assembler linker foobarbaz
  40. 40. foo.c bar.c baz.c make gcc *.c preprocessor ccontrol compiler ccache distcc assembler linker foobarbaz
  41. 41. 1988
  42. 42. entry void const volatile enum function prototypes
  43. 43. 1999
  44. 44. inline
  45. 45. foo.c bar.c baz.c preprocessor int compiler foo(int x)... assembler linker foobarbaz
  46. 46. foo.c bar.c baz.c preprocessor int compiler foo(int x)... assembler linker foobarbaz
  47. 47. foo.c bar.c baz.c preprocessor foo.h compiler assembler linker foobarbaz
  48. 48. foo.c bar.c baz.c preprocessor foo.h inline int foo(int x)... compiler assembler linker foobarbaz
  49. 49. WTF?
  50. 50. WTF? This isn't a scripting language!
  51. 51. Images from Wikipedia
  52. 52. C
  53. 53. C C
  54. 54. C C CC
  55. 55. C ontrol
  56. 56. C ycles
  57. 57. C ore
  58. 58. C ache
  59. 59. “Sell Me a C!”
  60. 60. The Magic
  61. 61. The Magic
  62. 62. struct list_head { struct list_head *next, *prev; };
  63. 63. struct list_head { struct list_head *next, *prev; }; struct thing { struct list_head elem; ... };
  64. 64. void *kmalloc(size_t size, gfp_t flags);
  65. 65. Just a little magic?
  66. 66. long f(struct foo *a, struct foo *b) { return b – a; }
  67. 67. Magic to get closer to the machine...
  68. 68. struct elems { unsigned int num_elems; struct elem[0]; };
  69. 69. #define memcpy(t, f, n) (__builtin_constant_p(n) ? __constant_memcpy((t),(f),(n)) : __memcpy((t),(f),(n)))
  70. 70. Magic to strengthen language features...
  71. 71. DANGER! Magic to strengthen language features...
  72. 72. #define new(type) ((type *)malloc(sizeof(type))
  73. 73. #define min(x,y) ({ typeof(x) _x = (x); typeof(y) _y = (y); (void) (&_x == &_y); _x < _y ? _x : _y; })
  74. 74. _Bool
  75. 75. #include <stdbool.h>
  76. 76. #include <stdbool.h> #define bool _Bool
  77. 77. #define begin { #define end }
  78. 78. talloc(context, type)
  79. 79. valgrind
  80. 80. C
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×