Giter Site home page Giter Site logo

rates's Introduction

Simple Utility to download exchange rates from openexchangerates.org and save them to CSV file

Downloads rates for the last business day of the month, for each month year to date and previous year. Saves them to a CSV file in the same directory as executable.

Versions in Python, Go and Rust.

Wrote them in that exact order:

  • Very quickly got it done in Python running as script. Pulled quite a few hairs to get it running smoothly as a frozen executable in somebody else's computer.
  • Refreshingly simple to code it in Go despite being new to the language. Took the same time to get it done as in Python.
  • Straightforward implementation in Rust although had to pay deeper attention to ownership details. Took twice as long to code compared to Go and Python.

Executable sizes:

Python 30.4 MB (pyinstaller frozen executable)

Go 7.3 MB

Rust 3.6 MB

Comments on Python version:

  • Uses pandas library. It needs to be installed first. Can be done with pip like this:

    pip install --upgrade pip

    pip install pandas

  • Can be run as an interpreted script or as an executable created with pyinstaller. That is why the code checks for if it is being run frozen (as part of executable) or not, to properly check where to save CSV.

  • Pyinstaller can be installed with:

    pip install pyinstaller

  • Executable can be created easily with:

    pyinstaller rates.py --name rates --onefile

  • If running frozen (as part of executable) needs ssl & certifi to be able to access internet due to permissions in other computers. Hope this is the right way to solve this. Not 100% sure.

Comments on Go version:

  • It was refreshing to get an executable and it to work flawlessly in any computer with no fuss unlike Python (when the recipient is not a developer and does not have everything setup as we do).

  • Instead of relying on libraries like I did in the Python version with pandas, in Go we calculated by hand the dates of the monthly last business days, and the transposing of the data (columns for rows).

  • Language of choice to quickly hack something together because of simplicity.

Comments on Rust version:

  • Same approach as in Go. The feeling of "if it compiles, it works - no surprises" is awesome.

  • It took me twice as long to code as the Go version despite knowing exactly what I wanted to do.

Example: the transpose function was originally written with &str instead of Strings, but after downloading the data got into ownership/borrowing issues, so I had to solve that by migrating a few functions to use Strings instead of &str in a domino effect.

  • Definitely my favorite language but it takes some time to iron everything out. It is very efficient in terms of size and speed. The feeling of its executable being bulletproof is great.

rates's People

Contributors

glella avatar

Watchers

 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.