News for hackers. Stuff that matters.
Re:Python past, present, and future with Guido van Rossum [a... by brianwawok on Thursday February 23, 2017 @10:31AM (#13714650)
I used Scala for a few years. I actually prefer python to it though. My reasons are:

1) Compile time. In a tight dev loop, you can run Unit tests in say 2 seconds in Python, vs 15, 30, 60, 90 seconds in Scala (depending on code base size)

2) Django. Play is ok, but for web stuff I think Django does a little better job.

3) Ease to find help. Finding someone to write scala is hard. Usually means hire a Java or a Haskell guy and train them. Way more people know Python.

4) Easier to metaprogram. Sometimes, metaprogramming is awesome. Don't do it nonstop, but sometimes it is amazing. Reflection and macros and all of that exists, but it gets seriously awful to deal with.

5) Code readability. I read scala fine, but it can still take a while to parse a file to know what is going on. Trying to think through crazy scalaz or something can hurt your head, even if you get it.

6) No SBT

Now this is not to say all is perfect, things I do miss from Scala:

1) When you really do need high performance, you can get there without dropping to C.

2) Compile time checks catch many many errors. Really sucks if you write something in prod and get a ValueException at runtime. Obviously this means you missed a test, but a scala codebase with say 25% test coverage will be generally less likely to have runtime erors than a Python codebase with even 75% coverage.

3) IDE support. Mypy is a work in progress, but click though stuff still works a little bit better in Scala. Scala is not Java good at this though due to implicit magic, so this is becoming more of a wash.

Re:Python past, present, and future with Guido van Rossum [a... by lmm on Thursday February 23, 2017 @12:01PM (#13715450)
> 1) Compile time. In a tight dev loop, you can run Unit tests in say 2 seconds in Python, vs 15, 30, 60, 90 seconds in Scala (depending on code base size)

True, but 95%+ of the issues you'd catch with unit testing in Python you catch during compilation in Scala, and that can be an incremental compile rather than a full compile. So once you have a properly set up dev environment the feedback loop takes less than 2 seconds in practice, though the one-off setup to reach that point is a lot fiddlier than for Python.

> 2) Django. Play is ok, but for web stuff I think Django does a little better job.

Heh, I don't like either, I'm a huge fan of Wicket (the one time I had to use Django I wrapped it in a Wicket-like layer I called smoff, which I think might even still be out there). Django is too page/request-oriented for my liking, I think a component-oriented library leads to much better design when you're making actual UIs. For REST endpoints spray is the best thing I've ever used, in any language: having your route definition look more-or-less like a route definition but being regular code that you can refactor in all the regular ways is amazing, especially when you get to the point of wanting to use e.g. custom directives and you can just click through to the standard directives and they're just ordinary code that you can adapt the same way as any other code.

> 4) Easier to metaprogram. Sometimes, metaprogramming is awesome. Don't do it nonstop, but sometimes it is amazing. Reflection and macros and all of that exists, but it gets seriously awful to deal with.

I think if you can't do it with Shapeless it's probably not worth doing. The typeclass-derivation stuff is more boilerplate than it should be, but it does work well apart from that, and always leaves you with something more-or-less understandable. Whereas some of the Python metaclass tricks I've seen have just been completely crazy.

> 5) Code readability. I read scala fine, but it can still take a while to parse a file to know what is going on. Trying to think through crazy scalaz or something can hurt your head, even if you get it.

I think you have to remember to compare code that does the same amount, not code that's the same length. Like, sometimes there will be a 1-liner in Scala that I'll have to mentally expand out to 6 lines to understand - but in Python the same code would have been 6 lines in the first place. And I think there's a huge benefit to being able to see a whole class definition on a single page, so I'd rather have the "compressed" single-line version even if it takes slightly longer to read in isolation than the "expanded" six-line version.

> 6) No SBT

Agreed. Can't stand it, have no idea why it's popular. I just use maven.

Re:Python past, present, and future with Guido van Rossum [a... by brianwawok on Thursday February 23, 2017 @12:11PM (#13715555)
> True, but 95%+ of the issues you'd catch with unit testing in Python you catch during compilation in Scala, and that can be an incremental compile rather than a full compile. So once you have a properly set up dev environment the feedback loop takes less than 2 seconds in practice, though the one-off setup to reach that point is a lot fiddlier than for Python.

Not sure I agree with either of those. Compiler catches different types of error compared to Unit tests. Lots of ways especially when dealing with external libs or APIs where compile can't catch anything.

> Django wicket etc

To each their own. I despise SPAs, and neither code them nor use them if I can help it. DRF is really good for rest endpoints though.

> Meta programming

meh, different levels of it. Look at using Django ORM for some queries, vs say Slick. Slick is a bit gross.

> 1 liner vs 6 liner

Meh. In practice, Python is very terse also. Java vs Scala is a big line of code difference. I have not found Scala vs Python is that different.

Re:Python past, present, and future with Guido van Rossum [a... by lmm on Thursday February 23, 2017 @12:21PM (#13715660)
> especially when dealing with external libs or APIs where compile can't catch anything.

It can if those libraries/APIs are written to use types effectively. In the early days of Scala there weren't many native libraries that did so, but there's a pretty established native-to-Scala ecosystem these days.

> To each their own. I despise SPAs, and neither code them nor use them if I can help it.

Um, agreed, which is exactly why I love Wicket ? I think we must've misunderstood each other at some level.

> Meh. In practice, Python is very terse also. Java vs Scala is a big line of code difference. I have not found Scala vs Python is that different.

In a lot of code I agree, but I think the cases where you will see "crazy scalaz or something" are precisely those cases where those things save a fair few lines. If you can write it in a readable line of Python, that will usually translate directly into an equally readable line of Scala.