frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

T-Ruby is Ruby with syntax for types

https://type-ruby.github.io/
64•thunderbong•7h ago

Comments

wsc981•1h ago
In the context of Lua, I’ve taken a liking to LuaLS (Lua Language Server). You can just write your Lua scripts with annotations (where needed) and the language server can help auto-complete and verify type usage. No compilation step needed.

I never tried “typed Lua” variants (such as MoonScript IIRC), but I believe those do require a compilation step.

kace91•1h ago
Honest question:

I like typescript and I think it makes sense:, the web makes you married to JavaScript, so it’s the reasonable path forward if you want types in that context.

But what is the point of the recent wave of types for python, Ruby, and similar languages?

If it’s type safety you want there, there’s a bajillion other languages you can use right?

wawj•1h ago
Languages take time to get used to and to get productive in. IF you already know Ruby, and want the same safety as C# for instance, then this makes sense.
actionfromafar•1h ago
Crystal is a cool Ruby-like.
shevy-java•24m ago
I agree on the first part. This is valid for all programming languages though.

I disagree that you get the same safety as C# anywhere though. But even more importantly - I don't think people should write C#-like code in ruby. It does not really work that well. It is better to write ruby like ruby; and even in ruby there are many different styles. See zverok using functional programming a lot. I stick to oldschool boring OOP; my code is very boring. But usually well-documented. I want to have to think as little as possible because my brain is very inefficient and lazy; zverok has a good brain so he can write more complex code. It is very alien code to me though, but he also documents his code a lot. You can find his code or some of his code here, it is a quite interesting ruby style, but also alien to me: https://zverok.space/projects/

