#deep dive

Subscribe
Deep dive is a term used to describe an in-depth exploration of a particular topic. It involves going beyond the basics and looking into more complex aspects of the subject matter. In the case of JavaScript, it could involve exploring more advanced concepts such as object-oriented programming, functional programming, or asynchronous programming. Deep diving into JavaScript also involves studying the language’s syntax, best practices, and frameworks. Doing so will help you better understand how to use JavaScript to create powerful web applications.
Making Magic: Building a TypeScript-First Framework
TypeScript Congress 2023TypeScript Congress 2023
31 min
Making Magic: Building a TypeScript-First Framework
Top Content
Daniel Rowe discusses building a TypeScript-first framework at TypeScript Congress and shares his involvement in various projects. Nuxt is a progressive framework built on Vue.js, aiming to reduce friction and distraction for developers. It leverages TypeScript for inference and aims to be the source of truth for projects. Nuxt provides type safety and extensibility through integration with TypeScript. Migrating to TypeScript offers long-term maintenance benefits and can uncover hidden bugs. Nuxt focuses on improving existing tools and finds inspiration in frameworks like TRPC.
Designing Effective Tests With React Testing Library
React Summit 2023React Summit 2023
151 min
Designing Effective Tests With React Testing Library
Top Content
Featured Workshop
Josh Justice
Josh Justice
React Testing Library is a great framework for React component tests because there are a lot of questions it answers for you, so you don’t need to worry about those questions. But that doesn’t mean testing is easy. There are still a lot of questions you have to figure out for yourself: How many component tests should you write vs end-to-end tests or lower-level unit tests? How can you test a certain line of code that is tricky to test? And what in the world are you supposed to do about that persistent act() warning?
In this three-hour workshop we’ll introduce React Testing Library along with a mental model for how to think about designing your component tests. This mental model will help you see how to test each bit of logic, whether or not to mock dependencies, and will help improve the design of your components. You’ll walk away with the tools, techniques, and principles you need to implement low-cost, high-value component tests.
Table of contents- The different kinds of React application tests, and where component tests fit in- A mental model for thinking about the inputs and outputs of the components you test- Options for selecting DOM elements to verify and interact with them- The value of mocks and why they shouldn’t be avoided- The challenges with asynchrony in RTL tests and how to handle them
Prerequisites- Familiarity with building applications with React- Basic experience writing automated tests with Jest or another unit testing framework- You do not need any experience with React Testing Library- Machine setup: Node LTS, Yarn
React Concurrency, Explained
React Summit 2023React Summit 2023
23 min
React Concurrency, Explained
Top Content
Watch video: React Concurrency, Explained
React 18's concurrent rendering, specifically the useTransition hook, optimizes app performance by allowing non-urgent updates to be processed without freezing the UI. However, there are drawbacks such as longer processing time for non-urgent updates and increased CPU usage. The useTransition hook works similarly to throttling or bouncing, making it useful for addressing performance issues caused by multiple small components. Libraries like React Query may require the use of alternative APIs to handle urgent and non-urgent updates effectively.
A Guide to React Rendering Behavior
React Advanced Conference 2022React Advanced Conference 2022
25 min
A Guide to React Rendering Behavior
Top Content
This transcription provides a brief guide to React rendering behavior. It explains the process of rendering, comparing new and old elements, and the importance of pure rendering without side effects. It also covers topics such as batching and double rendering, optimizing rendering and using context and Redux in React. Overall, it offers valuable insights for developers looking to understand and optimize React rendering.
Deep Diving on Concurrent React
React Advanced Conference 2022React Advanced Conference 2022
29 min
Deep Diving on Concurrent React
The Talk discussed Concurrent React and its impact on app performance, particularly in relation to long tasks on the main thread. It explored parallelism with workers and the challenges of WebAssembly for UI tasks. The concepts of concurrency, scheduling, and rendering were covered, along with techniques for optimizing performance and tackling wasted renders. The Talk also highlighted the benefits of hydration improvements and the new profiler in Concurrent React, and mentioned future enhancements such as React fetch and native scheduling primitives. The importance of understanding React internals and correlating performance metrics with business metrics was emphasized.
Inside Fiber: the in-depth overview you wanted a TLDR for
React Summit 2022React Summit 2022
27 min
Inside Fiber: the in-depth overview you wanted a TLDR for
This Talk explores the internals of React Fiber and its implications. It covers topics such as fibres and units of work, inspecting elements and parent matching, pattern matching and coroutines, and the influence of coroutines on concurrent React. The Talk also discusses effect handlers in React, handling side effects in components, and the history of effect handlers in React. It concludes by emphasizing the importance of understanding React internals and provides learning resources for further exploration.
React Hooks Tips Only the Pros Know
React Summit Remote Edition 2021React Summit Remote Edition 2021
177 min
React Hooks Tips Only the Pros Know
Top Content
Featured Workshop
Maurice de Beijer
Maurice de Beijer
The addition of the hooks API to React was quite a major change. Before hooks most components had to be class based. Now, with hooks, these are often much simpler functional components. Hooks can be really simple to use. Almost deceptively simple. Because there are still plenty of ways you can mess up with hooks. And it often turns out there are many ways where you can improve your components a better understanding of how each React hook can be used.You will learn all about the pros and cons of the various hooks. You will learn when to use useState() versus useReducer(). We will look at using useContext() efficiently. You will see when to use useLayoutEffect() and when useEffect() is better.
Effective Testing Strategies for React Components
Effective Testing Strategies for React Components
Article
Testing the contract of a component by focusing on inputs and outputs.Utilizing Jest mock functions for testing function props and module mocks for external modules.Implementing the React Testing Library for rendering components and simulating user interactions.Addressing asynchronous behavior in tests using the findBy query and awaiting promises.Balancing test coverage between lower-level and higher-level components.Testing React components effectively involves focusing on the contract of the component, which means understanding the inputs and outputs. This mindset helps ensure that tests are meaningful and maintainable. Instead of delving into implementation details, the aim is to test observable behavior that a user would interact with.Components have various inputs and outputs. Inputs include props, user interactions, and responses from external functions, while outputs are the rendered UI and calls to external functions. Testing begins by rendering the component and simulating user interactions to observe the outputs.Jest mock functions are essential for testing function props. They allow you to simulate and make assertions on functions passed as props. For example, if a component receives a function to handle form submission, a Jest mock function can verify that this function is called with the correct arguments.Jest module mocks are another powerful tool for handling external modules. They enable you to mock out any JavaScript module that your component depends on, ensuring that tests remain isolated from external dependencies. This is particularly useful when dealing with API calls, as it allows you to simulate responses without hitting a real server, thereby avoiding flakiness and improving test reliability.When testing asynchronous behavior, such as loading data from an API, it's crucial to handle promises correctly. The findBy query from the React Testing Library is an excellent way to wait for elements to appear on the page. It returns a promise that resolves when the element is found, allowing you to await its presence before making assertions.Organizing tests effectively involves making judgment calls about what to test at each level. Lower-level component tests focus on the detailed behavior of individual components, while higher-level tests ensure that components integrate correctly. This balance helps maintain a comprehensive test suite without excessive duplication.In addition to testing visible outputs, it's important to confirm that components make the correct external calls. This involves asserting not only on the presence of elements but also on the calls made to external functions, such as ensuring that the correct API endpoints are hit with the appropriate parameters.By focusing on the contract of a component and using tools like Jest and the React Testing Library, developers can create robust and reliable tests. This approach emphasizes testing what matters most to users and ensures that components behave as expected, both in isolation and when integrated with others.
Exploring the World of JavaScript Engine Creation
Exploring the World of JavaScript Engine Creation
Article
JavaScript engines like V8, SpiderMonkey, and JavaScriptCore are highly optimized and complex.Building a JavaScript engine involves choosing a language and defining the implementation scope.Starting the project can be flexible, with tools available to aid development.The ECMAScript specification provides detailed guidance and testing resources.Building a JavaScript engine enhances understanding of JavaScript and programming concepts.Creating a JavaScript engine is an intriguing endeavor that allows developers to dive deep into the mechanics of a language widely used in both client and server-side applications. The established engines, such as V8, SpiderMonkey, and JavaScriptCore, are sophisticated and have set high standards in terms of performance and integration. They have made JavaScript a viable option at scale, but their complexity can be overwhelming for newcomers.JavaScript engines are not simple interpreters; they include multiple tiers of just-in-time compilers that translate code into native machine code for performance gains. Their integration with browsers adds another layer of complexity, making them intimidating to approach. These engines are mature, feature-rich, and highly competitive, constantly evolving to remain at the forefront of performance and compliance. Their development is often tied to the product roadmaps of large companies like Google, Apple, and Mozilla, which adds constraints to their evolution.For those interested in creating a JavaScript engine for fun or educational purposes, the journey begins with selecting a programming language for implementation. Traditionally, languages like C or C++ are used due to their speed and memory control capabilities. However, these languages come with safety concerns and historical issues. Alternatives such as Go, Java, or even JavaScript itself can be considered, offering different levels of complexity and control based on the developer's preference.The next step is defining the engine's scope. This could range from implementing an ES5 transpiler to support older syntax, to embracing the latest and greatest features known as ES Next. Developers might also explore custom extensions, like the 'use math' feature in the Quick JS engine, which offers non-standard functionalities. The target audience and use case will significantly influence these decisions, whether for browser support or simple plugin functionality.Once the project is initiated with a Git repository, the challenge is deciding where to start. While the typical approach might be to develop a parser first, the flexibility of available tools allows for different starting points. Standalone parser libraries and other JS tooling enable quick progress, even allowing for manual creation of abstract syntax trees (AST) initially. Developers can choose to implement basic runtime features like string or number handling, or delve into more advanced concepts like typed arrays or proxies.The ECMAScript 262 specification is a comprehensive resource, offering pseudo code that can be translated into the engine's codebase. While it focuses on correctness and behavior, it leaves room for custom optimizations. Testing is an essential part of the process, with 50,000 tests available for free alongside the specification. This ensures that any new features are thoroughly vetted, and developers can track engine performance and compliance through platforms like test262.fyi.Engaging in this project provides immense learning opportunities. Understanding the intricacies of parsers, interpreters, and bytecode generation deepens one's comprehension of JavaScript and software development in general. Developers gain insights into low-level concepts and the standards that shape language evolution. This exposure to standards allows for interaction with contributors and even participation in the development of new features.Ultimately, building a JavaScript engine is not about competing with established giants but exploring the language's potential and enhancing one's programming knowledge. It offers a unique perspective on how JavaScript operates under the hood and the processes involved in its continual improvement. For those intrigued by the challenge, numerous projects exist that undertake this endeavor for the sheer enjoyment of learning and experimentation.
Unlocking Developer Magic with Nuxt and TypeScript
Unlocking Developer Magic with Nuxt and TypeScript
Article
Nuxt as a progressive framework built on Vue.jsDeveloper experience focused on reducing friction and distractionsIntegration of TypeScript for type safety and inferenceCustomizable framework with extensibility through modulesType-safe access to server endpoints and environment variablesUnderstanding what Nuxt offers starts with recognizing it as a progressive framework built on Vue.js. While Vue handles the rendering layer for the front end, Nuxt extends its functionality to be a full-stack framework. This is partly due to its server engine, Nitro, which has evolved into a framework used by other meta-frameworks.Nuxt prioritizes the developer experience, aiming to make the framework easy to use while incorporating best practices. It strikes a balance between simplicity and configurability, allowing developers to extend it as their projects grow. The goal is for Nuxt to grow alongside developers, adapting to different requirements without imposing a high barrier to entry.Rebuilding Nuxt involved contemplating how to enhance its magic. Magic, in this context, is about reducing friction and distractions during development. It means keeping developers in a single context and minimizing interruptions that slow down workflow. This involves adopting a minimalist approach, ensuring that developers can maintain focus and productivity.Switching contexts while coding disrupts the flow of ideas. Having to consult documentation frequently or check other parts of a project can create frustration. Similarly, dealing with complex bundler configurations or repetitive code can hinder productivity. Magic in a framework can significantly improve the developer experience by minimizing these issues.When rebuilding Nuxt, a focus was placed on TypeScript to create this magic. Building the framework with TypeScript is essential, but the aim was to integrate TypeScript at a core level, making the framework TypeScript-native. This involves several key design principles: being the source of truth in a project, leveraging TypeScript's inference capabilities, facilitating augmentation, and revealing project truths to the end user.Setting a single source of truth is crucial. Often, frameworks provide a TypeScript configuration template that diverges from the library's reality over time. Nuxt aims to be this source of truth by generating a TypeScript configuration that accurately reflects the project's state.Nuxt's approach to type safety extends beyond configuration. It aims to provide end-to-end type safety, ensuring that server endpoints and global singletons are type-safe without requiring developers to write additional types. This is achieved through TypeScript's inference capabilities.Extensibility is a core philosophy of Nuxt. It allows for augmentation through Nuxt modules, which are integrations that extend the framework's functionality. These modules can be community-maintained and cover various use cases, from authentication to data fetching and caching.Nuxt also provides type-safe access to server endpoints and environment variables through features like RuntimeConfig. This ensures that developers have accurate type hints for their environment, reducing the need for additional validation.The framework supports customizing and controlling the type environment, allowing module authors to add their own templates into the Nuxt build. This includes adding type templates to augment the types Nuxt provides or introducing new ones.Nuxt's approach to developer experience is about reducing the need for manual configuration and making the development process more seamless. By leveraging TypeScript and providing a flexible and extensible framework, Nuxt helps developers maintain focus and productivity, unlocking the magic of a smooth developer experience.
Building a JS Engine -- For Fun!
JSNation 2024JSNation 2024
9 min
Building a JS Engine -- For Fun!
Top Content
The Talk discusses the basics of building a JS engine, highlighting the complexity and feature completeness of existing engines. It emphasizes the possibility of creating a simpler engine tailored to specific use cases and target audiences. The speaker suggests starting anywhere in the process and provides tips on using parser libraries, implementing runtime features, and ensuring correctness through testing. Additionally, the Talk encourages exploring JavaScript standards and engaging with the open-source community.
Testing Frameworks, Mobile Frameworks, and Browsers Love Developers and Testers
TestJS Summit 2023TestJS Summit 2023
27 min
Testing Frameworks, Mobile Frameworks, and Browsers Love Developers and Testers
Today's Talk covered various topics including testing frameworks, browsers, and the challenges faced in testing complex systems. The importance of improving testing setup and productivity was highlighted, along with the principle of least surprise and the need for framework upgrades. The Talk also discussed the different browser engines and their unique features, as well as the benefits of sharing ideas and approaches within the software development community. The session concluded with insights on browser testing and the use of tools like Playwright and WebKit.
Hydration, Islands, Streaming, Resumability… Oh My!
React Advanced Conference 2023React Advanced Conference 2023
26 min
Hydration, Islands, Streaming, Resumability… Oh My!
Watch video: Hydration, Islands, Streaming, Resumability… Oh My!
Today's Talk introduces the concepts of hydration and off islands, explores the benefits of islands for enhancing server-side rendered HTML with client-side JavaScript, discusses the lazy approach of re-zoomability and its advantages over traditional hydration, highlights the use of resumability and concurrent React for improved rendering performance, examines the features and concerns of React server components, touches on the co-location of client and server code, and explores future trends in rendering and navigation. The Talk also reflects on past ideas and emphasizes the importance of identifying core metrics for performance optimization.
Unleashing Object Proxies: Building Type-Safe Wrappers for Anything
TypeScript Congress 2023TypeScript Congress 2023
16 min
Unleashing Object Proxies: Building Type-Safe Wrappers for Anything
Object proxies are middleware for objects that allow control over input and output. They have various use cases such as controlling data access, adding logging, and handling responses. Implementing object proxies involves transpiling calls into network requests and handling property access and method calls. Handling object proxy traps and errors involves faking object structure, logging target objects and properties, and resolving errors. Making API calls with object proxies involves defining the correct type, making backend calls, and wrapping methods to return promises. Object proxies are widely used in ORMs and RPC libraries and should be explored and experimented with.
How TypeScript is integrated in your editor
TypeScript Congress 2023TypeScript Congress 2023
18 min
How TypeScript is integrated in your editor
Today's Talk explores TypeScript integration and refactoring, code action handling, the TypeScript server and refactoring process, bug reporting, and the TypeScript protocol and LSP. The Talk discusses how TypeScript is integrated into editors, the role of code action providers, and the communication between the client and server. It also highlights the two-stage process of code actions and the importance of bug reporting. Additionally, it mentions the TypeScript protocol and how it allows for language-specific extensions. LSP is mentioned as a powerful extensibility solution used by various languages.
What is "TC39: Type Annotations" aka the Types as Comments proposal
TypeScript Congress 2023TypeScript Congress 2023
27 min
What is "TC39: Type Annotations" aka the Types as Comments proposal
The TC59 Type Annotations proposal, also known as Types with Comments, introduces the ability to run typed code in JavaScript. It aims to bring TypeScript back into JavaScript and create a separation between type system and runtime. TypeScript's popularity is on par with JavaScript, raising concerns about the influence of Microsoft. The proposal progresses by addressing runtime interaction and token soup in type specifications. Research, community involvement, and quantifying the effects of supporting this comment style are important goals.
Supercharged Code Refactoring via Abstract Syntax Trees
React Summit 2023React Summit 2023
29 min
Supercharged Code Refactoring via Abstract Syntax Trees
Watch video: Supercharged Code Refactoring via Abstract Syntax Trees
This Talk explores the power of Abstract Syntax Trees (ASTs) in software development. It covers the use of ASTs in maintaining React examples, automating dependency identification, and introducing generic typing. The Talk also discusses using ASTs to reason about and generate code, as well as their application in building ESLint plugins and code mods. Additionally, it highlights resources for exploring ASTs, testing AST scripts, and building Babel plugins.
Astro & Fresh - Understanding the Islands Architecture
React Advanced Conference 2022React Advanced Conference 2022
21 min
Astro & Fresh - Understanding the Islands Architecture
The islands architecture is a new way to build websites with low or no JavaScript, using libraries like Astro and Fresh. Server-side rendering improves SEO and loading times, but can still result in large JavaScript payloads. Hydration allows for islands of interactivity, loading only necessary JavaScript. Astro is a framework for implementing the islands architecture, supporting multiple libraries like React and SolidJS. It enables progressive migration between frameworks and integration of different libraries in the same project.
Building Age of Empires 2 in React
React Advanced Conference 2022React Advanced Conference 2022
22 min
Building Age of Empires 2 in React
Top Content
This Talk discusses the process of recreating Age of Empires II in React. The speaker shares their inspiration for the project and explores different approaches to game development using React. They demonstrate how to create an isometric grid, enable scrolling, and render units. The Talk also covers handling unit clicks and implementing right-click movement, as well as techniques for making React render more consistently. The speaker concludes by highlighting the value of exploring different tools and approaches in software development.
Arrows (At Length)
React Advanced Conference 2022React Advanced Conference 2022
23 min
Arrows (At Length)
This talk focuses on arrows and their unique features in diagramming tools. It explores the challenges of arrow positioning and connector selection, particularly with irregular shapes. The talk also discusses alternative arrow intersections and curved lines, as well as the challenges of creating curved arrows. The speaker presents a method for creating arrows and moving handles that always look good. The talk concludes with an invitation to try out the new version of Teal Draw and follow the speaker on Twitter for more arrow content.
What Happens When You Build Your App
React Advanced Conference 2022React Advanced Conference 2022
20 min
What Happens When You Build Your App
Today's Talk dives deep into React Native development, exploring the development process, JavaScript-native communication, and app deployment. It highlights the app building process, the React Native Run iOS command, and development gestures for efficient execution. The Talk also emphasizes the recommended process for starting and testing your app, as well as handling the 'red screen of death' error by installing missing libraries and understanding the role of the UI manager in creating native views.
Let’s Talk about Re-renders
React Summit 2022React Summit 2022
23 min
Let’s Talk about Re-renders
Top Content
This Talk discusses React performance and how re-renders can affect it. It highlights common mistakes and misconceptions, such as the overuse of useMemo and useCallback hooks. The importance of React.memo in preventing unnecessary child component re-renders is emphasized. Creating components in render functions is identified as a major performance killer, and the benefits of moving state down and wrapping state around children are explained. The Talk also covers optimizing component rendering through memoization and provides a recap of the key points.
Advanced TypeScript types for fun and reliability
TypeScript Congress 2022TypeScript Congress 2022
116 min
Advanced TypeScript types for fun and reliability
Workshop
Maurice de Beijer
Maurice de Beijer
If you're looking to get the most out of TypeScript, this workshop is for you! In this interactive workshop, we will explore the use of advanced types to improve the safety and predictability of your TypeScript code. You will learn when to use types like unknown or never. We will explore the use of type predicates, guards and exhaustive checking to make your TypeScript code more reliable both at compile and run-time. You will learn about the built-in mapped types as well as how to create your own new type map utilities. And we will start programming in the TypeScript type system using conditional types and type inferring.
Are you familiar with the basics of TypeScript and want to dive deeper? Then please join me with your laptop in this advanced and interactive workshop to learn all these topics and more.
You can find the slides, with links, here: http://theproblemsolver.nl/docs/ts-advanced-workshop.pdf
And the repository we will be using is here: https://github.com/mauricedb/ts-advanced
setState, We Need to Talk!
React Advanced Conference 2021React Advanced Conference 2021
20 min
setState, We Need to Talk!
In this Talk, the speaker discusses the importance of planning and maintaining UIs in React using state machines. They highlight the need to consider user experience and plan for performance and maintainability. The challenges of handling multiple UI states are addressed, and the benefits of using finite state machines are explained. The speaker demonstrates how to implement transitions and update the UI using a React state machine. They emphasize the benefits of state machines in handling errors, avoiding state explosions, and improving collaboration between designers and developers.