From Ruby to Haskell, Part 1: Testing
bendyworks.comJust talking aloud, here. Sorta frustrated.
I recently dove into Scala for fun and I enjoy its terse syntax (often more terse than Ruby's!) and principles. I was really excited about it at first.
But the excitement went away pretty quickly last weekend when I actually tried building things with it.
Setting up a Sinatra app in Ruby is a matter of 'gem install sinatra', a 'require "sinatra"', and you're ready to roll.
Meanwhile setting up a Scalatra app in Scala was a far more involved process, every tutorial getting me to use a tool called 'giter8' just to copy down app boilerplate from github. I also ran into general difficulties just setting up IntelliJ/Eclipse, falling back to Vim which makes compilation errors feel like runtime errors since I had to go back to the terminal to see that my program didn't even compile.
I pine for a world where I can just `scale install scalatra` (or pop it into my Scalefile), `$ vim app.scala`, and begin coding.
I still plan on writing some "Scala for Rubyists"-type blog posts, but it's a shame I couldn't figure out and enjoy the actual workflow. I'd have more patience coming from an ecosystem that didn't make things as easy as Ruby's does, but I've realized that tools/workflow/environment are showstoppers no matter how much you enjoy a language.
You are not alone in this. Scala has had ecosystem problems for a long time and because of the community status, that's unlikely to get much better anytime soon.
One of the reasons I've been preferring haskell and clojure for my work is because scala's toolchain abused me so badly.
As I've just scratched Scala's surface, I don't get what you meant by the community status. Considering how important the ecosystem is, could you point some resource to understand ? Thanks
I went through the exact same experience.
Fortunately, I had Clojure to fall back on already from Scala.
Leiningen single-handedly embarrasses the current state of the Scala community and it does SO much more but so effortlessly.
Can/did you try http://www.playframework.org/
It's more like a Rails framework for Scala.
libraryDependencies ++= Seq( "org.scalatra" %% "scalatra" % "2.0.4", "org.scalatra" %% "scalatra-scalate" % "2.0.4", "org.scalatra" %% "scalatra-specs2" % "2.0.4" % "test", "ch.qos.logback" % "logback-classic" % "1.0.0" % "runtime", "org.eclipse.jetty" % "jetty-webapp" % "7.6.0.v20120127" % "container", "javax.servlet" % "servlet-api" % "2.5" % "provided" )
in your build.sbt too difficult? Admittedly a bit longer than bundling/gem installing, but not too difficult?
(Although I haven't had to use scalatra personally in a project so there might be hackery I'm missing)
You just copy and pasted the output of giter8's black magic* and asked me if I think the resulting magical incantation is too difficult? Look at Scalatra's installation steps: http://www.scalatra.org/getting-started/installation.html. They don't even give you the sbt dependency. They just direct you to the tool that generates it for you. -- A tool that's only used for a couple other dozen projects: https://github.com/n8han/giter8/wiki/giter8-templates.
Even if you typed that in by hand, you sure took a big detour on your journey of simply declaring "I just want the latest version of Scalatra that works so I can begin coding" by having to go specify Jetty version 7.6.0.v2012012759 and friends.
I don't find it "too difficult". Rather, it's just confusing, nontrivial, and it obstructed my progress with Scala.
*I know g8 just copies down a project from Github like https://github.com/scalatra/scalatra-sbt.g8/blob/master/src/..., but having tools that generate input for other build tools is along my point.
Is Maven too complicated for you or something?
Those are just the latest version of the various libs.
Heh, never seen someone so defensive about using Haskell before.
I'm not sure that the "here's now to do this Ruby thing in Haskell" method of learning Haskell is a good way to go about it. It would work well to teach Python or JS but not a Lisp or Haskell or Prolog. They differ at a lower level and require different mental models to even understand them, nevermind thinking in them.
I don't see it helping if you are trying to cram monads, laziness, side effect free programming, inferred types and new syntax into the mental model of code execution you use for Ruby.
Has anyone learned that way and found it useful? Do you learn a few things in a familiar context while cargo-culting the rest and then fill in the gaps later? Does it just click all of a sudden?
My biggest struggle was learning to think in Haskell and this type of mixed metaphor teaching material would just make things worse. That might not apply to everyone, but if it applies to you then you aren't alone. Try learning the execution model with little toy programs first, then move on to the kind of software you are used to writing once you know how to look at Haskell code and reason about what it does.
"Has anyone learned that way and found it useful? Do you learn a few things in a familiar context while cargo-culting the rest and then fill in the gaps later? Does it just click all of a sudden?"
That's how I learned to write my first useful programs.
Maybe there is a better way, but that is the direct answer to your direct question.
Except I wouldn't say that it clicks "all of a sudden". It's a long process of learning. One day something doesn't work, and you think it should, and you just keep narrowing it down and eventually come to some deeper realization. It's the top-down approach to learning.
I've been trying to learn haskell bottom-up for a while, and I've done a few things and have some understanding of the theory. But I don't have anything to show for it. Every time I learn some new theoretical thing, I think "wow, what could I program with this?", at which point I've already lost. Because once I start thinking about the language rather than the utility, I'm not likely to create anything amazing.
I think that I'd be more successful if the next idea I had I just coded up in haskell (even though I don't really know it) and pushed through to a solution by any means necessary. But for me, learning a new language is secondary to realizing my visions; and my visions rarely start from an empty file any more.
That being said, I think a mix of bottom-up and top-down is probably best. There are some fundamental things that you need to learn deeply at some point to be good. Not sure the exact stages that these things should be learned, though.
Interesting, I did bottom up first and then when I started to feel that same itch to actually build something useful things were more top down.
I agree that a mix of bottom-up and top-down is probably best, I was curious about other paths because I found that starting with bottom-up worked really well for me and wondered if that generalized to other people or was just well suited to my learning style. My experience makes me think that a solid foundation is essential but it's entirely likely that's just "that's the way i learned" bias.
I had a similar experience switching from Java taught in college to self-teaching lisp. I essentially had to relearn everything that I knew and start looking at lisp as an entirely different beast, as most pattern matching that I did between the two came back to be wrong.
Apart from the basics, things like the CLOS definitely threw me for a spin, since it uses a different model for its object system.
Overall, probably best to approach most of the languages mentioned as a new way of thinking.
move from perhaps the most dynamic language to what is perhaps the most static?
I don't think this continuum has any meaning, but s/he should look at GHC Typeables, deferred type checking and the type holes work in the "most static"http://www.reddit.com/r/haskell/comments/10u7xr/ghc_head_now...
https://news.ycombinator.com/item?id=4380900
http://hackage.haskell.org/trac/ghc/wiki/DeferErrorsToRuntim...
Here's where the "most dynamic/static/whatever" probably came from
Why? whats the need or advantage of going to Huskel from Ruby??
He also goes into why he likes some of the things Haskell brings to the table in the remainder of the article.> If you read it as "stop using Ruby and start > using Haskell", you read it wrong.For some applications, Haskell is a big win. For some, Ruby is. Having a diversity of tools is almost always better.
my bad... sorry for posting without giving much thought to the blog post..
Native compiled code?