August 8th, 2024

The basics for a fullstack SPA in Gleam

Gleam is a functional programming language with a C-style syntax. It uses the Lustre framework for frontend development, emphasizing immutable data structures and message dispatching for state management and routing.

Read original articleLink Icon
The basics for a fullstack SPA in Gleam

Gleam is a functional programming language that offers a syntax familiar to users of C-style languages like C#, JavaScript, and Rust. Unlike many functional languages, it lacks traditional constructs such as for and while loops, instead utilizing functional recursion and a powerful case construct that combines if and switch statements. This article outlines the creation of a fullstack application using Gleam, focusing on routing, AJAX requests, and effects, culminating in a simple post-creation website. The Lustre framework, which follows the Model-View-Update architecture, is highlighted as the primary tool for frontend development in Gleam. The article contrasts state management in Lustre with React, emphasizing Lustre's approach of using immutable data structures and message dispatching for state updates. It also discusses the setup of a Gleam project, including the addition of necessary libraries like Lustre and Modem for routing. The Modem library facilitates client-side routing, although it requires some manual setup to handle initial page loads. The article provides code examples for implementing a simple counter and a basic routing mechanism, demonstrating how to manage application state and navigate between different pages effectively.

- Gleam is a functional programming language with a syntax similar to C-style languages.

- The Lustre framework is used for frontend development, following the Model-View-Update architecture.

- State management in Lustre is based on immutable data structures and message dispatching.

- The Modem library is utilized for client-side routing in Gleam applications.

- Code examples illustrate the implementation of a simple counter and routing mechanism.

Link Icon 0 comments