Hacker Newsnew | past | comments | ask | show | jobs | submit | pkuki's commentslogin

Also for GGO 2012 you can view entrants here: http://pkukielka.github.io/ggo12-viewer/ (disclaimer: viewer was done by me). If I remember correctly someone forked my code and did the same for 2013 edition.


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


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.


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 <- fmap (\(n:p3:chars:_) -> 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


Down in Poland as well.


It's simply incorrect. Where you found that information?

In section 2.3 android is mentioned explicitly: "These features are more useful on Android (besides micro-benchmarks) where a vast RAM doesn't masquerade redundant allocations."

In section 5.2 you can read: "This prototype requires -target:jvm-1.7. Right now scalac doesn't produce the newest class file format of JDK8. In the meantime, -target:jvm-1.7 can be used on that platform. A discussion about performance at: https://groups.google.com/d/msg/scala-internals/uBxprJixpwk/...

If you will check that link first sentence in the thread is: "To recap, the new backend supports Java 6 and 7. In an experimental branch (based itself on the experimental backend) there's now support for MethodHandles, building upon "Late Closure Classes", ie the ability of the new backend to materialize anonymous closure classes as it emits bytecode."

So yes, it supports java 1.7. And yes, it can help on android.


In Akka you can use typed actors as well: http://doc.akka.io/docs/akka/snapshot/scala/typed-actors.htm...


It seems that typed actor support it somewhat incomplete. Once you wanted to use typed actors with routers and resizing, there was no documentation. There were some mailing lists posts with suggestions that don't work. I don't know if anything changed in the meanwhile, but this blog post suggests that it's still not well-supported:

http://blog.codacy.com/2014/01/29/typed-actors-with-routing/

One thing that I dislike about the Akka implementation of actors is that they can't block, because this would block a thread in the thread pool. Quasar's implementation of actors allow you to block on e.g. I/O, because Quasar can preempt fibers that are parked. This makes Quasar's actor framework much more powerful and more Erlang-like.


Under Scala 2.10 there were bugs in the reflection system that made those almost unusable; is that now all fixed?


You can also use Scala: https://github.com/pkukielka/stronghold-defense

The main problem which you will get with languages like Scala , Clojure and other functional languages on JVM is a lot of garbage generated during the execution. And garbage collector on Android isn't even remotely as effective as standard one. This often forces you to write code which is not really idiomatic and which rather resembles java. That is possible in Scala (I'm not sure about Clojure), but to some extend it defeats whole purpose of using something other than java.

Disclaimer: I'm the author of linked game.


Maybe they are slower to some extend, but for most cases it won't matter too much. I wrote simple game in scala and it was easy to constantly get 55-60 fps on newer devices: https://github.com/pkukielka/stronghold-defense

That being said I agree that jars are bigger and scala generates much more anonymous classes. Even with ProGuard that could be a problem on Android 2.3 or older. And ProGuard is a bit slow (for my game it was taking 30+ seconds for every build). Also Typesafe doesn't have plans for making scala first class citizen of Android.

So while Android development with scala is certainly possible there are few inconveniences which one should be aware of.


Nice game!


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

Search: