Skip to content

TrisTheKitten/Programming-Languages-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Programming-Languages-Project

Nim Programming Language – Project

  1. Overview

Nim is a statically-typed, compiled language that aims to combine the readability of Python with the performance of C/C++. 2. Origins

Early 2000s: Andreas Rumpf conceptualizes a language as readable as Python but as fast as C.

2008: First public release under the name "Nimrod."

2014: Renamed to "Nim." The language, its community, and tooling begin to mature.
  1. Key Strengths

    Speed & Portability: Nim compiles to C, C++, or JavaScript. This allows the final compiled code to achieve performance comparable to hand-written C++ in benchmarks.

    Powerful Macros: Compile-time Abstract Syntax Tree (AST) macros enable developers to build domain-specific mini-languages and reduce boilerplate code.

    Flexible Memory Management: Offers a choice between tracing garbage collection (GC), reference counting, or manual pointer management. Custom memory allocators are also supported.

    Multi-Paradigm with Async Support: Supports imperative, object-oriented (OO), and functional programming styles. Built-in async/await coroutines simplify asynchronous I/O operations, leading to leaner code.

  2. Main Weaknesses

    Smaller Library Ecosystem: There are fewer readily available third-party packages compared to more established languages, which might mean more "do-it-yourself" work.

    Steeper Learning Curve: Features like macros and mixed memory management modes require dedicated study. Documentation can also be sparse in certain advanced areas.

    Evolving Language: The language specification and compiler are still undergoing changes. This means some existing code might break between new releases.

  3. How Nim Works 5.1 Syntax in a Nutshell

    Uses Python-style indentation for code blocks, though optional {} braces are also supported.

    Variable declarations:

     var: mutable variables
    
     let: immutable variables
    
     const: compile-time constants
    

    Uniform Function Call Syntax (UFCS): Allows any free function to be called as if it were a method of its first argument (e.g., myString.len() can be used instead of len(myString)).

5.2 Compilation Pipeline

The typical compilation process follows these stages:

Parse

Semantic Check

Macro Expansion

Optimization

C Code Emission (or C++/JavaScript)

Backend Compilation (using a C/C++ compiler like GCC, Clang, or an Emscripten for JS)

5.3 Runtime Snapshot

Default Garbage Collector: Uses a deferred reference counting GC with cycle detection.

Manual Memory Management: Allows for manual memory control and custom allocators, particularly useful for performance-critical sections ("hot paths").

Zero-Cost Exceptions: Exceptions have no runtime overhead if they are not thrown.

Concurrency: Supports true OS-level threads for CPU-bound tasks and lightweight coroutines for asynchronous I/O operations.
  1. When to Pick Nim

Consider using Nim when your project requires:

C-level performance.

Clean, readable code.

A single codebase that can target native applications, command-line tools, and web browser (via JavaScript) without extensive rewrites.
  1. When to Skip Nim

Nim might not be the best choice for projects that:

Heavily rely on a vast ecosystem of third-party libraries.

Demand iron-clad long-term Application Binary Interface (ABI) stability.

Need to onboard many new developers quickly, especially if they are unfamiliar with Nim's more advanced concepts.
  1. Project Team Members

    Min Myint Moh Soe

    Hpone Pyae Khine

    Ahkar Min Oo

About

Programming Languages course project research paper on Nim

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published