<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dhruvika Kevat on Medium]]></title>
        <description><![CDATA[Stories by Dhruvika Kevat on Medium]]></description>
        <link>https://medium.com/@dhruvika.k?source=rss-bd22ce8f98------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Dhruvika Kevat on Medium</title>
            <link>https://medium.com/@dhruvika.k?source=rss-bd22ce8f98------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 23:59:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dhruvika.k/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Explore Sinatra and its Potential for Building Web Apps]]></title>
            <link>https://medium.com/simform-engineering/explore-sinatra-and-its-potential-for-building-web-apps-8463a2db0a0b?source=rss-bd22ce8f98------2</link>
            <guid isPermaLink="false">https://medium.com/p/8463a2db0a0b</guid>
            <category><![CDATA[sinatra]]></category>
            <category><![CDATA[sinatra-project]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[sinatra-app]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Dhruvika Kevat]]></dc:creator>
            <pubDate>Wed, 19 Apr 2023 09:49:08 GMT</pubDate>
            <atom:updated>2023-04-19T09:57:42.848Z</atom:updated>
            <content:encoded><![CDATA[<h3>Explore Sinatra and its Potential for Building Performant Web Apps</h3><h4>Create web applications with Ruby on the minimalist Sinatra framework. Build fast, scalable, and modular applications with ease.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*27h-CO8y2Bz3unDQVMooog.png" /></figure><p>Ruby-based Sinatra is a compact web application development framework. It is frequently used to create small to medium-sized web apps, APIs, and microservices since it is designed to be straightforward, quick, and versatile. Sinatra enables developers to rapidly and simply construct web apps without the need for complex configuration or setup, thanks to its straightforward DSL (Domain Specific Language) and minimalistic approach.</p><p>This article talks about Sinatra in detail, along with a tutorial on how to build a simple app with Sinatra.</p><h4>What exactly is Sinatra, and when should it be used?</h4><p>“<a href="https://sinatrarb.com/">Sinatra</a> is a DSL for quickly creating web applications in Ruby with minimal effort.”</p><p>It is a distinctive open-source web application development framework released in 2007. By being lightweight, flexible, and having fewer dependencies, Sinatra makes it easier and faster to work on Ruby projects.</p><p>It can be used to quickly create anything from your own dynamic website to an API that allows data to be exposed to services.</p><h4><strong><em>Why should we use Sinatra?</em></strong></h4><p>Sinatra’s stability is a huge advantage.</p><p>You give up the functionality of a few Rails generators in exchange for making your own design decisions. Frameworks change infrequently, so writing in Sinatra can provide API stability for developers and enterprises.</p><p>As Sinatra is a lightweight framework, it is designed for building small web applications quickly and easily. It is often used for simple projects that do not require a lot of complexity, such as microservices or API endpoints. Sinatra is known for its simplicity, flexibility, and ease of use, and it’s a great choice if you want projects to get up and running quickly.</p><h4><strong><em>Pros</em></strong>:</h4><ol><li><strong>Lightweight</strong>: Sinatra is a very lightweight framework, which makes it a good choice for small web applications or microservices.</li><li><strong>Flexible</strong>: Unlike Rails, Sinatra doesn’t have many built-in conventions or structures, which makes it very flexible and customizable. This can be an advantage if you need to build something that doesn’t fit into the Rails mold.</li><li><strong>Easy to learn</strong>: Sinatra has a small, simple API, which makes it easy to learn and get started with. If you are unfamiliar with Ruby or web programming, this may be to your advantage.</li><li><strong>Fast</strong>: Because it’s lightweight and doesn’t have a lot of overhead, Sinatra can be very fast and efficient. This can be an advantage if you’re building a web application that needs to be responsive and performant.</li></ol><h4><strong><em>Cons</em></strong>:</h4><ol><li><strong>Limited functionality</strong>: Sinatra doesn’t have as much built-in functionality as Rails, which means you’ll need to build a lot of things from scratch. This can be a disadvantage if you’re building a large, complex application.</li><li><strong>Lack of conventions</strong>: While the flexibility of Sinatra can be an advantage, it can also be a disadvantage if you’re working on a team or need to follow a set of conventions. Without the Rails structure and conventions, it can be harder to maintain consistency and readability in your code.</li><li><strong>Limited community support</strong>: Rails has a large and active community, which means there are a lot of resources and tools available to help you. The Sinatra community is smaller and less active, so you might have to work harder to find the help and support you need.</li><li><strong>Not as scalable</strong>: While Sinatra can be very fast and efficient for small applications, it may not be as scalable as Rails for larger applications. Sinatra might not be the best choice if you need to build something that will need to handle a lot of traffic or data.</li></ol><p><strong>Here are some examples of applications that have been built using Sinatra:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZrrN0J3-Zu6eU5YMmL0pRg.png" /></figure><p><strong>GitHub</strong> <strong>Gis</strong>: GitHub’s code-sharing platform uses Sinatra to handle authentication and authorization.</p><p><strong>Basecamp</strong>: The popular project management tool uses Sinatra to handle its API endpoints.</p><p><strong>Heroku</strong>: The cloud-based Platform as a Service (PaaS) uses Sinatra to power its web interface.</p><p><strong>Fiverr</strong>: The freelance marketplace uses Sinatra to handle its payment processing system.</p><p><strong>Codeship</strong>: Sinatra is used by the continuous integration and deployment tool to handle webhooks and API endpoints.</p><p><strong>Thoughtbot: </strong>The software consultancy uses Sinatra for its internal tools and client projects.</p><p><strong>Feedbin: </strong>The RSS reader uses Sinatra to handle its web interface and API.</p><p><strong>The</strong> <strong>Changelog</strong>: The popular podcast and blog about open-source &amp; software development uses Sinatra to power its web interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*NIAh2_nKxPwK3gq2Jgrcfw.png" /></figure><h4><strong><em>Let’s build one simple application using Sinatra:</em></strong></h4><p><strong>Step 1: </strong>Install Sinatra by running &quot;gem install sinatra&quot; in your terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*_OYeBizB46fwiv2tCCqo0g.png" /></figure><p><strong>Step 2: </strong>Create a new file called &quot;app.rb&quot; and require Sinatra at the top.</p><pre>require &#39;sinatra&#39;</pre><p><strong>Step 3: </strong>Define a route.</p><p>In your app.rb file, you can define your application routes using the get, post, put, patch, and delete methods provided by Sinatra.</p><pre>require &#39;sinatra&#39;<br><br># List all tasks<br>get &#39;/tasks&#39; do<br>  # code to list all tasks<br>end<br><br># Create a new task<br>post &#39;/tasks&#39; do<br>  # code to create a new task<br>end<br><br># Show a specific task<br>get &#39;/tasks/:id&#39; do<br>  # code to show a specific task<br>end<br><br># Update a specific task<br>put &#39;/tasks/:id&#39; do<br>  # code to update a specific task<br>end<br><br># Delete a specific task<br>delete &#39;/tasks/:id&#39; do<br>  # code to delete a specific task<br>end</pre><p><strong>Step 4: </strong>Define your views.</p><p>In Sinatra, views are defined using templates. You can use a variety of templating engines, such as ERB or Haml, but for this example, we’ll use ERB.</p><p>Create a views directory in your project, and then create an index.erb file inside that directory:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Todo App&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;Todo List&lt;/h1&gt;<br>    &lt;ul&gt;<br>      &lt;% @tasks.each do |task| %&gt;<br>        &lt;li&gt;&lt;%= task %&gt;&lt;/li&gt;<br>      &lt;% end %&gt;<br>    &lt;/ul&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>Step 5: </strong>Implement your application logic.</p><p>Now that you have your routes and views set up, you can implement your application logic. For this example, we’ll use an array to store our tasks:</p><pre># Initialize an empty array to store our tasks<br>tasks = []<br><br># List all tasks<br>get &#39;/tasks&#39; do<br>  @tasks = tasks<br>  erb :index<br>end<br><br># Create a new task<br>post &#39;/tasks&#39; do<br>  task = params[:task]<br>  tasks &lt;&lt; task<br>  redirect &#39;/tasks&#39;<br>end<br><br># Show a specific task<br>get &#39;/tasks/:id&#39; do<br>  id = params[:id].to_i<br>  @task = tasks[id]<br>  erb :show<br>end<br><br># Update a specific task<br>put &#39;/tasks/:id&#39; do<br>  id = params[:id].to_i<br>  task = params[:task]<br>  tasks[id] = task<br>  redirect &#39;/tasks&#39;<br>end<br><br># Delete a specific task<br>delete &#39;/tasks/:id&#39; do<br>  id = params[:id].to_i<br>  tasks.delete_at(id)<br>  redirect &#39;/tasks&#39;<br>end</pre><p><strong>Step 6: </strong>Create your views</p><p>Next, we’ll create our show.erb file:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Todo App&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;&lt;%= @task %&gt;&lt;/h1&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>Step 7:</strong> Run your application</p><p>To run your application, navigate to your project directory in your terminal and run the following command:</p><pre>ruby app.rb</pre><p>Then, open your web browser and navigate to <a href="http://localhost:4567/tasks">http://localhost:3000/tasks</a></p><p>You should see an empty task list.</p><h4><strong><em>Conclusion:</em></strong></h4><p>In a nutshell, if you’re building a small, simple web application, Sinatra might be your better choice. It’s lightweight, easy to use, and doesn’t have a lot of overhead.</p><p>On the other hand, if you’re building a larger, more complex application, Rails might be the better choice. It has more built-in functionality, conventions, and tools that can make it easier to build and maintain a large application over time.</p><p>What are your thoughts on Sinatra? Let us know in the comments below!</p><blockquote><strong>Get the edge you need to succeed — follow </strong><a href="https://medium.com/simform-engineering"><strong><em>Simform Engineering</em></strong></a><strong> for crucial updates and insights on tools and technologies!</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8463a2db0a0b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/simform-engineering/explore-sinatra-and-its-potential-for-building-web-apps-8463a2db0a0b">Explore Sinatra and its Potential for Building Web Apps</a> was originally published in <a href="https://medium.com/simform-engineering">Simform Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>