Latest / CyberCode Academy / Course 37 - Building Web Apps with Ruby On Rails | Episode 1: From Ruby Basics to Web Development Conventions
Transcript
- 0:00Speaker 1: So imagine you're sitting at your computer and you click
- 0:02Speaker 1: a link on a website. In literally the blink of
- 0:05Speaker 1: an eye, a web server talks to a database somewhere,
- 0:10Speaker 1: dynamically generates an HTML page, and sends the whole thing
- 0:14Speaker 1: back to your browser.
- 0:15Speaker 2: Yeap, It happens millions of times.
- 0:16Speaker 1: A second, exactly. It feels instant to you, right, but
- 0:19Speaker 1: behind the scenes it's this massive, highly coordinated orchestration effort.
- 0:24Speaker 2: Oh, it's wild when you actually break down what's happening.
- 0:26Speaker 1: It is And you know, before two thousand and four,
- 0:29Speaker 1: building those dynamic web apps was well, it was a grueling,
- 0:33Speaker 1: super repetitive slog but then this one framework came along
- 0:37Speaker 1: and completely broke all the established rules of how the
- 0:40Speaker 1: Internet was built.
- 0:41Speaker 2: Yeah, and completely change the industry in the process.
- 0:44Speaker 1: Right, And today companies worth billions, like we're talking GitHub, Shopify, Airbnb,
- 0:50Speaker 1: they're completely dependent on the architecture that this one tool introduced.
- 0:54Speaker 1: So our mission for today's deep dive is to tear
- 0:57Speaker 1: up in the engine of that exact tool, which is
- 0:59Speaker 1: rub Beyond.
- 1:00Speaker 2: It's such a fun one to dig into.
- 1:02Speaker 1: It really is. We're going to walk through how modern
- 1:05Speaker 1: web architecture works step by step. But and this is
- 1:08Speaker 1: key without getting bogged down and you know boring one
- 1:12Speaker 1: oh one lecture jargon.
- 1:14Speaker 2: Yeah, no dry textbooks today, And it's a fascinating piece
- 1:17Speaker 2: of tech to unpack, largely because its design philosophy was
- 1:21Speaker 2: just so countercultural at the time.
- 1:23Speaker 1: Okay, so set the stage for us, where do we start.
- 1:27Speaker 2: Well, before we get into the actual plumbing of rails itself,
- 1:30Speaker 2: we kind of need to establish the basic topology of
- 1:32Speaker 2: web frameworks because traditionally, you know, the tool developers use
- 1:36Speaker 2: are split into two completely distinct environments.
- 1:39Speaker 1: Like the front end and the back end.
- 1:41Speaker 2: Right, You've got the back end, which is essentially the
- 1:43Speaker 2: data factory. It's managing the business logic, doing authentication, querying
- 1:47Speaker 2: the database, and it ultimately spits out raw data, usually
- 1:50Speaker 2: as like duss on.
- 1:51Speaker 1: Okay, so just raw information.
- 1:53Speaker 2: Exactly, and then sitting all the way across the network,
- 1:56Speaker 2: you have your front end framework. That's the presentation layer
- 1:58Speaker 2: running in your browser. It takes that raw jason and
- 2:01Speaker 2: turns it into the actual structure of the web page.
- 2:04Speaker 2: You see.
- 2:04Speaker 1: So the industry standard usually means you have to manage
- 2:07Speaker 1: two completely separate code bases, right, like two deployment pipelines,
- 2:10Speaker 1: two different sets of tools just to build one cohesive app.
- 2:13Speaker 2: Yeah, that is the modern standard. Yeah, but Rails. RAILS
- 2:18Speaker 2: just defies that split entirely. It's what we call a
- 2:21Speaker 2: full stack framework. Eating it does both exactly. It's a
- 2:23Speaker 2: multi tool. It handles the back end data processing, but
- 2:26Speaker 2: it also handles the front end HTML generation simultaneously. It
- 2:31Speaker 2: dynamically constructs the HTML right there on the server and
- 2:35Speaker 2: just ships a fully big page straight to your browser, which.
- 2:37Speaker 1: Has to cut down on the complexity of managing a
- 2:40Speaker 1: project and significantly.
- 2:41Speaker 2: Oh massively.
- 2:42Speaker 1: Well wait, I thought, doesn't it restrict you though? Like
- 2:45Speaker 1: what if you aren't building a web page? Rails doesn't
- 2:48Speaker 1: like mandate the full stack, does it.
- 2:50Speaker 2: Not at all. It's highly adaptable. I mean, if you're
- 2:52Speaker 2: building a native mobile app for iOS, obviously you don't
- 2:55Speaker 2: need server render at HTML. So in that case, you
- 2:58Speaker 2: just strip Rails down to function purely as an API.
- 3:01Speaker 2: It'll just serve raw Jason data if that's what you
- 3:04Speaker 2: tell it to do. You get the flexibility to use
- 3:06Speaker 2: the full stack, just the back end, or even hybrid
- 3:09Speaker 2: of both.
- 3:10Speaker 1: That's super adaptable. But okay, before we start looking at
- 3:13Speaker 1: how Rails physically constructs these pages. We have to clear
- 3:16Speaker 1: up a really massive point of confusion, the naming thing. Yes,
- 3:21Speaker 1: you hear the phrase ruby on Rails thrown around as
- 3:24Speaker 1: like a single noun, but they are absolutely not the
- 3:27Speaker 1: same thing. Rails is not Ruby, No.
- 3:29Speaker 2: And that distinction is paramount. Ruby is the underlying programming language.
- 3:33Speaker 2: Rails is just a framework that is written in that language.
- 3:36Speaker 2: I mean, Ruby itself is a standalone, general purpose, object
- 3:40Speaker 2: oriented language. It was created in the mid nineties, long
- 3:43Speaker 2: before Rails ever existed.
- 3:45Speaker 1: So what makes Ruby distinct from something like I don't know,
- 3:48Speaker 1: Java or C plus plus ten, Like, why did they
- 3:50Speaker 1: build this massive web framework on top of it?
- 3:53Speaker 2: Well, Ruby was designed with a really heavy emphasis on
- 3:56Speaker 2: developer ergonomics. It's supposed to be expressive, dynamically typed language,
- 4:01Speaker 2: meaning it does not enforce strong typing at compile time.
- 4:05Speaker 1: Wait unpacked that for a second. Contrast that with Java.
- 4:07Speaker 2: Okay, So in Java, if you declare a variable to
- 4:10Speaker 2: hold text, you have to explicitly define it as a string.
- 4:13Speaker 2: If you try to assign a number and integer to
- 4:16Speaker 2: that exact same variable later on, the compiler just throws
- 4:19Speaker 2: a fatal error.
- 4:20Speaker 1: It physically stops the code from running.
- 4:22Speaker 2: Exactly, It locks the data types in place. It's extremely rigid.
- 4:26Speaker 2: But Ruby takes a totally different approach. In Ruby, almost
- 4:29Speaker 2: everything is an object, and those objects just communicate by
- 4:32Speaker 2: sending messages to one another. It relies on a concept
- 4:35Speaker 2: called duck typing.
- 4:36Speaker 1: Duck typing as an if it walks like a duck
- 4:40Speaker 1: and quacts like a duck.
- 4:41Speaker 2: Then you treat it like a duck exactly. Ruby doesn't
- 4:43Speaker 2: really care about the strict class definition of an object.
- 4:46Speaker 2: If you pass an object into a function, Ruby simply asks, hey,
- 4:50Speaker 2: does this object respond to the method I'm trying to
- 4:52Speaker 2: call right now?
- 4:53Speaker 1: Oh? Interesting?
- 4:54Speaker 2: Yeah. If the answers yes, the code executes.
- 4:56Speaker 1: Yeah.
- 4:56Speaker 2: So imagine you create a variable name plant and assign
- 4:59Speaker 2: it to an actual plan object. Three lines later, you
- 5:03Speaker 2: could accidentally reassign that exact same plant variable to the
- 5:07Speaker 2: number forty two.
- 5:08Speaker 1: And Ruby just doesn't care.
- 5:09Speaker 2: Ruby won't panic it.
- 5:10Speaker 1: Okay, I mean I see the appeal of that for
- 5:12Speaker 1: rapid prototyping. It sounds incredibly liberating to write code without
- 5:16Speaker 1: the compiler constantly yelling at you about type errors.
- 5:18Speaker 2: It is very freeing.
- 5:20Speaker 1: But I have to push back here. If we're talking
- 5:22Speaker 1: about building enterprise scale applications like systems with hundreds of
- 5:27Speaker 1: thousands of lines of code and massive engineering teams, wouldn't
- 5:30Speaker 1: that dynamic freedom just turn into absolute chaos one hundred percent,
- 5:34Speaker 1: Like variables can just morph into numbers. Debugging sounds like
- 5:38Speaker 1: an absolute nightmare.
- 5:40Speaker 2: Your skepticism is entirely justified. If you try to build
- 5:44Speaker 2: a massive web app using raw, untamed Ruby, it will
- 5:48Speaker 2: very rapidly devolve into architectural chaos. The flexibility becomes a
- 5:52Speaker 2: huge liability, and that exact friction. That's why Rails was invented.
- 5:56Speaker 1: Ah, So Ruby is the wild dynamic engine, and Rails
- 6:00Speaker 1: provides the tracks.
- 6:01Speaker 2: Yes, that is the perfect way to visualize it. Rails
- 6:05Speaker 2: acts as a literal set of train tracks. When you
- 6:08Speaker 2: put a train on tracks, you heavily constrain its movement. Right,
- 6:11Speaker 2: it cannot veer off into the wilderness.
- 6:13Speaker 1: It's locked to a linear pass.
- 6:14Speaker 2: Exactly, It's predetermined. But by accepting those severe constraints, you
- 6:19Speaker 2: can travel significantly farther and significantly faster than you ever
- 6:23Speaker 2: could just driving off road.
- 6:25Speaker 1: You sacrifice arbitrary freedom for structural velocity. Well said, you
- 6:29Speaker 1: get the expressive power of Ruby, but Rails prevents you
- 6:32Speaker 1: from driving the project off a cliff precisely. Okay, So
- 6:36Speaker 1: how does Rails actually lay down those tracks? Because a
- 6:39Speaker 1: framework that restricts the developer's choices usually feels really heady
- 6:42Speaker 1: or bureaucratic. How does it impose order without ruining that
- 6:46Speaker 1: ergonomic joy of writing and Ruby.
- 6:48Speaker 2: It accomplishes this through its core operating philosophy. It's a
- 6:51Speaker 2: concept known as convention over configuration. Convention over configuration Okay, Basically,
- 6:56Speaker 2: the framework makes reasonable inferences for you based on industry standard,
- 7:00Speaker 2: so you can just skip all the bureaucratic setup.
- 7:02Speaker 1: Give me a concrete example of that, like, if I'm
- 7:04Speaker 1: building an app, where does the framework step in and
- 7:07Speaker 1: actually make a decision for me?
- 7:09Speaker 2: The most famous example is how Rails handles the database.
- 7:13Speaker 2: So let's say you're building a system and you create
- 7:15Speaker 2: a data model named person to handle user profiles.
- 7:18Speaker 1: Okay, pretty standard.
- 7:20Speaker 2: In a highly configurable framework, you'd have to write an
- 7:24Speaker 2: explicit mapping file telling the system, hey, connect the person
- 7:28Speaker 2: model to a database table, and I want you to
- 7:30Speaker 2: name that table person stable.
- 7:33Speaker 1: So you have to manually wire the components together every
- 7:36Speaker 1: single time.
- 7:37Speaker 2: Yes, which is exhausting. But Rails has this internal engine
- 7:41Speaker 2: called the inflector. It literally understands English grammar.
- 7:44Speaker 1: Wait.
- 7:45Speaker 2: Really yeah, So when you create a model named person,
- 7:48Speaker 2: Rails automatically knows the grammatically correct chloral is people no way,
- 7:52Speaker 2: without you writing a single line of configuration. It automatically
- 7:55Speaker 2: looks for a database table named people.
- 7:57Speaker 1: Wait, but what if my legacy database already has a
- 8:00Speaker 1: table named persons? Am I just locked out because the
- 8:02Speaker 1: tracks are too rigid?
- 8:03Speaker 2: Not at all. Conventions are not handcuffs. You can easily
- 8:07Speaker 2: override the default and just tell Rails no, look for
- 8:09Speaker 2: a person's table.
- 8:10Speaker 1: Okay, gotcha.
- 8:11Speaker 2: The point is that like ninety nine percent of the time,
- 8:14Speaker 2: you don't need to override it. Rails makes those micro
- 8:16Speaker 2: decisions for you, which just preserves your cognitive load for
- 8:20Speaker 2: the actual business logic.
- 8:22Speaker 1: That optimization for the developer is so fascinating, and it
- 8:26Speaker 1: extends deeply into the syntax itself, doesn't it absolutely because
- 8:29Speaker 1: looking at Rails code alongside standard programming logic is striking.
- 8:33Speaker 1: Like if I want to calculate a date exactly two
- 8:36Speaker 1: days in the past, and a traditional language, I usually
- 8:39Speaker 1: have to instantiate a current timestamp, then calculate the number
- 8:43Speaker 1: seconds and forty eight hours and perform this messy date
- 8:46Speaker 1: math subtraction, which sure.
- 8:48Speaker 2: Is mathematically accurate, but when another developer reviews that code
- 8:51Speaker 2: six months later, they are forced to parse raw math
- 8:55Speaker 2: instead of just reading the intent of.
- 8:56Speaker 1: The logic exactly. But in Rails you literally write to
- 9:01Speaker 1: dot day's dot ago.
- 9:02Speaker 2: I love that example.
- 9:03Speaker 1: It's so clean. The framework actually modifies the core Ruby
- 9:07Speaker 1: integer class, adding methods like days and ago, so the
- 9:10Speaker 1: number two suddenly understands how to calculate time, and.
- 9:13Speaker 2: That focus on human readability is everywhere. Data sanitation is
- 9:18Speaker 2: another great one. Imagine a user submits a form but
- 9:21Speaker 2: they've copy pasted their input.
- 9:23Speaker 1: Oh, so it leaves a mess of trailing spaces, weird
- 9:26Speaker 1: line breaks, tabs exactly.
- 9:28Speaker 2: In most environments, cleaning that input requires writing a regular expression.
- 9:33Speaker 1: Redex the absolute bane of every developer's existence. I swear
- 9:37Speaker 1: it looks like someone fill asleep on their keyboard.
- 9:40Speaker 2: It is notoriously difficult to read, but Rails provides a
- 9:43Speaker 2: built in method called squish squish.
- 9:45Speaker 1: That's adorable, right.
- 9:46Speaker 2: You just call squish on the string and Rails automatically
- 9:49Speaker 2: strips the leading and trailing white space, and it collapses
- 9:52Speaker 2: any consecutive spaces or line breaks inside the text into
- 9:56Speaker 2: just a single space.
- 9:57Speaker 1: Or generating safe URLs. Instead of writing custom some logic
- 10:00Speaker 1: to strip out special characters and replace spaces with hyphens,
- 10:04Speaker 1: you just call parameterize on a string and it instantly
- 10:06Speaker 1: spits out a URLs safe format.
- 10:08Speaker 2: It abstracts away all the tedious implementation details. That way,
- 10:13Speaker 2: the human reading the code can immediately grasp what it's
- 10:17Speaker 2: trying to do.
- 10:17Speaker 1: Okay, I buy the micro level argument naming tables automatically
- 10:21Speaker 1: squish two days dotgo. Those are fantastic quality of life improvements.
- 10:26Speaker 1: But automatic table naming doesn't prevent a developer from creating
- 10:29Speaker 1: a completely disorganized nightmare of a file structure. So how
- 10:34Speaker 1: does Rails impose order on the macro level architecture of
- 10:37Speaker 1: say a massive application?
- 10:39Speaker 2: And that brings us to the structural core of Rails
- 10:42Speaker 2: the MVC architecture Model View Controller MVC. Yes, this is
- 10:48Speaker 2: the pattern that dictates where every single piece of logic belongs.
- 10:52Speaker 2: When you initialize a new Rails project, it instantly generates
- 10:55Speaker 2: a highly opinionated folder structure on.
- 10:57Speaker 1: Your machine, so you don't even have to think about it.
- 10:59Speaker 2: Right, You don't have debate where to put your database
- 11:01Speaker 2: queries or your htmail templates. The folders are already there,
- 11:03Speaker 2: just waiting for you.
- 11:04Speaker 1: Okay, let's trace exactly how those three components interact. Walk
- 11:07Speaker 1: me through a real world scenario. Let's say I navigate
- 11:11Speaker 1: to a GitHub profile, GitHub being you know, one of
- 11:14Speaker 1: the most famous rails applications in existence. My browser sends
- 11:18Speaker 1: a request to look at a user. What physically happens
- 11:22Speaker 1: inside the NVC architecture the moment that request hits the server.
- 11:26Speaker 2: Okay, So the first component to intercept that request isn't
- 11:29Speaker 2: actually the MVC try it itself. It's the rails router.
- 11:33Speaker 1: The router.
- 11:34Speaker 2: Yeah, the router acts as the switchboard. It parses the
- 11:37Speaker 2: incoming URL and maps it to a specific control.
- 11:39Speaker 1: So the controller is the entry point for the actual logic.
- 11:42Speaker 2: Yes, think of the controller as the traffic cop It
- 11:45Speaker 2: receives the request from the router and says, okay, the
- 11:48Speaker 2: user wants to see the profile for account number forty two, right,
- 11:51Speaker 2: But the controller doesn't talk to the database directly. It
- 11:54Speaker 2: delegates that task to the model.
- 11:56Speaker 1: Because the model is the layer that actually understands SQL
- 11:59Speaker 1: and the unlying database structure exactly.
- 12:01Speaker 2: The controller asks the user model to find account forty two.
- 12:04Speaker 2: Then the model translates that request into a SQL query,
- 12:07Speaker 2: executes it against the database, retrieves the profile data, wraps
- 12:11Speaker 2: it up in a nice ruty object, and hands it
- 12:13Speaker 2: back up to the controller.
- 12:14Speaker 1: Okay, so now the controller has the data, but it's
- 12:17Speaker 1: just raw object data. It's not a web page.
- 12:19Speaker 2: Jet right, So the controller's final job is to hand
- 12:22Speaker 2: that raw Ruby object down to the view.
- 12:24Speaker 1: Ah, the view.
- 12:25Speaker 2: Yeah, the view is the presentation template, usually an HTML
- 12:29Speaker 2: file embedded with Ruby tags.
- 12:30Speaker 1: So it takes the object and builds the page exactly.
- 12:33Speaker 2: It extracts the username, the profile, picture, url, the repository account,
- 12:39Speaker 2: and it injects that data into the actual HTML structure.
- 12:42Speaker 1: Got it.
- 12:43Speaker 2: Once the view finishes rendering the complete HTML document, it
- 12:46Speaker 2: hands it back to the controller, which fires it over
- 12:49Speaker 2: the network to your browser.
- 12:50Speaker 1: That entire orchestrated round trip from reader to controller, down
- 12:54Speaker 1: to the model, back to the controller, down to the view,
- 12:56Speaker 1: and out to the client all happens in a fraction
- 12:59Speaker 1: of a second.
- 13:00Speaker 2: It does, and because every single Rails application adheres strictly
- 13:04Speaker 2: to that exact flow, a developer can jump into a
- 13:07Speaker 2: codebase they'd never seen before and immediately know exactly where
- 13:10Speaker 2: to find the database logic and where to find the
- 13:13Speaker 2: HTMIL templates.
- 13:14Speaker 1: It's standard across the board. Okay, so that covers the
- 13:17Speaker 1: internal organization of the files. But how does RAILS handle
- 13:21Speaker 1: the external organization? Like, how does it structure the actual
- 13:24Speaker 1: URLs the user interacts with?
- 13:26Speaker 2: Oh that's a great question.
- 13:27Speaker 1: Because if the router is the switchboard, what rules dictate
- 13:31Speaker 1: how the switchboard operates?
- 13:33Speaker 2: RAILS strongly relies on a standard called REST that stands
- 13:37Speaker 2: for Representational State Transfer.
- 13:39Speaker 1: Okay, REST.
- 13:40Speaker 2: It basically enforces a predictable pattern for mapping URLs to
- 13:44Speaker 2: application resources.
- 13:45Speaker 1: Break that down for me, If I'm interacting with a
- 13:47Speaker 1: database table of people, how does REST dictate those URLs?
- 13:52Speaker 2: So it creates a standardized grammar for the web. If
- 13:55Speaker 2: you navigate to the path people, the router understands you
- 13:58Speaker 2: are asking for the index the entire collection people. Okay,
- 14:01Speaker 2: but if you want to see a specific individual, you
- 14:04Speaker 2: pin their unique ID, so people one represents the very
- 14:07Speaker 2: first record in that collection.
- 14:08Speaker 1: Well wait, if the URL is just people, how does
- 14:12Speaker 1: the application know my intent?
- 14:13Speaker 2: What do you mean?
- 14:14Speaker 1: Well, a URL is just a location, right, How does
- 14:17Speaker 1: it know the difference between me wanting to view a
- 14:19Speaker 1: list of people versus me submitting a form to create
- 14:22Speaker 1: a new person. Both actions involve the people resource.
- 14:26Speaker 2: Ah, this is where HTTP.
- 14:29Speaker 1: Verbs come in HTTP verbs, right, The.
- 14:31Speaker 2: URL itself is not the entire message. Whenever your browser
- 14:35Speaker 2: makes a request, it silently attaches an HTTP.
- 14:37Speaker 1: Verb like a hidden instruction tag.
- 14:39Speaker 2: Exactly, if you simply tap the URL into your address
- 14:42Speaker 2: bar and hit enter, your browser defaults to sending a
- 14:45Speaker 2: good d request. Okay, the router sees giddy people and
- 14:48Speaker 2: knows your intent is to retrieve and read data.
- 14:51Speaker 1: But if I fill out a form to register a
- 14:53Speaker 1: new user.
- 14:53Speaker 2: Your browser doesn't send a good request. It sends a
- 14:56Speaker 2: post request. The URL is exactly the same, it's still people,
- 14:59Speaker 2: but the sees the post verb and rots the request
- 15:02Speaker 2: to an entirely different controller action, one that is designed
- 15:06Speaker 2: specifically to insert new records into the database.
- 15:08Speaker 1: That is a remarkably elegant system. You don't need clunky
- 15:11Speaker 1: URLs like creating person. The combination of the resource path
- 15:15Speaker 1: and the HTTP verb inherently describes the action.
- 15:18Speaker 2: It creates a uniform interface, and RAILS even provides workarounds
- 15:23Speaker 2: for verbs like patchuhal to update data and delete to
- 15:27Speaker 2: destroy it. So you have a complete set of tools
- 15:30Speaker 2: to manipulate resources.
- 15:31Speaker 1: Okay, So synthesizing all of this, RAILS gives us automatic
- 15:34Speaker 1: database mapping, built in data sanitation, a strict MVC file structure,
- 15:39Speaker 1: and standardized rest routing.
- 15:42Speaker 2: Pretty much.
- 15:42Speaker 1: It essentially controls every single layer of the stack, which
- 15:46Speaker 1: naturally leads us to the most contentious architectural debate surrounding
- 15:50Speaker 1: RAILS today.
- 15:51Speaker 2: Oh boy, I know where this is going.
- 15:53Speaker 1: If a framework does absolutely everything, doesn't it become a monolithic,
- 15:57Speaker 1: single point of failure.
- 15:58Speaker 2: You've hit on the core ideal logical divide in modern
- 16:01Speaker 2: back end engineering. RAILS is by definition a monolith. A monolith, right.
- 16:05Speaker 2: It is an integrated system where the routing database, logic,
- 16:08Speaker 2: background jobs, and HTML views all live inside a single codebase,
- 16:12Speaker 2: deployed as a single unit.
- 16:14Speaker 1: And the prevailing industry trend right now is running in
- 16:16Speaker 1: the exact opposite direction. Everyone is obsessed with micro services,
- 16:20Speaker 1: Yes they are.
- 16:21Speaker 2: The micro service architecture breaks an application down into dozens,
- 16:25Speaker 2: sometimes hundreds, of tiny independent.
- 16:28Speaker 1: Programs, so they're all split up.
- 16:29Speaker 2: Yeah, one service handles user authentication, a completely different service
- 16:34Speaker 2: handles billing, another handles email processing. They all operate independently
- 16:40Speaker 2: and just communicate with each other over the network.
- 16:42Speaker 1: And the argument for microservices is usually about scale and modularity.
- 16:45Speaker 2: Right exactly.
- 16:46Speaker 1: But building a web app that way, I mean it
- 16:48Speaker 1: sounds like trying to cook a massive banquet. But your
- 16:51Speaker 1: oven is in one building, your refrigerators down the street,
- 16:54Speaker 1: and your prep station is in another zip code.
- 16:57Speaker 2: That is a perfect analogy.
- 16:58Speaker 1: You'd spend more time coordinating the logistics of getting the
- 17:01Speaker 1: ingredients back and forth than you would actually cooking.
- 17:03Speaker 2: The network latency and coordination overhead in a micro services
- 17:07Speaker 2: architecture are massive. You have to handle failures if say
- 17:11Speaker 2: the building service goes down while the authentication service is
- 17:14Speaker 2: still up. It requires an incredibly complex DevOps operation.
- 17:18Speaker 1: Whereas a monolithic rails app is like a perfectly organized,
- 17:22Speaker 1: fully stocked commercial kitchen. Every single tool, every ingredient, the ovens,
- 17:27Speaker 1: the sinx, it's all within arms reach in a single room. Yes,
- 17:31Speaker 1: it's highly opinionated about where the knives are stored, sure,
- 17:34Speaker 1: but because everything is integrated, a single developer can cook
- 17:37Speaker 1: an absolute feast with incredible speed, and that speed is
- 17:41Speaker 1: the ultimate value proposition of the monolith.
- 17:44Speaker 2: It optimizes for developer happiness and raw productivity.
- 17:47Speaker 1: But can a monolith truly scale? Because that's always the
- 17:50Speaker 1: counter argument, right, if the application becomes wildly successful, won't
- 17:54Speaker 1: a single massive code base just collapse under its own weight.
- 17:57Speaker 2: The fear of monolithic scaling is largely a myth. I mean, yes,
- 18:00Speaker 2: at a certain massive scale you might need to extract
- 18:03Speaker 2: specific high load services. But the proof is in the
- 18:06Speaker 2: reality of the Internet.
- 18:08Speaker 1: Right.
- 18:08Speaker 2: Look at Shopify. They handle catastrophic levels of traffic during
- 18:11Speaker 2: Black Friday sales. GitHub manages the codebases for millions of developers.
- 18:16Speaker 2: Both of those platforms scaled to billion dollar valuations. Operating
- 18:21Speaker 2: primarily is monolithic rails applications.
- 18:23Speaker 1: Wow, So how do they do it?
- 18:25Speaker 2: You scale the database, you implement aggressive caching, and you
- 18:29Speaker 2: provision more server hardware. You don't necessarily have to shatter
- 18:32Speaker 2: the codebase into one hundred tiny pieces to achieve massive scale.
- 18:37Speaker 1: So the monolic works. Okay, So lock in what we've
- 18:40Speaker 1: unpack today. I want to pose a quick mental exercise
- 18:43Speaker 1: for you listening.
- 18:43Speaker 2: Oh, quiz, let's do it.
- 18:44Speaker 1: Let's say you are building a new social networking app
- 18:47Speaker 1: for gardeners using rails. You sit down and generate a
- 18:50Speaker 1: new model, and you name it plant.
- 18:52Speaker 2: Okay, plant?
- 18:53Speaker 1: Based on the convention over configuration rules and the rest
- 18:56Speaker 1: routting architecture, we just explored question one, what will rails
- 19:01Speaker 1: automatically name the underlying database table? In question two, if
- 19:06Speaker 1: you are submitting a form to add a brand new
- 19:08Speaker 1: plant to that database, what HTTP verb is the browser
- 19:12Speaker 1: sending to the router.
- 19:13Speaker 2: I'll give everyone a second to trace the logic. Okay.
- 19:16Speaker 2: For question one, the inflector kicks in rails, looks at
- 19:19Speaker 2: plant and automatically looks for a database table.
- 19:22Speaker 1: Named plants pluralized and lowercas. No custom mapping required, exactly.
- 19:26Speaker 2: And for question two, because you are creating a new
- 19:29Speaker 2: record rather than just reading data, the browser wouldn't send
- 19:32Speaker 2: a get tea request. It would send a PST request
- 19:35Speaker 2: to the plants URL.
- 19:36Speaker 1: Nailed it. You understand the tracks.
- 19:38Speaker 2: Now, as we wrap up, I want to leave you
- 19:40Speaker 2: with a provocative thought. T'am all over hit me. We
- 19:42Speaker 2: are currently operating in a technology landscape obsessed with fragmentation.
- 19:47Speaker 2: We have hyper complex cloud architectures AI generated microfunctions and
- 19:53Speaker 2: massive schisms between front end and back end environments.
- 19:55Speaker 1: Yeah, the complexity overhead for a solo developer is just staggering.
- 19:59Speaker 2: It is which raises the question, in an era where
- 20:02Speaker 2: web development has become increasingly fragmented and logistically exhausting to deploy,
- 20:08Speaker 2: is the original countercultural rails philosophy.
- 20:10Speaker 1: The idea of monolithic simplicity.
- 20:13Speaker 2: Right the rigid conventions and prioritizing the ergonomic happiness of
- 20:17Speaker 2: the human programmer. Is that approach actually becoming more revolutionary
- 20:21Speaker 2: today than it was twenty years ago.
- 20:22Speaker 1: That is a brilliant question. When the entire industry is
- 20:25Speaker 1: running toward maximum complexity, sometimes the most radical choice you
- 20:29Speaker 1: can make is to stay in one well organized kitchen.
- 20:32Speaker 1: Well said, thank you all for joining us on this
- 20:34Speaker 1: deep dive. Hopefully, the next time you interact with a
- 20:37Speaker 1: complex web platform, you'll have a clear mental model of
- 20:40Speaker 1: the model, view and controller working furiously behind the screen
- 20:44Speaker 1: to deliver that data. Keep questioning the architecture around you,
- 20:48Speaker 1: and we will catch you on the next deep dive.