Hello there! My name is [Jeyson Flores](https://github.com/JeysonFlores) and I 
am a Software Engineer that works mainly with the Python programming language. 
I have been taking a look at the Nim programming language for more than a year 
but I never had the time nor the idea to build something with it.

Last week I created the Energy project, a set of libraries that can be used to 
build reliable enterprise-level applications. The project does not have a 
specific field or topic to move around and I am still designing the majority of 
the libraries but is planned to have CLI utilities, field-specific math 
algorithms, SDK/API integrations of some Cloud providers, and networking. By 
delivering well-designed and reliable libraries the main objective of the 
Energy project is to provide solid foundations for enterprise-level 
applications. I would love to use Nim on a daily basis in my work(and I am sure 
many Nim users wish the same) but it's difficult to convince teams and 
technical leaders about the advantages of Nim. This project is an effort to 
make (at least) a small advancement in that regard.

The first library of this project to be released is **_measures_**. A library 
for measurement units with implicit conversions/comparisons/operations and 
handy definitions. It is kinda hard to explain the functionality so I will just 
drop a piece of code that can illustrate it better:
    
    
    import
      measures/[core, temperature]
    
    
    25.°C == 77.°F # true
    
    25.°C == 25.°F # false
    
    (20.°C + 41.°F) == 298.15.°K # true
    
    (12.5.°C * 2) == 77.°F # true
    
    
    Run

Kinda funky right? But these examples use just literals, what about variable 
data?
    
    
    import
      measures/[core, temperature]
    
    
    var someTemp = 25.°C
    
    someTemp.isOf(Celsius) # true
    someTemp.isOf(Farenheit) # false
    someTemp.isOf(Kelvin) # false
    
    someTemp.value # 25
    
    someTemp.getValueAs(Farenheit) # 77
    someTemp.getValueAs(Kelvin) # 298.15
    
    # Let's convert this temperature to farenheit
    someTemp.to(Farenheit)
    
    someTemp.isOf(Farenheit) # true
    
    someTemp.value # 77
    
    
    Run

"So... is it just for temperatures then?" \- No! At the moment of the 
publication of this post besides from temperatures, **_measures_** also 
supports: Angles
    
    
    import
      measures/[core, angle],
      std/math
    
    180.° == PI.rad # true
    
    # `~=` is the operator for almost equality
    check 80.° ~= 1.396263401595464.rad # true
    
    
    Run

and Information
    
    
    import
      measures/[core, information]
    
    1.kb == 0.001.mb # true
    1.gb == 1000.mb  # true
    1.tb == 1000.gb    # true
    
    
    Run

Measurement units for Length (Meters, Kilometers, Feet, Inches, etc.), 
Weight(Grams, Kilograms, Ounces, Pounds, etc.), and others are being worked on 
and they will be released in future versions of the library.

The idea behind **_measures_** and all the future libraries of the Energy 
project is to provide a developer-friendly and modular API to satisfy as many 
use cases as possible.

Thanks for reading.

Repo of the library: <https://github.com/energy-nim/measures>

Reply via email to