

Language War - Scala versus Python - zubinmehta
http://blog.zlemma.com/2013/02/20/language-war-at-zlemma-scala-versus-python-part-1/

======
tikhonj
I think you shouldn't have let people talk you out of using Haskell. It's a
very nice language and has some advantages for this sort of project (at least
based on your cursory description).

However, its advantages are really not the important part. Rather, I just wish
you wouldn't dismiss it immediately as a crazy choice. It's no more crazy than
any other less-popular language. It has a reputation for being impractical,
but this reputation is rather unfair especially in the light of recent very
practical developments like simpler concurrency, an improved IO manager, very
good web frameworks and a fair about of strong libraries both for very
specific domains and general productivity.

The main disadvantage is that many people find it hard to learn. However, this
is a function (heh) of functional programming rather than the language itself.
It's actually a simpler language than Scala in many ways because it tries to
do one thing well--for example, it has no sub-typing, so you do not have to
ever worry about covariance and contravariance.

Now, my point here is not that you should always use Haskell, just that you
should seriously consider it. Too many people dismiss it out of hand almost as
a joke when it is anything but.

~~~
cover_drive
Thanks for your support. Like I mentioned, I will circle back to Haskell as
the business develops. If I was the only programmer in my startup, I would
likely go with Haskell for important components of our software. But I have
concerns about hiring a large team that would thrive in Haskell. One never
knows - I'm keeping an open mind :)

~~~
jerf
"The core of ZLemma.com is a mathematical framework involving highly
structured data representations and numerical algorithms."

You might also consider a Haskell core, surrounded by a Python website. (Or
any other website language/framework you like.) It strikes me as likely you
have some sort of relatively small interface you can define between those two
things, and then you can use the strengths of everything.

~~~
cover_drive
I am with you on this. More on this in Part 2 of the post.

------
wheaties
Novus Partners also does Scala. We've even got a few Python guys coding in
Scala. It's just a language with the JVM ecosystem to back it up. Python has
it's own ecosystem and for numerics, access to LAPACK and UBLAS is pretty
awesome, I must admit. That said, both can exist fairly comfortably in a
company and can be used for different purposes.

I like Python for prototyping, algorithm validation, and just to hack on. I
like Scala for damned near everything else. (Also, Adam is going to be open
sourcing what is essentially a Scala clone of Pandas but statically typed and
with comparable performance.)

------
drucken
The article's basis of the comparison for building an entire business seems to
be very shallow.

Surely other considerations are more important, such as,

\- encapsulation/domain partitioning

\- messaging

\- libraries and library maturity

\- native code interoperability (likely critical for this application)

\- concurrency

\- performance

\- JVM platform

\- etc.

Maybe, as a result of this type of analysis, Python-like language is more
suitable in some domains and a JVM language in others.

In my opinion, for the requirements quoted, with a deep and performant
mathematical framework involved, I cannot envisage how Scala/JVM could win any
"war" for the core of the business.

~~~
userulluipeste
This kind of comparison reminds me about something similar about Git vs
Mercurial: [http://importantshock.wordpress.com/2008/08/07/git-vs-
mercur...](http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/)

It looks more like an emotional kind of story than one about practical
decisions.

~~~
cover_drive
Indeed! At the early stages of a startup, most decisions (including technical
ones) have a strong emotional/instinctive flavor. When I worked at large
corporations, the decisions were almost always devoid of emotions.

------
leothekim
"And who the hell does Scala? (Actually, Twitter does!)"

Foursquare also uses Scala, as does LinkedIn. Here's a page of organizations
using it:

<http://www.scala-lang.org/node/1658>

~~~
melling
This was done a few years ago. I'd love to hear what people have to say about
Scala now that code bases have grown. Anyone working with a couple hundred
thousand lines of Scala?

For instance, I know compilation performance was always frustrating for
developers. What's it like for teams of people dealing with a large code base?

~~~
leothekim
We are working with Scala at that scale at Foursquare, and compilation times
are definitely a headache. What helps is ensuring your dependencies are
acyclic so you're able to do smaller incremental compiles when you make
changes. To get us on the path of a DAG-ified codebase, we've been using a
build tool developed by Twitter called "pants":

<https://github.com/twitter/commons>

which has some similarities to Google's Blaze build tool.

------
voidlogic
No discussion of run-time characteristics? I realize for a some start-ups this
is not the most important metric, but these guys sound like they might be
compute bound. And faster language can mean cheaper/less hardware.

Scala vs Python:
[http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t...](http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?test=all&lang=scala&lang2=python3)

Also since he mentioned Haskell at first, Haskell vs Scala: is also
interesting:
[http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t...](http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=scala)

Haskell vs Python is just for lolz:
[http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t...](http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?test=all&lang=ghc&lang2=python3)

