Giter VIP home page Giter VIP logo

nimacros's Introduction

nimacros

Documentation for Nim Macros

This work assumes that the reader already knows how to program and is familiar with command line tools. Therefore, as far as programming goes, the only subject that the author discusses is macro designing. Below, you will learn how to build the documentation for Nim macros, by using pandoc. For the convenience of those who don't want to install pandoc, here is a link to the Portable Document Format (PDF) version of the file:

Documentation for Nim macros

If you have a snippet that can help with the understanding a concept that was not well explained in this tutorial, please send us your snippet. This is a collective work that depends on your collaboration.

Installation

The Nim programming language is very easy to install. Follow the instructions on the link below, and you cannot go wrong or even astray.

Documentation for Nim macros

Tutorial

The goal of this project is to prepare documentation on Nim macros. You will find two things in this repository. The first one is a Portable Document Format (PDF) file, where you can learn how to write macros in Nim. It is work in progress, therefore you will find many spelling mistakes, grammar errors and, what is worse, incomplete explanations. I hope that these shortcomings will disappear with time and hard work from my collaborators. The other things you will find here are short examples, that you can compile with the help of a Makefile. Let us suppose that you want to compile the rdwrt.nim source code file, that implements an emulator for an HP calculator. From the src folder, type the following command:

~/nim/nimacros/src master ×
› make APP=rdwrt
nim c -o:rdwrt.x -d:danger --hints:off --nimcache:lixo rdwrt.nim
CC: stdlib_formatfloat.nim
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: stdlib_parseutils.nim
CC: stdlib_strutils.nim
CC: stdlib_posix.nim
CC: stdlib_times.nim
CC: stdlib_os.nim
CC: rdwrt.nim

~/nim/nimacros/src master ×
› ./rdwrt.x
> 3 4 x 5 6 x +
42.0

You can also modify the nimdoc.md, which is written in the Markdown format. There is an application called pandoc that compiles Markdown to PDF. The compilation from the Markdown format to PDF is also achieved through a Makefile script, as shown below:

~/nim/nimacros master ×
› make D=nimdoc
pandoc -V geometry:margin=1in -V documentclass=report\
        chaps/*.md  nimdoc.md --syntax-definition\
        nimrod.xml -o nimdoc.pdf

Nim Language

The Nim programming language has a syntax that is similar to the one you will find in the Python programming langauge. This syntax is recognised as easy to learn, friendly, and therefore efficent to write code in. The main difference between Nim and Python is that Nim generates fast code with small runtime and heap consumption. The Python programming language is instead interpreted, so generally requires the Python runtime to be installed on a computer too, before the programer's code can be run. Nim code however compiles into a single binary file, and does not require any addtional Nim runtime to be installed on a computer, before that binary is exectuted. The complied Nim program usually runs many times faster that the equivilent Python program as well, which is always a nice benefit to have.

Macro is a tool that you can use for tailoring the language for the application. If the language is enriched with macros it can help model a problem well, so the developer will potentially find a solution without errors in less time.

nimacros's People

Contributors

femtoemacs avatar wiremoons avatar

Stargazers

Roman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.