\section{Conclusions}
This thesis is about providing a bridge between two communities,  the
scientists/engineers/students who like to program in \matlab on one
side;  and the programming language and compiler community who have
designed elegant languages and powerful compiler techniques on the other
side.   

The \xten language has been designed to provide high-level  array and
concurrency abstractions,  and  our main goal was to develop a tool that
would allow programmers to automatically convert their \matlab code to
efficient \xten code.    In this way programmers can port their existing
\matlab code to \xten,  or continue to develop in \matlab and use our
\mixten compiler as a backend to generate \xten code.    Since \xten is
publicly available under the Eclipse Public License
(\url{x10-lang.org/home/x10-license.html}),  users could have efficient
high-performance code that they could freely distribute.    Further,
\xten itself can compile the code to either Java or C++,  so our tool
could be used in a tool chain to convert \matlab to those languages as
well.

Our tool is part of the McLab project, which is entirely open
source.   Thus, we are providing  an infrastructure for other compiler
researchers to build upon this work,  or to use some of our approaches
to handle other popular languages such as R.

In this thesis we demonstrated the end-to-end organization of the \mixten
tool, and we identified that the correct handling of arrays, the
minimization of casting by safely mapping \matlab double variables to
\xten integer variables via \emph{IntegerOkay} analysis,  and handling concurrency
features were the key challenges.   We developed a custom version of \xten's
rail-backed simple arrays,  and identified where and how this
could be used for generating efficient \xten code.  For cases where
precise static array shape and type information is not available, we
showed how we can use the very flexible region-based arrays in \xten,
and our experiments demonstrated that it is very important to use the
simple rail-backed arrays, for both the Java and C++ backends for \xten.

Our experiments show that our generated \xten code is competitive with
other state-of-the art code generators which target more traditional
languages like C and Fortran.   The C++ \xten backend produces faster
code than the Java backend,  but good performance is achieved in both
cases.  

One of the main motivations of choosing \xten as the target language is
that it supports high-performance computing,  which is often desirable
for the computation-intensive applications developed by the engineers
and scientists.   To demonstrate how to take advantage of \xten's
concurrency, we presented 
an effective translation of the \matlab \texttt{parfor} construct to
semantically equivalent \xten.    

Our experiments showed significant performance gains for our generated
parallel \xten code, as compared to \matlab's parallel toolbox. This
confirms that compiling \matlab to a modern high-performance language
can lead to significant performance improvements. 

In the process of developing \mixten, we also stressed the \xten compiler with
machine generated code and found it to be mostly robust and efficient. We found
that the \xten Java backend's optimizations may in some cases generate Java code
that is too large to be JIT compiled. We also found the random number generation
for the C++ backend to be slower than that for the Java backend. We reported our
feedback to the \xten development team and hope that our findings would help to
make \xten even better. Overall, we found that with the right techniques, \xten
can be used as an effective and efficient target language for scientific and
array-based languages, for both, the sequential core and the parallel part.   

\section{Future Work}
Based on our positive experiences to date,  we plan to continue
improving the \mixten tool.  There are three major areas where we plan to take
ahead the development of \mixten, with the aim of making it more complete and
more efficient:
\begin{description}

\item[Exploiting parallelism] To help us better understand and efficiently
exploit the inherent concurrency in the \matlab programs, first of all we would 
like to thoroughly evaluate and fine tune
the concurrency constructs we introduced in \matlab via structured comments, and
parallelism of the vectorized operations. Further, we would like to experiment
to find the best way to tune the generated code for different
sorts of parallel architectures. We are also planning to further our research
into the direction of automatically parallelizing \matlab codes through
static analysis mixed with run-time checks.   

\item[Efficient builtin implementation] One of the greatest strengths of
\matlab is its \ large and efficient set of
builtin libraries. This thesis concentrates more on effective and efficient
compilation of \matlab constructs than finding the most efficient
\xten implementations for the builtin operations. However, our experiments showed that there
are some key library routines such as matrix multiply and transpose for
which we need to have better \xten code for. Thus, there is scope for more
work on \xten libraries, which could also be useful for other
source-to-source compilers targeting \xten.

\item[Readability] The code that we generate is already quite
clean, but has a quite low-level structure, which might not be easily readable for
non-experienced \xten programmers. We would like to apply further transformations on it to
aggregate some low-level expressions, and to make the generated code
look as ``natural" as possible. This would help \mixten users, who are familiar
with \xten, to easily
fine-tune the generated \xten code to better suite their execution environments.
It would also help in easy maintenance of the generated \xten code, and better
integration with hand-written \xten code.   

\end{description}

Our tool is open source, and we hope that the other research teams will use
our infrastructure, as well as learn from our experiences of generating
effective and efficient \xten code.
