Difference between revisions of "GSOC 2014 Ideas"
m (→Compiler Improvements for D) |
m (→D on mobile devices) |
||
Line 148: | Line 148: | ||
For D to be usable on iOS it's basically essential to be able to easily use the Objective-C system libraries and frameworks of the platform. GUI programming on Mac OS X would also get a big boost of this. The best way to do this is to add direct support for Objective-C in the compiler. Michel Fortin has already stared a [http://michelf.ca/projects/d-objc/ project] for this but it needs to be finished, updated with the latest compiler changes and merged back into the mainline. | For D to be usable on iOS it's basically essential to be able to easily use the Objective-C system libraries and frameworks of the platform. GUI programming on Mac OS X would also get a big boost of this. The best way to do this is to add direct support for Objective-C in the compiler. Michel Fortin has already stared a [http://michelf.ca/projects/d-objc/ project] for this but it needs to be finished, updated with the latest compiler changes and merged back into the mainline. | ||
− | =D on mobile devices= | + | =D on mobile/embedded devices= |
==ARM support== | ==ARM support== |
Revision as of 22:08, 13 February 2014
Refer to our GSoC 2014 page for details about this project.
GSoC idea pages from past years (GSoC 2013 (not accepted), GSoC 2012, and GSoC 2011).
This is the most important part of our application, and where you can significantly improve our chance of being accepted this year. Please add your ideas to the list.
Contents
Phobos modules
std.i18n
Design and implement a basic internationalization framework. It should provide at least the following functionality:
- A locale part, std.i18n.locale
- detect a users default language
- select a global application language
- types to describe and work with locales
- A text translation part, std.i18n.translation
- Gettext compatible
- Preferably using the gettext serialized hashtables in .mo files
- Low level, gettext like API and high level, boost::locale like API
- A tool to extract strings which need to be translated from D code
- Prefereably based on DScanner (https://github.com/Hackerpilot/Dscanner)
- Alternatively as a D program using regular expressions
- Optionally adding support for D code to xgettext
- It might also be possible to do with pragma(msg)... proof of concept http://arsdnet.net/dcode/i18n.d
Internationalization is required in all kinds of programs, therefore std.i18n must be as portable as possible. This especially means it must work on systems without a Garbage Collector and it must be easy to adapt the 'current locale detection' code and all code accessing the filesystem.
Think 'std.i18n should be portable to a system with 4MB Ram, no GC and no usual OS (e.g. game consoles)'
Large parts of the code can be ported from boost::locale.
std.compression
(Please insert requirements)
std.event
Design and implement a event IO system with switchable backends. At least on backend which works on all OSs D supports should be implemented (libevent, libev). A D backend which directly uses OS functions (epoll, ...) should be started. It should be considered how another event loop (gtk,...) can be integrated with this D event loop in a efficient way. For more requirements, see http://wiki.dlang.org/Event_system
std.xml and std.json replacement
Requirements for std.json:
- A pull parser (tokenizer)
- Preferably based on std.lexer (http://hackerpilot.github.io/experimental/std_lexer/phobos/lexer.html)
- Must work without any dynamic allocations
- A JSONWriter
- Must accept JSONTokens produced by the tokenizer
- Must provide a higher level API, JSONWriter.beginArray() ...
- Must work without any dynamic allocations
- Must provide basic pretty printing either in a different type (PrettyJSONWriter) or integrated into JSONWriter
- A DOM which does parsing/formatting via JSONTokenizer/JSONWriter
- Convenience functions
- JSONObject parseJSON(Range input)
- string printJSON(JSONObject)
- void printJSON(JSONObject, Sink)
- simple! (de)serialization using JSONTokenizer/JSONWriter
- Must not allocate any memory
- struct MyStruct; void printJSON(T, Sink)
- T parseJSON(T)(Range)
For XML a pull parser and a XMLWriter should be provided. If there's time left, a XML DOM and XML validation can be implemented. See also: http://wiki.dlang.org/Wish_list/std.json
std.socket
std.units
std.log
std.benchmark
std.numeric.matrix
D compilers
GDC
GDC is a D compiler based on the GCC backend. There are a few outstanding issues in GDC that have ended up in the backlog of known issues to fix.
- Get shared library support working. The current implementation upstream in DM druntime has not been tested or merged in, and it is not clear what changes are required to support it, or whether is even going to be feasibly possible with GDC.
- Implement support for compiling with LTO (
-flto
) turned on. - GDC EH support is lacking the ability to chain multiple thrown exceptions together in its deh personality routines.
- Now GCC has __atomic primitives defined for the new C++ memory model. We should take advance of these and update the API in gcc.atomics which hash out the old __synchronise primitives. The new __atomic primitives having a one-to-one mapping with core.atomic being just one of the benefits of this.
- There are various XBUG markers in GDC's testsuite, some haven't been looked at in a long time. There should be fewer!
LDC
LDC is based on LLVM, so this suggests several small project ideas, like porting some of the LLVM tools/features designed for C/C++ to the D-LDC world. Things like:
Port LDC to a new platform
Requirements are:
- Update CMake files to support cross-compilation
- Make sure that code generation works for the choosen platform. This includes fixing blocking LLVM bugs discovered during porting.
- Platform-specific requirements:
- For a traditional Linux platform (e.g. MIPS, SPARC, SystemZ):
- Check and update the Posix bindings in Druntime.
- Make sure the compiler test suite and Phobos/Druntime unit tests passes.
- For a GPU platform (NVPTX, R600):
- Create and implement a concept how to mix and compile kernel code with standard D. (A look at A simple tutorial on generating PTX assembler out of Ada source code using LLVM NVPTX backend might help here.)
- Evaluate which runtime can be provided. (E.g. is the GC usable? Are the arrayOp functions usable?)
- Based on your evaluation, port an existing runtime or create a minimalistic one.
- Make sure the compiler test suite passes.
- For a complete new platform (AIX on POWER7):
- Check and update the OS support of LLVM. Compile with a recent gcc before trying to switch to platform-vendor compiler.
- Contribute new OS binding files to Druntime.
- Make sure the compiler test suite and Phobos/Druntime unit tests passes.
- For a traditional Linux platform (e.g. MIPS, SPARC, SystemZ):
- The compiler should be usable as native and cross-compiler.
Improve optimization using D specific knowledge
Requirements are:
- Research new library optimizations and new code improvement patterns and implement them in SimplifyDRuntime pass. (Examples can be found in this forum thread)
- Improve code generation by using more stack allocation instead of heap allocation. This can be done by exploiting scope parameters or by improving the GarbageCollect2Stack pass
- Improve IR generation
- Check alignment of allocations and enforce usage (see issue #531)
- Currently, all parameters get some space on the stack allocated. Identify conditions when this is not needed and implement them.
- Create test cases to show the impact of the new optimizations.
Other ideas
- Perform more static analysis, like abstract compilation or linting (Clang does both);
- Develop a simple way to compile D for the browser with Emscripten to "asm.js" (this is a very small project);
- Perform other run-time tests as done by Clang;
- Use some of the D semantics to improve D code optimization (Walter talks about this all the time);
- Implement better high level optimizations for D code that uses array ops.
SDC
SDC is a work in progress in order to implement a D frontend in D. The lexing/parsing/semantic part is available as a lib in order to allow other tools to be built on top of it. The long term goal is to improve the tooling around D in general.
If SDC is to handle the most advanced features of D (CTFE, templates, static ifs, mixin), many things remain to do. They include:
- Full support of D's OOP capabilities.
- Context pointers creation (closures and delegate passed by alias).
- pure, @safe
- shared/synchronized.
- and much more!
A lot of work, but the project has a solid base to build upon.
SDC is leveraging LLVM in order to do JIT CTFE and for codegen. It is probably possible to mutually work around LLVM with LDC (for instance Emscripten and asm.js ).
Integration with other languages
PyD
Once remaining issues with shared libraries are resolved, it becomes feasible to use D code from dynamic languages. Clearly it's vital to provide easy path for calling it from Python, as it's used by many scientists, amongst others. Although there's PyD, the last few years saw rising interest in PyPy because it shows much better performance than CPython. For PyPy, the way to go seems to be generating extern(C) wrappers for classes/functions/etc. + CFFI bindings for that C code. First part of this can be reused for producing C++ wrapping code -- this is similar in goals to dtoh but here entities to be wrapped should be explicitly mentioned. Extra benefit of producing C++ bindings is ability to call SWIG on them to support other languages. So, perhaps, C++ is the number one target in this respect.
Objective-C support
For D to be usable on iOS it's basically essential to be able to easily use the Objective-C system libraries and frameworks of the platform. GUI programming on Mac OS X would also get a big boost of this. The best way to do this is to add direct support for Objective-C in the compiler. Michel Fortin has already stared a project for this but it needs to be finished, updated with the latest compiler changes and merged back into the mainline.
D on mobile/embedded devices
ARM support
The ARM architecture is predominant on mobile devices. Enabling D developement on those requires support from the compiler, from druntime and phobos and documentation on toolchain setup. There are existing approaches for GDC/LDC. The goal of this project would be to take up the existing work and get GDC/LDC to pass their testsuites on Linux and Android. Building a cross-compiler for these targets should become a simple and documented process. Additional time could be spent on exploring bare-metal targets or Windows support.
iPhone support
This should also exist alongside the Android support. The needs and objectives are probably similar, though less discussed.
GUI library
D really needs an official, or de facto standard, GUI library. There are already various GUI libraries available, with different pros and cons and in different states. What needs to be done varies quite much depending on which library is chosen. A few of the existing libraries are: QtD, GtkD, DWT, wxD.
Of these four libraries, only DWT and wxD use native operations to draw their widgets. Of these libraries only DWT is completely written in D. The rest of the libraries are only bindings to C/C++ libraries. There have been many discussions about which library would be best for D. My suggestion is to use DWT because it's completely written in D and it uses native operators to draw its widgets.
What can be done for DWT:
- Finish the Mac OS X port
- Port to 64bit
- Update to later versions of SWT
- Port to Qt, QtWebkit
Bare Metal D
This is a project that goes hand in hand with ARM support in D but focuses on getting bare metal cross-compiler and appealing eco-system to surround it. The goal is to raise the awareness of D in the open hardware community at large and prove D's systems programming lanugage title along the way.
It's hard not to notice the growing momentum of the open hardware movement. Yesterday's newbies awkwardly messing with theirs first Arduinos are today's mature embedded systems hackers. The hanger for ever more powerful systems takes them en mass towards ARM development boards. These systems are cheap, have 32bit CPUs and plenty of RAM/ROM so that D certainly can be a compelling offering in this setting (compared to C/C++ in usability).
The project is two-fold and can be geared towards any of the 2 major parts:
- Getting a bare-metal D runtime support on Cortex-M3/M4 wtih as many language features as possible. A minor victory would be having a minimal thread-less and GC-less runtime. A more ambitious plan here is creating a small-ish RTOS in D, to provide full runtime with threads, mutexes etc.
- Create a Wiring look alike library in D for a select family of popular chips (and consequently a range of boards). Alternativly instead of blindly copying a popular API is to design your own hardware abstraction library. The challenge here is to tackle things like GPIOs, USARTs, I2C, SPIs, PWM, ADC and other peripherals commonly found in MCUs in a future-proof way.
Cool demos (including public videos) are an obligatory part of the project ;)
For a starting point see e.g. this project (some D working on STM32 boards): https://bitbucket.org/timosi/minlibd