Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More rust training content #7

Merged
merged 11 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rust/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*~
yarn-error.log
target/
1 change: 1 addition & 0 deletions rust/CONTRIBUTING.html
92 changes: 92 additions & 0 deletions rust/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
TODO organize this

Every md file has a html relative symlink to index.html:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to explain the reason? I first felt confused until I find out we are loading the md dynamically according to the url.


`ln -s index.html CONTRIBUTING.html`

The static website loads the page content from markdown dynamically,
based on the URL of its HTML page.

Project text doesn't link directly to documentation resources containing
solutions - students should learn where to get the answers from the
pre-requisites and lessons.

Project text may include inline links to pages that offer explanatios of terms
and concepts.

Keep the project summary (the **Task**, **Goals**, etc. text) synced between
plan.md and the project description.

Common sections of project descriptions:

- The project summary (directly after h1)
- "Introduction"
- "Project spec"

Headers do not capitalize every word; words after a colon
are capitalized:

> ## Project spec

> ## Lesson: Tools and good bones

In projects, be clear on when the student should start hacking, and what they
should be hacking, by writing an imperative statement. Format that command in
italics:

> <i>Use [crates.io](https://crates.io) to find the documentation
for the `clap` crate, and implement the command line interface
such that the `cli_*` test cases pass.</i>

> _Try it now._

## Developing a new section

Each section provides a similar project to previous sections, while expanding
the scope and building off of learnings from previous sections. Each project
lends itself to being extended by the next section's project.

New sections are developed in pairs, to benefit from the feedback.

Approximate workflow:

- Author 1 and 2 collaborate on an outline for the new section, adding it to
plan.md, following the format of existing sections. This includes supporting lessons
and readings. Submit PR.

- Author 1 writes the entire project description; optionally with test cases if
that makes the writing easier. Add new background readings or otherwise modify
the section plan as needed. Submit PR. Author 2 reviews.

- Author 2 writes the remaining test cases and an example solution project. Add
new background readings or otherwise modify the section plan as needed. Submit
PR. Author 1 reviews.

- Author 2 makes changes to the project text for clarification, improvement,
scope expansion, etc. Add new background readings or otherwise modify the
section plan as needed. Submit PR. Author 1 reviews.

##

When writing a project, look for steps where the design could be specified differently,
where there are multiple solutions, where there is deeper understanding to be gained,
and ask questions formulated to get the reader to think more deeply.

Projects should be written to take between 2 - 4 hours to implement.

When writing a project, look for optional "extension" steps that teach
additional practical subjects, but which either aren't necessary to complete the
project or require more time and skill to implement. Extenion steps go at the
end of a project.

## Contributor notes

- each md file needs an html relative symlink to index.html
- lessons need a .slides.html symlink
- links are generally to markdown files, not html files
- exception: links to slides from plan go to the hosted website
- all links rewritten when browsed locally
- in markdown, write links as relative to current directory
- keep "task", "goals", etc in project intros in sync between "plan.md" and
project pages

13 changes: 6 additions & 7 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
A training course on practical software construction in Rust.

The final project in this course is a networked, persistent [key-value store]
with multithreading, asynchronous I/O (via [tokio] and [tower]), a
high-performance network protocol ([GRPC] via [prost] and [tower-grpc]),
backed by a simple [LSM-tree] that the student will write themselves.
with multithreading, asynchronous I/O (via [hyper]).

Subjects covered include:

- Structuring and maintaining Rust programs
- Fun and foolproof parallel programming
- Asyncronous programming with [futures] and [tokio]
- High-performance networking with [GRPC] and [prost]
- Asyncronous programming with [futures]
- Networking with [hyper]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hyper focuses on the HTTP protocol. I wonder what kind of service this subject will accomplish? (Plain HTTP 1.0 APIs or HTTP2 steaming APIs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't planning to do anything HTTP2 specific, though I assume hyper will negotiate a HTTP2 upgrade if it can. Do you have any suggestions?

I'm torn about using HTTP for this, since gRPC is what PingCAP uses. But @siddontang and I discussed that it may be too much to require gRPC for this project. If we don't do gRPC in the initial set of projects, I'm thinking it could be in a subsequent project.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think teaching 'networking with Hyper' is not a good idea since we don't use it at pingCAP (afaik) and it is not an essential library and the domain is still in flux. I think it is OK to use Hyper, just emphasize that we're teaching networking in Rust rather than any particular library (could even just use TCP?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nrc Somewhere @sticnarf suggested having the student just implement basic HTTP for that project, which does force them to write "real" networking code (vs just dropping in hyper).

- Benchmarking with [criterion] and [critcmp]
- Robust and reliable error handling with [failure]
- Serialization with [serde]
Expand Down Expand Up @@ -119,7 +117,7 @@ recommended to teach this course.

## Contributing

TODO
See [CONTRIBUTING.md].

## License

Expand Down Expand Up @@ -148,4 +146,5 @@ TODO
[Distributed Systems in Rust]: todo
[The Rust Book]: https://doc.rust-lang.org/book/
[plan]: plan.md
[serde]: todo
[serde]: todo
[CONTRIBUTING.md]: CONTRIBUTING.md
7 changes: 1 addition & 6 deletions rust/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ nav#site-nav {
position: absolute;
top: 0px;
width: 100%;
background: #666666;
background: #555;
color: white;
padding: 1rem;
line-height: 1.5rem
Expand All @@ -20,8 +20,3 @@ nav#site-nav a:hover {
color: orange;
}

section#content {
margin: 1rem;
margin-top: 4.5rem; /* nav border * 2 + line-height + 1rem */
}