(Ruby also adopted some habits from perl. I also don't think writing perl-like ruby makes a lot of sense. See also the old global variables inspired by perl; I can not recall most of them off-hand, so I avoid using them. My brain really needs structure - it is such a poor thinking machine really. And slow. My fingers are much faster than my brain really.)

matteotom•1h ago
At least for Python (since I'm more familiar with Python code and the Python ecosystem): progressive typing lets you incrementally add typing to an existing Python codebase. So you can have at least some of the benefits of typing for new or updated code without needing to re-write in a new language.
MGriisser•1h ago
(I'm not sure if this still holds under a world where LLMs are doing the majority of writing code but this is my opinion from prior to LLMs)

From someone who has worked mostly in Ruby (but also Perl and TypeScript and Elixir) I think for web development, a dynamic language with optional types actually hits maybe the best point for developer productivity IMO.

Without any types in a dynamic language, you often end up with code that can be quite difficult to understand what kinds of objects are represented by a given variable. Especially in older poorly factored codebases where there are often many variations of classes with similar names and often closely related functions it can feel almost impossible until you're really familiar with the codebase.

With an actual fully typed language you're much more constrained in terms of what idioms you can use and how you can express and handle code by the type system. If you're not adept or knowledgeable about these things you can spend a lot of time trying to jam what you're attempting into the type system only to eventually realize it's impossible to do.

A gradual type system on top of a dynamic language gets you some of the best of both worlds. A huge amount of the value is just getting typing at function boundaries (what are the types of the arguments for this function? what is the type of what it's returning?) but at the same time it's extremely easy to just sidestep the type system if it can't express what you want or is too cumbersome.

shevy-java•28m ago
> the best point for developer productivity IMO.

That is a fair opinion. My opinion is different, but that's totally fine - we have different views here.

What I completely disagree with, though, is this statement:

> Without any types in a dynamic language, you often end up with code that can be quite difficult to understand what kinds of objects are represented by a given variable.

I have been writing ruby code since about 22 years (almost) now. I never needed types as such. My code does not depend on types or assumptions about variables per se, although I do, of course, use .is_a? and .respond_to? quite a lot, to determine some sanitizing or logic steps (e. g. if an Array is given to a method, I may iterate over that array as such, and pass it recursively into the method back).

Your argument seems to be more related to naming variables. People could name a variable in a certain way if they need this, e. g. array_all_people = []. This may not be super-elegant; and it does not have as strong as support as types would, but it invalidates the argument that people don't know what variables are or do in complex programs as such. I simply don't think you need types to manage this part at all.

> Especially in older poorly factored codebases where there are often many variations of classes with similar names and often closely related functions it can feel almost impossible until you're really familiar with the codebase.

Note that this is intrinsic complexity that is valid for ANY codebase. I highly doubt just by using types, people automatically understand 50.000 lines of code written by other people. That just doesn't make sense to me.

> With an actual fully typed language you're much more constrained in terms of what idioms you can use

I already don't want the type restrictions.

> A gradual type system on top of a dynamic language gets you some of the best of both worlds.

I reason it combines the worst of both worlds, since rather than committing, people add more complexity into the system.

cosmic_cheese•27m ago
> Without any types in a dynamic language, you often end up with code that can be quite difficult to understand what kinds of objects are represented by a given variable. Especially in older poorly factored codebases where there are often many variations of classes with similar names and often closely related functions it can feel almost impossible until you're really familiar with the codebase.

One of the worst parts of exploring an unfamiliar codebase written in a language without type labeling is tunneling through the code trying to figure out what this thing you see being bounced around in the program like the a ball in a pinball machine actually is.

jweir•7m ago
This is our experience. We have added Sorbet to a 16 year old Rails app. It is a big win in avoiding errors, typos, documentation, code completion, fewer tests are required, etc.

And the LLMs take advantage of the types through the LSP and type checking.

rajangdavis•1h ago
I have been programming with Ruby for 11 years with most of the time in a professional context. It's my favorite language :).

I don't care much for types, but it can be useful with denser libraries where IDE's can assist with writing code. It has been helpful in my professional life with regards to typed Python and Typescript.

One potential example that would be interesting is utilizing types for reflection for AI tool calling, the python library for Ollama already supports this[0].

It would make it easier to use such tools in a Ruby context and potentially enhance libraries like ruby-llm [1] and ollama-ruby [2].

[0] https://docs.ollama.com/capabilities/tool-calling#using-func...

[1] https://rubyllm.com/

[2] https://github.com/flori/ollama-ruby

zem•38m ago
the overall field is known as "gradual typing", and it is an attempt to combine some of the benefits of both static and dynamic typing (or to put it more accurately, to explore more of the benefits and tradeoffs on the static to dynamic spectrum). in the "type checkers for ruby/python/js" part of the spectrum what you are trying to ask is "how much static type safety can I add without giving up the power of the dynamic bits", so for instance you have code that generates classes as runtime (not really compatible with a strictly static type system in the most general case), but specific very common uses of code generation, like python's dataclasses, have support within the type checker.
shevy-java•34m ago
That still has not really explained why they (those who propose that) need types in ruby specifically. Whether python has it or not is not relevant because it is another language. The argument that "language xyz has it, so ruby needs it", can be compelling, but does not necessarily have to be compelling. It needs to have a use case for ruby in and by itself. I don't see that intrinsic use case.
zem•21m ago
the argument is not "some other language has it so we should", the argument is "static type checking is very useful even if it is not 100% strict, and ruby's lack of syntactic support for type annotations makes them clunky to use, so here's an enhancement that adds them".

the intrinsic use case is that your code is often implicitly statically typed, even if the language itself doesn't enforce that, so it's nice for tools to check it for you. this gets more and more useful the larger your codebase gets; python and javascript have shown that in practice.

and note that people have already written type checkers for ruby, they are just much less pleasant to use because there is no nice way to express the types you would like to check/enforce.

resonious•17m ago
I work in Ruby a lot on large/old projects. I think the main reasons are: people nowadays are very dependent on editor intellisense, and "undefined method ... for nil" errors in production are very frustrating.

That said, I am actually in the "don't want types in Ruby" camp. Intellisense isn't as needed if you're good at using irb (the repl). And the dynamism makes it super easy to write unit tests, which can give you back a lot of the guarantees you'd otherwise get from static types. Most importantly, a lot of the fun in Ruby comes from the ability to make nice DSLs and aggressively metaprogram boilerplate away.

lofaszvanitt•36m ago
Religious coders spreading their religion.
shevy-java•27m ago
I agree somewhat, but I'd rather call it their brain adjustment than a religion though.

I think about 99% of people who suggest to slap down types onto dynamic languages have already been using types since decades, or many years, in another language. Now they switch to a new language and want to have types because their brain is used to.

t-writescode•8m ago
Nah. 99.9% of the people who wanted the addition of DryStructs to a codebase I worked on wanted it because they'd been bit, repeatedly, by someone sending one kind of object into a function rather than what the function accepted and it just not getting caught.

A robust type system allows you to make "compiler errors" out of runtime errors. One of these takes *way more tests to catch* than the other. I'll let you guess which.

shevy-java•35m ago
Yeah. I have the same question and none of the type addicted folks could answer that. The explanations usually boil down to "I used C, so now I need types in other languages too". That's like 90% of the explanations you can see.
CodingJeebus•24m ago
Being able to retroactively apply type definitions to a system can be helpful for large legacy application refactoring where simply choosing a type-safe language is not an option.
atomicnumber3•25m ago
In large - and honestly even medium - and honestly-honestly even _not-small_ python projects, you often end up losing track of what stuff is.

At one of my jobs, i was often plagued by not knowing if "f" - short for file, naturally, that part is fine tbh - was a string, an io-like thing, a path object, a file object, or what-have-you. Sure sure, some argue this is the magic of python - just try to do whatever you want to it, and if it doesn't work, throw an error - I know I know. I'll tell you that's all really cool until you have 8 different people passing around 8 different types and you're just trying to have the darn program not crash and also not print logs like "could not snafucate file: [whatever str/repr comes out when you print() an IO object]". And this isn't one of those cases where being able to shrug at the type is like, buying you anything. It's just a damn file.

So, when python's types came out, I started going in and type hinting f: str where i found it and could determine it was a string. (and various other things like this - obviously f is just an example). And suddenly after enough of this, we just stopped having that problem. Coworkers thanked me when they saw me in the diffs adding them. People just passed in strings.

I'll also add that in most programs, most types are just primitives, built-in collections, and structs composing those two. So while it's quite nice yes that you can do crazy backflips that would simply not work in more rigidly typed languages, often I do want to just reassure everyone that yes, please pass in a str for "file". And if i've typed it as str|IO then do feel free to also pass in an IO. It just lets me talk to the other programmers in the codebase a lot more easily. I'm not trying to enforce correctness of types necessarily. I'm just trying to communicate.

t-writescode•10m ago
Ruby provides a lot of really nice libraries; and Ruby on Rails - *especially its ActiveAdmin infrastructure* is best-in-class for "build something stupid-fast". Legitimately, I'll spend a day or so per-page on making administrative sites that do a 1/10th of what ActiveAdmin does in like 2 lines. And AA does it much prettier, too.

I write in Kotlin for myself, and Ktor and React or Ktor and Htmx + SolidJS, for web stuff; but those are decisions I made for myself, (edit: and) I know what it's costing me to not have the raw convenience that is Ruby's Active Admin infrastructure, among other things, I'm sure.

rajangdavis•1h ago
If it is at all possible, it would be nice to have a little bit better support for metaprogramming namely around `define_method` and supplying a typed lambda or block for the dynamic method. I can see why this would be a pain to implement, so I don't expect it :).

Otherwise, I think in terms of typed Ruby, this is an incredible undertaking with very well written documentation. Thank you for making this library, I think there's a lot that the Ruby community can benefit from with it. Cheers!

jrochkind1•1h ago
Wait, what happens if you want keyword arguments?
t-writescode•7m ago
keyword arguments are, internally, syntactic sugar over a hash. It probably doesn't easily work with typing the explicit values of a raw hash
jhealy•55m ago
interesting idea, good on them for trying something different in the Ruby ecosystem.

The website is quite extensive, but the gem only has ~1.5k downloads. It’s presumably very early on the adoption curve

shevy-java•36m ago

    def greet(name: String): String
      "Hello, #{name}!"
    end
Yep - looks like utter s...

I understand that many programmers come from languages where their brain has been adjusted to necessitate and depend on types. And they get help from the compiler in capturing some errors. But it is the wrong way to think about programs and logic. I'd wish these guys would stop trying to ruin existing languages. Go add types somewhere else please.

Note: I also use java, so I am not against types per se. I am against a want-on need to slap down types onto everything and your Grandma, merely because your brain (of type afficionados) needs them for survival.

koteelok•30m ago
Don't show this to DHH
omarqureshi•19m ago
I don't programme much any more but the whole beauty of Ruby that it pretty much heavily relies on #respond_to? / duck typing and thus you don't rely on types or class checking at all.
omoikane•16m ago
> https://type-ruby.github.io/playground

The playground seems broken, I can't get it to report any kind of error. It seems to accept even syntactically incorrect files (e.g. just one unmatched closing parenthesis).

t-writescode•14m ago
That article was way better prepared than I was prepared for. I like how it translates its code into Ruby's official types-in-headers format. Very nice.

I think this is a nice way to include types into a project if you like it. I know when you're working on large Ruby projects - 10s of thousands of lines across hundreds of files - types become really, really helpful to figure out what on earth is happening where. In the past I've used DryRb and was pretty happy with it; but an even deeper connection, like this, looks wonderful.

I'd really enjoy it, I think :)

How uv got so fast

https://nesbitt.io/2025/12/26/how-uv-got-so-fast.html
624•zdw•10h ago•201 comments

QNX Self-Hosted Developer Desktop

https://devblog.qnx.com/qnx-self-hosted-developer-desktop-initial-release/
35•transpute•2h ago•9 comments

Always Bet on Text

https://graydon2.dreamwidth.org/193447.html
104•jesseduffield•4h ago•51 comments

T-Ruby is Ruby with syntax for types

https://type-ruby.github.io/
64•thunderbong•7h ago•31 comments

Experts explore new mushroom which causes fairytale-like hallucinations

https://nhmu.utah.edu/articles/experts-explore-new-mushroom-which-causes-fairytale-hallucinations
324•astronads•10h ago•153 comments

The Best Things and Stuff of 2025

https://blog.fogus.me/2025/12/23/the-best-things-and-stuff-of-2025.html
143•adityaathalye•3d ago•16 comments

How Lewis Carroll computed determinants (2023)

https://www.johndcook.com/blog/2023/07/10/lewis-carroll-determinants/
142•tzury•8h ago•28 comments

One million (small web) screenshots

https://nry.me/posts/2025-10-09/small-web-screenshots/
25•squidhunter•4d ago•1 comments

Package managers keep using Git as a database, it never works out

https://nesbitt.io/2025/12/24/package-managers-keep-using-git-as-a-database.html
591•birdculture•14h ago•336 comments

Show HN: Witr – Explain why a process is running on your Linux system

https://github.com/pranshuparmar/witr
218•pranshuparmar•12h ago•29 comments

Publishing your work increases your luck

https://github.com/readme/guides/publishing-your-work
14•magoghm•2h ago•1 comments

Drawing with zero-width characters

https://zw.swerdlow.dev
76•benswerd•8h ago•26 comments

-tucky (2023)

https://languagelog.ldc.upenn.edu/nll/?p=58650
29•benatkin•2d ago•31 comments

Retreating from EVs could be hazardous for Western carmakers

https://www.economist.com/business/2025/12/17/retreating-from-evs-could-be-hazardous-for-western-...
13•smurda•1h ago•18 comments

LearnixOS

https://www.learnix-os.com
200•gtirloni•14h ago•78 comments

My insulin pump controller uses the Linux kernel. It also violates the GPL

https://old.reddit.com/r/linux/comments/1puojsr/the_device_that_controls_my_insulin_pump_uses_the/
347•davisr•8h ago•140 comments

Parasites plagued Roman soldiers at Hadrian's Wall

https://arstechnica.com/science/2025/12/study-roman-soldiers-battled-parasites-at-hadrians-wall/
42•sipofwater•1w ago•29 comments

Moravec's Paradox and the Robot Olympics

https://www.physicalintelligence.company/blog/olympics
27•beklein•3d ago•2 comments

SIMD City: Auto-Vectorisation

https://xania.org/202512/20-simd-city
5•brewmarche•6d ago•0 comments

FFmpeg has issued a DMCA takedown on GitHub

https://twitter.com/FFmpeg/status/2004599109559496984
416•merlindru•9h ago•130 comments

Perfect Aircrete, Kitchen Ingredients [video]

https://www.youtube.com/watch?v=z4_GxPHwqkA
86•surprisetalk•6d ago•31 comments

Ask HN: What did you read in 2025?

172•kwar13•14h ago•236 comments

Show HN: Xcc700: Self-hosting mini C compiler for ESP32 (Xtensa) in 700 lines

https://github.com/valdanylchuk/xcc700
94•isitcontent•12h ago•18 comments

Gaussian Splatting 3 Ways

https://github.com/NullandKale/NullSplats
50•nullandkale•8h ago•4 comments

MongoBleed

https://github.com/joe-desimone/mongobleed/blob/main/mongobleed.py
59•gpi•9h ago•9 comments

The Algebra of Loans in Rust

https://nadrieril.github.io/blog/2025/12/21/the-algebra-of-loans-in-rust.html
194•g0xA52A2A•4d ago•96 comments

Rob Pike goes nuclear over GenAI

https://skyview.social/?url=https%3A%2F%2Fbsky.app%2Fprofile%2Frobpike.io%2Fpost%2F3matwg6w3ic2s&...
1287•christoph-heiss•13h ago•1547 comments

Unix "find" expressions compiled to bytecode

https://nullprogram.com/blog/2025/12/23/
102•rcarmo•14h ago•14 comments

What happened to all the gold Spain got from the New World? (1985)

https://www.straightdope.com/21341789/what-happened-to-all-the-gold-spain-got-from-the-new-world
81•titaniumtown•4d ago•111 comments

Migrating my web analytics from Matomo to Umami

https://stanislas.blog/2025/12/migrating-matomo-to-umami-web-analytics/
37•angristan•2d ago•5 comments