index 日本語

Internet of Tomohiro

If you found my articles interesting or useful, please donate using following links:


Use Nim on Google Colaboratory

Article about Google Colaboratory

You can use Nim language on Google Colaboratory by using Nim4Colab extension.

How to use

Copy and paste following code to a cell on Google Colaboratory and run. This code download, install and load Nim4Colab extension.

!pip install git+https://github.com/demotomohiro/nim4colab.git
%load_ext nim4colab

Then, you can run Nim code by writing your code under %%nimc.

%%nimc
echo NimVersion

Sample Codes

Basic

Make PNG image

Make animation PNG using EGL & OpenGL

Show line numbers

Nim prints error messages with line numbers. This is how to show line numbers on editor so that you can find a line that cause the error. In menu, click "Tools" -> "Preferences..." and check "Show line numbers".

How it work

Nim4Colab downloads and installs latest Nim from Nim nightlies when first time one of Nim4Colab command is called. User code is saved to ~/code.nim file and nim command is called.

If you want to use Nim on Google Colaboratory's virtual machine via SSH or VNC:

How to access Google Colaboratory using ssh

How to run OpenGL desktop programs on Google Colaboratory


by Tomohiro

index