nim-wiki/GSoC-2015-Ideas.md

329 lines
16 KiB
Markdown
Raw Normal View History

2015-01-31 15:11:20 +00:00
# Introduction
2015-02-11 17:45:25 +00:00
Below is a list of project ideas for [GSoC 2015](https://www.google-melange.com/gsoc/homepage/google/gsoc2015). These projects require familiarity with the Nim programming language so it is absolutely essential that you become familiar with Nim ahead of time.
2015-01-31 15:11:20 +00:00
2015-02-03 08:37:08 +00:00
[Nim](http://nim-lang.org) is a statically typed programming language which compiles primarily to C and has an excellent performance/productivity ratio. Nim's design focuses on efficiency, expressiveness, elegance.
Areas of the project you may wish to work on include the [Nim compiler](#wiki-nim-compiler) which is itself written in Nim, Nim's [standard library](#wiki-standard-library) and/or the [tools and infrastructure](#wiki-tools--infrastructure) of Nim which includes the Nim build farm (Nimbuild) and the Nim package manager (nimble).
2015-01-31 15:11:20 +00:00
To get started you will need to clone the Nim repository and then subsequently bootstrap the compiler, instructions for doing this are located [here](https://github.com/Araq/Nim#compiling). You can then move onto the [tutorial](http://nim-lang.org/tut1.html) and read through the [other documentation](http://nim-lang.org/documentation.html) as well.
2015-02-11 13:00:07 +00:00
We encourage you to join the #nim IRC channel on Freenode to discuss these projects with the community and our mentors. The Nim [Forum](http://forum.nim-lang.org) and [mailing list](http://www.freelists.org/list/nim-dev) are also available. Because communication is a big part of open source development you are expected to get in touch with us before making your application, failure to do so will put your application at a great disadvantage.
2015-01-31 15:11:20 +00:00
The following list of projects are just some ideas that the community and the developers have come up with. You will be contributing to a programming language so there is a lot of flexibility when it comes to the projects that you can work on, this list is certainly not comprehensive so we are happy to hear any suggestions that you may have.
# Projects
## Nim Compiler
2015-02-11 12:46:28 +00:00
#### Create a new REPL for Nim using TinyCC
**Desirable skills:** Experience with C and with REPLs in other languages (Python, GHCi, ...)
**Description:**
2015-02-11 17:45:25 +00:00
A REPL (read-eval-print loop) can be a valuable tool while exploring a
2015-02-11 12:46:28 +00:00
language, new libraries and during regular development, as it allows faster
2015-02-11 17:45:25 +00:00
feedback. Nim provides a simple REPL (nim i) based on its compile-time virtual
machine, but it is not adequate. For example importing C based code does not
work.
2015-02-11 12:46:28 +00:00
An alternative approach is the development of a new REPL that actually compiles
2015-02-11 13:02:32 +00:00
the entered code to C and then uses TinyCC to immediately execute this code.
2015-02-11 12:46:28 +00:00
TinyCC is well suited for this as it can execute C code very quickly.
**Tasks:**
* Add a simple TinyCC based REPL for Nim.
2015-02-11 19:58:43 +00:00
* Ensure that global state (that is: state stored in global variables) is kept during recompilations of the generated C code. This means the C codegen needs to emit some kind of getters and setters for global variable access.
2015-02-11 17:45:25 +00:00
* Make sure common Nim code works as well as importing C based libraries
* Investigate how to reduce the overhead to improve performance
2015-02-11 12:46:28 +00:00
**Difficulty:** Medium to Hard
**Mentor:** def- ([@def-](http://github.com/def-)), Araq ([@Araq](https://github.com/Araq))
___
#### Make Nim a viable research platform for Garbage Collection algorithms
**Desirable skills:** Familiarity with the various GC approaches and algorithms, knowledge of the compiler codegen modules.
**Description:**
Most of the popular garbage collected languages of today require a separately distributed run-time environment, providing only a predetermined set of garbage collection algorithms. This leaves little room for experimentation with various approaches and condemns GC researchers to develop and test their algorithms on specialized platforms such as the [Jikes RVM](http://jikesrvm.org/) that have limited practical significance.
In contrast, in Nim, the garbage collection algorithm is chosen at compile-time and embedded in the resulting stand-alone native executable. This enables the users to pick a GC algorithm that's most suitable to their project and allows for a proliferation of GC algorithms, developed by independent groups and individuals, without requiring any modifications to be made to the standard Nim distribution.
The Nim code generator and type system can provide various GC roots marking strategies, various kinds of write/read barriers and all necessary static type information (e.g. static cycle analysis) and a GC implementation will consist only of a single Nim module (supplied as a command-line parameter) that
provides configuration for the code generator and implements the logic of the garbage collection algorithm. This module will be compiled as C code with the rest of the program and it could be easily debugged using standard C/C++ debugging and profiling tools.
**Tasks:**
* Add support for precise stack marking
* Add support for read barriers and polish the support for Levanoni/Petrank style of write barriers
* Implement the infrastructure for picking a user-supplied GC module
**Bonus points:** Implement simple forms of variety of GC algorithms as a proof-of-concept
**Difficulty:** Medium to Hard
2015-02-09 16:51:09 +00:00
**Mentor:** zahary ([@zah](http://github.com/zah))
2015-02-03 19:13:02 +00:00
___
#### Add a code generator for OpenCL
**Desirable skills:** Good OpenCL knowledge, knowledge of the compiler internals, basics of type theory.
**Description:**
2015-02-11 17:45:25 +00:00
Nim currently supports C, C++, Objective C and JavaScript code generation. However to run efficiently on GPUs an OpenCL backend is required. The easy way to do this is to copy OpenCL's low level mode of operation with its different ``private``, ``local``, ``global`` storage and simply provide a idiomatic syntax for OpenCL. So apart from syntactic sugar users get all of Nim's meta programming advantages plus good integration into Nim's infrastructure.
2015-02-03 19:13:02 +00:00
2015-02-03 23:43:47 +00:00
The vision is a ``gpu`` pragma that means a proc and all of its dependencies are translated into OpenCL instead of C but can be invoked from ordinary Nim code that is translated to C. The ``gpu`` code generator is allowed to only translate a subset of Nim, in particular things like function pointers that are not supported by OpenCL do not have to be supported. The compiler should produce a clean error message for unsupported features.
2015-02-03 19:13:02 +00:00
**Expected Result:** The GPU code generator works on a selected set of examples/test cases.
**Tasks:**
* Add support for new pointer types in the compiler like ``global``, ``private``.
* Add support for work groupss.
* Add support for the ``gpu`` pragma that translates to the OpenCL, version 2: https://www.khronos.org/registry/cl/sdk/2.0/docs/man/xhtml/
**Bonus points:** Support version 1.2 of the OpenCL specification: https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/. This should be significantly harder as version 1.2 doesn't support a shared address space with the host environment.
**Difficulty:** Hard
**Mentor:** Araq ([@Araq](http://github.com/Araq))
___
#### Improve the JavaScript Backend
**Desirable skills:** Familiarity with JavaScript.
**Description:**
Nim has a JavaScript backend, which allows one to write the backend as well as
frontend in Nim. The JS backend is simple, so this is a good way to get started
with learning about Nim compiler internals.
**Tasks:**
2015-02-11 13:06:43 +00:00
* Fix the remaining JavaScript backend bugs.
* Port relevant parts of the standard library to JS.
* Make the code generator emit "source maps" for better debugging support. The current debugging support is done by emitting stack tracing instructions which slow things down and are not standard.
* Make JS test cases.
**Bonus points:**
2015-02-11 17:45:25 +00:00
* Speed up the JavaScript backend by targetting `asm.js`
2015-02-14 18:05:42 +00:00
* Write a library for communication between client-side Nim (compiled to JavaScript) and server-side Nim (compiled to C).
**Difficulty:** Medium
2015-02-09 16:51:09 +00:00
**Mentor:** Araq ([@Araq](https://github.com/Araq)), def- ([@def-](http://github.com/def-))
2015-02-11 21:12:50 +00:00
___
2015-02-11 20:55:16 +00:00
#### A strong theoretical foundation for Nim's parallel statement
**Description:**
Nim uses a fresh idea to model fork&join parallelism via its ``parallel``
builtin that performs a range of additional checks at compile-time
like array bounds checking or the so called "disjoint check". The disjoint
check ensures the datasets are disjoint; that means every processed element is
only accessed by one worker. This way no locking is required and yet (memory)
safety is guaranteed.
Unfortunately, how exactly this checking is performed is not
yet documented: It's done in a pretty adhoc fashion that mostly uses
the transitivity of inequality relations and some simple control flow analysis.
However, in the context of *optimization* and code generation there has been
2015-02-13 12:50:55 +00:00
lots of progress in commercial compilers in the form of auto vectorization.
2015-02-11 20:55:16 +00:00
One such framework that enables auto vectorization is the polyhedral model.
The polyhedral model deals with iteration spaces and serves to parallelize loop
programs automatically by applying algebraic transformations. As it is a
traditional optimization pass in a compiler it has to prove these
transformations are correct. This is remarkably similar to the task of proving
the code written down by a human being correct. So the idea of this task is to
leverage the polyhedral model for program verification as opposed to program
optimization.
See these papers for an introduction of the polyhedral model:
http://www.cs.ucla.edu/~pouchet/doc/cc-article.10.pdf
http://icps.u-strasbg.fr/~bastoul/research/papers/Bas04-PACT.pdf
Here is a sketch of a possible implementation:
* Implement an AST to polyhedral model transformation.
* Implement a semantic checking pass that works on the polyhedral model and
proves array bounds correct as well as that the datasets are disjoint.
* In addition to that it needs to be proven that the code is free
of "write after write" or "write after read" etc. conflicts.
**Desirable skills**: Knowledge of optimizers.
**Difficulty:** Hard
**Mentor:** Araq ([@Araq](https://github.com/Araq))
2015-02-03 21:46:23 +00:00
## Standard Library
#### Enhance and expand standard library documentation
**Desirable skills:** Basic writing and documentation skills, webdesign and infrastructure setup.
**Description**:
The [Nim documentation](http://nim-lang.org/lib.html) is generally good but it
2015-02-11 12:46:28 +00:00
needs to be made more accessible and lacks helpful code examples. Writing
documentation is also a great way to get a better understanding of Nim. [Read
the docs](https://readthedocs.org/) is a good example of attractive as well as
readable documentation, it is something we would be after in this project.
Additionally the documentation should be generated more automatically. The
documentation of each nimble package should automatically be available online,
similar to Hackage. Upon installation of a library with nimble, its
documentation should be installed on the system as well.
**Tasks:**
* Ensure that documentation exists for all public methods and modules.
* Add code examples to all modules and to all procedures (where appropriate).
* Add search capabilities to the online documentation.
* Improve the website design and usability
* Add cross-linking capabilities in nim doc
* Make nimble build and install the documentation locally so you have
docs of all your installed libraries
2015-02-13 12:50:55 +00:00
* Automatically create online documentation of each nimble package
**Bonus Points:**
* Implement testing of the examples in the documentation into the ``testament`` test suite.
2015-02-11 17:45:25 +00:00
**Difficulty:** Easy to Medium
**Mentor:** def- ([@def-](http://github.com/def-))
___
2015-02-11 12:46:28 +00:00
#### Xpath like support for macros
2015-02-11 17:45:25 +00:00
**Desirable skills:**
**Description:**
2015-02-11 12:46:28 +00:00
TODO: Fill out
2015-02-11 17:45:25 +00:00
**Expected Result:**
**Difficulty:** ...
2015-02-11 12:46:28 +00:00
**Mentor:** Araq ([@Araq](http://github.com/Araq))
___
#### MPI support
Message Passing Interface (MPI) is a portable system for writing highly
2015-02-13 12:50:55 +00:00
parallel programs. Nim, with its excellent performance/productivity ratio, would
make a great language for this use.
**Tasks**:
2015-02-11 17:45:25 +00:00
* Create a low level wrapper of a C library for the MPI standard using c2nim
* Write a high level abstraction library for comfortable MPI in Nim
**Difficulty:** Medium
**Mentor:** def- ([@def-](http://github.com/def-))
2015-02-03 21:46:23 +00:00
## Tools & Infrastructure
#### nimfmt: Automatically format Nim code
Gofmt is often cited as one of the major points for the Go programming
2015-02-13 12:50:55 +00:00
language. It completely eliminates the need to manually adhere to style
formatting, by automatically converting Go code into a consistent style.
Something similar would be nice to have in Nim, where we have additional
2015-02-13 12:50:55 +00:00
freedoms, like case insensitivity, that should be handled in a consistent way
for big projects.
**Tasks**:
* Write a `nimfmt` tool
2015-02-11 12:49:00 +00:00
**Difficulty:** Medium
2015-02-09 16:51:09 +00:00
**Mentor:** Araq ([@Araq](https://github.com/Araq)), def- ([@def-](http://github.com/def-))
___
#### c2nim: Improve the automation of low-level C bindings
**Desirable skills:** Knowledge of C
**Description**:
Nim's c2nim tool helps create nim bindings for C libraries. However, c2nim does not parse the whole C language, and is not currently supposed to import whole APIs into nim mechanically, but rather to serve as a starting point for manual definition of interfaces to C libraries. c2nim is particularly effective in dealing with C's preprocessor macros, but is
not currently capable of parsing many C header files.
Make c2nim accept more C declarations than it currently does, and produce corresponding Nim declarations. This can be done either by directly filling-in the missing capabilities, or by interfacing it with a mature tool for parsing C code, such as LLVM's CLang or the GCC-XML tool. If one of these tools is used, then it is expected that it would not suffice by itself, but rather augment the current c2nim parser, since these tools have their own limitations. A possible implementation might pass
the header file once through gcc-xml to parse C declarations, and would use the current c2nim parser on lines that start with '#' to parse preprocessor definitions. c2nim would then process the parsed headers and produce constants, types, macros and proc declarations similar to those that it produces now.
C comments should be converted into nim documentation where appropriate.
Although c2nim currently converts function implementations (and not only declarations), this functionality is outside the scope of this task.
**Tasks**:
Depending on the chosen implementation technique, the tasks would be either:
* detect individual deficiencies in c2nim support for .h files and fix them
or:
* interface with a feature-complete parser for C, such as that of GCC or CLANG.
* refactor c2nim so that it can generate declarations from the parsed output of the above parser, rather than directly from .h files as it currently does.
* combine the output from the previous task with the declarations that c2nim produces for preprocessor macros.
**Difficulty:** Medium
2015-02-09 16:51:09 +00:00
**Mentor:** Araq ([@Araq](https://github.com/Araq)), def- ([@def-](http://github.com/def-))
2015-02-11 12:46:28 +00:00
___
2015-02-11 20:05:50 +00:00
#### Implement re2nim, a lexer generator for Nim
2015-02-11 12:46:28 +00:00
**Description:**
2015-02-11 13:00:07 +00:00
Lexer generators are useful tools for writing all sorts of parsers. Currently Nim lacks a native Lexer generators. This project involves the implementation of a lexer generator. It should be modelled after [re2c](http://re2c.org/) or alternatively it can be based on the wide number of existing lexer generators such as Flex.
2015-02-11 12:46:28 +00:00
Here is a sketch of a possible implementation:
2015-02-11 12:47:50 +00:00
* Parse regular expressions into an NFA and ensure the attached Nim actions are kept around through the next different passes.
2015-02-11 12:46:28 +00:00
* Translate the NFA to an DFA: http://web.cecs.pdx.edu/~harry/compilers/slides/LexicalPart3.pdf
* Minimize the DFA with Hopcroft's algorithm: http://en.wikipedia.org/wiki/DFA_minimization
2015-02-11 12:47:50 +00:00
* Translate the DFA into Nim code and attach the actions.
2015-02-11 12:46:28 +00:00
**Desirable skills**: Knowledge of lexer generators. How to translate regexes into DFAs and how to optimize the resulting automatons.
**Difficulty:** Medium to Hard
**Mentor:** zahary ([@zah](http://github.com/zah))
___
2015-02-11 12:47:50 +00:00
#### Implement a Nim backend for the Ragel state machine generator
2015-02-11 12:46:28 +00:00
**Description:**
2015-02-11 12:47:50 +00:00
[Ragel](http://www.complang.org/ragel/) is a "finite-state machine compiler with output support for C, C++, C#, Objective-C, D, Java, OCaml, Go, and Ruby source code." This project involves the implementation of a Nim backend for Ragel. This can be based on the large number of pre-existing backends listed previously.
2015-02-11 12:46:28 +00:00
**Desirable skills**: Knowledge of Ragel's internals.
2015-02-11 17:45:25 +00:00
**Difficulty:** Easy
2015-02-11 12:46:28 +00:00
2015-02-11 17:45:25 +00:00
**Mentor:** def- ([@def-](http://github.com/def-))
2015-02-11 12:46:28 +00:00
2015-01-31 15:11:20 +00:00
# Project spec
Please add your project ideas in the following format.
## Sub-project
#### Title
**Desirable skills:**
**Description:**
**Expected Result:**
**Difficulty:** ...
2015-02-11 19:58:43 +00:00
**Mentor:** Mentor name ([@MentorName](http://github.com/MentorName))