← Back to context

Comment by spongebobism

6 days ago

Perlis's 10th epigram feels germane:

> Get into a rut early: Do the same process the same way. Accumulate idioms. Standardize. The only difference(!) between Shakespeare and you was the size of his idiom list - not the size of his vocabulary.

Well sure - being in a rut is good. But the language is the medium in which you cast your idiom, right?

Here's a Python rut:

  n = 20  # how many numbers to generate
  a, b = 0, 1
  for _ in range(n):
    print(a, end=" ")
    a, b = b, a + b
  print()

Here's that rut in Raku:

  (0,1,*+*...*)[^20]

I am claiming that this is a nicer rut.

  •   seq = [0,1]
      while len(seq) < 20:
          seq.append(sum(seq[-2:]))
      print(' '.join(str(x) for x in seq))
    

    > I am claiming that (0,1,+...*)[^20] is a nicer rut.

    If it's so fantastic, then why on earth do you go out of your way to add extra lines and complexity to the Python?

    • Complexity-wise, this version is more complicated (mixing different styles and paradigms) and it's barely less tokens. Lines of code don't matter anyway, cognitive load does.

      Even though I barely know Raku (but I do have experience with FP), it took way less time to intuitively grasp what the Raku was doing, vs. both the Python versions. If you're only used to imperative code, then yeah, maybe the Python looks more familiar, though then... how about riding some new bicycles for the mind.

      6 replies →