Latest / CyberSecurity Summary / Developing Web Apps with Haskell and Yesod: Safety-Driven Web Development
Transcript
- 0:00Speaker 1: You know, when you think about structural engineering, like say
- 0:05Speaker 1: building a suspension bridge or I don't know, a massive skyscraper,
- 0:09Speaker 1: there is this expectation of absolute mathematical precision, right.
- 0:15Speaker 2: Yeah. You calculate the exact load bearing weight of the steel.
- 0:18Speaker 1: Exactly, you pour the concrete bedrock to like very specific tolerances,
- 0:24Speaker 1: and you know mathematically what forces that structure can actually withstand.
- 0:28Speaker 2: Yeah, because the alternative is well catastrophic. I mean, it's
- 0:31Speaker 2: an industry completely built on rigorous, non negotiable laws of physics.
- 0:36Speaker 1: But then you look at modern web development. Yeah, and
- 0:39Speaker 1: if we're being completely honest here, for those of you
- 0:41Speaker 1: out there writing code every single day, a lot of
- 0:44Speaker 1: the time, it feels like we are, you know, building
- 0:46Speaker 1: skyscrapers out a wet cardboard and duct tape.
- 0:49Speaker 2: Oh for sure, just kind of crossing her finger, yeah.
- 0:51Speaker 1: Just hoping a strong wind doesn't knock the whole thing down. Yeah.
- 0:54Speaker 1: I mean, we patch vulnerabilities only after they get exploited, right,
- 0:57Speaker 1: We write endless tests just hoping to catch our own typos,
- 1:01Speaker 1: and we just sort of accept a certain level of
- 1:03Speaker 1: chaos as like the cost of doing business on the internet.
- 1:07Speaker 2: It's true, I mean we've really grown accustomed to run
- 1:10Speaker 2: time errors and broken states as this natural, unavoidable part
- 1:15Speaker 2: of the digital ecosystem, which is kind of wild when
- 1:17Speaker 2: you think about it.
- 1:18Speaker 1: It really is. Well, today we're exploring a completely different paradigm.
- 1:22Speaker 1: We're doing a deep dive into Michael Snoyman's book developing
- 1:25Speaker 1: Web Apps with Haskell and YES'D from a Riiley Media,
- 1:29Speaker 1: a classic, oh totally and frankly with its stark white
- 1:32Speaker 1: cover featuring this massive, intricately detailed whinoceros beetle and all.
- 1:36Speaker 2: The barcodes and QR codes on the back.
- 1:38Speaker 1: Yes, the physical book itself just screams like serious, rigorous
- 1:43Speaker 1: technical manual. But our mission today isn't to get bogged
- 1:47Speaker 1: down in academic syntax, so don't worry about that.
- 1:49Speaker 2: Oh definitely not.
- 1:50Speaker 1: We are here to decode what Snyman calls safety driven
- 1:53Speaker 1: web development. We're looking at how pairing the famously strict
- 1:56Speaker 1: language of Askell with this web framework called YESOD creates
- 2:00Speaker 1: to building incredibly fast, modular, and like virtually bug proof
- 2:05Speaker 1: web application.
- 2:06Speaker 2: And that's the real appeal, you know, for anyone who
- 2:09Speaker 2: is just exhausted from chasing bugs. We want to understand
- 2:12Speaker 2: the mechanisms, like the actual why and the how behind
- 2:16Speaker 2: this architecture, because we live in an Internet that is
- 2:19Speaker 2: absolutely flooded with security vulnerabilities and fragile systems, and we
- 2:24Speaker 2: are looking at a framework here that's designed to structurally
- 2:27Speaker 2: prevent those things from even compiling in the first place.
- 2:30Speaker 1: So to understand how it actually achieves that, we have
- 2:32Speaker 1: to start at the perimeter of the application. Snoyman talks
- 2:36Speaker 1: about this fundamental hurdle that he calls the boundary issue.
- 2:40Speaker 2: Yeah, the boundary issue.
- 2:42Speaker 1: This is crucial because inside a Haskell application, everything is pristine.
- 2:47Speaker 1: Haskell has a notoriously strict type system, so like the
- 2:51Speaker 1: string of text is a string, and integers and integer,
- 2:53Speaker 1: and the compiler physically will not allow them to mix.
- 2:56Speaker 2: Right, It's a very controlled environment.
- 2:58Speaker 1: But the Internet itself, it doesn't care about Haskell's rules
- 3:00Speaker 1: at all, not.
- 3:01Speaker 2: Even a little bit. I mean, the Internet is essentially
- 3:03Speaker 2: this wild West of raw, untyped bites. Whenever a user
- 3:08Speaker 2: submits a form, or you fetch data from a third
- 3:10Speaker 2: party API, or even just load a record from a database,
- 3:14Speaker 2: it enters your application as raw text.
- 3:16Speaker 1: Just a string of characters exactly.
- 3:18Speaker 2: So if a user type say twelve into an age field.
- 3:22Speaker 2: The web just sends the character one and the character two.
- 3:25Speaker 2: It's inherently untyped. So, however mathematically pure your application is
- 3:30Speaker 2: on the inside, every single boundary with the outside world
- 3:34Speaker 2: has to be meticulously sanitized. You have to translate the
- 3:37Speaker 2: chaots of the Internet into the strict order of Haskell.
- 3:41Speaker 1: Okay, let's unpack this. If you're building a typical node
- 3:43Speaker 1: or Python backen treating that boundary is like having a
- 3:47Speaker 1: nightclub bouncer who just asks, hey, are you twenty one
- 3:50Speaker 1: and takes a total stranger's word for it.
- 3:52Speaker 2: Yeah, that happens a lot.
- 3:53Speaker 1: It implicitly trusts the data. But yes, I treats the
- 3:56Speaker 1: web boundary like a bouncer who explicitly scans the ID like,
- 4:00Speaker 1: checks the data types, checks the hologram, and cross references
- 4:04Speaker 1: the database.
- 4:04Speaker 2: Right, they aren't messing around.
- 4:06Speaker 1: No, It enforces the data types at the door before
- 4:08Speaker 1: anyone is allowed inside the club.
- 4:10Speaker 2: That is a highly accurate analogy. And you know, this
- 4:13Speaker 2: strict boundary validation is actually where the framework gets its name.
- 4:17Speaker 2: The word yesod means foundation in Hebrew.
- 4:20Speaker 1: Oh wow. Yeah.
- 4:22Speaker 2: By explicitly declaring the exact data types you expect at
- 4:25Speaker 2: the boundary. You eliminate entire classes of bugs before the
- 4:28Speaker 2: code even executes.
- 4:30Speaker 1: Because if the incoming data doesn't perfectly match the expected type,
- 4:34Speaker 1: the foundation rejects it automatically.
- 4:36Speaker 2: Right, Exactly, You don't have to write fifty unit tests
- 4:38Speaker 2: to see what happens when a user submits malicious JavaScript
- 4:42Speaker 2: instead of their age, because the bouncer just handles it
- 4:45Speaker 2: at the door.
- 4:45Speaker 1: And what's interesting is that this foundation isn't just a
- 4:48Speaker 1: conceptual metaphor. I mean, every YASOD application literally revolves around
- 4:52Speaker 1: a specific foundation data type that you define yourself.
- 4:56Speaker 2: Right, you might just call it my app or whatever
- 4:59Speaker 2: you want.
- 4:59Speaker 1: Yeah, but it holds all the crucial initialized data for
- 5:02Speaker 1: your entire application.
- 5:03Speaker 2: It acts as the central nervous system when your application launches.
- 5:06Speaker 2: This foundation data type is instantiated and it holds your
- 5:09Speaker 2: database connection pools, your configuration files, your HTTP connection managers
- 5:14Speaker 2: all of it.
- 5:15Speaker 1: So it's all centralized exactly.
- 5:17Speaker 2: By tying everything your app needs to run to the
- 5:19Speaker 2: central foundation, which implements the YASAD type class, you ensure
- 5:22Speaker 2: that every single request has safe, concurrent access to the
- 5:26Speaker 2: exact same reliable state.
- 5:28Speaker 1: Okay, so we have this uldistrict bounder at the door
- 5:30Speaker 1: and a rock solid foundation inside. But you know, if
- 5:33Speaker 1: you're a developer listen to this, you're probably spotting the
- 5:35Speaker 1: obvious trade off here.
- 5:36Speaker 2: Oh yeah, the verbosity issue, right.
- 5:38Speaker 1: Because if I have to manually declare every single data type,
- 5:42Speaker 1: write a parser for every incoming string, and handle every
- 5:45Speaker 1: boundary explicitly, I mean I'm going to be writing thousands
- 5:48Speaker 1: of lines of tedious, repetitive boilerplate code.
- 5:51Speaker 2: Yes, that is the standard critique of strictly typed languages.
- 5:55Speaker 2: You usually trade brevity for safety. But ysad bypasses this
- 5:59Speaker 2: verbosity by leaning heavily into metaprogramming. Specifically, it uses a
- 6:04Speaker 2: feature of the language called template Haskell, alongside a related
- 6:07Speaker 2: tool called quasi quotes metaprogramming.
- 6:10Speaker 1: So basically, code that writes code precisely.
- 6:13Speaker 2: Template Haskell allows developers to write Haskell code that executes
- 6:17Speaker 2: during the compilation process.
- 6:19Speaker 1: During Yeah, during this code generates a Haskell abstract syntax
- 6:24Speaker 1: tree or AST, which is then fed back into the compiler.
- 6:28Speaker 2: Okay, let's slow down on that per second. An abstract
- 6:30Speaker 2: syntax tree. For those who maybe haven't taken a compiler
- 6:33Speaker 2: design course, what are we actually generating here.
- 6:37Speaker 1: Think of an ast like the grammatical diagram of a sentence,
- 6:41Speaker 1: but for code. When you write a line of code,
- 6:44Speaker 1: the compiler has to break it down into a tree
- 6:46Speaker 1: structure to understand the logic.
- 6:48Speaker 2: Like this is a noun, this is a verb, exactly, but.
- 6:51Speaker 1: In this case, this is a function, this is a variable,
- 6:53Speaker 1: this is an operator. With template Haskell, instead of typing
- 6:57Speaker 1: out repetitive text, you are giving the compiler a tiny
- 7:00Speaker 1: script that programmatically generates that structural tree for you.
- 7:04Speaker 2: Right, so, you might write a single line like a
- 7:05Speaker 2: dollar sign, followed by a function say hamlet hamsot file
- 7:09Speaker 2: myfile dot hamlet for an external file.
- 7:11Speaker 1: Or use quasi quotes right yeah, which let you embed
- 7:14Speaker 1: domain specific languages right inside your Haskell file using square
- 7:18Speaker 1: brackets and pipes like weimleth Hello World, and behind the scenes,
- 7:24Speaker 1: using a function called mech oshassade, the compiler translates that
- 7:27Speaker 1: one line into all the complex parsing and routing boilerplate
- 7:31Speaker 1: you normally have to type by hand.
- 7:32Speaker 2: It perfectly maps the untyped web requests to your strict
- 7:36Speaker 2: foundation data types.
- 7:37Speaker 1: But wait, if I'm letting the framework secretly generate all
- 7:40Speaker 1: my routing and parsing code behind the scenes. Don't I
- 7:44Speaker 1: lose control. I mean, in my experience, magic in programming
- 7:48Speaker 1: is great until it breaks, and then you have a
- 7:49Speaker 1: black box you literally can't debug.
- 7:51Speaker 2: What's fascinating here is that YESOD specifically avoids the black
- 7:54Speaker 2: box problem. Really how it provides a flag you can
- 7:57Speaker 2: pass to the compiler called dud dump splice ooh okay, yeah,
- 8:01Speaker 2: if you enable this, the compiler prints out exactly the
- 8:04Speaker 2: code it generated on your behalf.
- 8:05Speaker 1: No way, so you can see everything everything.
- 8:07Speaker 2: You can peek right under the hood and read the
- 8:09Speaker 2: routing data types. The parser functions the dispatch logic. It
- 8:13Speaker 2: handles the parsing, dispatching, and rendering perfectly in sync, saving
- 8:17Speaker 2: human fingers from inevitable typeos. But it keeps everything entirely
- 8:21Speaker 2: transparent to the developer.
- 8:23Speaker 1: So it's less like magic and more like having a
- 8:25Speaker 1: tireless junior developer who just writes perfect boilerplate at the
- 8:30Speaker 1: speed of light and always shows their work.
- 8:32Speaker 2: That's a great way to put it.
- 8:33Speaker 1: Yeah, and we could actually see the power of this
- 8:35Speaker 1: metaprogramming when we look at how YSAD handles routing, Because
- 8:39Speaker 1: this leads us to type safe URLs, which is huge.
- 8:43Speaker 2: This is arguably one of yusod's most defining features.
- 8:46Speaker 1: Yeah.
- 8:47Speaker 2: To appreciate it, we have to look at the routing pattern.
- 8:49Speaker 2: Unlike legacy systems that map a URL directly to a
- 8:52Speaker 2: physical file on a server like old PHP sites, YESOD
- 8:57Speaker 2: uses a front controller pattern.
- 8:58Speaker 1: Meaning every single request enters through one single point, and
- 9:02Speaker 1: YESAD acts as a traffic cop basically routing it to
- 9:05Speaker 1: the appropriate handler exactly.
- 9:07Speaker 2: But here is the critical difference. Instead of routing based
- 9:11Speaker 2: on raw strings of text, which are notoriously fragile, YESAD
- 9:15Speaker 2: routes are defined as data constructors.
- 9:17Speaker 1: Okay, let's define that, because data constructor is very specific
- 9:20Speaker 1: to functional programming. In a traditional framework, you tell a
- 9:23Speaker 1: system if the URL string is slash profile, slash home,
- 9:28Speaker 1: run this function. But a data constructor is a native type, right,
- 9:33Speaker 1: it's not text correct.
- 9:35Speaker 2: The convention in YESOD is to add a capital R
- 9:37Speaker 2: to the end for resource, so it becomes Homer Homer God.
- 9:40Speaker 2: Because Homer is a data constructor, it is a plain
- 9:43Speaker 2: old Haskell value. It's a structural type, just like a
- 9:46Speaker 2: boolean or an integer. So the compiler inherently understands what
- 9:50Speaker 2: Homer is.
- 9:50Speaker 1: Here's where it gets really interesting for anyone who has
- 9:53Speaker 1: ever had to refactor a massive codebase. If you define
- 9:56Speaker 1: your routes as data types, you don't use string. You
- 9:59Speaker 1: are ls in your HML anymore.
- 10:01Speaker 2: Nope, you use the data type.
- 10:02Speaker 1: Yeah. It's like using a dynamic GPS instead of drawing
- 10:06Speaker 1: a static line on a paper map. If a destination moves,
- 10:09Speaker 1: say you change a blog route from a numeric ID
- 10:12Speaker 1: to like a date based SLUG, the GPS updates your
- 10:16Speaker 1: route automatically. You don't have to go find and erase
- 10:18Speaker 1: the line on.
- 10:19Speaker 2: The paper map, and the maintenance implications of that are
- 10:21Speaker 2: just huge. Think about a standard web application. If you
- 10:26Speaker 2: change a route structure and forget to update a link
- 10:29Speaker 2: somewhere on page forty seven of your site, you wouldn't
- 10:32Speaker 2: know you made a mistake until the code is deployed
- 10:34Speaker 2: and a user actually complains about a four h four error.
- 10:37Speaker 1: Right, it's a nightmare.
- 10:38Speaker 2: But in YASAUD, the Haskell compiler physically refuses to compile
- 10:43Speaker 2: the application. It will throw an error and pinpoint every
- 10:46Speaker 2: single line in your entire code base that's still referencing
- 10:49Speaker 2: the old broken.
- 10:50Speaker 1: Route, So it effectively kills dead links at compile time,
- 10:53Speaker 1: they literally can't exist in production it does.
- 10:55Speaker 2: It's the death of the four h four error and
- 10:57Speaker 2: that metaprogramming we discussed earlier that rates a class called
- 11:01Speaker 2: render root to handle the translation back to text.
- 11:03Speaker 1: Right, because the browser still needs text eventually.
- 11:06Speaker 2: Yeah, exactly when it compiles your type safe links into
- 11:08Speaker 2: texts for the browser to read, render root generates absolute URLs,
- 11:13Speaker 2: meaning it includes the full domain name.
- 11:16Speaker 1: Oh interesting.
- 11:17Speaker 2: Yeah, this is a subtle but vital feature because it
- 11:19Speaker 2: consolidates your domain name to prevent search engines from penalizing
- 11:22Speaker 2: you for duplicate content across subdomains, and it ensures formats
- 11:26Speaker 2: that require absolute paths, like RSS or atom feeds, they
- 11:30Speaker 2: just function flawlessly out of the box.
- 11:33Speaker 1: Okay, so our inputs are meticulously sanitized by the foundation,
- 11:36Speaker 1: our boilerplate is generated perfectly via the AST, and our
- 11:40Speaker 1: routes are mathematically guaranteed to exist. Right. But eventually we
- 11:43Speaker 1: have to actually draw the page. We have to serve HTML,
- 11:46Speaker 1: CSS and JavaScript, and this requires a completely different approach
- 11:51Speaker 1: to templating, doesn't it.
- 11:52Speaker 2: Yes, To maintain that strict type safety all the way
- 11:55Speaker 2: down to the browser, ysaud uses a suite of templating
- 11:57Speaker 2: languages collectively named after Shakespeare. Love it's very clever. We
- 12:01Speaker 2: have Hamlet for HTML, Lucius and Cashus for CSS, and
- 12:04Speaker 2: Julius for JavaScript.
- 12:06Speaker 1: The naming convention is brilliant, and just like Haskell, these
- 12:09Speaker 1: languages have their own strict structural rules. Hamlet, for instance,
- 12:14Speaker 1: is white space sensitive. It relies on indentation instead of
- 12:17Speaker 1: closing tags. Right, so you don't write an opening tag,
- 12:20Speaker 1: type your text and then pray you remember the closing
- 12:22Speaker 1: tag later on. You just write the tag, indend, write
- 12:25Speaker 1: your text, and the structure is heavily implied.
- 12:28Speaker 2: Which naturally forces developers to write clean, visually hierarchical code.
- 12:33Speaker 2: You can't be sloppy with it. But the real ingenuity
- 12:36Speaker 2: of the Shakespearean templates is how they handle data interpolation
- 12:40Speaker 2: and security.
- 12:41Speaker 1: Yeah, let's talk about that.
- 12:42Speaker 2: When you inject a variable into Hamlet, you use a
- 12:45Speaker 2: specific syntax hash followed by braces like hashtag variable. And
- 12:49Speaker 2: to inject one of those types safe URLs we're talking about,
- 12:52Speaker 2: you use an at sign like at homer And.
- 12:54Speaker 1: Because the compiler knows the exact data type you're injecting,
- 12:58Speaker 1: it knows how to handle it safely. One of the
- 13:00Speaker 1: most terrifying vulnerabilities in web development cross site scripting or EXSS.
- 13:05Speaker 2: Yes, EXSS is a nightmare.
- 13:07Speaker 1: If you aren't familiar. This is what a malicious user
- 13:09Speaker 1: inputs a script into a text field like the blog comment,
- 13:13Speaker 1: and if your site renders that text blindly, it executes
- 13:16Speaker 1: their malicious script on your other user's machines.
- 13:19Speaker 2: It's a massive vector for data theft. I mean, it's
- 13:21Speaker 2: how session tokens get stolen. Most frameworks try to solve
- 13:25Speaker 2: this by running text through a filter to strip out
- 13:28Speaker 2: dangerous tags.
- 13:29Speaker 1: Like trying to sanitize it after the fact exactly.
- 13:31Speaker 2: But Hamlet prevents EXSS structurally. When you interpolate a standard
- 13:36Speaker 2: string variable into a Hamlet template, it automatically entity escapes
- 13:40Speaker 2: the string at the type level.
- 13:41Speaker 1: Okay, meaning what exactly?
- 13:42Speaker 2: It transforms characters like HTML brackets into harmless display entities,
- 13:47Speaker 2: so the script cannot execute because the browser is forced
- 13:50Speaker 2: to read it as literal text, not executable code.
- 13:53Speaker 1: But hold on, what if I want to render preexisting HTML.
- 13:57Speaker 1: Say have a developer blog and I want to display
- 14:00Speaker 1: colorized code snippets that already have like SPAN tags injected
- 14:04Speaker 1: into them.
- 14:04Speaker 2: Right, A very common use case.
- 14:06Speaker 1: Yeah, so if Hamlet escapes absolutely everything by default wanted,
- 14:10Speaker 1: just mangle my snippets and print the literal words, span
- 14:13Speaker 1: class equals across the screen.
- 14:15Speaker 2: If we connect this to the bigger picture, this is
- 14:17Speaker 2: where type level trust really outshines simple filtering. You saw.
- 14:21Speaker 2: It doesn't treat everything as a dumb string. It utilizes
- 14:24Speaker 2: an HTML data type, which is provided by a highly
- 14:27Speaker 2: optimized package called Blaze HTML. Okay, if you want to
- 14:31Speaker 2: render pre existing HTML, you don't just ask Hamlet to
- 14:35Speaker 2: ignore it. You run the data through a specific function
- 14:38Speaker 2: called pre escape to markup.
- 14:40Speaker 1: Uh. So you are explicitly coercing the type. You are
- 14:43Speaker 1: tagging it as safe HTML.
- 14:46Speaker 2: Exactly, you are changing its type. When Hamlet encounters data
- 14:49Speaker 2: that has been typed as HTML rather than a standard string,
- 14:52Speaker 2: it recognizes that you have explicitly vouched for this data,
- 14:56Speaker 2: so it passes it through unmodified.
- 14:57Speaker 1: So it's not a filter, it's a type contract exactly.
- 15:00Speaker 2: You have a system where the default state is absolute safety,
- 15:03Speaker 2: but you retain deliberate fine grain control to overwrite it,
- 15:06Speaker 2: all backed by the compiler verifying your data types.
- 15:09Speaker 1: That is beautifully elegant, but it brings us to a
- 15:13Speaker 1: major structural headache for modern component based design.
- 15:16Speaker 2: The CSS in JavaScript routing.
- 15:18Speaker 1: Yes, we have our HTML or CSS and our JavaScript
- 15:22Speaker 1: safely generated by the Shakespeare languages. But HTML demands a
- 15:26Speaker 1: very rigid document structure. Like CSS belongs globally up in
- 15:31Speaker 1: the head tag. JavaScript usually belongs down to the bottom
- 15:33Speaker 1: of the body tag. If I'm building a modular piece
- 15:36Speaker 1: of a web page, say a dynamic navigation bar, how
- 15:40Speaker 1: do I keep it CSS and JS organized without breaking
- 15:43Speaker 1: the document structure?
- 15:44Speaker 2: True modularity is notoriously difficult on the web for exactly
- 15:48Speaker 2: this reason. You build a beautiful component, but to use it,
- 15:51Speaker 2: you have to manually ensure its styles go to the
- 15:53Speaker 2: head and its scripts go to the footer. It is
- 15:56Speaker 2: but disad solves the structural disconnect with something called widgets.
- 16:00Speaker 1: It's the ultimate glue for the modern web.
- 16:02Speaker 2: As they say, yeah, widgets fundamentally shift how you architect
- 16:05Speaker 2: a page. Instead of viewing a web page as a
- 16:07Speaker 2: single monolithic tree of HTML, widgets treat the page as
- 16:11Speaker 2: an assembly of distinct components. A widget is a discrete
- 16:15Speaker 2: bundle that holds its own title, its own CSS declarations,
- 16:19Speaker 2: its own external scripts, and its own body content.
- 16:23Speaker 1: So how do you actually construct one? I mean, the
- 16:25Speaker 1: documentation highlights a type class called two widget. So you
- 16:28Speaker 1: take your Hamlet, your Lucius, and your Julius templates and
- 16:31Speaker 1: you bundle them together using Haskell's monad do notation right,
- 16:36Speaker 1: which if you aren't a Haskell developer, is essentially a
- 16:40Speaker 1: way to strictly sequence operations step by step so the
- 16:43Speaker 1: compiler can safely package all these different side effects like
- 16:47Speaker 1: adding a style or adding a script into one cohesive
- 16:50Speaker 1: monetic widget.
- 16:51Speaker 2: And once you have that cohesive widget, you use a
- 16:54Speaker 2: function called default layout to actually render the page.
- 16:56Speaker 1: Of trying to picture how default layout works. Yeah, and
- 16:59Speaker 1: it's almost like a post sorting facility.
- 17:00Speaker 2: Right now, that's a good way to look at it.
- 17:02Speaker 1: You hand it this bundled package, and the sorting facility unwraps.
- 17:05Speaker 1: It takes the CSS and routes it directly to the
- 17:08Speaker 1: head container, takes the JavaScript and routes it to the
- 17:10Speaker 1: script compaigner, and takes the HTML and places it perfectly
- 17:14Speaker 1: in the body. It automatically sorts everything into its legally
- 17:17Speaker 1: correct place in the document.
- 17:18Speaker 2: That is exactly what happens.
- 17:19Speaker 1: It does the heavy lifting for you, But I have
- 17:21Speaker 1: to push back here for a second. If I'm reusing
- 17:23Speaker 1: these widgets, Let's say I dropped three different dynamic image
- 17:26Speaker 1: carousels onto the exact same page. Don't I run the
- 17:29Speaker 1: risk of CSS class name collisions? Oh? Sure, because if
- 17:33Speaker 1: the framework is auto sorting my CSS into the global headtag,
- 17:37Speaker 1: I feel like that's just a recipe for styling nightmares
- 17:40Speaker 1: and dombloat.
- 17:41Speaker 2: Well it would be if you were hard coding the
- 17:44Speaker 2: class names.
- 17:45Speaker 1: Ah.
- 17:45Speaker 2: Okay, Yes, it anticipates this with a function called new
- 17:48Speaker 2: ident new dent. Yeah. When you build a widget, you
- 17:52Speaker 2: can use new ident to automatically generate mathematically unique IDs
- 17:56Speaker 2: and class names for that specific instance of the widget.
- 18:00Speaker 2: Oh wow, it scopes the CSS locally. You can drop
- 18:03Speaker 2: that image carousel onto the page twenty times, and new
- 18:06Speaker 2: iden guarantees there will be zero styling collisions.
- 18:09Speaker 1: So what does this all mean? The modularity is basically absolute.
- 18:13Speaker 1: You write the complex logic once and you can drop
- 18:15Speaker 1: it anywhere, knowing it will sort its own dependencies and
- 18:18Speaker 1: never bleed into the rest of the page. And from
- 18:20Speaker 1: a developer experience standpoint, you really get the best of
- 18:23Speaker 1: both worlds. For local development, YASAD provides this tool yesad Devil,
- 18:28Speaker 1: which auto rebuilds your code on the fly, so you
- 18:31Speaker 1: get the rapid iterative prototyping speed of a dynamic scripting language.
- 18:35Speaker 2: It feels very fast to work with, but then when
- 18:37Speaker 2: you compile it for production, you deploy it on ysad's
- 18:40Speaker 2: custom web server called WARP, and because it's compiled down
- 18:45Speaker 2: to machine code, the memory footprint is incredibly small and
- 18:49Speaker 2: the raw performance is frankly staggering compared to traditional interpreted frameworks.
- 18:54Speaker 1: So to pull all of this together for everyone listening,
- 18:56Speaker 1: we looked at how Haskell's strict typing acts as a
- 18:59Speaker 1: boundary be right, how the foundation provides a safe central state,
- 19:03Speaker 1: how metaprogramming and type safe URLs just eradicate deadlinks, how
- 19:07Speaker 1: Shakespearean templates structurally defeat XSS, and how modular widgets cleanly
- 19:12Speaker 1: assemble the final product.
- 19:13Speaker 2: It really is a comprehensive architecture for building bulletproof web applications.
- 19:17Speaker 2: It redefines the baseline of what we should expect from
- 19:20Speaker 2: our tools.
- 19:20Speaker 1: Yeah, it does, And you know.
- 19:22Speaker 2: This raises an important question something for you to think
- 19:25Speaker 2: about after we sign off.
- 19:26Speaker 1: Cable's here.
- 19:27Speaker 2: If you saw it uses compile time metaprogramming to automatically
- 19:30Speaker 2: handle routing logic, enforce data sanitization at the boundaries, and
- 19:34Speaker 2: structurally prevent EXSS attacks before the serer even starts. Yeah, well,
- 19:39Speaker 2: could this paradigm eventually make manual unit testing obsolete for
- 19:44Speaker 2: UI and routing?
- 19:45Speaker 1: Oh wow?
- 19:46Speaker 2: I mean if the compiler mathematically guarantees the code is
- 19:49Speaker 2: structurally perfect, do we still need armies of QA testers
- 19:53Speaker 2: writing brittle browser automation scripts or does the compiler itself
- 19:57Speaker 2: evolve into the ultimate QA department.
- 19:59Speaker 1: That is a wild thought to leave on a world
- 20:02Speaker 1: where the compiler actually does the QA for you. Well,
- 20:06Speaker 1: that is all the time we have for today's deep dive.
- 20:08Speaker 1: Thank you for joining us as we explore the underlying
- 20:10Speaker 1: mechanisms of safety driven web development. Remember, the Internet might
- 20:14Speaker 1: be made of wet cardboard and duct tape, but your
- 20:16Speaker 1: applications foundation definitely doesn't have to be. Keep asking questions,
- 20:20Speaker 1: keep exploring, and keep digging deep. We'll catch you next time.