Changeset cfc3e0f for doc/papers/general/Paper.tex
- Timestamp:
- May 7, 2018, 1:40:24 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- c5e5109
- Parents:
- 01ff4e1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
r01ff4e1 rcfc3e0f 174 174 \lstMakeShortInline@% 175 175 176 \let\OLDthebibliography\thebibliography 177 \renewcommand\thebibliography[1]{ 178 \OLDthebibliography{#1} 179 \setlength{\parskip}{0pt} 180 \setlength{\itemsep}{4pt plus 0.3ex} 181 } 176 182 177 183 \title{\texorpdfstring{\protect\CFA : Adding Modern Programming Language Features to C}{Cforall : Adding Modern Programming Language Features to C}} … … 191 197 The C programming language is a foundational technology for modern computing with millions of lines of code implementing everything from commercial operating-systems to hobby projects. 192 198 This installation base and the programmers producing it represent a massive software-engineering investment spanning decades and likely to continue for decades more. 193 Nevertheless, C, first standardized over thirty years ago, lacks many features that make programming in more modern languages safer and more productive. 194 The goal of the \CFA project is to create an extension of C that provides modern safety and productivity features while still ensuring strong backwards compatibility with C and its programmers. 199 Nevertheless, C, first standardized almost fourty years ago, lacks many features that make programming in more modern languages safer and more productive. 200 201 The goal of the \CFA project (pronounced ``C-for-all'') is to create an extension of C that provides modern safety and productivity features while still ensuring strong backwards compatibility with C and its programmers. 195 202 Prior projects have attempted similar goals but failed to honour C programming-style; for instance, adding object-oriented or functional programming with garbage collection is a non-starter for many C developers. 196 203 Specifically, \CFA is designed to have an orthogonal feature-set based closely on the C programming paradigm, so that \CFA features can be added \emph{incrementally} to existing C code-bases, and C programmers can learn \CFA extensions on an as-needed basis, preserving investment in existing code and programmers. … … 226 233 Love it or hate it, C is extremely popular, highly used, and one of the few systems languages. 227 234 In many cases, \CC is often used solely as a better C. 228 Nevertheless, C, first standardized over thirty years ago, lacks many features that make programming in more modern languages safer and more productive.235 Nevertheless, C, first standardized almost fourty years ago~\cite{ANSI89:C}, lacks many features that make programming in more modern languages safer and more productive. 229 236 230 237 \CFA (pronounced ``C-for-all'', and written \CFA or Cforall) is an evolutionary extension of the C programming language that adds modern language-features to C, while maintaining both source and runtime compatibility with C and a familiar programming model for programmers. … … 324 331 int max( int a, int b ) { return a < b ? b : a; } $\C{// (3)}$ 325 332 double max( double a, double b ) { return a < b ? b : a; } $\C{// (4)}\CRT$ 326 max( 7, -max ); $\C [2.75in]{// uses (3) and (1), by matching int from constant 7}$333 max( 7, -max ); $\C{// uses (3) and (1), by matching int from constant 7}$ 327 334 max( max, 3.14 ); $\C{// uses (4) and (2), by matching double from constant 3.14}$ 328 max( max, -max ); $\C{// ERROR :ambiguous}$329 int m = max( max, -max ); $\C{// uses (3) and (1) twice, by matching return type} \CRT$335 max( max, -max ); $\C{// ERROR, ambiguous}$ 336 int m = max( max, -max ); $\C{// uses (3) and (1) twice, by matching return type}$ 330 337 \end{cfa} 331 338 … … 336 343 As is shown later, there are a number of situations where \CFA takes advantage of available type information to disambiguate, where other programming languages generate ambiguities. 337 344 338 \Celeven added @_Generic@ expressions , which is used in preprocessor macros to provide a form ofad-hoc polymorphism;345 \Celeven added @_Generic@ expressions~\cite[\S~6.5.1.1]{C11}, which is used with preprocessor macros to provide ad-hoc polymorphism; 339 346 however, this polymorphism is both functionally and ergonomically inferior to \CFA name overloading. 340 347 The macro wrapping the generic expression imposes some limitations; … … 369 376 \begin{cfa} 370 377 forall( otype T `| { T ?+?(T, T); }` ) T twice( T x ) { return x `+` x; } $\C{// ? denotes operands}$ 371 int val = twice( twice( 3.7 ) ); 378 int val = twice( twice( 3.7 ) ); $\C{// val == 14}$ 372 379 \end{cfa} 373 380 which works for any type @T@ with a matching addition operator. 374 381 The polymorphism is achieved by creating a wrapper function for calling @+@ with @T@ bound to @double@, then passing this function to the first call of @twice@. 375 382 There is now the option of using the same @twice@ and converting the result to @int@ on assignment, or creating another @twice@ with type parameter @T@ bound to @int@ because \CFA uses the return type~\cite{Cormack81,Baker82,Ada} in its type analysis. 376 The first approach has a late conversion from @double@ to @int@ on the final assignment, while the second has an ea gerconversion to @int@.383 The first approach has a late conversion from @double@ to @int@ on the final assignment, while the second has an early conversion to @int@. 377 384 \CFA minimizes the number of conversions and their potential to lose information, so it selects the first approach, which corresponds with C-programmer intuition. 378 385 … … 420 427 \begin{cfa} 421 428 forall( otype T | { int ?<?( T, T ); } ) void qsort( const T * arr, size_t size ) { /* use C qsort */ } 422 {429 int main() { 423 430 int ?<?( double x, double y ) { return x `>` y; } $\C{// locally override behaviour}$ 424 qsort( vals, size );$\C{// descending sort}$431 qsort( vals, 10 ); $\C{// descending sort}$ 425 432 } 426 433 \end{cfa} … … 534 541 \begin{cquote} 535 542 \lstDeleteShortInline@% 536 \begin{tabular}{@{}l|@{\hspace{ 2\parindentlnth}}l@{}}543 \begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}} 537 544 \begin{cfa} 538 545 forall( otype R, otype S ) struct pair { … … 578 585 \begin{cfa} 579 586 struct _pair_conc0 { 580 const char * first; 581 int second; 587 const char * first; int second; 582 588 }; 583 589 \end{cfa} … … 587 593 \begin{cfa} 588 594 struct _pair_conc1 { 589 void * first; 590 void * second; 595 void * first, * second; 591 596 }; 592 597 \end{cfa} … … 645 650 \begin{cquote} 646 651 \lstDeleteShortInline@% 647 \begin{tabular}{@{}l @{\hspace{2\parindentlnth}}l@{}}652 \begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}} 648 653 \begin{cfa} 649 654 forall( dtype Unit ) struct scalar { unsigned long value; }; … … 661 666 half_marathon; 662 667 scalar(litres) two_pools = pool + pool; 663 `marathon + pool;` // compilation ERROR668 `marathon + pool;` // ERROR, mismatched types 664 669 \end{cfa} 665 670 \end{tabular} … … 1006 1011 \begin{cfa} 1007 1012 forall( dtype T0, dtype T1 | sized(T0) | sized(T1) ) struct _tuple2 { 1008 T0 field_0; $\C{// generated before the first 2-tuple}$ 1009 T1 field_1; 1013 T0 field_0; T1 field_1; $\C{// generated before the first 2-tuple}$ 1010 1014 }; 1011 1015 _tuple2(int, int) f() { 1012 1016 _tuple2(double, double) x; 1013 1017 forall( dtype T0, dtype T1, dtype T2 | sized(T0) | sized(T1) | sized(T2) ) struct _tuple3 { 1014 T0 field_0; $\C{// generated before the first 3-tuple}$ 1015 T1 field_1; 1016 T2 field_2; 1018 T0 field_0; T1 field_1; T2 field_2; $\C{// generated before the first 3-tuple}$ 1017 1019 }; 1018 1020 _tuple3(int, double, int) y; 1019 1021 } 1020 1022 \end{cfa} 1021 {\sloppy 1022 Tuple expressions are then simply converted directly into compound literals, \eg @[5, 'x', 1.24]@ becomes @(_tuple3(int, char, double)){ 5, 'x', 1.24 }@. 1023 \par}% 1023 Tuple expressions are then converted directly into compound literals, \eg @[5, 'x', 1.24]@ becomes @(_tuple3(int, char,@ @double)){ 5, 'x', 1.24 }@. 1024 1024 1025 1025 \begin{comment} … … 1105 1105 \begin{cquote} 1106 1106 \lstDeleteShortInline@% 1107 \begin{tabular}{@{}l @{\hspace{2\parindentlnth}}l@{}}1107 \begin{tabular}{@{}l|@{\hspace{2\parindentlnth}}l@{}} 1108 1108 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1109 1109 \begin{cfa} … … 1174 1174 \centering 1175 1175 \lstDeleteShortInline@% 1176 \begin{tabular}{@{}l @{\hspace{2\parindentlnth}}l@{}}1177 \multicolumn{1}{c @{\hspace{2\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\1176 \begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}} 1177 \multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1178 1178 \begin{cfa} 1179 1179 `choose` ( day ) { … … 1220 1220 \centering 1221 1221 \lstDeleteShortInline@% 1222 \begin{tabular}{@{}l @{\hspace{2\parindentlnth}}l@{}}1223 \multicolumn{1}{c @{\hspace{2\parindentlnth}}}{\textbf{non-terminator}} & \multicolumn{1}{c}{\textbf{target label}} \\1222 \begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}} 1223 \multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{non-terminator}} & \multicolumn{1}{c}{\textbf{target label}} \\ 1224 1224 \begin{cfa} 1225 1225 choose ( ... ) { … … 1264 1264 \begin{figure} 1265 1265 \lstDeleteShortInline@% 1266 \begin{tabular}{@{\hspace{\parindentlnth}}l @{\hspace{\parindentlnth}}l@{\hspace{\parindentlnth}}l@{}}1267 \multicolumn{1}{@{\hspace{\parindentlnth}}c @{\hspace{\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{@{\hspace{\parindentlnth}}c}{\textbf{C}} \\1266 \begin{tabular}{@{\hspace{\parindentlnth}}l|@{\hspace{\parindentlnth}}l@{\hspace{\parindentlnth}}l@{}} 1267 \multicolumn{1}{@{\hspace{\parindentlnth}}c|@{\hspace{\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{@{\hspace{\parindentlnth}}c}{\textbf{C}} \\ 1268 1268 \begin{cfa} 1269 1269 `LC:` { … … 1349 1349 \subsection{Exception Handling} 1350 1350 1351 The following framework for \CFA exception 1351 The following framework for \CFA exception-handling is in place, excluding some runtime type-information and virtual functions. 1352 1352 \CFA provides two forms of exception handling: \newterm{fix-up} and \newterm{recovery} (see Figure~\ref{f:CFAExceptionHandling})~\cite{Buhr92b,Buhr00a}. 1353 1353 Both mechanisms provide dynamic call to a handler using dynamic name-lookup, where fix-up has dynamic return and recovery has static return from the handler. … … 1360 1360 \begin{cquote} 1361 1361 \lstDeleteShortInline@% 1362 \begin{tabular}{@{}l @{\hspace{2\parindentlnth}}l@{}}1363 \multicolumn{1}{c @{\hspace{2\parindentlnth}}}{\textbf{Resumption}} & \multicolumn{1}{c}{\textbf{Termination}} \\1362 \begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}} 1363 \multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{Resumption}} & \multicolumn{1}{c}{\textbf{Termination}} \\ 1364 1364 \begin{cfa} 1365 1365 `exception R { int fix; };` … … 1852 1852 This provides a much more orthogonal design for library implementors, obviating the need for workarounds such as @std::reference_wrapper@. 1853 1853 Secondly, \CFA references are rebindable, whereas \CC references have a fixed address. 1854 \newsavebox{\LstBox}1855 \begin{lrbox}{\LstBox}1856 \lstset{basicstyle=\footnotesize\linespread{0.9}\sf}1857 \begin{cfa}1858 int & r = *new( int );1859 ... $\C{// non-null reference}$1860 delete &r; $\C{// unmanaged (programmer) memory-management}$1861 r += 1; $\C{// undefined reference}$1862 \end{cfa}1863 \end{lrbox}1864 1854 Rebinding allows \CFA references to be default-initialized (\eg to a null pointer\footnote{ 1865 While effort has been made into non-null reference checking in \CC and Java, the exercise seems moot for any non-managed languages (C/\CC), given that it only handles one of many different error situations: 1866 \begin{cquote} 1867 \usebox{\LstBox} 1868 \end{cquote} 1869 }% 1870 ) and point to different addresses throughout their lifetime, like pointers. 1855 While effort has been made into non-null reference checking in \CC and Java, the exercise seems moot for any non-managed languages (C/\CC), given that it only handles one of many different error situations, \eg using a pointer after its storage is deleted.}) and point to different addresses throughout their lifetime, like pointers. 1871 1856 Rebinding is accomplished by extending the existing syntax and semantics of the address-of operator in C. 1872 1857 … … 1880 1865 \begin{itemize} 1881 1866 \item 1882 if @R@ is an rvalue of type {@T &@$_1 \cdots$@ &@$_r$} where $r \ge 1$ references (@&@ symbols) th an @&R@ has type {@T `*`&@$_{\color{red}2} \cdots$@ &@$_{\color{red}r}$}, \\ \ie @T@ pointer with $r-1$ references (@&@ symbols).1867 if @R@ is an rvalue of type {@T &@$_1 \cdots$@ &@$_r$} where $r \ge 1$ references (@&@ symbols) then @&R@ has type {@T `*`&@$_{\color{red}2} \cdots$@ &@$_{\color{red}r}$}, \\ \ie @T@ pointer with $r-1$ references (@&@ symbols). 1883 1868 1884 1869 \item … … 1914 1899 \end{cfa} 1915 1900 This allows complex values to be succinctly and efficiently passed to functions, without the syntactic overhead of explicit definition of a temporary variable or the runtime cost of pass-by-value. 1916 \CC allows a similar binding, but only for @const@ references; the more general semantics of \CFA are an attempt to avoid the \newterm{const hell} problem, in which addition of a @const@ qualifier to one reference requires a cascading chain of added qualifiers.1901 \CC allows a similar binding, but only for @const@ references; the more general semantics of \CFA are an attempt to avoid the \newterm{const poisoning} problem~\cite{Taylor10}, in which addition of a @const@ qualifier to one reference requires a cascading chain of added qualifiers. 1917 1902 1918 1903 … … 1928 1913 \begin{tabular}{@{}l@{\hspace{3em}}l|l@{}} 1929 1914 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C Type Nesting}} & \multicolumn{1}{c|}{\textbf{C Implicit Hoisting}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1930 \hline1931 1915 \begin{cfa} 1932 1916 struct S { … … 2259 2243 W w, heavy = { 20 }; 2260 2244 w = 155|_lb|; 2261 w = 0b1111|_lb|; // error,binary unsupported2245 // binary unsupported 2262 2246 w = 0${\color{red}\LstBasicStyle{'}}$233|_lb|; // quote separator 2263 2247 w = 0x9b|_kg|; … … 2307 2291 \begin{cquote} 2308 2292 \lstDeleteShortInline@% 2309 \begin{tabular}{@{}l@{\hspace{ 2\parindentlnth}}l@{}}2310 \multicolumn{1}{c@{\hspace{ 2\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\2293 \begin{tabular}{@{}l@{\hspace{\parindentlnth}}l@{}} 2294 \multicolumn{1}{c@{\hspace{\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 2311 2295 \begin{cfa} 2312 2296 MIN 2313 2314 2297 MAX 2315 2316 2298 PI 2317 2299 E … … 2319 2301 & 2320 2302 \begin{cfa} 2321 SCHAR_MIN, CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, 2322 LLONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN 2323 SCHAR_MAX, UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, 2324 LLONG_MAX, FLT_MAX, DBL_MAX, LDBL_MAX 2303 CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN 2304 UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX, FLT_MAX, DBL_MAX, LDBL_MAX 2325 2305 M_PI, M_PIl 2326 2306 M_E, M_El … … 2441 2421 2442 2422 \begin{table} 2423 \caption{Storage-Management Operations} 2424 \label{t:StorageManagementOperations} 2443 2425 \centering 2444 2426 \lstDeleteShortInline@% … … 2460 2442 \lstDeleteShortInline~% 2461 2443 \lstMakeShortInline@% 2462 \caption{Storage-Management Operations}2463 \label{t:StorageManagementOperations}2464 2444 \end{table} 2465 2445 … … 2589 2569 \end{cquote} 2590 2570 There is a weak similarity between the \CFA logical-or operator and the Shell pipe-operator for moving data, where data flows in the correct direction for input but the opposite direction for output. 2591 2571 \begin{comment} 2592 2572 The implicit separator character (space/blank) is a separator not a terminator. 2593 2573 The rules for implicitly adding the separator are: … … 2608 2588 }% 2609 2589 \end{itemize} 2590 \end{comment} 2610 2591 There are functions to set and get the separator string, and manipulators to toggle separation on and off in the middle of output. 2611 2592 … … 2656 2637 2657 2638 2658 \section{ Evaluation}2639 \section{Polymorphism Evaluation} 2659 2640 \label{sec:eval} 2660 2641 2661 Though \CFA provides significant added functionality over C, these features have a low runtime penalty. 2662 In fact, \CFA's features for generic programming can enable faster runtime execution than idiomatic @void *@-based C code. 2663 This claim is demonstrated through a set of generic-code-based micro-benchmarks in C, \CFA, and \CC (see stack implementations in Appendix~\ref{sec:BenchmarkStackImplementations}). 2642 \CFA adds parametric polymorphism to C. 2643 A runtime evaluation is performed to compare the cost of alternative styles of polymorphism. 2644 The goal is to compare just the underlying mechanism for implementing different kinds of polymorphism. 2645 % Though \CFA provides significant added functionality over C, these features have a low runtime penalty. 2646 % In fact, it is shown that \CFA's generic programming can enable faster runtime execution than idiomatic @void *@-based C code. 2647 The experiment is a set of generic-stack micro-benchmarks~\cite{CFAStackEvaluation} in C, \CFA, and \CC (see implementations in Appendix~\ref{sec:BenchmarkStackImplementations}). 2664 2648 Since all these languages share a subset essentially comprising standard C, maximal-performance benchmarks should show little runtime variance, differing only in length and clarity of source code. 2665 2649 A more illustrative comparison measures the costs of idiomatic usage of each language's features. … … 2692 2676 \end{figure} 2693 2677 2694 The structure of each benchmark implemented is: C with @void *@-based polymorphism, \CFA with the presented features, \CC with templates, and \CC using only class inheritance for polymorphism, called \CCV.2678 The structure of each benchmark implemented is: C with @void *@-based polymorphism, \CFA with parametric polymorphism, \CC with templates, and \CC using only class inheritance for polymorphism, called \CCV. 2695 2679 The \CCV variant illustrates an alternative object-oriented idiom where all objects inherit from a base @object@ class, mimicking a Java-like interface; 2696 2680 hence runtime checks are necessary to safely down-cast objects. 2697 2681 The most notable difference among the implementations is in memory layout of generic types: \CFA and \CC inline the stack and pair elements into corresponding list and pair nodes, while C and \CCV lack such a capability and instead must store generic objects via pointers to separately-allocated objects. 2698 Note that the C benchmark uses unchecked casts as there is no runtime mechanism to perform such checks, while \CFA and \CC provide type-safety statically.2682 Note, the C benchmark uses unchecked casts as C has no runtime mechanism to perform such checks, while \CFA and \CC provide type-safety statically. 2699 2683 2700 2684 Figure~\ref{fig:eval} and Table~\ref{tab:eval} show the results of running the benchmark in Figure~\ref{fig:BenchmarkTest} and its C, \CC, and \CCV equivalents. … … 2711 2695 2712 2696 \begin{table} 2713 \centering2714 2697 \caption{Properties of benchmark code} 2715 2698 \label{tab:eval} 2699 \centering 2716 2700 \newcommand{\CT}[1]{\multicolumn{1}{c}{#1}} 2717 2701 \begin{tabular}{rrrrr} … … 2726 2710 The C and \CCV variants are generally the slowest with the largest memory footprint, because of their less-efficient memory layout and the pointer-indirection necessary to implement generic types; 2727 2711 this inefficiency is exacerbated by the second level of generic types in the pair benchmarks. 2728 By contrast, the \CFA and \CC variants run in roughly equivalent time for both the integer and pair of @short@ and @char@ because the storage layout is equivalent, with the inlined libraries (\ie no separate compilation) and greater maturity of the \CC compiler contributing to its lead.2712 By contrast, the \CFA and \CC variants run in roughly equivalent time for both the integer and pair because of equivalent storage layout, with the inlined libraries (\ie no separate compilation) and greater maturity of the \CC compiler contributing to its lead. 2729 2713 \CCV is slower than C largely due to the cost of runtime type-checking of down-casts (implemented with @dynamic_cast@); 2730 The outlier in the graph for \CFA, pop @pair@, results from the complexity of the generated-C polymorphic code. 2731 The gcc compiler is unable to optimize some dead code and condense nested calls; a compiler designed for \CFA could easily perform these optimizations. 2714 The outlier for \CFA, pop @pair@, results from the complexity of the generated-C polymorphic code. 2715 The gcc compiler is unable to optimize some dead code and condense nested calls; 2716 a compiler designed for \CFA could easily perform these optimizations. 2732 2717 Finally, the binary size for \CFA is larger because of static linking with the \CFA libraries. 2733 2718 … … 2746 2731 The \CFA benchmark is able to eliminate all redundant type annotations through use of the polymorphic @alloc@ function discussed in Section~\ref{sec:libraries}. 2747 2732 2733 We conjecture these results scale across most generic data-types as the underlying polymorphic implement is constant. 2734 2748 2735 2749 2736 \section{Related Work} … … 2751 2738 2752 2739 \subsection{Polymorphism} 2740 2741 ML~\cite{ML} was the first language to support parametric polymorphism. 2742 Like \CFA, it supports universal type parameters, but not the use of assertions and traits to constrain type arguments. 2743 Haskell~\cite{Haskell10} combines ML-style polymorphism, polymorphic data types, and type inference with the notion of type classes, collections of overloadable methods that correspond in intent to traits in \CFA. 2744 Unlike \CFA, Haskell requires an explicit association between types and their classes that specifies the implementation of operations. 2745 These associations determine the functions that are assertion arguments for particular combinations of class and type, in contrast to \CFA where the assertion arguments are selected at function call sites based upon the set of operations in scope at that point. 2746 Haskell also severely restricts the use of overloading: an overloaded name can only be associated with a single class, and methods with overloaded names can only be defined as part of instance declarations. 2753 2747 2754 2748 \CC provides three disjoint polymorphic extensions to C: overloading, inheritance, and templates. … … 2804 2798 Go does not have tuples but supports MRVF. 2805 2799 Java's variadic functions appear similar to C's but are type-safe using homogeneous arrays, which are less useful than \CFA's heterogeneously-typed variadic functions. 2806 Tuples are a fundamental abstraction in most functional programming languages, such as Standard ML~\cite{sml} and~\cite{Scala}, which decompose tuples using pattern matching.2800 Tuples are a fundamental abstraction in most functional programming languages, such as Standard ML~\cite{sml}, Haskell, and Scala~\cite{Scala}, which decompose tuples using pattern matching. 2807 2801 2808 2802 … … 2835 2829 Finally, we demonstrate that \CFA performance for some idiomatic cases is better than C and close to \CC, showing the design is practically applicable. 2836 2830 2837 There is ongoing work on a wide range of \CFA features, including arrays with size, runtime type-information, virtual functions, user-defined conversions, concurrent primitives, and modules. 2838 While all examples in the paper compile and run, a public beta-release of \CFA will take another 8--12 months to finalize these extensions. 2839 There are also interesting future directions for the polymorphism design. 2840 Notably, \CC template functions trade compile time and code bloat for optimal runtime of individual instantiations of polymorphic functions. 2841 \CFA polymorphic functions use dynamic virtual-dispatch; 2842 the runtime overhead of this approach is low, but not as low as inlining, and it may be beneficial to provide a mechanism for performance-sensitive code. 2831 While all examples in the paper compile and run, a public beta-release of \CFA will take 6--8 months to reduce compilation time, provide better debugging, and add a few more libraries. 2832 There is also new work on a number of \CFA features, including arrays with size, runtime type-information, virtual functions, user-defined conversions, and modules. 2833 While \CFA polymorphic functions use dynamic virtual-dispatch with low runtime overhead (see Section~\ref{sec:eval}), it is not as low as \CC template-inlining. 2834 Hence it may be beneficial to provide a mechanism for performance-sensitive code. 2843 2835 Two promising approaches are an @inline@ annotation at polymorphic function call sites to create a template-specialization of the function (provided the code is visible) or placing an @inline@ annotation on polymorphic function-definitions to instantiate a specialized version for some set of types (\CC template specialization). 2844 2836 These approaches are not mutually exclusive and allow performance optimizations to be applied only when necessary, without suffering global code-bloat. … … 2849 2841 2850 2842 The authors would like to recognize the design assistance of Glen Ditchfield, Richard Bilson, Thierry Delisle, Andrew Beach and Brice Dobry on the features described in this paper, and thank Magnus Madsen for feedback on the writing. 2851 This work is supported by a corporate partnership with Huawei Ltd.\ (\url{http://www.huawei.com}), and Aaron Moss and Peter Buhr are partially funded by the Natural Sciences and Engineering Research Council of Canada. 2852 2853 2843 Funding for this project has been provided by Huawei Ltd.\ (\url{http://www.huawei.com}), and Aaron Moss and Peter Buhr are partially funded by the Natural Sciences and Engineering Research Council of Canada. 2844 2845 {% 2846 \fontsize{9bp}{12bp}\selectfont% 2854 2847 \bibliography{pl} 2855 2848 }% 2856 2849 2857 2850 \appendix
Note: See TracChangeset
for help on using the changeset viewer.