TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Roda – A new Ruby web framework

106 pointsby sebkomianosalmost 11 years ago

15 comments

UUMMUUalmost 11 years ago
The problem with this approach is readability. If you look at the code vs Sinatra every time you want to figure out which route to edit, you have to traverse the tree as opposed to just scanning for the route you want. As an example, editing the route /artist/:id/album/:number requires you to first find the /artist/:id then scan down and look for /album/:number making sure you watch for the closing end because what if the route isn't defined? In Sinatra, you look for /artist/:id/album/:number. The solution to this is to put a comment on every route to denote where it is. I agree the tree methodology can be faster O(log N) (for GET and POST) vs O(N) but readability suffers with no comments.
评论 #8155617 未加载
评论 #8155919 未加载
评论 #8154005 未加载
评论 #8152734 未加载
评论 #8154173 未加载
评论 #8154174 未加载
jeremyevansalmost 11 years ago
I&#x27;m glad Roda is finally getting some publicity. I submitted it here when it was released.<p>I&#x27;ve converted about 15 apps from Sinatra to Roda, and a couple of Rails apps to Roda (working on converting my final Rails app). Personally, I&#x27;ve found that the biggest advantages come when the URL structure mirrors your application structure, and you have redundant code in many routes, as that type of code becomes simpler, faster, and DRYer with Roda.<p>Yes, you can use a before block with wildcard routes with Sinatra, but Sinatra will still traverse the routing list sequentially and recheck the full route for every entry in the list. Unfortunately, while I love Sinatra, have contributed patches to it, and have used it since 0.1.0, the approach doesn&#x27;t scale well for sites with a lot of routes.<p>The code non-locality issue shouldn&#x27;t be ignored, and is probably the largest issue with Roda, but the issue is probably going to happen with any approach that DRYs up the code to the same degree. It&#x27;s true if you use a before block in Sinatra, or a before_filter in Rails.<p>The use of a routing tree really isn&#x27;t an innovative approach (at least not innovated by me). It&#x27;s been around in Ruby since Rum was released in 2008 (and maybe earlier elsewhere). However, it&#x27;s not well known, and I hope that Roda brings it into the mainstream.<p>One of the best things about Roda that I don&#x27;t think has been mentioned in the comments yet is the plugin system, which I borrowed from Sequel. This makes it easy to extend Roda beyond its very small core. For example, the multi_route plugin makes it easy to scale Roda to larger sites by splitting up routing subtrees into specific files. There are currently about 15 plugins, and I have ideas for quite a few more that I will implement after finishing up my current Rails-&gt;Roda conversion.<p>I apologize that the code on the website isn&#x27;t syntax highlighted. If anyone can offer their design skills, I would greatly appreciate it.<p>If you have any questions about Roda, please ask.
评论 #8155131 未加载
评论 #8155507 未加载
swansonalmost 11 years ago
I don&#x27;t really buy the &quot;big win&quot; over Sinatra (&quot;much DRYer&quot;, no need to set ivars for each action) because you can just use a `before` block with wildcard routes.<p><pre><code> before &#x27;&#x2F;artist&#x2F;:id*&#x27; do @artist = Artist[params[:id]] end before &#x27;&#x2F;artist&#x2F;:id&#x2F;album&#x2F;:number*&#x27; do @album = @artist.album_with_number(params[:number]) end</code></pre>
diminishalmost 11 years ago
Welcome Roda and congrats for this new innovative routing idea. As much as I see some value in a tree-like routing definition in this nice comparison with Sinatra, <a href="http://roda.jeremyevans.net/why.html" rel="nofollow">http:&#x2F;&#x2F;roda.jeremyevans.net&#x2F;why.html</a>, Sinatra&#x27;s routing approach still appears to be more readable and manageable. Maybe Sinatra could optimize the storage of the routing entries internally in a tree to make it as fast as Roda (if it doesn&#x27;t already do).
评论 #8152841 未加载
krisdolalmost 11 years ago
I love it. I think the concerns about the code being unmaintainable from the example are a bit unfair. There is nothing preventing a developer from moving the blocks out into separate files&#x2F;classes for a more coder-friendly organization. How deep do you guys nest your javascript callbacks?<p>This also lead me to check out sequel, which I can&#x27;t believe that I&#x27;m just now finding out about.
benvdsalmost 11 years ago
I&#x27;m very fond of his sequel gem. The source is really great just to browse through and learn from.
评论 #8152526 未加载
SeoxySalmost 11 years ago
I&#x27;ve been using a web &quot;framework&quot; I wrote for a few years now. It now powers various projects, from the Chartboost Store backend, to the entire the entire backend codebase for my new startup, FreshPay.<p><a href="https://github.com/kballenegger/kenji" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kballenegger&#x2F;kenji</a><p>One of the big things that makes Kenji awesome is that, like Roda, it uses a routing tree.
jasonlfunkalmost 11 years ago
I think this looks great. However, even in his simple example comparing Roda and Sinatra the code ends with 7 &#x27;end&#x27;s. I can imagine how deeply nested a non-simple app can be. In my experience, the deeper you get in your nesting - the more complicated the code is to read.
programminggeekalmost 11 years ago
Oh boy another web framework to benchmark... :-)<p><a href="http://www.madebymarket.com/blog/dev/ruby-web-benchmark-report.html" rel="nofollow">http:&#x2F;&#x2F;www.madebymarket.com&#x2F;blog&#x2F;dev&#x2F;ruby-web-benchmark-repo...</a>
fingerprinteralmost 11 years ago
It might be just me, but that is insanely hard to read. I MUCH prefer the Sinatra approach for that reason alone. Looking at the examples side-by-side I couldn&#x27;t tell what was going on in Roda...at all.
james-skempalmost 11 years ago
My apologies if this is off-topic, but since I see mention of various frameworks ... it seems relevant.<p>I&#x27;m a .NET dev finally looking at Ruby again. I have a Rails book from a long while ago that I&#x27;m working through (well, planning on - Rails 4 in Action, still in MEAP) but looking at this data I&#x27;m wondering if that&#x27;s the best idea.<p>Any recommendations on a framework for someone getting started?<p>If it helps, I&#x27;ve been using ASP.NET MVC since 1.0 if not slightly earlier.
评论 #8156234 未加载
davexunitalmost 11 years ago
I wish that routes weren&#x27;t stuck within strings like `&#x2F;artist&#x2F;:id`, but instead used some kind of pattern matching like `[&#x27;artist&#x27; :id]`. It&#x27;s better to use Ruby syntax instead of a quoted string of characters that can&#x27;t be manipulated or verified as easily.
评论 #8154996 未加载
thefreemanalmost 11 years ago
Anyone know where the name came from? It happens to be my last name and it&#x27;s really amusing me reading the docs and these comments.
评论 #8155027 未加载
评论 #8154966 未加载
noonatalmost 11 years ago
Definitely feels like an improvement on Cuba! I&#x27;m not a huge fan of the `is` method here, though. I feel like you could get the same thing from a terser DSL if you treated HTTP methods as terminators and only allowed `on` to filter the path.
farrelalmost 11 years ago
Jeremy Evans ain&#x27;t nothing to fsck with.