Live data from Hacker News

Confessions of a Ruby Developer Whose Heart was Stolen by Scala

speakerdeck.com

31–40 of 74 posts

Re: Confessions of a Ruby Developer Whose Heart was Stolen by Scala

#31
post #17

It seemed like most of his slides came down to the old typed/untyped flame war. Yes, in Scala you can look at your objects in an IDE and be told what type they are, in Ruby you can't. Some organizations and people need that, some don't. And yes, it's easier to optimize typed languages. Some applications need that extra speed, most don't. I'm happy he found a language he enjoys working with, but I doubt this will chan…

Somewhat true but I find Scala's inferred typing a surprisingly great compromise between the two.

For example:

val i = 1;

i = "some string" // throws a compiler error, because it knows i is an integer

It's great when you haven't declared the types, you change for example an int to a double or a class to some other class (eg swapping a data structure) and it just flows through the code base without problems like a dynamically typed language.

It can also be pretty useful to look up types when they get complex in the middle of some function, like a Map[List[(String,SomeObject)]] (a map of lists of (String,SomeObject) tuples). Allowing the types to get complex lets me focus on the problem while giving a crutch to quickly remember where it's at half way through (and while finding other methods/source of data) and keep moving towards the solution.

Re: Confessions of a Ruby Developer Whose Heart was Stolen by Scala

#32

Well, of course a classic programming language is better then a script language for majority of tasks. Script languages like JS and Ruby just should not be abused and should only be used as a very thin layer on top. E.g. GUI scripting.

I go the other way -- I write in Python by default, then only go to another language if I specifically need it, for example these scenarios:

(a) Python isn't fast enough, and Pypy doesn't make it fast enough, or isn't a viable option in the target environment. So you write in C, OpenCL or assembly language.

(b) A vital library or other dependency can't talk to Python and you can't quickly find or write a reimplementation or bridge.

(c) Python isn't supported in the target environment, for example, the web browser [1] or the iPhone.

[1] Yes, yes, I know, things like Skulpt and Pyjamas exist. But I think those dependencies are too heavy for a lot of projects.

Re: Confessions of a Ruby Developer Whose Heart was Stolen by Scala

#33

