Live data from Hacker News

Make a Lisp in Nim

hookrace.net

41–48 of 48 posts

Re: Make a Lisp in Nim

#41
I thought it could be interesting to see ratio of program performance to its length. If I didn't make any mistake it looks like that:

              perf3                   perf3 / 
              macros      chars       chars * 100
  -------------------------------------------------
  scala       15963       24885       64,15
  nim         11121       20263       54,88
  java        17969       53223       33,76
  ocaml       7063        24371       28,98
  coffee      2326        15653       14,86
  racket      2461        17229       14,28
  cs          5414        45039       12,02
  clojure     1174        10099       11,62
  ruby        1255        13247       9,47
  go          3048        36321       8,39
  vb          4523        58099       7,78
  rust        4084        56516       7,23
  js          1726        26437       6,53
  c           3649        73047       5,00
  haskell     1163        30115       3,86
  python      304         19632       1,55
  forth       563         44715       1,26
  php         331         27332       1,21

Re: Make a Lisp in Nim

#42
post #41

I thought it could be interesting to see ratio of program performance to its length. If I didn't make any mistake it looks like that: perf3 perf3 / macros chars chars * 100 ------------------------------------------------- scala 15963 24885 64,15 nim 11121 20263 54,88 java 17969 53223 33,76 ocaml 7063 24371 28,98 coffee 2326 15653 14,86 racket 2461 17229 14,28 cs 5414 45039 12,02 clojure 1174 10099 11,62 ruby 1255 13…

What is perf3?

Also, which specific interpreters/AOT compilers/JIT compilers are being used for each language being measured?

Re: Make a Lisp in Nim

#43
post #8
post #7

Earlier quoted context omitted.

It's weird that people that make benchmarks don't investigate which flags to pass for getting the most optimized build. Many compilers don't do max optimization by default. In particular, people making benchmarks with rust code seem to tend to forget or be unaware of the `release` flag.

