Changeset 804b57e3
- Timestamp:
- Feb 2, 2018, 3:28:14 PM (7 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, resolv-new, with_gc
- Children:
- d7d4702
- Parents:
- 0188a0bc
- Location:
- doc
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
r0188a0bc r804b57e3 148 148 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. 149 149 This installation base and the programmers producing it represent a massive software-engineering investment spanning decades and likely to continue for decades more. 150 The \cite{TIOBE} ranks the top 5 most popular programming languages as: Java 16\%, \Textbf{C 7\%}, \Textbf{\CC 5\%}, \Csharp 4\%, Python 4\% = 36\%, where the next 50 languages are less than 3\% each with a long tail.150 The TIOBE\cite{TIOBE} ranks the top 5 most popular programming languages as: Java 16\%, \Textbf{C 7\%}, \Textbf{\CC 5\%}, \Csharp 4\%, Python 4\% = 36\%, where the next 50 languages are less than 3\% each with a long tail. 151 151 The top 3 rankings over the past 30 years are: 152 152 \lstDeleteShortInline@% … … 185 185 \label{sec:poly-fns} 186 186 187 \CFA{}\hspace{1pt}'s polymorphism was originally formalized by \cite{Ditchfield92}, and first implemented by\cite{Bilson03}.187 \CFA{}\hspace{1pt}'s polymorphism was originally formalized by Ditchfield\cite{Ditchfield92}, and first implemented by Bilson\cite{Bilson03}. 188 188 The signature feature of \CFA is parametric-polymorphic functions~\cite{forceone:impl,Cormack90,Duggan96} with functions generalized using a @forall@ clause (giving the language its name): 189 189 \begin{lstlisting} … … 258 258 } 259 259 \end{lstlisting} 260 Within the block, the nested version of @ <@ performs @>@ and this local version overrides the built-in @<@ so it is passed to @qsort@.260 Within the block, the nested version of @?<?@ performs @?>?@ and this local version overrides the built-in @?<?@ so it is passed to @qsort@. 261 261 Hence, programmers can easily form local environments, adding and modifying appropriate functions, to maximize reuse of other existing functions and types. 262 262 … … 337 337 % While a nominal-inheritance system with associated types could model one of those two relationships by making @El@ an associated type of @Ptr@ in the @pointer_like@ implementation, few such systems could model both relationships simultaneously. 338 338 339 340 339 \section{Generic Types} 341 340 … … 466 465 However, the \CFA type-checker ensures matching types are used by all calls to @?+?@, preventing nonsensical computations like adding a length to a volume. 467 466 468 469 467 \section{Tuples} 470 468 \label{sec:tuples} … … 544 542 p`->0` = 5; $\C{// change quotient}$ 545 543 bar( qr`.1`, qr ); $\C{// pass remainder and quotient/remainder}$ 546 rem = [ 42, div( 13, 5 )]`.0.1`; $\C{// access 2nd component of 1st component of tuple expression}$544 rem = [div( 13, 5 ), 42]`.0.1`; $\C{// access 2nd component of 1st component of tuple expression}$ 547 545 \end{lstlisting} 548 546 … … 730 728 \end{lstlisting} 731 729 Hence, function parameter and return lists are flattened for the purposes of type unification allowing the example to pass expression resolution. 732 This relaxation is possible by extending the thunk scheme described by ~\cite{Bilson03}.730 This relaxation is possible by extending the thunk scheme described by Bilson\cite{Bilson03}. 733 731 Whenever a candidate's parameter structure does not exactly match the formal parameter's structure, a thunk is generated to specialize calls to the actual function: 734 732 \begin{lstlisting} … … 901 899 \end{comment} 902 900 901 \section{Improved Procedural Paradigm} 902 903 It is important to the design team that \CFA subjectively ``feel like'' C to user programmers. 904 An important part of this subjective feel is maintaining C's procedural programming paradigm, as opposed to the object-oriented paradigm of other systems languages such as \CC and Rust. 905 Maintaining this procedural paradigm means that coding patterns that work in C will remain not only functional but idiomatic in \CFA, reducing the mental burden of retraining C programmers and switching between C and \CFA development. 906 Nonetheless, some features of object-oriented languages are undeniably convienient, and the \CFA design team has attempted to adapt them to a procedural paradigm so as to incorporate their benefits into \CFA; two of these features are resource management and name scoping. 907 908 \subsection{Constructors and Destructors} 909 910 One of the strengths of C is the control over memory management it gives programmers, allowing resource release to be more consistent and precisely timed than is possible with garbage-collected memory management. 911 However, this manual approach to memory management is often verbose, and it is useful to manage resources other than memory (\eg file handles) using the same mechanism as memory. 912 \CC is well-known for an approach to manual memory management that addresses both these issues, Resource Allocation Is Initialization (RAII), implemented by means of special \emph{constructor} and \emph{destructor} functions; we have implemented a similar feature in \CFA. 913 914 \TODO{Fill out section. Mention field-constructors and at-equal escape hatch to C-style initialization. Probably pull some text from Rob's thesis for first draft.} 915 916 \subsection{@with@ Statement} 917 918 In any programming language, some functions have a naturally close relationship with a particular data type. 919 Object-oriented programming allows this close relationship to be codified in the language by making such functions \emph{class methods} of their related data type. 920 Class methods have certain privileges with respect to their associated data type, notably un-prefixed access to the fields of that data type. 921 When writing C functions in an object-oriented style, this un-prefixed access is swiftly missed, as access to fields of a @Foo* f@ requires an extra three characters @f->@ every time, which disrupts coding flow and clutters the produced code. 922 923 \TODO{Fill out section. Be sure to mention arbitrary expressions in with-blocks, recent change driven by Thierry to prioritize field name over parameters.} 924 925 \section{References} 926 927 \TODO{Pull draft text from user manual; make sure to discuss nested references and rebind operator drawn from } 903 928 904 929 \section{Evaluation} … … 1013 1038 In contrast, \CFA has a single facility for polymorphic code supporting type-safe separate-compilation of polymorphic functions and generic (opaque) types, which uniformly leverage the C procedural paradigm. 1014 1039 The key mechanism to support separate compilation is \CFA's \emph{explicit} use of assumed properties for a type. 1015 Until \CC ~\cite{C++Concepts} are standardized (anticipated for \CCtwenty), \CC provides no way to specify the requirements of a generic function in code beyond compilation errors during template expansion;1040 Until \CC concepts~\cite{C++Concepts} are standardized (anticipated for \CCtwenty), \CC provides no way to specify the requirements of a generic function in code beyond compilation errors during template expansion; 1016 1041 furthermore, \CC concepts are restricted to template polymorphism. 1017 1042 … … 1021 1046 In \CFA terms, all Cyclone polymorphism must be dtype-static. 1022 1047 While the Cyclone design provides the efficiency benefits discussed in Section~\ref{sec:generic-apps} for dtype-static polymorphism, it is more restrictive than \CFA's general model. 1023 \cite{Smith98} present Polymorphic C, an ML dialect with polymorphic functions and C-like syntaxand pointer types; it lacks many of C's features, however, most notably structure types, and so is not a practical C replacement.1024 1025 \cite{obj-c-book} is an industrially successful extension to C.1048 Smith and Volpano~\cite{Smith98} present Polymorphic C, an ML dialect with polymorphic functions, C-like syntax, and pointer types; it lacks many of C's features, however, most notably structure types, and so is not a practical C replacement. 1049 1050 Objective-C~\cite{obj-c-book} is an industrially successful extension to C. 1026 1051 However, Objective-C is a radical departure from C, using an object-oriented model with message-passing. 1027 1052 Objective-C did not support type-checked generics until recently \cite{xcode7}, historically using less-efficient runtime checking of object types. 1028 The ~\cite{GObject} framework also adds object-oriented programming with runtime type-checking and reference-counting garbage-collection to C;1053 The GObject~\cite{GObject} framework also adds object-oriented programming with runtime type-checking and reference-counting garbage-collection to C; 1029 1054 these features are more intrusive additions than those provided by \CFA, in addition to the runtime overhead of reference-counting. 1030 \cite{Vala} compiles to GObject-based C, adding the burden of learning a separate language syntax to the aforementioned demerits of GObject as a modernization path for existing C code-bases.1055 Vala~\cite{Vala} compiles to GObject-based C, adding the burden of learning a separate language syntax to the aforementioned demerits of GObject as a modernization path for existing C code-bases. 1031 1056 Java~\cite{Java8} included generic types in Java~5, which are type-checked at compilation and type-erased at runtime, similar to \CFA's. 1032 1057 However, in Java, each object carries its own table of method pointers, while \CFA passes the method pointers separately to maintain a C-compatible layout. 1033 1058 Java is also a garbage-collected, object-oriented language, with the associated resource usage and C-interoperability burdens. 1034 1059 1035 D~\cite{D}, Go, and ~\cite{Rust} are modern, compiled languages with abstraction features similar to \CFA traits, \emph{interfaces} in D and Go and \emph{traits} in Rust.1060 D~\cite{D}, Go, and Rust~\cite{Rust} are modern, compiled languages with abstraction features similar to \CFA traits, \emph{interfaces} in D and Go and \emph{traits} in Rust. 1036 1061 However, each language represents a significant departure from C in terms of language model, and none has the same level of compatibility with C as \CFA. 1037 1062 D and Go are garbage-collected languages, imposing the associated runtime overhead. … … 1054 1079 \CCeleven introduced @std::tuple@ as a library variadic template structure. 1055 1080 Tuples are a generalization of @std::pair@, in that they allow for arbitrary length, fixed-size aggregation of heterogeneous values. 1056 Operations include @std::get<N>@ to extract val es, @std::tie@ to create a tuple of references used for assignment, and lexicographic comparisons.1081 Operations include @std::get<N>@ to extract values, @std::tie@ to create a tuple of references used for assignment, and lexicographic comparisons. 1057 1082 \CCseventeen proposes \emph{structured bindings}~\cite{Sutter15} to eliminate pre-declaring variables and use of @std::tie@ for binding the results. 1058 1083 This extension requires the use of @auto@ to infer the types of the new variables, so complicated expressions with a non-obvious type must be documented with some other mechanism. … … 1068 1093 The goal of \CFA is to provide an evolutionary pathway for large C development-environments to be more productive and safer, while respecting the talent and skill of C programmers. 1069 1094 While other programming languages purport to be a better C, they are in fact new and interesting languages in their own right, but not C extensions. 1070 The purpose of this paper is to introduce \CFA, and showcase twolanguage features that illustrate the \CFA type-system and approaches taken to achieve the goal of evolutionary C extension.1095 The purpose of this paper is to introduce \CFA, and showcase language features that illustrate the \CFA type-system and approaches taken to achieve the goal of evolutionary C extension. 1071 1096 The contributions are a powerful type-system using parametric polymorphism and overloading, generic types, and tuples, which all have complex interactions. 1072 1097 The work is a challenging design, engineering, and implementation exercise.
Note: See TracChangeset
for help on using the changeset viewer.