Gem Changeblog

The story behind Gem's evolution and design decisions

Version 1.3.0 - Time and Precision

Released: May 30th 2025

Mastering Time and Fixing the Fundamentals

Version 1.3.0 brings essential time-handling capabilities to Gem while addressing critical scoping issues that were affecting variable resolution. This release focuses on two key areas: providing developers with robust time operations and ensuring the language's core scoping mechanisms work reliably.

The new Time module enables everything from simple delays to sophisticated performance monitoring, while our scoping fixes ensure that variables behave predictably across all contexts. Together, these improvements make Gem more reliable and capable for real-world applications.

We'd like to give a special thanks to @DevYatsu for their excellent work on the Time module!

What Changed

Time Module - Comprehensive Time Operations

The new Time standard library module provides essential time-related functionality for modern applications:

require "time";

# Get current timestamp
puts "Current time: #{Time.now()}";

# Sleep operations with millisecond precision
puts "Starting operation...";
Time.sleep(2000);  # Sleep for 2 seconds
puts "Operation completed";

# Function timing for performance monitoring
def heavyWork() void
    Time.sleep(1500);  # Simulate 1.5 seconds of work
    puts "Heavy work completed";
end

# Measure execution time
Time.measure(heavyWork);

# Timeout operations for reliability
def quickTask() void
    puts "Quick task executed";
end

def slowTask() void
    Time.sleep(5000);  # 5 second operation
    puts "Slow task completed";
end

# Run with timeout protection
Time.timeout(quickTask, 2);  # Should complete
Time.timeout(slowTask, 2);   # May timeout

Critical Scoping Bug Fixes

We've resolved several important scoping issues that were causing variable resolution problems:

# Variable scoping now works correctly in all contexts
def outerFunction() void
    string message = "Hello from outer";
    
    def innerFunction() void
        # Can now properly access outer scope variables
        puts message;  # Works correctly
        
        string localMessage = "Hello from inner";
        puts localMessage;  # Local scope works too
    end
    
    innerFunction();
end

# Class method scoping improvements
class Calculator
    def init() void
        this.value = 0;
    end
    
    def calculate() void
        # Method-local variables now scope correctly
        int localResult = this.value * 2;
        this.value = localResult;  # 'this' resolution fixed
    end
end

Technical Implementation

Time Module Architecture

The Time module is implemented using system-level time functions for accuracy and reliability:

  • High-precision timestamps - Floating-point timestamps provide microsecond accuracy
  • Cross-platform sleep - Millisecond-precision sleep works on all supported platforms
  • Function timing - Accurate measurement of function execution duration
  • Timeout handling - Attempt to limit function execution time (implementation-dependent)

Scoping System Improvements

The scoping fixes address fundamental issues in variable resolution:

  • Lexical scoping - Variables are now correctly resolved based on lexical scope
  • Closure capture - Inner functions properly capture outer scope variables
  • Method resolution - Class method variable lookup works reliably
  • Scope chain traversal - Proper traversal of nested scopes during variable lookup

Design Philosophy

Version 1.3.0 reflects our commitment to both expanding Gem's capabilities and ensuring rock-solid fundamentals:

  • Essential Functionality - Time operations are fundamental to modern applications
  • Reliability First - Scoping bugs undermine developer confidence and must be fixed
  • Practical Utility - Time module enables performance monitoring and timeout handling
  • Consistent Behavior - Variable scoping should be predictable and intuitive

Known Limitations

While the Time module provides essential functionality, there are some current limitations:

  • Duration Class - Advanced duration arithmetic is not yet available
  • Time.elapsed() - Has type compatibility issues and is not recommended
  • Timeout Reliability - Timeout interruption may not work in all scenarios
  • Return Value Handling - Some functions return values that are difficult to access

Looking Forward

The Time module foundation opens possibilities for future enhancements like date/time parsing, timezone handling, and more sophisticated timing utilities. It also lays the groundwork for more advanced features like async/await, cryptography, random number generation, and more. The scoping fixes ensure that Gem's core language mechanics are solid as we continue to build more advanced features.

Version 1.2.0 - The Connectivity Update

Released: May 25th 2025

Building Bridges to the Modern Web

Version 1.2.0 represents a major leap forward in Gem's capabilities, transforming it from just a simple toy language into a versatile tool for modern application development. This release was driven by a simple realization: programming languages need to speak HTTP fluently and handle data structures naturally.

The centerpiece of this release is our comprehensive HTTP module, but that's just the beginning. We've also introduced hash data structures, enhanced the developer experience with REPL improvements, added flexible mutability syntax, and implemented intelligent type coercion - all while maintaining Gem's core commitment to safety and performance.

What Changed

HTTP Module - First-Class Web Support

The new HTTP module brings production-ready web request capabilities to Gem. No more external dependencies or complex setup - just clean, type-safe HTTP operations:

require "http";

# Simple GET request with full response handling
hash response = Http.get("https://api.example.com/users");
bool success = response["success"] as bool;
int status = response["status"] as int;
string body = response["body"] as string;

# POST with custom headers and data
hash headers = {};
headers["Authorization"] = "Bearer token123";
headers["Content-Type"] = "application/json";

hash userData = {};
userData["name"] = "Alice";
userData["email"] = "alice@example.com";

hash result = Http.post("https://api.example.com/users", userData, headers);

Hash Data Structures

Hashes (key-value maps) are now a first-class data type in Gem, enabling natural data manipulation and API response handling:

# Create and manipulate hashes
hash user = {};
user["name"] = "Bob";
user["age"] = "30";
user["active"] = "true";

# Type-safe value extraction
string name = user["name"] as string;
int age = user["age"] as int;
bool isActive = user["active"] as bool;

