3 ms·
Scala is becoming my programming language of choice, especially since I tried out Scala.js which really works well. I am currently porting a Clojure library of
by auggierose 13y ago
Scala is becoming my programming language of choice, especially since I tried out Scala.js which really works well.
I am currently porting a Clojure library of mine to Scala, and it is about 10% less code, and obviously more robust because of static type checking.
Scala.js: https://github.com/lampepfl/scala-js https://github.com/lampepfl/scala-js
- the1 13y agothat runtime is larger than firefox update. why not make a proper user agent?
- TylerE 13y agoI'm not sure how that's relevant. A full Firefox install on Windows currently weighs in at 47MB. xul.dll (e.g. the UI) is 20MB of that.
- bad_user 13y agoAs a word of warning, Scala.js is very new project (started I think only 7 months ago) and thus it's very immature.
- auggierose 13y agoI am using Scala.js for a week now, and I am surprised by how mature it already is. Optimized Scala.js is less than a megabyte, and therefore actually usable. Obviously there are caveats, for example Character.isLetter is not implemented; but the entire collection library of Scala is available.
- smrtinsert 13y agorobust is debatable, I suppose you mean type safe.
- auggierose 13y agoI mean type safe, therefore much faster code out of the box, easier refactoring (not trivial refactoring, but changing interfaces of libraries and the like), better documentation generator, better build tool, up-to-date tools for google app engine, great Eclipse support, .... In short: more robust
- benburton 13y agoYou actually mean statically typed. Scala is only limitedly type-safe, and is certainly not type-theoretic type-safe at all: $ cat NotTypesafe.scala object NotTypesafe { def main(args: Array[String]) { println("5".asInstanceOf[Int]) } } $ scalac NotTypesafe.scala $ scala NotTypesafe java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer http://en.wikipedia.org/wiki/Type_safety http://en.wikipedia.org/wiki/Type_safety
- auggierose 13y agoWell, I've got a PhD in computer science, I just use the words as I please. But yes, you are right ;-)
- warcher 13y agoI bet this comment read differently in your head.
- TylerE 13y agoCan you compare and contrast Scala with Clojure? I've dabbled in both... I in theory prefer Scala, but I found it just has sooo many moving parts I can't keep it in my head.
- auggierose 13y agoI can show you two code samples of mine, one in Clojure, the other one doing something very similar in Scala: (defn completion-items [grammar doc items-bin-index completed-bin-index items nonterminal value] (loop [items items completed '()] (if-let [[^Item item previous-value] (first items)] (let [alpha (expected-symbol grammar item) dot (.dot item)] (if (and alpha (= nonterminal alpha)) (let [rule-nonterminal (.nonterminal item) ruleindex (.ruleindex item) origin (.origin item) value' (gen-nextvalue grammar doc origin items-bin-index completed-bin-index rule-nonterminal ruleindex dot previous-value value)] (if (nil? value') (recur (next items) completed) (let [item' (->Item rule-nonterminal ruleindex (+ dot 1) origin)] (recur (next items) (cons-item-value completed item' value'))))) (recur (next items) completed))) (apply hash-map completed)))) -------------------------------------------------------- def complete_items(completed_binindex : Int, bin : ItemBin, nonterminal : Nonterminal, value : Value) : MoreItems = { var completed_items : List[(Item, IntermediateValue)] = List() for ((item, v) <- bin.items) { val s = expectedSymbol(item) if (s == Some (nonterminal)) { grammar.nextValue(document, item.origin, bin.binindex, completed_binindex, nonterminal, item.ruleindex, item.dot, v, value) match { case None => case Some(nextvalue) => completed_items = (item.inc -> nextvalue) :: completed_items } } } completed_items }
- brandonbloom 13y agoThat's quite non-idiomatic Clojure... 1) Unnecessary type hint 2) No use of destructuring or field lookup by keyword 3) Alteration of record objects with positional constructors instead of update-in 4) Explicit loop with previous item instead of reduce over (partition 2 1 items) 5) Way too many parameters 6) Apply hash-map instead of into 7) (+ ... 1) instead of inc 8) Weird gen-nextvalue auxiliary function instead of a lazy sequence I could keep going...