Hacker News new | past | comments | ask | show | jobs | submit login

  $ cat hello.tl
  (pprinl "hello, world")
  $ strace txr hello.tl 2>&1 > /dev/null | wc -l
  77

  $ cat hello.c
  #include <stdio.h>
  int main(void) { printf("Hello, world\n"); }
  $ cc -O hello.c -o hello
  $ strace ./hello 2>&1 > /dev/null | wc -l
  29

  $ strace gawk 'BEGIN { print "hello") }' 2>&1 > /dev/null  | wc -l
  84



  $ cat HelloWorld.java
  public class HelloWorld
  {
    public static void main(String[] args)
    {
        System.out.println("Hello, world");
    }
  }
  $ strace java HelloWorld 2>&1 > /dev/null | wc -l
  122


    $ strace python -c "print('hello world')" 2>&1 > /dev/null | wc -l
    924

    $ strace python3 -c "print('hello world')" 2>&1 > /dev/null | wc -l
    543


Python's site module contributes a lot to this. It attempts to load a lot of other modules, many of which may not exist for a given install.

Using your example:

    $ strace python3 -c 'print("hello world", end="")' 2>&1 | hist
     1. stat                 122
     2. rt_sigaction         68
     3. fstat                67
     4. read                 55
     5. close                47
     6. open                 37
     7. mmap                 34
     8. lseek                30
     9. getdents             18
    10. mprotect             16
        ...                 
        TOTAL:               567

    $ strace python3 -S -c 'print("hello world", end="")' 2>&1 | hist
     1. rt_sigaction         68
     2. stat                 51
     3. fstat                39
     4. mmap                 31
     5. read                 27
     6. close                26
     7. open                 23
     8. mprotect             16
     9. lseek                15
    10. brk                  10
        ...                 
        TOTAL:               350


Wow, that's bad even by interpreted language standards:

  % strace perl -e "print 'Hello, World';" 2>&1 > /dev/null | wc -l
  192


    $ strace node -e 'console.log("hello world")' 2>&1 > /dev/null | wc -l
      304


$ strace lua5.3 -e 'print("hello")' 2>&1 > /dev/null | wc -l

67


  $ strace txr -e '(put-line "hello")' 2>&1 > /dev/null | wc -l
  70
Very similar.

Obviously there are those who care about reasonable startup times and, ... others. :)

By the way, TXR supports setuid operation, and so it makes a few extra syscalls to check its security situation (am I running setuid? setgid?)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: