News for hackers. Stuff that matters.

dabears

Re:Use Your Type System on Friday July 25, 2025 @08:04PM (#44689976)
Hello! I was curious if you would happen to have any advice or particular comp sci papers you would point as aspiring compiler developer towards.

I think I'm sort of who you're talking about. I have no formal education and I am excited to have my compiler up to the point I can run a basic web server. I think it's a fairly traditional approach with a lexer, recursive decent parser, static analysis, then codegen. I'm going for a balance between languages like Ruby and Rust to get the best of both worlds.

You'll probably find it funny that I don't know the name for the technique Im using for dynamic dispatch. The idea is that as long as a collection doesn't have mixed types then the compiler statically knows the type even in loops and such. Only for mixed type collections, or maybe trait functions, will the compiler be forced to fall back to runtime dynamic dispatch. I find this cool because experts can write fast static code, but beginners won't be blocked by the compiler complaining about things they shouldn't have to care about yet. But, syntax highlighting or something may hint there are improvements to be made. If there is a name for this, or if it's too small a piece to deserve one, I would be very curious to know!

On Refinement Types, I not sure they are a good idea for general purpose languages and would love to be challenged on this. Succinctly, I think it's a leaky abstraction. To elaborate, having something like a `OneThroughTen` type seems helpful at first, but in reality it's spreading behaviour potentially all over the app as opposed to having a single function with the desired behaviour. If a developer has multiple spots they're generating a number and one spot is missing a check and causes a bug, then hopefully a lesson was learned not to do that and instead have a single spot for that logic. The heavy handed complexity of Refinement Types is not worth it to solve this situation.

If there are any thoughts out there they would be greatly appreciated!

I was tired of feeling slowed down by grepping in large Ruby code, and the artificial boundary gems create requiring a `bundle open` to keep digging. I created my own Ruby LSP to solve these problems: https://github.com/pheen/fuzzy_ruby_server

I think it works well, is stable, and I would still reach for it over Shopify's LSP personally. Feel free to use it! Though as a heads up, I don't work in Ruby much anymore unfortunately so I'm not actively working on it or accepting issues.

Re:Code Is Not Literature on Tuesday August 15, 2023 @01:52PM (#37137083)
The real trick is doing both. Code that reads like a short story while including error handling and edge cases. This is achieved in a practical way by first keeping it as simple as possible only implementing strictly necessary abstractions. When the code reaches a "tipping point" then refactor. Rinse and repeat. If the code is structured reasonably that refactor should be mostly limited to the trouble spot.
I'm curious what you're really trying to say here and why feel the need to compare yourself to your peers in such a way. Do you feel like you wasted those years because your peers are "smarter" than you now?

Show HN: Fuzzy Ruby Server – Go to Definition for Ruby

https://github.com/pheen/fuzzy_ruby_server

Ruby language servers today are largely missing features like Go To Definition because most Ruby code lacks type definitions. Fuzzy Ruby Server accepts that uncertainty and creates a search index using what information is available as there is often enough to reliably match symbols.I felt the need to create this tool as constantly grepping for patterns like "def some_method" is like hunting...

( Read More... | no comments | on HN )
Re:Rewriting the Ruby Parser on Tuesday June 13, 2023 @06:04PM (#36318223)
I made a Ruby LSP because of this problem. It's not perfect but incase it's helpful for you. It can parse a large project with all of its gems in a few minutes. That data is indexed in an in-memory db with Tantivy. https://github.com/pheen/fuzzy_ruby_server
Personally, I strongly disagree. I self-taught myself into a Junior role. From there I rarely interacted with other developers outside of pull requests. I push what I think is my best work for review, the seniors tear it apart, rinse-and-repeat while trying not to make the same mistake twice. While I was in the office during that time, I don't think it contributed much to the pace I was learning.

Perhaps the real issue is at the individual level. Are you self-motivated, or do you always need breadcrumbs put before you?

Show HN: Fuzzy Ruby Server, go-to definition for Ruby

https://github.com/pheen/fuzzy_ruby_vscode_client

Hello!I work in a large Ruby codebase and have had a lot of frustrations with the existing tooling. Solargraph is far too slow, and the rest of the Ruby language servers don't support features like Go-To Definition, which is primarily what I'm after. It's not reasonable that I should have have to search `def some_method` constantly, what year is this!? The codebase I work in will not add...

( Read More... | no comments | on HN )
Re:Take Advantage of Git Rebase on Thursday October 06, 2022 @02:56PM (#33112436)
This is my workflow as well, it's great. Github is configured so merging a PR into master will automatically produce a squashed commit.

My rule of thumb, always rebase unless you hit a series of merge conflict while rebasing. Then either merge, or squash your branch then re-run the rebase.

Re:Watchman: Execute a command when something changes on Wednesday October 05, 2022 @05:17PM (#33101339)
Inotify can drop events when there is a burst of file changes. You can bump up the max number of queued events though. For example, if you're watching a git repo and switch to an old branch that has 1500+ changed files then inotify will likely miss some with a default configuration.
Re:Ten Years of TypeScript on Saturday October 01, 2022 @11:54PM (#33052665)
Just have to say thank you so much for CoffeeScript! It was pivotal in my career and has brought me a lot of joy :)
Ideally you have a reliable Change Data Capture (CDC) mechanism like a Binlog Reader. Debezium, for example, can write directly to a queue like Kafka. A Kafka consumer picks up the events and writes to your secondary datastore. Something like that can probably handle all of your events without bucketing them, but if you want to cut down the number of messages written to the queue you can add that logic into the Binlog Reader so it emits a burst every 5 seconds or so. During those 5 seconds it buffers the messages in the processes memory or externally in something like Redis using a key so only the latest message is stored for a given record.