News for hackers. Stuff that matters.
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?