文档章节

Ubuntu下nim language环境配置

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

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


© 著作权归作者所有

共有 人打赏支持
卜库塔
粉丝 21
博文 2
码字总数 528
作品 0
郑州
配置指定使用tcc编译器编译nim程序

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

黑暗圣堂武士
2016/10/13
68
0
Nim 0.10.2 发布,命令式编程语言

Nimrod (已改名为Nim)是一个新型的静态类型、命令式编程语言,支持过程式、函数式、面向对象和泛型编程风格而保持简单和高效。Nimrod从Lisp继承来的一个特殊特性--抽象语法树(AST)作为语言规...

oschina
2014/12/30
2.5K
2
Ubuntu_Server版安装Gnome图形桌面

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

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

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

JohnSuesan
2017/04/20
0
0
使用 xCAT 简化 AIX 集群的部署和管理

xCAT 简介 xCAT (Extreme Cloud Administration Toolkit) 是一个开源的可扩展的高级集群管理和配置工具,允许使用者通过一个单点控制和管理一个集群系统。xCAT 最先是为 IBM xSeries 系列 Li...

红薯
2010/09/06
2.1K
0

没有更多内容

加载失败,请刷新页面

加载更多

CentOS7防火墙firewalld操作

firewalld Linux上新用的防火墙软件,跟iptables差不多的工具。 firewall-cmd 是 firewalld 的字符界面管理工具,firewalld是CentOS7的一大特性,最大的好处有两个:支持动态更新,不用重启服...

dingdayu
今天
1
0
关于组件化的最初步

一个工程可能会有多个版本,有国际版、国内版、还有针对各种不同的渠道化的打包版本、这个属于我们日常经常见到的打包差异化版本需求。 而对于工程的开发,比如以前的公司,分成了有三大块业...

DannyCoder
今天
2
0
Spring的Resttemplate发送带header的post请求

private HttpHeaders getJsonHeader() { HttpHeaders headers = new HttpHeaders(); MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); ......

qiang123
昨天
3
0
Spring Cloud Gateway 之 Only one connection receive subscriber allowed

都说Spring Cloud Gateway好,我也来试试,可是配置了总是报下面这个错误: java.lang.IllegalStateException: Only one connection receive subscriber allowed. 困扰了我几天的问题,原来...

ThinkGem
昨天
27
0
学习设计模式——观察者模式

1. 认识观察者模式 1. 定义:定义对象之间一种一对多的依赖关系,当一个对象状态发生变化时,依赖该对象的其他对象都会得到通知并进行相应的变化。 2. 组织结构: Subject:目标对象类,会被...

江左煤郎
昨天
4
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部