Yeah, this is happening again and again in Rust: people publish Rust benchmarks without optimization on. In fact, we just decided this week to change "Compiling" to "Compiling (Debug)" in Cargo if optimization isn't turned on to address this problem. It's sad :(

If it helps it doesn't happen only to Rust but to all languages.

There is this misunderstanding between implementations and languages where people equate whatever they have installed on their computer with all implementations of the said language.

Also not knowing about profilers and optimization flags.

So yeah, it is sad.

Re: Make a Lisp in Nim

#44
post #42
post #41

I thought it could be interesting to see ratio of program performance to its length. If I didn't make any mistake it looks like that: perf3 perf3 / macros chars chars * 100 ------------------------------------------------- scala 15963 24885 64,15 nim 11121 20263 54,88 java 17969 53223 33,76 ocaml 7063 24371 28,98 coffee 2326 15653 14,86 racket 2461 17229 14,28 cs 5414 45039 12,02 clojure 1174 10099 11,62 ruby 1255 13…

What is perf3? Also, which specific interpreters/AOT compilers/JIT compilers are being used for each language being measured?

Look at the original blog post. I just added third column to show ratio between given data.

Re: Make a Lisp in Nim

#45
post #44
post #42

Earlier quoted context omitted.

What is perf3? Also, which specific interpreters/AOT compilers/JIT compilers are being used for each language being measured?

Look at the original blog post. I just added third column to show ratio between given data.

I will do it at home. Currently behind a corporate firewall.

Re: Make a Lisp in Nim

#46
post #25

Earlier quoted context omitted.

That's a bummer, because until then, you'll be strongly mis-representing Rust :/

I hope that you are mis-representing Rust. I'd be pretty discouraged if I was learning a new language and one of the first interactions I had with a notable community member was a notice of take-down containing neither encouragement nor constructive criticism.

I agree with you that this comment is quite harsh, but i'd like to point out that it's not a fair representation of steveklabnik's usual interaction with the community on reddit and IRC, as far as i can tell.

Re: Make a Lisp in Nim

#47
post #6

Are your graphs up to date ? Seems just an hour ago [1]: > Rust: build with --release. 10X performance boost! That might mean that Rust would top the charts instead of Nim. [1]: https://github.com/kanaka/mal/commit/434516e0d172904e06b05f6...

Just one glance at the Rust version (e.g. [1]) shows a lot of needless allocation. For example: if *strn == "&".to_string() { ... } is a very slow (and verbose) way to write if &strn[..] == "&" { ... } and rr_string("'".to_string() + k.to_string() + "' not found".to_string()) is a very slow (and verbose) way to write rr_string(format!("'{}' not found", k))` Etc. etc. [1]: https://github.com/kanaka/mal/blob/master/rus…

pcwalton: thanks to Alex Crichton, the implementation has been cleaned up and updated to Rust 1.0.0 nightly. Yay! The feedback you noted has been applied to the code base. The performance has definitely improved some. Alex did some performance profiling and it looks like that hashmap performance may be the main bottleneck. The micro-benchmarks (and yes I admit they aren't good tests) don't really test strings, so it's probably the newer Rust version and the other cleanup that Alex did.

But if you want to take another pass through the code now that it's not based on an ancient Rust version, I'm always happy to take any advice from the master. :-)

Re: Make a Lisp in Nim

#48
post #41

I thought it could be interesting to see ratio of program performance to its length. If I didn't make any mistake it looks like that: perf3 perf3 / macros chars chars * 100 ------------------------------------------------- scala 15963 24885 64,15 nim 11121 20263 54,88 java 17969 53223 33,76 ocaml 7063 24371 28,98 coffee 2326 15653 14,86 racket 2461 17229 14,28 cs 5414 45039 12,02 clojure 1174 10099 11,62 ruby 1255 13…

For whatever reason I felt the random need to parse your table here in Haskell, so.... here's the code :P

    λ> import qualified Data.Text.IO as T
    λ> import qualified Data.Text as T
    λ> data Entry = Entry {name :: T.Text,  macroPerf :: Int, charLength :: Int} deriving Show
    λ> -- parse into list of lists
    λ> let table = (fmap T.words) . T.lines  T.readFile "langstats.txt"
    λ> -- I need to parse these things... safely.. using the Safe package!
    λ> import Safe
    λ> -- parse table into list of `Maybe Entry` taking advantage of applicative instance
    λ> -- the list of lists are just name, perf3 macros, chars, and a field I'm ignoring for now
    λ> -- we can just use list destructuring (\(name : perf3macros : chars : _))
    λ> entries  liftA3 Entry (Just n) (toInt p3) (toInt chars))  table
    λ> :t entries
    entries :: [Maybe Entry]
    λ> -- for easy sorting, we want just [Entry]
    λ> -- safely turn our [Maybe Entry] into [Entry]
    λ> import Data.Maybe (isJust, fromJust)
    λ> let entries' = map fromJust . filter isJust $ entries -- safe because we filter out the justs first!
    λ> -- speaking of sorting... we need a couple imports
    λ> import Data.List (sortBy)
    λ> import Data.Function (on)
    λ> let results = sortBy (compare `on` macroPerf) entries'
    [Entry {name = "python", macroPerf = 304, charLength = 19632},Entry {name = "php", macroPerf = 331, charLength = 27332},Entry {name = "forth", macroPerf = 563, charLength = 44715},Entry {name = "haskell", macroPerf = 1163, charLength = 30115},Entry {name = "clojure", macroPerf = 1174, charLength = 10099},Entry {name = "ruby", macroPerf = 1255, charLength = 13247},Entry {name = "js", macroPerf = 1726, charLength = 26437},Entry {name = "coffee", macroPerf = 2326, charLength = 15653},Entry {name = "racket", macroPerf = 2461, charLength = 17229},Entry {name = "go", macroPerf = 3048, charLength = 36321},Entry {name = "c", macroPerf = 3649, charLength = 73047},Entry {name = "rust", macroPerf = 4084, charLength = 56516},Entry {name = "vb", macroPerf = 4523, charLength = 58099},Entry {name = "cs", macroPerf = 5414, charLength = 45039},Entry {name = "ocaml", macroPerf = 7063, charLength = 24371},Entry {name = "nim", macroPerf = 11121, charLength = 20263},Entry {name = "scala", macroPerf = 15963, charLength = 24885},Entry {name = "java", macroPerf = 17969, charLength = 53223}]
    λ> -- how about some pretty printing?
    λ> mapM_ (\e -> putStrLn $ (T.unpack (name e)) ++ "\t" ++ show (macroPerf e) ++ "\t" ++ show (charLength e)) results
Post reply on HN