Enhanced Mutability with `mut` Keyword

Developers can now choose between `mut` and `!` for mutable variables, providing flexibility while maintaining clarity:

# Both syntaxes work - choose your preference
mut string name1 = "Alice";
string! name2 = "Bob";

# Both can be modified
name1 = "Alice Updated";
name2 = "Bob Updated";

Type Coercion System

Intelligent type coercion makes working with different data types more natural while preserving safety:

# Automatic string conversion
string numberStr = 42 as string;        # "42"
string boolStr = true as string;        # "true"

# Safe numeric conversion
int value = "123" as int;               # 123
int decimal = "3.14159" as int;         # 3

# Ruby-style truthiness
bool isEmpty = "" as bool;              # true (non-nil is truthy)
bool hasValue = "hello" as bool;        # true
bool isNil = nil as bool;               # false

REPL Improvements

The interactive experience got major upgrades:

  • Line Navigation - Arrow keys for command history and editing
  • Post-Script REPL - New `--repl` flag drops into interactive mode after script execution
  • Version Information - `--version` flag shows detailed version info

Technical Implementation

HTTP Module Architecture

The HTTP module is built using the curl command-line tool via shell execution for maximum compatibility and simplicity. Each request constructs and executes a curl command with proper argument escaping and security measures. The response includes:

  • success - Boolean indicating request success
  • status - HTTP status code (0 for network errors)
  • body - Response body as string
  • response_time - Request duration in seconds

Hash Implementation

Hashes are implemented as dynamic hash tables with string keys and variant values. The type system ensures safe value extraction through explicit casting, preventing runtime type errors while maintaining flexibility.

Type Coercion Safety

Our type coercion system is designed to be predictable and safe. All coercions are explicit (using `as` keyword) and follow well-defined rules. Invalid coercions result in compile-time errors rather than runtime surprises.

Design Philosophy

Version 1.2.0 embodies Gem's evolution from a simple toy language to a versatile tool for modern development. We've maintained our core principles while embracing the realities of contemporary programming:

  • Safety First - All new features maintain Gem's safety guarantees
  • Developer Experience - REPL improvements and flexible syntax reduce friction
  • Real-World Utility - HTTP and hash support enable practical applications
  • Explicit Over Implicit - Type coercion requires explicit casting

Looking Forward

The connectivity foundation laid in 1.2.0 opens doors for future enhancements like async/await, WebSocket support, and advanced data processing capabilities. This release proves that safety and modern convenience can coexist beautifully.

Version 1.1.0 - Optional Semicolons

Released: May 25th 2025

The Twitter Moment

Sometimes the best features come from unexpected places. Version 1.1.0 was born from a simple Twitter interaction between @Dishpit and @null_enigma regarding semicolon preferences.

The brief exchange highlighted something important: developers should have the freedom to choose their preferred syntax style (within reason). Some love the explicit nature of semicolons, while others prefer the clean look of newline-terminated statements. Why force a choice when you can support both?

What Changed

Gem now supports optional semicolons. You can write code in whatever style feels natural:

# Modern style - clean and minimal
string name = "Alice"
int age = 30
puts "Hello, " + name

# Traditional style - explicit and familiar  
string name = "Alice";
int age = 30;
puts "Hello, " + name;

# Mixed style - use what feels right
string name = "Alice"
int age = 30;
puts "Hello, " + name

Technical Implementation

This wasn't just a simple parser change. We carefully implemented newline handling to ensure:

  • Backward compatibility - All existing Gem code continues to work
  • Clear semantics - No ambiguity about statement boundaries
  • Inline statements - Semicolons are still required for multiple statements on one line
  • Consistent behavior - The same rules apply everywhere in the language

Design Philosophy

This change reflects Gem's core philosophy: developer happiness without sacrificing safety. We believe that syntax should serve the programmer, not the other way around. By making semicolons optional, we're giving developers the freedom to express themselves while maintaining all of Gem's safety guarantees.

Version 1.0.0 - The Beginning

Released: May 24th 2025

The Vision

Gem 1.0.0 marks the initial release of our vision for a programming language that combines safety, performance, and developer joy. We set out to create something that felt both familiar and fresh - a language that learned from the successes and mistakes of its predecessors.

Core Features

The initial release includes all the fundamental features that make Gem special:

  • Static Type System - Catch errors at compile time, not runtime
  • Memory Safety - No null pointer dereferences, no buffer overflows
  • Immutability by Default - Variables are immutable unless explicitly marked mutable
  • Null Safety - Nullable types prevent the billion-dollar mistake
  • First-Class Functions - Functions as values with full type checking
  • Object-Oriented Programming - Classes, inheritance, and encapsulation
  • Module System - Organize code with a clean import/export system

Design Principles

From day one, Gem is being built around these core principles:

# Safety First - prevent common errors
string? name = getName()  # Explicit nullability
if (name != nil) {
    puts "Hello, " + name  # Safe to use
}

# Explicit is Better - clear intent
string! mutableText = "Hello"  # Clearly mutable
mutableText = "World"          # Allowed

# Immutable by Default - safer code
string greeting = "Hello"
# greeting = "Hi"  # Error: immutable variable

The Journey Ahead

Version 1.0.0 is just the beginning. We know that a programming language is never truly "finished" - it evolves with its community, adapts to new needs, and grows through feedback and real-world usage.

What's Next?

Gem will continue to evolve based on community feedback and real-world usage. We're always working on new features, performance improvements, and developer experience enhancements.

Have ideas for Gem's future? Join the conversation on GitHub or follow us on social media. The best programming languages are built by their communities, and we'd love to have you be part of Gem's story.