Ep 116: The Main Focus

Ep 116: The Main Focus

Update: 2024-05-16
Share

Description

Each week, we discuss a different topic about Clojure and functional programming.


If you have a question or topic you'd like us to discuss, tweet @clojuredesign, send an email to feedback@clojuredesign.club, or join the #clojuredesign-podcast channel on the Clojurians Slack.


This week, the topic is: "frontend matters". We turn our attention to the frontend, and our eyes burn from the complexity.


Our discussion includes:



  • What is a Single Page Application (SPA)?

  • The progression from static websites, to multi-page websites, to JavaScript-enhanced pages, to SPAs.

  • Why we like SPAs.

  • Where's the "main" for the frontend?

  • The complexity of frontend builds.

  • How does the frontend app start running?

  • How does the "table of contents" concept apply on the frontend?

  • How can you make the most important parts of the application clear?

  • What are the most important parts of a SPA?

  • What is the "backend of the frontend"?

  • The asynchronous, reactive cycle that drives a SPA.


Selected quotes


You don't usually go into a code base just to browse it, or just to have fun. You go there with a purpose. You need to work. You need to get something done fast.


We like rich frontends. We're able to do a lot more interactivity. There's less interruption when the page has to load. There are a lot of advantages to SPAs.


With a SPA, it's really, really fast to switch between everything. It feels almost instantaneous because there is almost nothing to load each time.


The counterpart is that a SPA is more sophisticated, so it ends up being more complicated. It's almost like a process that's running continuously. There's more code that's present in a SPA than any individual page load.


From the browsers point of view, the "main" is the markup, and you have to tell it to run some code.


It's just one blob of code to the browser. You can't look at that code because it's transpiled, minified JavaScript.


I do think it's interesting that we've gotten several minutes into this episode, and we're still talking about how things get made into the final sausage. It's reflective of how much effort it takes to set up the JavaScript ecosystem.


We make a "main.cljs" file, and that is the top of the application. It's a signpost. "Hey! Hey! Look here first!"


The tab's not going to go away, so all we need to do is start up all the event listeners because JavaScript is a very event-driven language.


I want "main" to be a table of contents of everything that matters in the app: the views, the routes, the URLs, browser hooks, web sockets, etc.


The worst kind of "main" is no "main" at all. There are frameworks where you make a whole bunch of separate files for each of your routes.


I love how many times we said the word "react" in this episode. It's all very event driven. That's just the model of the whole browser. It's the water that you swim in, so you must swim the right way in order for the application to succeed.


Reactive cycle


User Interaction → Event → Callback → Reactive Model → Re-Render


Kinds of frontend components



  • Navigation (eg. browser history)

  • Router

  • Settings

  • State holders (eg. app state, reactive atoms)

  • Pure models

  • Browser integrations (eg. camera, microphone, GPS, notification API, fullscreen API)

  • Render


Links


Comments 
In Channel
Ep 118: Pure Parts

Ep 118: Pure Parts

2024-06-2728:28

Ep 116: The Main Focus

Ep 116: The Main Focus

2024-05-1622:44

Ep 115: The Main Event

Ep 115: The Main Event

2024-05-0928:42

Ep 113: Highlightify!

Ep 113: Highlightify!

2024-02-2927:13

Ep 112: Purify!

Ep 112: Purify!

2024-02-2233:20

Ep 111: Loopify!

Ep 111: Loopify!

2024-02-1528:54

Ep 110: Contextify!

Ep 110: Contextify!

2024-02-0823:22

Ep 109: Extractify!

Ep 109: Extractify!

2024-02-0126:35

Ep 108: Testify!

Ep 108: Testify!

2024-01-2522:42

Ep 107: Idempotify!

Ep 107: Idempotify!

2024-01-1831:53

Ep 106: Robustify!

Ep 106: Robustify!

2024-01-1130:37

Ep 105: Codify!

Ep 105: Codify!

2024-01-0425:42

Ep 104: Assembleify!

Ep 104: Assembleify!

2023-12-2135:03

Ep 103: Explorify!

Ep 103: Explorify!

2023-12-1432:15

Ep 102: REPLify!

Ep 102: REPLify!

2023-12-0728:11

Ep 101: Sportify!

Ep 101: Sportify!

2023-11-3017:03

loading
00:00
00:00
x

0.5x

0.8x

1.0x

1.25x

1.5x

2.0x

3.0x

Sleep Timer

Off

End of Episode

5 Minutes

10 Minutes

15 Minutes

30 Minutes

45 Minutes

60 Minutes

120 Minutes

Ep 116: The Main Focus

Ep 116: The Main Focus

Christoph Neumann and Nate Jones