NotDefine.dev

Defining the Undefined. Exploring system design, performance, and memory safety with Go and Rust.

  • void *notdefine; // Why this blog?

    In computer science, Undefined Behavior is the land of the unpredictable. It’s what happens when code goes off the rails and the compiler stops guaranteeing the outcome.

    I chose NotDefine.dev for three main reasons:

    1. The Name Hack: The name of this site is a creative play on my own name, Nicola De Filippo. By shuffling the concepts and letters, NotDefine was born—an identity that bridges my personal roots with one of the most infamous concepts in systems programming.
    2. The Nature of Systems: Writing in Go and Rust is often about taming complexity and making deterministic what would otherwise be “undefined.” This space is dedicated to exploring how to build robust systems that leave nothing to chance.
    3. An Evolving Identity: In a world of rigid definitions, this blog is about pure exploration. It’s not just about a single language; it’s an engineering journal covering software architecture, performance, and low-level mechanics.

    What you’ll find here:

    • Deep dives into Go and Rust internals.
    • Memory Safety strategies and performance optimization.
    • Architectural patterns for scalable, “fearless” software.
    exit(0);

  • Golang in twenty minutes

    In this first post of the series “Golang in Twenty Minutes”, we will see the fundamentals of the Go language. I assume that the reader already knows at least one programming language.

    A variable can be declared in two ways:

    var name string
    name = "Bob"
    
    lastName := "Smith"

    Thus, we can declare a variable using the var keyword followed by a variable name and its type. The short form allows you to declare and assign a variable in a single step by setting its value; the variable then gets its type from the value assigned during initialization.

    Like variables, constants exist, but their value cannot be changed once assigned.

    const Pi float64 = 64
    const G = 9.18

    In this case, the keyword is const, followed by the constant name, the type, and the value. Alternatively, using the short form, we can omit the type, which is inferred from the initialization.

    (more…)
  • WaitGroup.Go() 

    At the moment, Go 1.26 is in RC, but before looking at the new features, it may be useful to review something that was introduced in Go 1.25.

    In this post, we look at WaitGroup.Go(). The purpose of this function is to create a goroutine and automatically increment the counter used by the WaitGroup to track when all goroutines have completed.

    Let’s see an example using what we had in version 1.24:

    package main
    
    import (
    	"fmt"
    	"sync"
    	"time"
    )
    
    func main() {
    	var wg sync.WaitGroup
    
    	for i := 0; i < 10; i++ {
    		wg.Add(1)
    		go func() {
    			defer wg.Done()
    			time.Sleep(1000 * time.Millisecond)
    			fmt.Printf("Goroutine %d \n", i)
    		}()
    	}
    	wg.Wait()
    	fmt.Println("All goroutines completed")
    }
    (more…)
  • Order map in Go

    As you may know, it’s not possible to order a map in Go (just like in any language where maps are implemented as hash maps). However, we can achieve the same result by working with the map’s keys.

    The approach is to extract the keys into a slice, sort them, and then retrieve the corresponding values from the map using the sorted keys.

    (more…)