Skip to content

Instantly share code, notes, and snippets.

@TypeSafeSchwalbe
Last active June 2, 2024 18:55
Show Gist options
  • Save TypeSafeSchwalbe/a9ea1f06b2b32587113c28e0493913b1 to your computer and use it in GitHub Desktop.
Save TypeSafeSchwalbe/a9ea1f06b2b32587113c28e0493913b1 to your computer and use it in GitHub Desktop.
Pseudocode

Pseudocode

I asked the people on the r/ProgrammingLanguages Discord server to "implement a function that prints N numbers of the Fibonacci sequence". For fun, I decided to analyse the results a bit.

Function keyword

  • no keyword: 4 (28.57%)
  • no function declared: 3 (21.42%)
  • fn: 2 (14.28%)
  • def: 2 (14.28%)
  • function: 2 (14.28%)
  • func: 1 (7.14%)

Block syntax

  • indentation: 8 (57.14%)
  • braces: 5 (35.71%)
  • no block used: 1 (7.14%)

Assignment operator

  • =: 10 (71.42%)
  • no assignments used: 3 (21.42%)
  • <-: 1 (7.14%)

Loop

  • for: 7 (50.00%)
  • repeat n times, repeat n, n times: 3 (21.42%)
  • no loop used: 3 (21.42%)
  • while: 1 (7.14%)

Expression terminator

  • no explicit terminator: 10 (71.42%)
  • semicolon: 2 (14.28%)
  • did not write multiple statements: 2 (14.28%)

Types

  • no type annotations: 11 (78.57%)
  • type annotations: 2 (14.28%)
  • no variables declared: 1 (7.14%)

Implementation technique

  • loop: 10 (71.42%)
  • recursive function: 2 (14.28%)
  • no proper implementation: 2 (14.28%)

Output

  • prints n elements of the Fibonacci sequence (a separate loop that called the actual fib implementation once for each element counts as well): 8 (57.14%)
  • does not print anything, but is able to return the nth element of the Fibonacci sequence: 3 (21.42%)
  • no proper implementation: 2 (14.28%)
  • does not print anything, but is able to return a list containing n elements of the Fibonacci sequence: 1 (7.14%)

Pseudocode with existing implementations

  • wrote working Javascript: 1 (7.14%)
  • wrote working Python: 1 (7.14%)
  • wrote something else: 12 (85.71%)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment