Live data from Hacker News

How knowing Lisp destroyed my programming career (2006)

coding.derkeiler.com

431–433 of 433 posts

Re: How knowing Lisp destroyed my programming career (2006)

#431
post #86

Earlier quoted context omitted.

What made it click for me is the nature of scheme: a few, very well thought out abstractions, that compose well to build a really neat language. I never really made friends with other languages. Where scheme composes the primitives for problem solving, I find that languages like python or ruby provide either one way for each different thing, or a very large hammer for every problem you might find, be it list comprehe…

> a very large hammer for every problem you might find, be it list comprehensions or generators or whatever OO voodoo you can come up with. List comprehensions, to me, are what makes Python a productive (or the most productive) prototyping language. It allows me to think and program in mathematical relations without much fuss. Add to that nice sets and dicts (needed for asymptotic efficiency), and I can easily forgiv…

Looking at a page about list comprehensions in Python.

  S = {x² : x in {0 ... 9}}
  V = (1, 2, 4, 8, ..., 2¹²)
  M = {x | x in S and x even}
Python (from that page)

  S = [x**2 for x in range(10)]
  V = [2**i for i in range(13)]
  M = [x for x in S if x % 2 == 0]
I did not see 10 or 13 in the original definitions

Perl 6 closest syntax to original

  my \S = ($_² for 0 ... 9);
  my \V = (1, 2, 4, 8 ... 2¹²); # almost identical
  my \M = ($_ if $_ %% 2 for S);
Perl 6 closest syntax to Python

  my \S = [-> \x { x**2 } for ^10];
  my \V = [-> \i { 2**i } for ^13];
  my \M = [-> \x { x if x % 2 == 0 } for S];
Perl 6 more idiomatic

  my \S = (0..9)»²;
  my \V = 1, 2, 4 ... 2¹²;
  my \M = S.grep: * %% 2;
Perl 6 with infinite sequences

  my \S = (0..*).map: *²;
  my \V = 1, 2, 4 ... *;
  my \M = S.grep: * %% 2;
---

Python

  string = 'The quick brown fox jumps over the lazy dog'
  words = string.split()
  stuff = [[w.upper(), w.lower(), len(w)] for w in words]
Perl 6

  my \string = 'The quick brown fox jumps over the lazy dog';
  my \words = string.words;
  my \stuff = [[.uc, .lc, .chars] for words]
I wouldn't say Python's list comprehensions are really that big of a selling point. I mean based on what I've seen to understand it the biggest difference is that feature in Python runs from the inside out.

  noprimes = [j for i in range(2, 8) for j in range(i*2, 50, i)]
                         range(2, 8)
                for i in
                                              range(i*2, 50, i)
                                     for j in
              j
             [                                                 ]
Whereas Perl 6 is either left-to-right

  my \noprimes = (2..^8).map: { |($^i*2, $i*3 ...^ 50).map: { $^j }}
                 (2..^8)
                        .map:
                              { |($^i*2, $i*3 ...^ 50)             }
                                                      .map:
                                                            { $^j }
or right-to-left

  my \noprimes = ({ $^j } for ({ |($^i*2, $i*3 ...^ 50) } for 2..^8))
                                                              2..^8
                                                          for
                               { |($^i*2, $i*3 ...^ 50) }
                              (                                    )
                          for
                  { $^j }
                 (                                                  )
Here are a couple other translations using Set operators

  primes = [x for x in range(2, 50) if x not in noprimes]

  my \primes = (2..^50).grep: * ∉ noprimes;

  my \prime-set = 2..^50 (-) noprimes; # a Set object
  my \primes = prime-set.keys.sort;
Also I'm fairly certain Python doesn't have a way of using them on a Supply concurrently.

  # create a prime supply and act on it in the background
  Supply.interval(1).grep(*.is-prime).act: &say;

  say 'main thread still running';
  # says 'main thread still running' immediately

  # deadlock main thread,
  # otherwise the program would terminate
  await Promise.new;

  # waits 2 seconds from the .act call, says 2
  # waits 1 second , says 3
  # waits 2 seconds, says 5
  # waits 2 seconds, says 7
  # waits 4 seconds, says 11
  # and so on until it is terminated
Basically the only selling point of that feature in Python over say Perl6 is that is at times a bit closer to what a mathematician would normally write.

I'm not a mathematician.

To me it seems a bit verbose and clunky. It probably also only works as a single line, which seems odd in a line oriented programming language. Basically it seems like a little DSL for list generation, sort of like Perl's regexes are a DSL for string operations.

Perhaps you may want to reread the last paragraph from the original article. Maybe in a few years the world will have passed you by. Then again maybe not.

Re: How knowing Lisp destroyed my programming career (2006)

#432

Earlier quoted context omitted.

I like to think of each programming language as a separate musical instrument. If Java is a tuba, then maybe Python is a trumpet. They're two very different instruments, but they share a lot of the same underlying intuitions. In fact, I would say that C-style languages are probably equivalent to the collection of brass instruments. There are major variations from trombones to trumpets to french-horns, but not as larg…

Perl fits into C-Like, Pure Fun and Code-Golfy in addition to Stringy.

In general languages tend to focus on one thing, where Perl tend to focus on many things. So it is difficult to classify.

In addition almost everything that is easy in Perl 5 is also easy in Perl 6, but it also makes a wide variety of additional things easy. For example there is are several meta operators for dealing with lists.

  (1,2,3) Z+ (10,20,30); # (11, 22, 33)
  [Z+] ( (1,2,3), (10,20,30), (100,200,300) ); # (111, 222, 333)

  [Z*] (1,2,3,4,5), ( 10 xx Inf ), ( i xx Inf ); # (0+10i, 0+20i, 0+30i, 0+40i, 0+50i)

  ((1,1),(2,2),(3,3)) «+» ((40,50,60),)
  # ((41, 51, 61), (42, 52, 62), (43, 53, 63))
So it has a lot in common with data-driven languages.

There are also features which you might expect to see in a distributed language.

Basically if there is a choice between A and B, Perl tends to choose both. With Perl 6 doing this to a greater extent than previous Perls.

Re: How knowing Lisp destroyed my programming career (2006)

#433
post #321
post #313

Earlier quoted context omitted.

https://www.quora.com/Where-did-we-go-wrong-Why-didnt-Common... In the above answer to a question in Quora, he seems to suggest that most of the features in lisp eventually got adopted in most other mainstream languages. Or in other words the concept of 'acceptable lisp'. I get what you are saying, and I feel the same way. But I think what people try to imply here- If you are using Lisp for a certain set of features,…

> Today, all those features, except for macros, are common in the popular languages. But not in the same language and/or less well integrated. Example: mostly no popular language has flexible macros as tightly integrated in the language as Lisp has. Those who have macros, either have a different view on macros and/or have them as preprocessing steps. You find very few languages with generic functions. There are lots…

Perl is not an acronym, Larry wanted to call it Pearl, but there was already a language by that name.

Also we tend to prefer Perl 6 to be spelled with a non-breaking space before the 6. [U+A0]

Perl 6 has features from many sources, so it is indeed a departure from Lisp.

Post reply on HN