-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.html
317 lines (308 loc) · 12 KB
/
.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<!DOCTYPE html>
<html>
<head>
<!--
- CodeBits.html
- ver 1.0 - 10 June 2019
- Jim Fawcett, Emeritus Teaching Professor, Syracuse University
-->
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta name="description" content="Software Projects. Code Samples. Software Links" />
<meta name="keywords" content="Repository, Design, Code" />
<meta name="Author" content="Jim Fawcett" />
<meta name="Author" content="James Fawcett" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Code Bits</title>
<script src="js/ScriptsUtilities.js"></script>
<script src="js/ScriptsTemplate.js"></script>
<script src="js/ScriptsKeyboard.js"></script>
<script src="js/ScriptsMenuOtherRepo.js"></script>
<script src="js/ScriptsWebComponents.js"></script>
<link rel="stylesheet" href="css/StylesWebComponents.css" />
<link rel="stylesheet" href="css/StylesTemplate.css" />
<link rel="stylesheet" href="css/StylesDefault.css" />
<link rel="stylesheet" href="css/StylesMenu.css" />
<link rel="stylesheet" href="css/StylesBrownTheme.css" />
<style>
#github summary {
padding: 3px 0px 5px 0px;
}
#github ul.tight > li {
margin-bottom: 2px;
}
#github .undefined {
opacity: 0.4;
}
#github hr {
margin-top: 0.5em;
margin-bottom: 0.25em;
margin-left: -2em;
}
#github div ol > li {/* white-space: nowrap;*/ }
#github menu-item {
display: block;
/*width: 17em;*/
font-weight: bold;
user-select:none;
}
menu-right {
display: block;
user-select:none;
}
</style>
</head>
<body id="github" onload="initializeMenu()">
<navKeys-Container>
<nav-Key id="sKey" onclick="toggleSwipeEvents()">S</nav-Key>
<nav-Key id="rKey" onclick="location.reload()">R</nav-Key>
<nav-Key id="tKey" onclick="scrollPageTop()">T</nav-Key>
<nav-Key id="bKey" onclick="scrollPageBottom()">B</nav-Key>
<nav-Key id="hKey" onclick="helpWin()">H</nav-Key>
<nav-Key id="pKey" onclick="loadPrev()">P</nav-Key>
<nav-Key id="nKey" onclick="loadNext()">N</nav-Key>
</navKeys-Container>
<nav>
<div id="navbar"></div>
</nav>
<a id="Next" href="IdiomsAndPatterns.html">N</a>
<a id="Prev" href="DesignBites.html">P</a>
<header>
<a class="repoLink" href="https://github.com/JimFawcett/IdiomsAndPatterns">IdiomsAndPatterns code</a>
<hgroup id="pagetitle">
<h1 id="title">Idioms and Patterns Repository</h1>
<h3 id="subtitle">Comparing C#, C++, and Rust</h3>
</hgroup>
<div style="padding-right:25px; position:absolute; top:2.5em; right:1.2em;">
<details>
<summary class="lightItem quickStatus">Quick Status</summary>
<status-grid style="padding:5px 10px;" class="lightItem border">
<status-itemLeft>
Many short demos
</status-itemLeft>
<status-itemRight>
only a few installed
</status-itemRight>
<status-itemLeft>
Demonstration code
</status-itemLeft>
<status-itemRight>
coming
</status-itemRight>
<status-itemLeft>
Documentation
</status-itemLeft>
<status-itemRight>
yes
</status-itemRight>
<status-itemLeft>
Test cases
</status-itemLeft>
<status-itemRight>
NA
</status-itemRight>
<status-itemLeft>
Static library
</status-itemLeft>
<status-itemRight>
NA
</status-itemRight>
<status-itemLeft>
Build requires
</status-itemLeft>
<status-itemRight>
dotnet, CMake, Rust installed
</status-itemRight>
<status-itemLeft>
Planned design changes
</status-itemLeft>
<status-itemRight>
Add many short fragments
</status-itemRight>
</status-grid>
</details>
</div>
</header>
<!--<div style="display:flex;">
<indent-block style="position:relative; z-index:10; background-color:#fefefa; display:inline; padding:0px 10px; max-width:70%;">
"Champions aren't made in the ring. They are merely recognized there."
<br />
- Joe Frazier, professional boxer
</indent-block>
</div>-->
<hr class="spread" />
<div>
<h3>Contents:</h3>
<!--<t-b>
<a href="#code">Code List</a>, <a href="#bites">Bite List</a>
</t-b>-->
<indent-blocks>
<t-b>
This repository is starting a growing sequence of short stories about Idioms and Patterns, that we illustrate
with code snippets from C#, C++, and Rust.
</t-b>
<!--<t-b>
Some Bites may eventually have accompanying videos if that seems worthwhile. The goal is to make each Bite
small and clear enough to digest in a half hour before lunch. The effort needs to be low enough
that you will actually read them and write a few lines of code.
</t-b>-->
<h3>Snippets:</h3>
<t-b>
Here are the currently planned code snippets.
The ordering of some of these may change. Ordering so that each code snippet depends only on its
predecessors doesn't necessary provide a good logical ordering. I'll be thinking about this
as the list gets completed.
</t-b>
<div class="indent">
<ol class="tight">
<!--<li>
<hr />
<menu-item><a href="Resources/IdiomsAndPatterns/ObjectModels.html">Object Models</a></menu-item>
<menu-right>Background information to help you interpret code presented here</menu-right>
</li>-->
<li>
<hr />
<menu-item><a href="Resources/IdiomsAndPatterns/Tooling.html">Tooling</a></menu-item>
<menu-right>Tools to develop C#, C++, and Rust on both Windows and Linux</menu-right>
</li>
<li>
<hr />
<menu-item><a href="Resources/IdiomsAndPatterns/IaP_Hello.html">Hello World</a></menu-item>
<menu-right>use C# with dotnet CLI, C++ with CMake, and Rust with cargo to build Hello World</menu-right>
</li>
<li>
<hr />
<menu-item><a href="Resources/IdiomsAndPatterns/IaP_Objects.html">Hello Objects</a></menu-item>
<menu-right>Declare Classes/Structs and create instances.</menu-right>
</li>
<li>
<hr />
<menu-item><a href="Resources/IdiomsAndPatterns/IaP_Data.html">Manage data</a></menu-item>
<menu-right>Explore types. Consider bind, copy, assign, and move operations</menu-right>
</li>
<li>
<hr />
<menu-item><a href="Resources/IdiomsAndPatterns/IaP_BasicDIP.html">Basic DIP</a></menu-item>
<menu-right>Demonstrate basic Dependency Inversion Principle</menu-right>
</li>
<li>
<hr />
<menu-item><a href="Resources/IdiomsAndPatterns/IaP_GenericDIP.html">Generic DIP</a></menu-item>
<menu-right>Demonstrate Dependency Inversion Principle using Generic Trait</menu-right>
</li>
<li>
<hr />
<menu-item><a href="Resources/IdiomsAndPatterns/IaP_Iteration.html">Iteration</a></menu-item>
<menu-right>Demonstrate iteration through strings, slices, and byte arrays</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="Resources/IdiomsAndPatterns/IaP_Libs.html">Create static libraries</a></menu-item>
<menu-right>Explore projects with library and console executive</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Explore performance</a></menu-item>
<menu-right>use timers written in each language to compare performances</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Explore ownership</a></menu-item>
<menu-right>implement simple graphs using C# references, C++ (smart) ptrs, and Rust indexes</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Sharing with Rc<T> and Arc<T></a></menu-item>
<menu-right>Shared data</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Explore strings</a></menu-item>
<menu-right>C#, C++, and Rust all use different string types</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Iterations</a></menu-item>
<menu-right>Iterating over byte arrays and strings</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">More strings</a></menu-item>
<menu-right>Creating, mutating, converting</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Functions</a></menu-item>
<menu-right>Syntax, passing by value and reference, return types</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">User defined types</a></menu-item>
<menu-right>Declaring, instantiating, methods, access, state mutation</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Generics</a></menu-item>
<menu-right>Parameterization, Policies, lifetimes</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Traits</a></menu-item>
<menu-right>Bounds on generic types, Static and dynamic dispatching</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Lambdas</a></menu-item>
<menu-right>Syntax, data capture, transporting across scopes</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Liskov Substitution Principle</a></menu-item>
<menu-right>Inheritance, dynamic dispatch, trait objects</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Dependency Inversion Principle</a></menu-item>
<menu-right>Interfaces, object factories, trait objects</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Decorator Pattern</a></menu-item>
<menu-right>Structure, application flow</menu-right>
</li>
<li class="undefined">
<hr />
<menu-item><a href="javascript:;">Observer Pattern</a></menu-item>
<menu-right>Structure, application flow</menu-right>
</li>
</ol>
</div>
<s-1Em></s-1Em>
<spacer-15></spacer-15>
<h3>Build:</h3>
<t-b>
The three languages have different tool chains, but this story shows that the build processes can
be very similar. Our goals are to build on both Windows and Linux. We do that using Visual Studio
Code as a text editor and building from its terminal.
<ul class="tight">
<li>
C# code was built from the command line with dotnet.
</li>
<li>
C++ code was built from the command line using CMake.
</li>
<li>
Rust code was built from the command line using the rust cargo tool.
</li>
</ul>
All of these builds work in nearly identical ways on both OS platforms.
</t-b>
<h3>Status:</h3>
<t-b>
Just startiing.
</t-b>
</div>
<spacer-25></spacer-25>
<!--<img class="strip-photo" src="Pictures/CampusAtNight.jpg" alt="campus at night" />-->
<info-bar onclick="location.reload()"></info-bar>
</body>
</html>