文档章节

Ubuntu下nim language环境配置

卜库塔
 卜库塔
发布于 2015/02/22 13:51
字数 528
阅读 339
收藏 0

码上生花,ECharts 作品展示赛正式启动!>>>

Getting Started

Nim is a powerful statically typed language that allows the programmer expressiveness without compromising run-time performance. As a general purpose programming language, it gives the same sort of power and performance as C++, but in a nicer package and with even more powerful tools!

Note: The Nim compiler requires a C compiler to compile software. GCC is recommended on Linux and Clang on Mac.

Downloading from Git

To install Nim from git, ensure that you have gcc installed on Windows, Linux, and BSDs and clang on Mac. Afterwards, run the following series of commands to download and bootstrap Nim:

 $ git clone -b master git://github.com/Araq/Nimrod.git
 $ cd Nimrod
 $ git clone --depth 1 git://github.com/nimrod-code/csources
 $ cd csources
 $ sh build.sh
 $ cd ..
 $ bin/nim c koch
 $ ./koch boot -d:release

Once compiled, you may want to add the bin directory to your path for easy access.

Nimble

Nimble is a beta-grade package manager for the Nim programming language.

On Unix operating systems Nimble can be compiled and installed with two simple commands. After successfully grabbing the latest Nim compiler simply execute the following commands to clone nimble, compile it and then install it.

$ git clone https://github.com/nim-lang/nimble.git
$ cd nimble
$ nim c -r src/nimble install

After these steps nimble should be compiled and installed. You should then add ~/.nimble/bin to your$PATH. Updating nimble can then be done by executing 

$ nimble install nimble

.

Aporia

Aporia is an IDE for the Nim programming language. Aporia uses GTK as the default toolkit, and the gtksourceview for the text editor component.

Dependencies

  • GTK

  • GtkSourceView (libgtksourceview-2.0.so)

  • PCRE

Use your linux package manager to install the dependencies.

Compiling

To compile Aporia you need the latest version of the nim compiler, preferably the unstable release from github. Aporia sometimes relies on bug fixes which have not yet made it to a stable release.

You can build it by running :

$ nim c aporia

 or by using nimble :

$ nimble build

You can also quickly install it using nimble without the need to clone this repo yourself, just execute:

$ nimble install aporia@#head

Example

The code for a simple program is as follows:

import tables, strutils

var wordFrequencies = initCountTable[string]()

for line in stdin.lines:
  for word in line.split(", "):
    wordFrequencies.inc(word)

echo "The most frequent word is '", wordFrequencies.largest, "'"

Save this text as frequentword.nim. To compile and execute the program, the following command should be run with some input words :

$ nim c -r --verbosity:0 frequentword.nim
大黄, 小白, 大黄, 小白, 小白, 小白, 大黄
The most frequent word is '(key: 小白, val: 4)'

The command has several elements:

  • c is an alias for compile, which compiles the Nim sources into C and then invokes the C compiler on them

  • -r is an alias for --run, which runs the program

  • --verbosity:0 makes the compiler only output essential messages, since by default it also outputs some debugging messages. From now on, we assume that --verbosity:0 is set

  • ./frequentword.nim is the path to the source you want to compile


© 著作权归作者所有

卜库塔
粉丝 20
博文 2
码字总数 528
作品 0
郑州
私信 提问
加载中
请先登录后再评论。
配置指定使用tcc编译器编译nim程序

配置指定使用tcc编译器编译nim程序 1、前言 nim是什么? nim是一门静态编译型语言,语法类似python,nim的代码被翻译成C代码再被C编译器编译成可执行文件。因此nim的可执行文件比较小,性能应...

黑暗圣堂武士
2016/10/13
162
0
Unix Study之--AIX 6.1配置网络安装服务

Unix Study之--AIX 6.1配置网络安装服务 通过网络安装可以减轻管理员的维护负担,并可以批量部署AIX系统的安装。 一、配置网络安装服务器 1)Server端配置 # prtconf|more System Model: IBM...

客居天涯
2016/03/01
0
0
Ubuntu_Server版安装Gnome图形桌面

由于公司的服务器在安装Ubuntu12.10时候,默认是没有桌面,但由于某些原因,某些部门要用到桌面模式! 一、配置好Source源列表   详情可以参考:http://www.cnblogs.com/sbaicl/archive/20...

喵王不瞌睡
2015/01/04
132
0
ubuntu 修改语言环境

对于使用ubuntu server版的朋友,可能就要适应英文环境了,面对一个纯英文的文本界面吧!如果安装过程中选择了中文界面,则ubuntu会自动将安装够的系统语言配置为中文,但是没有安装汉字系统...

JohnSuesan
2017/04/20
0
0
eclipse的C/C++开发搭建

环境 宿主机:ubuntu 16.04 交叉编译:gcc-linaro-4.9-2014.11 ubuntu自带源 eclipse 安装(想使用新版直接跳过) 安装eclipse sudo apt-get install eclipse-platform 安装C/C++开发插件 su...

osc_c10h48oh
2019/07/31
1
0

没有更多内容

加载失败,请刷新页面

加载更多

解决Cannot download "https://github.com/sass/node-sass/releases/download/binding.nod的问题

输入命令解决即可 npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

千年典韦
9分钟前
6
0
测试jar 是否完整有错

cd WEB-INF/lib/for j in *.jar; do echo $j; jar tvf $j > /dev/null ; echo $j done; done

xiaodong16
14分钟前
19
0
ats02.

https://xdays.me/proxy%E6%9C%8D%E5%8A%A1%E5%99%A8-trafficserver%E5%9F%BA%E7%A1%80/ apache traffic server 简称ats 入坑(一)开始使用...

MtrS
14分钟前
11
0
Elasticsearch如何查询使用JSON字符串的DSL

背景 Java处理ES查询逻辑,有一种情况是用户从其他地方粘贴或者手动输入的JSON字符串的DSL语句;这个时候就没法使用QueryBuilder来构建所需要的SearchSource。查了查发现有个Wrapper的方式可...

叫我哀木涕
今天
19
0
JDBC:ResultSet Types

ResultSet Types 用于确定ResultSet的某些特征和功能。 ResultSet.TYPE_FORWARD_ONLY 只能调用 next,不能调用 previous 。否则报错 ResultSet.TYPE_SCROLL_INSENSITIVE 能调用 next/previou...

mrsuperli
昨天
7
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部