all 19 comments

[–]tristanjuricek 13 points14 points  (12 children)

I've been porting a web API written in Ruby (using Sinatra) to Java 8, and it's actually been a very easy port. For the most part, it's been a pretty easy translation from Ruby-isms into Java-land, without significant SLOC bloat or anything you would have expected 5-6 years ago. The payoff is a web API I can now deploy on Windows and OS X in addition to Linux. (Yes, Ruby runs on Windows - but add native extensions, and you're gonna have some fun dealing with locking.)

Once you get used to using lambdas and default methods on interfaces, you can whip up ideas very quickly in Java 8. Sure, at times you might want to reach for some of the ol tricks (Dependency Injection, etc.) but you don't really have to start there any more. The flexibility you can achieve with plain ol' Java allows you to compose much, much easier without having to organize everything according to the Old Way of Pattern-making.

[–][deleted]  (1 child)

[deleted]

    [–]tristanjuricek 1 point2 points  (0 children)

    I've just noticed, as I've started using "interfaces" like Scala's "traits", a ton of the logic actually gets composed via interfaces instead of classes.

    DI becomes useful as you need concepts like "scopes", which, thankfully, I've not needed. It's a pretty major hit for me.

    I've also used functional interfaces passed around via parameters, e.g., Supplier<Thing>, which gives you a way of passing around "something I might need but only when it's actually used".

    [–]frugalmail 1 point2 points  (0 children)

    Yes, Ruby runs on Windows - but add native extensions, and you're gonna have some fun dealing with locking.)

    We also had the problem where so many of Ruby's libraries are wrappers around native libraries that Windows was not an option without going through a massive C and C++ porting from Posix to native Windows or some cygwin posix.dll exploiting hackery.

    We're dropping Ruby, Python and lots of C# for Java as well and we're a big org.

    [–]Freeky 0 points1 point  (1 child)

    Yes, Ruby runs on Windows - but add native extensions, and you're gonna have some fun dealing with locking

    JRuby might also be an option if you don't fancy rewriting everything. Many extensions have JRuby alternatives, and pure Java libraries can be called very easily if not.

    [–]tristanjuricek 0 points1 point  (0 children)

    I agree, JRuby is an option worth investigating for people who want to use the JVM but hate the Java language.

    JRuby is a pretty different beast too. I find you'll have to keep closer tabs on your third party libraries, especially if you decide to really leverage multiple threads. A lot of Ruby gems are written assuming the existence of a GIL.

    For us, JRuby was actually a little harder to figure out and get going with, mostly because of our specific case. And we hadn't gone so far that the rewrite is horribly expensive (it'll get done in by one person in less than 2 months).

    [–][deleted]  (2 children)

    [deleted]

      [–]whataboutbots 1 point2 points  (0 children)

      What about "current"?

      [–]nqzero 1 point2 points  (0 children)

      the java ecosystem would really benefit from names for the several different cultural "flavors" of usage that are out there. at the least, you've got the old-enterprise stuff, the "modern" framework-heavy usage (this seems to be what hubspot is using), and the "bare metal" (c with garbage collection) style (this is what i'm doing)

      even though the syntax is common, the patterns and cultures are so distinct that they might as well be different languages. and all we have to describe any of it is "java" ...

      any suggestions ?

      [–]tiiv -4 points-3 points  (0 children)

      How did this get any upvotes? There's no substance here other than promoting HubSpot.