~~~
fijal
Seriously, computer language shootout is just harmful. Those benchmarks are
bad (but it's unclear whether cross-language comparisons can get much better),
implementations are worse. And on top of that it does not include opitmized
VMs like PyPy or LuaJIT (in fact, it does not include PyPy because we
complained at some point).

~~~
voidlogic
All benchmarks come with the implicit disclaimer:

The best benchmark is always your application. All benchmarks are flawed, use
your judgement and determine how flawed a benchmark is; Any flaws are relative
to your application similarity to what the benchmark tests. An imperfect tool
is not a useless tool, so long as you are smart about how you use it.

This is probably relevant too: [http://benchmarksgame.alioth.debian.org/dont-
jump-to-conclus...](http://benchmarksgame.alioth.debian.org/dont-jump-to-
conclusions.php)

~~~
igouy
Those comparison pages come with an explicit wake-up call:

"These are not the only compilers and interpreters. These are not the only
programs that could be written. These are not the only tasks that could be
solved. These are just 10 tiny examples."

------
tapan_pandita
Python has real good, battle tested and actively developed libraries for math,
scientific computing and analytics. Most of these are written in C and hence
give great performance in addition to the flexibility of python. Some great
ones are: Numpy/Scipy, LAPACK, Pandas (lots more for machine learning as
well). Also, I think the REPL is no match for IPython :). For your specific
domain (math and analytics) python could be a great fit. Of course the lack of
type systems and no compile step can be scary, but for a startup, which needs
to move fast, python gives you the power of quick iteration. Just to round
this off, from the zen of python:

"practicality beats purity."

~~~
zubinmehta
+django

------
beggi
I haven't tried Scala but since no one has mentioned it: Clojure is a pleasure
to work with if you want a functional language in JVM.

I have no idea which and how many startups use Clojure, besides Datomic :) It
would be interesting to know.

~~~
dwelch2344
I'd like to agree here. IMO up-and-coming Clojure is an up-and-coming
competitor to Scala. As a Lisp variant for the JVM, I'm a major fan of it.

Unfortunately I can't share any personal experience as the core of my work is
in the Enterprise so I haven't had the right opportunity to present itself.
But if you're coming from a mathematical background you should check it out

------
nnq
> Typecheck in Python

People actually use it? It seems abandoned and the link to homepage broken:
<https://pypi.python.org/pypi/typecheck>. _I'm asking because I'd really like
the idea of starting a project the dynamic typing way and then bolting on a
(semi)-static type system on top once more new programmers join the game,
preferably being able to completely disable it on production machines for best
performance._

~~~
shared4you
Have you checked out Cython[1]? It's used quite often in Numpy. Basically, you
add some type annotations like, int, double, etc. for some speed-up. There is
a quick tutorial as well [2].

[1]: <http://cython.org/>

[2]: <http://wiki.cython.org/tutorials/numpy>

~~~
nnq
I know, it great for the speed-up. But for just making things more manageable
it's not worth the added complication of build/compile. I know, my problem is
actually solved by "properly written tests" :) ...for I still long for some
optional drop-in static typing.

------
wyqueshocec
> Besides, dynamic typing scares the hell out of me

Funny. I feel exactly the opposite. Static typing is false security.

I program in JS. My coworkers in Java. They have so many bugs that make it to
prod because they assume that just because it compiles it must therefore be
safe.

~~~
tikhonj
Yeah, Java is not a fair example. It has a type system with the worst
compromise between being awkward (and infamously verbose) and not very
effective: it gets the short end of the stick on both accounts. It's better
than C, granted, but that's saying nothing. It does not compare to a good type
system like Scala's or especially Haskell's.

Good type systems can catch far more bugs than you imagine. Moreover, they can
actually make writing code easier: there are some extremely valuable and
expressive features like typeclasses that simply cannot be reproduced in a
dynamically typed language.

~~~
yxhuvud
You are totally missing the point of the parent. Just because types work out
doesn't mean the behavior of the program is correct.

The problem is not how to make something compile, regardless of how complex
the types are. The problem is how to do the right thing. It is not enough to
return a string - you must return the _correct_ string, and that is not
normally not something a type can solve for you. I suppose you _may_ solve
that problem too in haskell, but then you will get bugs in the type definition
instead. TANSTAAFL.

~~~
jerf
"It is not enough to return a string - you must return the correct string, and
that is not normally not something a type can solve for you."

It can, however, ensure that you have returned a legally-formatted email
address instead of someone's first name, with proper use of the type system.
You'd probably be surprised what you can do with a real type system, based on
what you're saying here. It is not a proof of correctness, but there's a great
deal more possible than in Java.

It of course can not ensure you returned the _correct_ email address, but
often that's a much less pressing problem, because the thing returning the
address may very well have had only one address in hand to chose from, in
which case it can't be wrong. There's a lot of logic like that you can deploy
in Haskell, when scopes and inputs to functions are much more carefully
controlled than a traditional language.

------
Flow
Did you guys consider Google Go? I really like the language and its
environment after coding in it for a bit.

~~~
shared4you
I think the reason was the math libraries. There aren't mature libraries _yet_
for numerical computing. Python has Numpy/Scipy, but am not sure of Scala (I
don't use).

------
z3phyr
Haskell all the way!

~~~
cover_drive
:)

