Alpine Perl Workshop 2016 • brian d foy
The Surprisingly Tense
History of the
Schwartzian Transform
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
http://bit.ly/2bHNNx4
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform Randal Schwartz
Just another
hack...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Tom Christiansen
•Languages geek
...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
The Technique
Its Expression
The ...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
decorate
sort
undecorate
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
compute
associate
sort
map
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Richard Stallman
•Editor editor
•...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
TECO - Text Editor and Corrector
...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Lisp
(defun schwartzian-transform...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
December 16, 1994
#!/usr/bin/perl...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Unfamiliar
Complex
Undocumented
H...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
OMFG
Awesome
New features
Lists o...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Not documented
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Easy to learn
Power tools
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
FMTEYEWTK
I'm not ragging on Rand...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
August 30, 1995
Or for possibly m...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
January 1996
http://www.stoneheng...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
April 1996
Tom labels a benchmark...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
July 1996
https://groups.google.c...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
October 1996
Tom posts a draft of...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
December 1996
https://groups.goog...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
I hereby propose that the aforeme...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
December 1996
I wonder if this ch...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
1999
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Orcish Manuever
@sorted = sort {
...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
2000
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Python 2.4, 3
sorted = sorted(str...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Python 2
tmp2 = [ (int(s[10:15]),...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
Ruby
[1,1.1,1.2,10].sort_by {|n| ...
ThePerlReview•www.theperlreview.com
TheSurprisinglyTenseHistoryoftheSchwartzianTransform
•Innsbruck - CC BY 2.0 by Reisend...
Upcoming SlideShare
Loading in …5
×

The Surprisingly Tense History of the Schwartzian Transform

1,029 views

Published on

Randal Schwartz dropped a small Perl 5 code sample into comp.unix.shells, and the world went mad.

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
1,029
On SlideShare
0
From Embeds
0
Number of Embeds
34
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

The Surprisingly Tense History of the Schwartzian Transform

  1. 1. Alpine Perl Workshop 2016 • brian d foy The Surprisingly Tense History of the Schwartzian Transform
  2. 2. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform http://bit.ly/2bHNNx4
  3. 3. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Randal Schwartz Just another hacker. •troff •emacs •Lisp •Perl •Smalltalk •…
  4. 4. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Tom Christiansen •Languages geek •Csh god •Perl evangelist
  5. 5. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform The Technique Its Expression The Arguments Its Name The Reckoning
  6. 6. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform decorate sort undecorate
  7. 7. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform compute associate sort map
  8. 8. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Richard Stallman •Editor editor •GNU •Free Software
  9. 9. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform TECO - Text Editor and Corrector Emacs - Editing MACroS EINE - E. Is Not Emacs ZWEI - Z. Was EINE Initially GNU Emacs
  10. 10. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Lisp (defun schwartzian-transform (list costly-function predicate) (mapcar #'cdr (stable-sort (mapcar (lambda (x) (cons (funcall costly-function x) x)) list) predicate :key #'car))) (require :sb-posix) (schwartzian-transform (directory "/etc/*") (lambda (x) (sb-posix:stat-mtime (sb-posix:stat x))) #'<=) http://codereview.stackexchange.com/a/138436/13050
  11. 11. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform December 16, 1994 #!/usr/bin/perl require 5; # new features, new bugs! print map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [$_, /(S+)$/] } <>; Randal Schwartz in comp.unix.shells
  12. 12. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Unfamiliar Complex Undocumented Hard to learn Too clever New Different
  13. 13. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform OMFG Awesome New features Lists of lists Power tools
  14. 14. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Not documented
  15. 15. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Easy to learn Power tools
  16. 16. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform FMTEYEWTK I'm not ragging on Randal, merely teasing a bit. He's just trying to be clever, and that's what he does. I'm just submitting a sample chapter for his perusal for inclusion the mythical Alpaca Book :-) Tom Christiansen Far More Than Everything You've Ever Wanted to Know About Sorting, http://www.perl.com/doc/FMTEYEWTK/sort.html
  17. 17. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform August 30, 1995 Or for possibly more efficiency, ensure that the calls only happen once per record, rather than approximately NlogN times, with the Schwartz transformation:-) @keys = map { $_->[0] } sort { $a->[1] <=> $b->[1] or $a cmp $b } map { [ $_, datexform($foo{$_}) ] } keys %foo; Bennett Todd in comp.lang.perl.misc https://groups.google.com/forum/?hl=en#!topic/comp.lang.perl.misc/fLo0RNV8oW8
  18. 18. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform January 1996 http://www.stonehenge.com/merlyn/UnixReview/col06.html Randal explains map-sort-map in Unix Review I'm going to talk about some sorts of sorts, and hopefully you'll sort everything out by the time you're finished reading. (And no, despite the similarity to my name, I will not talk about ``random sorts''.)
  19. 19. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform April 1996 Tom labels a benchmark "Schwartzian XFrom" in comp.lang.perl.misc for “Read directory in timestamp order?” https://groups.google.com/d/msg/comp.lang.perl.misc/pw-Hl4byLnc/yzejRnku3RoJ
  20. 20. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform July 1996 https://groups.google.com/d/msg/comp.lang.perl.misc/6NEeX4XJx54/nmpMmReMIbcJ Colin Howarth in comp.lang.perl.misc "Schwartzian transform of %$self ... help?"
  21. 21. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform October 1996 Tom posts a draft of perllol with "Schwartzian Transform"
  22. 22. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform December 1996 https://groups.google.com/d/msg/comp.lang.perl.misc/fPx42DB2jd8/cC_6osV70mMJ Tom in comp.lang.perl.misc I'm still pissed at Randal for having posted it, especially the way he did.
  23. 23. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform I hereby propose that the aforementioned Lispism, yclept “Schwartzian Transform", be recast in a less Teutonic albeit darker light; to wit, "Black Transform", as this spelling more accurately connotes its sinister subtleties. :-) Tom later in the same thread
  24. 24. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform December 1996 I wonder if this chunk of code will haunt us forever. Eric Arnold in comp.lang.perl.misc https://groups.google.com/d/msg/comp.lang.perl.misc/fPx42DB2jd8/CTRmyWyJW6MJ
  25. 25. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform 1999
  26. 26. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Orcish Manuever @sorted = sort { ( $times{$a} ||= -M $a ) <=> ( $times{$b} ||= -M $b ) } @old_array; Perl 4 compatible version
  27. 27. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform 2000
  28. 28. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Python 2.4, 3 sorted = sorted(string_list, key=…) string_list.sort(key=lambda …) map(lambda x: x[1], sorted( map(lambda x: (f(x), x), old_list))) new_list = zip(* sorted( zip(map(f, old_list), old_list)))[1]
  29. 29. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Python 2 tmp2 = [ (int(s[10:15]), s) for s in L ] tmp2.sort() Isorted = [ x[1] for x in tmp2 ] sorted([5, 2, 4, 1, 3], cmp=…)
  30. 30. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform Ruby [1,1.1,1.2,10].sort_by {|n| n.to_s}
  31. 31. ThePerlReview•www.theperlreview.com TheSurprisinglyTenseHistoryoftheSchwartzianTransform •Innsbruck - CC BY 2.0 by Reisender1701 (Flickr) https://goo.gl/PuILnA •Randal Schwartz - CC BY-SA 3.0 by Chris Marquardt https://commons.wikimedia.org/wiki/File:Randal_Schwartz_headshot_by_Chris_Marquardt.png •Tom Christiansen - CC BY-SA 3.0 by Tim Bray https://en.wikipedia.org/wiki/File:Tom_Christiansen_in_2008.jpg •Richard Stallman - CC BY-SA 3.0 by Thesupermat https://commons.wikimedia.org/wiki/File:Richard_Stallman_-_Fête_de_l%27Humanité_2014_-_010.jpg

×