20 changes: 20 additions & 0 deletions rust/css/text.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Styles for non-slide pages */

section#content {
margin-top: 5.5rem; /* nav border * 2 + line-height + 2rem */
}

section#content {
padding-left: 100px;
padding-right: 100px;
}

pre {
background-color: #555;
color: white;
padding: 1rem;
}

body {
margin-bottom: 5rem;
}
2 changes: 2 additions & 0 deletions rust/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export function mdUrlFromUrl(url) {
let mdUrl = url;
if (url.indexOf("index.html") != -1) {
mdUrl = url.replace("index.html", "README.md");
} else if (url.endsWith("/")) {
mdUrl = url + "README.md";
} else if (url.indexOf(".slides.html") != -1) {
mdUrl = url.replace(".slides.html", ".md");
} else if (url.indexOf(".html") != -1) {
Expand Down
14 changes: 14 additions & 0 deletions rust/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function init() {
contentElement: contentElement,
};

addCssForPageType(config);
dispatchInitForPageType(config);
}

Expand All @@ -45,6 +46,19 @@ function getPageType(url) {
return type;
}

function addCssForPageType(config) {
if (config.pageType === "lesson-slides") {
return;
}

let head = document.querySelector("head");
console.log(head);
let link = document.createElement("link");
link.setAttribute("rel", "stylesheet");
link.setAttribute("href", "css/text.css");
head.appendChild(link);
}

function dispatchInitForPageType(config) {
let mainModule = null;
if (config.pageType === "md") {
Expand Down
18 changes: 9 additions & 9 deletions rust/notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ in the README.
- Ana likes this
- variable shadowing
- DSTs
- configuring clippy / rustfmt
- scripting clippy / rustfmt for CI
- CI setup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, it is very important for open-source projects, I just fixed a bug today during setting up CI. But which one do we want to target? Maybe we can make a list of CI doc link, let students choose.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offhand I'd prefer to be opinionated and pick either travis or circle, whichever has the most open source mindshare (or maybe whichever pingcap uses). That way we can be specific about requirements, and have a better chance at automatically verifying they set up CI correctly.

It's not a strong opinion though.

It's also a chance to talk about the README and other boilerplate files, the various badges and other services Rust projects typically use.


## Sources

Expand All @@ -51,25 +54,22 @@ in the README.

## Subjects to potentially cut

- Whirlwind rust lesson
- Parallelism section
- Formatting lesson
- Build time lesson
- Collections and iterators

## Contributor notes
## Grading

- each md file needs a relative symlink to index.html
- lessons need a .slides.html symlink
- links are generally to markdown files, not html files
- exception: links to slides from plan go to the hosted website
- all links rewritten when browsed locally
- in markdown, write links as relative to current directory
- automated text-based cheat detection
- automated grading of test cases
- automated grading of non-unit-test requirements via python script
- how to grade freeform answers?

## TODO

- do survey of other sources' subject progression
- lessons and labs pose questions
- have a chinese native identify and remove 'hard' words and phrases
- mention somewhere that we're using rust 2018 only, how to verify
- change slides.html URLS to link to the hosted file
- change slides.html URLS to link to the hosted file
Loading