Scala is a fantastic language, but my heart seems to resist due to things like this (slide 27/42): implicit class RichSeq[A, C[A]

Attention to syntax is what ruby is good at. Scala, Haskell treat syntax as a chore.

Scala maybe, not Haskell (which barely has any syntax).

Re: Confessions of a Ruby Developer Whose Heart was Stolen by Scala

#34
post #19

Scala is a fantastic language, but my heart seems to resist due to things like this (slide 27/42): implicit class RichSeq[A, C[A]

This is very dense code, and takes some getting-used-to in order to read. What it achieves is beyond the reach of many languages. All it does is convert a Seq (sequence) to a lazy stream that will infinitely cycle through the values. Seq(1, 2, 3).cycle.take(8).toList res3: List[Int] = List(1, 2, 3, 1, 2, 3, 1, 2) It will work for any seq-like structure (including List. Vector, Queue, etc.) If you try to use it with a…

> This is very dense code, and takes some getting-used-to in order to read.

I don't think so. It is full of syntactic noise, for what is really just notation for building a cyclic structure.

* type annotations stated explicitly, not inferred

* type variables given multiple times

* too much non-verb, non-noun syntax e.g. `#:::`

* and the actual construction of the cycle is stated imperatively with great ceremony (despite it being an applicative)

It is the opposite of dense.

Re: Confessions of a Ruby Developer Whose Heart was Stolen by Scala

#35
post #4

Earlier quoted context omitted.

I would recommend that you immediately inform Yahoo, 37 Signals, Hulu, GitHub, Penny Arcade, and every other Node, Rails, Sinatra, and EventMachine user of this fact! Also, Tcl/Tk called and wants its use case back.

Why do microsoft and google insist on static compiled languages?

I've been thinking about private fields lately.

In Python, a private field starts with an underscore, and someone who knows the culture of Python knows that the initial underscore encodes the notion "This field is not considered to be part of this library's public API, and it may go away or change behavior at any time, not necessarily a major version bump of this library, and if you look at it or change it, you'll be responsible for maintaining your code when we break it. Also it's probably totally undocumented, so you'd better read the library code to make sure it does what you think it does before you use it."

A good developer will weigh the work that can be accomplished today by using the private field against the future consequences of the underscore's admonition, and come to a wise decision -- if (s)he decides to use the field, the Python language will defer to the programmer's human judgment and allow it.

A mediocre developer won't understand the underscore's implications, and will blithely use private and public fields in exactly the same way, because Python won't stop them.

In Java, the language itself will prevent this from occurring -- a private field, in Java, is really private. So the compiler [1] prevents mediocre developers from producing brittle code by referencing private fields everywhere.

If you have a lot of mediocre developers in your organization -- which IMHO tends to happen more in larger organizations -- then you want a stricter compiler to stop them from writing unmaintainable code.

I personally prefer the Python way, simply because I've been bitten by this Java "feature" on multiple occasions -- a third-party library marks some field as private, but I really want to use it, to the extent of being willing to deal with instability by updating my code or freezing the dependency, if necessary. But I can't, without making my own fork of the library.

[1] The runtime also prevents private field access. So even if you bypass the compiler's checks by patching it or hex editing the compiled bytecode, you'll still get runtime errors from trying to read private fields outside the class where they're defined.

Re: Confessions of a Ruby Developer Whose Heart was Stolen by Scala

#36
post #4

Earlier quoted context omitted.

Why do microsoft and google insist on static compiled languages?

Because they allow us to put very useful limits on the degree to which changes in a large and evolving codebase will violate the expectations of developers. When adding and changing code in large collaborative projects, the primary question in every developer's mind is "OK, what else depends on this, i.e., what is possibly going to break?" This goes back to the old wisdom of separating interface from implementation.…

programs in languages which enable, if not encourage, developers to add new methods to the integer '5' can quickly become very difficult to reason about.

You do know that Scala allows just that, right?

Re: Confessions of a Ruby Developer Whose Heart was Stolen by Scala

#38

Scala is a fantastic language, but my heart seems to resist due to things like this (slide 27/42): implicit class RichSeq[A, C[A]

The same thing in Haskell:

    cycle seq = circular where circular = seq ++ circular
(or if you want to really golf it)

    cycle = fix . (++)
Ok, to be fair the Scala code is a bit more generic as it works for any abstract sequence, but still, Scala's syntax is awfully heavy compared to Haskell.

That's one reason I still prefer Haskell even though Scala is easier to sneak into enterprise projects thanks to JVM. Not to mention that Haskell gives stronger static guarantees and has a more sophisticated type inference system.

Re: Confessions of a Ruby Developer Whose Heart was Stolen by Scala

#39

Can someone comment on the current state of tooling in the Scala world. Last I had tried (some months back), SBT was extremely slow. Googling about SBT came back with a lot of complaints about the state of scala tooling back then.

I've been using Scala on Android + Intellij IDEA for about the past month after wanting to try something new[1]. Other than having to run it through proguard first, the compile process in Intellij is comparable to how it is with just Java. Scala plays nicely with Android and I have loved using it so far. Makes Android development a bit more fun than with just plain old Java.

[1] https://github.com/yareally/android-scala-intellij-no-sbt-pl...

Re: Confessions of a Ruby Developer Whose Heart was Stolen by Scala

#40
post #26

Earlier quoted context omitted.

As a Scala programmer I find Ruby syntax complex and inscrutable, almost like Perl.

As a Python programmer, I agree. Here's a Ruby snippet. I don't want to pick on this particular project [1], rather, I've found that this is typical of Ruby code: state_machine :state, initial: :active do after_transition any => :blocked do |user, transition| # Remove user from all projects and user.users_projects.find_each do |membership| return false unless membership.destroy end end My conclusion? Ruby's syntax is…

* __len__() or len() : More than one way to do it ? Oh my !

* Use setuptools, easy_install, pip while we have fun with our rake and gems.

* lambda : Please have fun, with this vomit of a feature.

* __init__.py explain that to a python beginner.

* Have fun with, { "quote": "shit" } while we use our :symbols

* What scope ?

* Have you migrated code to class Foo(object): yet ?

* How is py3 coming along ? Having fun with the worlds cleanest and bossy language community ?

* Write all your list comprehensions line noise, while we add a elegant method.

I just realized, whitespace is also, precisely the entire content of a pythonista's head.

Post reply on HN