News for hackers. Stuff that matters.
Re:I Miss Rails by fny on Thursday March 28, 2019 @10:21PM (#19518600)
Honestly, I just wish Rails had some degree of static typing (a la TypeScript.) As a Rails code base grows and patterns are required beyond the basics, it becomes a nightmare to tell what comes from where. You'd probably gain some mileage from that in your React codebase.
Re:I Miss Rails by ethagnawl on Friday March 29, 2019 @12:22AM (#19519140)
I've been meaning to revisit Kotlin's web framework offerings. I've used it in small doses for Android and AWS Lambda functions and, IMO, it seems to potentially be the best of both worlds; strict where it needs to be and flexible where it doesn't. I'm currently supporting a few Python Lambda functions at work and they feel very slapdash in comparison.
Re:I Miss Rails by jrs95 on Friday March 29, 2019 @12:32AM (#19519171)
The biggest problem with Kotlin is also it's biggest strength: excellent interop with Java. This means that you can use all of the Java libraries...but that also makes writing new libraries in idiomatic Kotlin unnecessary, so you're going to get less of them, and have to use a lot of crummy old Java APIs.
Re:I Miss Rails by vbsteven on Friday March 29, 2019 @03:04AM (#19519714)
Try Kotlin with the Spring Boot framework. I view Spring Boot as the Rails of the Java world and the Spring team has done a lot of work lately on Kotlin compatibility and idiomatic APIs.

This week I’ve been porting one of my Spring Boot apps to Kotlin and that was a great experience.

The only thing I’m waiting for is good reactive drivers for Postgres and then you can go with their new reactor based apis instead of the older one-thread per request Spring MVC.

Re:I Miss Rails by m23khan on Friday March 29, 2019 @09:47AM (#19521617)
+1 - Kotlin/Java with Spring is a totally different beast as compared to java apps of yester years.
Re:I Miss Rails by ethagnawl on Friday March 29, 2019 @10:33AM (#19522006)
This is a good point. I haven't used Spring in forever, so I don't know if/how it takes advantage of any modern Java features, but I could see Java 8/9/10 and (a framework like) Spring being pleasant and productive.
Re:I Miss Rails by vbsteven on Friday March 29, 2019 @11:39AM (#19522582)
The Spring and Spring Boot teams have done a lot of work on this. IIRC Spring Boot 2.1 is compatible up until Java 11, and Java 12 support should be in 2.2.

Some API's are adapted to take advantage of modern Java features like for example JPA repositories that can return Optional<T> for single row queries and Stream<T> for multi row queries. Some API's have been improved with functional equivalents.

If you combine this with Kotlin you get all the power of the Spring framework together with excellent nullability checks and modern language features that Kotlin brings to the table.

Re:I Miss Rails by ganonm on Friday March 29, 2019 @06:41AM (#19520464)
Kotlin + Dropwizard is a great choice (or Spring Boot). I've used it in production and it's got the best aspects of Rails (opinionated) with the best aspects of a modern, statically typed language running on the JVM (need I say more?).
Re:I Miss Rails by hombre_fatal on Thursday March 28, 2019 @10:27PM (#19518622)
Static-typing seems so at odds with Ruby/Rails that I can't even imagine what that would look like.
Re:I Miss Rails by gurkendoktor on Thursday March 28, 2019 @10:56PM (#19518769)
I'm waiting for a chance to try out Crystal/Amber, which is type-checked (not sure how safe?) and can be pre-compiled like Go apps. It looks really close to Rails:

https://github.com/ChangJoo-Park/amber-realworld-example-app...

(I couldn't find any code snippets on the official Amber framework page, I hope this is representative.)

Re:I Miss Rails by realusername on Friday March 29, 2019 @01:30AM (#19519387)
Crystal/Amber combination is such a joy to work with, it's too bad it's not more popular, I'm contributing a bit to the project sometimes and use it for personal stuff. I regret it's not that trendy because it's the best web experience I ever had.
Re:I Miss Rails by Willamin on Thursday March 28, 2019 @11:10PM (#19518834)
Crystal is definitely type safe, I’d recommend taking a look at the Lucky web framework also written in Crystal.
Re:I Miss Rails by ethagnawl on Friday March 29, 2019 @12:18AM (#19519126)
Kemal is great, too. Though, IIRC, it's more akin to Sinatra.
Re:I Miss Rails by pwim on Thursday March 28, 2019 @10:35PM (#19518664)
Stripe has built a type checker for Ruby that they're using internally. I don't think it has been released yet, but you can get a preview of it at https://sorbet.run/.
Re:I Miss Rails by pmontra on Friday March 29, 2019 @02:03AM (#19519502)
So it's something along the lines of Erlang / Elixir dialyzer. I don't like it much (dialyzer) because of the verbosity and unDRYness. Every function definition becomes two lines and the name of the function is repeated in both. Type names are longer than they should and are separated from argument names.

We had a discussion about Ruby's type annotations 4 years ago at https://news.ycombinator.com/item?id=9481186

I found it by googling the status of the work on Ruby 3 type annotations. The top comment is mine and I still agree with the past myself.

Re:I Miss Rails by ehsanu1 on Thursday March 28, 2019 @10:32PM (#19518645)
It would ideally look pretty similar to typescript. There's actually a few projects adding typing to ruby, but they seem to be mostly trying to catch issues at runtime, which to me is pointless. Or the syntax is onerous, using decorators and/or separate type definitons.

I'd be really interested in a typescript like superset of ruby, and I've even thought about building a prototype of it, though it's quite outside my area of expertise.

Re:I Miss Rails by hombre_fatal on Thursday March 28, 2019 @10:42PM (#19518701)
I don't mean the syntax, I mean the abuse (ostensibly a language feature) of method_missing that's incumbent in the ecosystem. What would be the type signature of Active Record?
Re:I Miss Rails by favorited on Thursday March 28, 2019 @11:36PM (#19518967)
Aren't your ActiveRecord models basically the only place in a Rails app where you do specify the types of your properties?
Re:I Miss Rails by hombre_fatal on Friday March 29, 2019 @12:17AM (#19519124)
I'm referring to things like dynamic find_by_* messages since more people might be familiar with that.

But I don't know why you'd say that. ActiveRecord models are one of the main places you'll see a bunch of `use SomeGem::Thing` that introduce a bunch of magic methods on model instances.

And my point is that we aren't talking about method composition here that you can statically analyze with a bolted-on type system. Ruby's metaprogramming runs so deep that it's a substantially bigger challenge than other dynamically-typed languages.

One clue is that humans even have a hard time with it. The first shock that people have with Ruby is when you see a method or identifier and grep shows up with zero results.

Aside, I can kinda tell that Ruby is entering Perl territory when there are no beginners around to chime in with their gripes.

Re:I Miss Rails by asark on Friday March 29, 2019 @11:20AM (#19522430)
The magic stuff's awful. Any time you have to dig into a mothballed Rails codebase from a version either older or newer than what you're used to, or with a bunch of Railsy magic gems that aren't in your usual toolkit, it's hell. I'd rather let the computer tell me what stuff is and where it's defined than memorize a bunch of magic prefixes.
Re:I Miss Rails by favorited on Friday March 29, 2019 @12:37AM (#19519192)
I only say that because it seems like low-hanging fruit. If I have a class with a random @ivar that's added inside a random method, there's nothing up-front to check against. An ActiveRecord subclass at least has a database schema to validate against.
Re:I Miss Rails by digitaltrees on Friday March 29, 2019 @03:27PM (#19524758)
I am a beginner. I don’t know enough to gripe, I bet that’s a common feeling among beginners.
Re:I Miss Rails by tomc1985 on Friday March 29, 2019 @12:26AM (#19519153)
Have you tried elixir?
Re:I Miss Rails by benbristow on Saturday March 30, 2019 @06:52AM (#19528804)
That's more a Ruby issue than a Rails issue.

https://sorbet.run/

Stripe have been working on a type-checker. No idea when they're going to release it to the public though.