Explaining to students why to use double instead of float (unless there's a very good reason) I keep seeing students use float in lab lessons:

For example, a simple physics calculation of kinematics. Many, many students use float to hold the variables:

float y,g,t,v

etc.

In this specific lab, they idea is for them to see:

$$y(t_{n+1})=y(t_n)+\frac{\Delta y}{\Delta t}\Delta t\approx y(t_n)+v(t_n)\,(t_{n+1}-t_n)$$
with
$$v(t_{n+1})\approx v(t_n)+g*(t_{n+1}-t_n)$$

and then run over times $\{t_i\}_{i=1}^n$ and see that the $y$ values they get are the same as:

$$y(t_n)\approx y(t_1)+v(t_1)\,t_n+\frac{1}{2}g\,t_n^2$$

However, because they use float, they get rounding errors when dealing with small time differences ($\Delta t$). I don't want to get into the whole floating point arithmetics field, because they won't understand that (the word "exponent" would frighten them, to say the least).

On the other hand, if they use double, then the rounding errors wouldn't be significant (because they aren't dealing with $\Delta t \le 10^{-5}$ of a second). So I try to explain that they should use double, but just stating it as a "rule of thumb" isn't a good idea (because there are cases where one would prefer float)

So, what explanation, as to why they should use double for these things, would be compelling?

Better yet, is there any way I can show the students such an explanation? (Perhaps an online, interactive demonstration of floating point precision etc. - I couldn't find one)

Luckily this is quite simple to make clear, even if you are steering clear of the IEEE standard.  Honestly, even binary is not needed here.

I would start by borrowing a page from Scheme, and say that we can't make blanket guarantees about the exactness of decimal numbers.  For instance, when we try to express $2/3$ in decimal, and it doesn't work!

All the more so when we are restricted to 10 digits.  We write $0.666666667$.  Why?  It's not that 2/3 is $0.66666667$, it's just that we can't precisely represent $2/3$ in decimal, and at the 10th digit, we just round to get as close as we can.

This is really a problem with any number that has a decimal place.  There are infinite numbers that we can't represent!

The computer has the same problem with decimal numbers as we do.  This isn't a fault of the computer, it's just a feature of floating point numbers, and the computer has to work around it, just like we do.

Now, we do have a way of increasing that precision: we can increase the number of digits allowed.  It doesn't solve the problem, exactly, but it does get us closer to the true numbers.

That's the difference between a float and a double.  A double allows more digits.  And that's why it's usually a better idea to use a double.


What qualities should be considered when designing a front end project? I'm working on designing a project where the students will use HTML+CSS to replicate a specific layout which I will give them as a picture. The goal of the project is to allow each student to practice their HTML+CSS skills by implementing the design in a clean way that follows the best practices that I have taught.

I would want to give each person a different task (or at least have more than one design so that each person could get a random design to implement). In order to ensure that the assignments I design are challenging, interesting, distinct, and of similar difficulty, what qualities should I try to emphasize? Keep in mind that these students should have a full knowledge of HTML+CSS, so anything can be included.

Both specific ideas for layouts and CSS/HTML skills to try to include are valuable. Some things that I have thought of have included multi-column layouts, a sticky nav, or notifications/lightboxes.

As a student I would find this assignment uninteresting and a waste of my skills. I would feel the professor is just trying to be lazy and not having to properly grade assignments.

If they really should know HTML and CSS by now, don't treat them like babies. Just ask them to build a complex responsive page that works as their resume and/or portfolio. They will be glad to make something beautiful and actually interested in your assignment. You can of course set minimum requirements like having transitions and animations, media queries, etc.

My point is: don't create an assignment to try to make your students fail a few points off your check list, but create one that will make all your students interested and proud of their creation.


What are good examples that actually motivate the study of recursion? One of the traps of imperative-first is how difficult it becomes to help students make sense of recursion when they finally encounter it.  And if those kids are fairly competent iterative programmers, they may also resist the new technique, as they feel perfectly comfortable solving problems without it. Many of the obvious examples of recursion (such as Fibonacci numbers) are either faster or cleaner when done iteratively.

What examples, then, cleanly motivate recursion?  To be honest, they don't have to even be coding examples.  What I want is for students to intuitively understand the purpose of this new (to them) technique.

(I am aware of this question of course, but, while it is helpful, is is after an explanatory analogy to clarify recursion, while this question is about finding a clear motivation to study it in the first place.)

I find a very easy to understand example for recursion is the folder structure on a computer.
Look through all folders (within a certain location) and... list all .doc files, for example.

First, you look in the location you were given and see what you're looking for... or not, but you see more folders.
Then you take each of those folders, look into them and see what you're looking for... or not, but you see more folders.
Then you take each of those folders... (you get the idea)

It's a simple function to write and understand (at least in pseudocode, actual implementations may vary^^) and a concept that's easy to grasp for even a complete beginner. Introducing the problem and the manual solution, it's already obvious that each time, the same thing happens again and again. Pseudocode implementation is equally simple to write and grasp:
function findFiles(folder) {
  look for .doc files, if found add them to fileList.txt
  look for folders
  for each found folder: findFiles(foundFolder)
}

I've used this example to explain recursion several times, and never had trouble getting the person to understand it. Even non-programmers can grasp the concept like this.


How do you wow second-year students into saying "bare-metal programming is cool!"? Next semester I will be TAing a computer organization/assembly language course. I will be full-fledgedly (co-)teaching the lab. The first lab will take place before the first lecture, so me and the other TA will partly be responsible for preparing the students to not resent this class they're forced to take. At this point, the students have taken an intro class with Python and a class on OO concepts in Java, and they might be taking a language-agnostic algorithms class at the same time. The professor's standard way of motivating the concept on the first day is showing how going through an array column by column is slower than row by row even though they give the same result using the same approach.

Therefore, I have to motivate on two fronts: why is assembly programming (or even C) interesting/relevant, and why is computer organization interesting/relevant. The latter may seem obvious if you're already in the know, but it sure didn't for me before I took this very course.

Here are some of the points that I already intend to include in my opening spiel (everything that starts with a backslash is spurious):

"If you go into data science: the information in this course will explain why certain programs are slow, which is important if you're churning a lot of data.
\You will learn how to write faster programs in general.
You will understand how computers actually work, no magic [I don't have to mention that they won't learn everything].
\This class might make you interested in systems-level programming, even considering a career.
Do you ever feel awed at those other guys with their cool Arduino or Raspberry Pi projects? This class will teach you how to do what they do."

What are some other motivators that I can include?

EDIT: Just to be clear: I have no control over the lab, and definitely none over the lecture. I won't even be present for the professor's lecture. What I have control over is what I explain as I explain the pre-baked labs, which in the first three weeks include an introduction to ssh, C, certain binary algorithms, and pointers. Aside from the ssh, these are supposed to segue everyone into asm.

First, just a disambiguation: are you teaching Assembly language or C? Cos, they are not same as your question seems to suggest. C is a high-level procedural clean code language with tremendous abilities to speak to the bare metal similar to but not as Assembler pls. It may help you bridge to assembly but it is not assembly. Let that be clear to your students.

Never taught machine programming/ASM. But your question touches something in me: the need to wow! the student; I have same predilection with students. So I felt obliged & did some talking with friends in the know and some research.

Here’s the widow’s mite I pieced together. Hope it helps:
You can add the following to your first lab “sales pitch’:

Let the first lab be a NO CODE, no Technical stuff class. Just getting familiar with selves and ASM in a general way with nothing too technical and thus “intimidating” or “off-putting”. The class should be (pardon my cliché): sugar and spice and all things nice. Toward this:
Add to your spiel, a history of Assembly telling them of Kathleen Booth & others etc. Make it interesting. Search & find some spectacular successes and exploits using ASM and also some disasters of sloppy ASM. Apart from sparking interest and discussion, the last part will have the additional pedagogic value of sensitising the students to their power as oracles speaking to the small dumb “god” in the machine. Also it will put them on notice of the enormous responsibilities their heightened power as bare metal oracles imposes on them to avoid sloppy code (not only for ASM but programming generally).
Let the students see how the higher level languages with their swagger and leaky algorithms are actually, mostly dependent on ASM and C. Let them see that a lot of our higher level constructs e.g. macro were borrowed from Assembler.
As @Buffy I. rightly pointed out, talk alone can’t win a non-committal or skeptical mind. To give them something interesting: show them some good things (e.g. games) made in Assembler and display for them on slide (s) the assembly code snippets that made such things. In this regard I found some of these online and hope they may help or stimulate some interesting ideas:
https://spectrum.ieee.org/geek-life/reviews/three-computer-games-that-make-assembly-language-fun.amp.html

https://www.quora.com/What-are-some-cool-assembly-language-projects-I-can-do?top_ans=21546329

https://brianslam.wordpress.com/2014/04/06/assembly-is-fun-sort-of/

https://news.ycombinator.com/item?id=16710543

This one is a Compendium of Assembly Coding Practices from Coding Project. It may help illuminate your teaching:
https://www.codeproject.com/Articles/1116188/40-Basic-Practices-in-Assembly-Language-Programmin


How do you distinguish jargon from normal language in explaining a concept? For example, words like "method," "puts," and "object" do not have as much linguistic markedness as "comparator," "eff-gets," and even "function" (because context alone at the very least conjures up the math term). So, for example, how do you make clear when explaining classes that when you say "your method doesn't work," that you mean the class's function doesn't work rather than the manner in which a student is carrying out the task at hand doesn't work? My current method(!) is to never use the word with its mundane meaning in a tutoring context: "In the last session, the professor went over ways for writing methods for a class."

(It may be the case that this isn't a problem for some, but in my first year, I didn't realize that "for-loop" wasn't jargon on the first exposure.)

EDIT: People have missed the point of the question. The names of certain CS concepts have more markedness (“standing-out-ness”) than the names of other concepts. Which particular concepts do not matter: “variable” sounds more like a jargon word, more like a reason to have the ears perk up and know to start taking notes, than “assignment.” When speaking out loud, how do you non-stiltedly mark jargon whose meaning may be overshadowed by a more common meaning in a non-jargon context?

In direct answer to your question: not much.  I keep my approach here very simple.  I do as I would for any other time that a word could have two meanings.  If the word use feels ambiguous, I clarify which version I mean.  If it doesn't, I let it stand.

It sounds like you're trying to put a lot of careful discipline into your speech patterns.  There's nothing wrong with that; it's admirable!  It may even help to stem a bit of confusion, but I honestly haven't found that being more relaxed (and clarifying as needed) has caused many roadblocks for my students, so I don't worry about it too much.

I do occasionally discuss trap words when first introducing them, just to make clear to my students that there are now two meanings in play.


Database theory (normalization) for beginners (adult education, MS Access) When teaching database basics to non IT beginners, what is the minimum requirement in theory and technical terms?
So what is absolutely necessary to talk about DBs? What helps students grasp the basic idea of relational databases?

Especially with normal forms. NF1-2-3? Boyce-Codd? Or even NF4-5-6 makes sense?

In my trainings we don't have a lot of time, we focus on the practice, but since this is a new concept to my students, they will need to understand a few fundamental things.

Context:

I'm holding company trainings. As tasks get more and more complex at corporations, and the general IT literacy is (somewhat, slowly) raising, more and more people are looking for ways to swap out their huge and cumbersome "Excel can do it all" solutions. This either means they start learning VBA programming or they turn towards databases, namely MS Access. The trainings I do are 2-3 day intensive courses with very strong practical focus.

Based on the comments, the minimum for theory and technical is how the nomenclature of MS Access relates to Excel.

If they've been doing everything in Excel anyway, they've developed habits for, or against, normalization that you're not going to break in a couple days, intensive or not.

If they haven't discovered the pitfalls of redundant data in Excel, they probably won't in MS Access either. If they have, then they've already learned the lesson, and developed their own methods of "normalization."

You can bring it up, and have resources available for them to access, online in their own time, if they develop the interest in "doing it right." Otherwise, concentrate on helping them become fluent in MS Access, an hopefully reduce the calls for help you get when they don't remember how that works in two weeks.


How can we motivate students to review each other's code? Code review is crucial to student's academic and professional lives, yet some students see code review as a burden and a new way teachers have found to "ditch some work".

By experience, code review works better if the majority of the class is into it, yet this is becoming more and more rare.

What strategies do you have to motivate students to review each other?

Sidenote 1: I've seen some teachers ask the class to write some code and ask a student to showcase and the rest of the class would review it, it did not work very well, because it was always the same 4/5 students participating.

Sidenote 2: I'm dealing with high school and college students

You have an opportunity for several things here:

You can make it a small-team effort rather than a whole-class thing. Say, a team of about 5.
The team reviews everyone's code in sequence so all get to participate. Instead of a "code-review" it can be a "code-quality-workshop".
The team has to write up the results of the review, with an addendum by the code's author about how the code was improved. (Writing is good.)
A whole-class retrospective on the process and its effect. (Retrospectives are good.)

If you have several groups working at once, you will need to wander around and participate in each group, giving pointers on process (rather than product). But you also need to do that if you have the whole class as the set of reviewers, of course.

An alternative to code reviews, of course, is pair programming, where the need for reviews is lessened or eliminated. Two minds working together are stronger than than the two working separately it turns out when creating code. Code quality has been observed to improve and quantity (statistically speaking) doesn't go down by enough to overcome the quality issue.

You may need to add a level of peer evaluation/review to this as well. Something like the following has worked for me over several years. In any group assignment, each member of the group also submits a peer review sheet. For a group of two (e.g. pair programming) I ask each participant to detail the most important contribution of their partner AND their own most important contribution. I don't ask who worked harder or ask them to make an evaluation. I ask them for the contributions.

In a group of about five, I will ask each member to name the (say) three most important members of their group and to mention the key contribution of each. I tell them that they can include themself in the list of three. I also ask, separately for their own most important contribution.

I let them know at the beginning of the course that this will happen and its parameters, so it isn't a surprise.

Students see that they are supposed to contribute to a group and are not asked to speak ill of anyone. Keep the questions entirely positive. But you also learn a lot from what is not said and who is not included in the contributor list.

If the project happens outside your view, you also learn things about individuals that you can not otherwise know. I've had students I thought were slacking who were praised by teammates for making the team work properly.

These peer evaluations are not optional.

This same idea was also discussed here: https://cseducators.stackexchange.com/a/2578/1293

Let me note that there may be cultural limitations here. In some cultures it may be odd to name oneself as a top contributor. In others it might be very natural. You can modify the scheme, of course, either requiring or forbidding naming oneself as one of the top people. Use your judgement here.


Is it worth to learn to make a MD5-hash cracker? I found a puzzling site where one puzzle was to find a string whose MD5-hash is given. Is such a puzzles good for learning? I mean, I believe that hash might be cracked by using enough computing resources. You might learn distributed computing or GPU/assembly programming if you try to make a cracker as fast as possible. On the other hand, why should one spend weeks to crack some hashes?

I have used a similar idea - writing an SHA-1 hash cracker - as a mini-project for students learning Java. These students had previously learned to program in other languages, so they had experience with variables, if/else, loops and functions; the main goal was to get them used to Java's syntax, but some of the specific things they had to do were:

Import and use a library method (DigestUtils.sha1 from the Apache Commons library).
Write a for loop over a range of characters instead of a range of integers.
Use nested for loops to generate every combination of characters, of a fixed length.
Use recursion to generate every combination, where the password length is a parameter.
Estimate how long it would take to crack a password of a particular length by brute force.
Read from a text file with one word on each line.
Test their code.

Your question implies you are thinking of writing your own implementation of the hash function itself. I think that's probably less worthwhile, since you'll just be directly translating from the hash function's specification into code, or from an implementation in one programming language to another. You would be practicing your skills in reading and making sense of specifications or code, and you might learn some things about bitwise operators; but the design of a hash function is arbitrary and opaque to almost everybody, and there would not be much real "problem solving" required.

I think for a learner-programmer, there is more to gain from using a library for the actual hash function, and writing the rest of the cracking program yourself - i.e. the part which generates the candidate passwords to feed into the hash function. For example, the next mini-project I got those students to do involved generating all combinations of playing cards to work out probabilities of winning in a simple card game; this is not entirely unlike generating combinations of characters for a password, and some students did notice the similarity.


How to answer questions about how I became interested in programming? I teach programming to students seeking employment as programmers who know little or nothing about programming, and I was last employed as a programmer over a decade ago. Sometimes I am asked what got me started, or what my main interest was. Students are often surprised when I explain that I last programmed professionally near the start of the millennium, and also that I have learned the language I am teaching only recently (C#, which did not exist way back when).

I think that some students ask because they are trying to find a point of interest themselves, so that this can become something they desire to be, rather than just a job. When I tell them that I wanted to know how computers actually are able to function / operate / control themselves, ever since I was a child before anyone had a computer, they can understand that. I say I wanted to write Operating Systems, and although I did not achieve that, I did lots of low-level stuff from sharing modems over a Novell Network to creating a multi-threaded web server.

They might not end up with those sorts of assignments when they become employed, but the point of learning to program is to understand how all this magic can happen. It is most fascinating when "The magic goes away" and we understand fully. That is what I want for my students. How do you answer such questions, and the flurry of "what languages do you know" etc?

If you are doing a good job of teaching then your students probably think you are smarter than you really are. They may also think that you arrived magically at your current position without effort or setback. It is good for them to know the truth. That what looks to them like brilliance was more likely just hard work and never giving up.

It is also good for them to know that the world they are entering (sometimes called adulthood, or the real world) won't always offer them what they hoped it would, but that if things are bad they will probably get better. But also, if they are good, they won't always remain so.

It is good for them to know that you are a human being who makes mistakes, admits them, and learns from them. Letting them think you are perfect is probably a mistake as they may be overly disappointed if you ever falter.

So, my advice, even to a question that may not be the best fit for this place, is to open yourself to them as honestly as you can, letting them know that it takes effort to succeed, but also that it takes plenty of desire.

It is especially useful if you let them know that some, perhaps many, of them are "smarter" than you are on nearly any scale. Whatever "smarter" really means. Just don't let them get the idea that you don't work as hard as you ask them to do.

You can teach these lessons in small bits without really taking much class time. I wouldn't devote a lecture to it, but a stray comment now and then ("I found this topic really hard when I first learned it.") might give them the confidence that "yes, it really is hard", rather than the fear that "I'm so dumb".

A few, at least, of your students might be inspired enough to follow a similar path to yours.


How to figure out what I need to search for in order to create a program? I'm a student in computer science and got my bachelor's degree 2 weeks ago. I had the opportunity to practice a lot of C/C++ (more C than C++) during the past 2 years.

I frequently don't know what I should know in order to realize what I want to do, or in order to fix a bug, because in order to do what I want to do, I need to know what the steps are to reach my goal, or at least in which direction I should look in order to figure out the intermediate step.

For example, let's say I ask you to create a shell from scratch. A friend told me that:

There is a function which allows you to execute some builtins command (execv() function in C)
There is also a function which allows you to execute a function without leaving the current process (fork() function in C)

How are you supposed to know that you need a function which allows you to execute a function without leaving the current process? How are you supposed to came to the conclusion that you need a function to execute builtins, but inside a child process in order to keep the program running normally?

How can I figure out what steps I need to take to realize what I want to do, or how to figure out what I need to search for in order to create a program?

I ask the question because I may have a bachelor in computer science but I'm not capable of keeping a job as a developer.

To a certain degree, it comes down to experience. But if you don't have experience, I feel you can get a lot of mileage of just trying to do the simplest thing possible to see what'll happen and googling your questions as you go.

At some point, you'll run into an obstacle you didn't anticipate and realize you need to pivot and adjust or even entirely re-write your code to accommodate. (Having to rewrite code can seem painful at first, but it's basically something everybody needs to get used to. It's helpful to have a sort of zen mindset, where you let go of your attachment to your code).

Once you do this enough times, you start to develop a sort of gut sense for what sorts of obstacles you might end up.

For example, take your shell example. If I had absolutely no idea what I was doing but just moved forward instead, I would probably...

Start by writing the code to do the user input/output stuff so I can get commands from the user. This code would likely be extremely minimal/something you'd write in a CS1 class.
Next implement some basic shell navigation functionality like cd and ls directly within the shell. Now, my shell is a little more complicated: I need to remember things like where I'm located in the file system; I'd probably have to do some research on how you'd implement things like ls within C...
Next, try I'd try and implement the ability to have my shell call other programs. Since I'm a beginner, I have no idea how to do this, so I'd pretty much immediately just google "C run another program". This will immediately bring up results that mention the "fork" and "exec" keywords.

I might not know what those mean, but it gives me just enough context that I can form more specific google queries. ("C exec example", "C exec vs excv", etc...)

Now, depending on how I previously wrote my shell, I might immediately be able to adapt these examples to my own code, or I might need to rewrite and rearrange things significantly. This is mildly painful, but such is the life of a beginner -- no biggie, I do what I need to.

Then you rinse and repeat...

Another strategy you can try is to try planning ahead: specifically, figure out what precisely you want to do, then decompose that plan into smaller and smaller subproblems. The nice thing about this approach is that it forces you to think about potential obstacles you might run into and can help make it easier for you to form precise google queries.

For example, we want to write a shell. Well, what exactly does this shell need to be able to do? Let's say as a minimum prototype, I want to be able to:

Get user input
Run basic navigational commands like cd and ls
Define basic environment variables
Be able to run other programs

Ok, how do we do all three of these things? Well, if we drill down, we might end up coming up with something like this:

Get user input

Recognize and expand environment variables first?

Run basic navigational commands like cd and ls

Make some kind of system or library call to get the data I need? (Note to self: google this)

Define basic environment variables

Process the user input to get the variable name and the value somehow?
Store the variables in a map of some sort?

Be able to run other programs

??? (Note to self: google this)

Notice that if we had kept drilling down, we'd end up learning about the fork and exec thing here as well.


Good beginning assembly language for teaching about stack function calls We are considering integrating our processors design and architecture course with our assembly programming course by using the same processor for both. The processor class (which does its work in Logisim) does not have to necessarily implement the entire processor used by the assembly class.  A usable subset would be fine.

The assembly class focuses on stack operations, function calls, and PC operations, so any assembly language that we move to would have to support these as well.

Currently, our assembly class uses 6502, which has 6 registers (including flags), and a very limited number of commands.  This might end up being our best choice for integrating into processors, as I have not found anything simpler yet.

As far as the processor design class is concerned, 8-bit machines are about twice as good as 16-bit machines, and about 4x as good as 32-bit machines, and I'd like to keep the number of registers down to a manageable number.  6502's 6 registers is pretty reasonable.

The only assembly language for beginners that I have found is ACSL assembly, but it lacks a memory bus entirely (so no stack).  Are there other languages that I am overlooking?

Go with the 6502. Its market penetration and popularity has generated a lot of resources over the years, giving you more to work with. Looking into the "home-brew CPU" realm should supply significant material to make reproducing the 6502 in Ligisim fairly easy. It already has a small instruction set (around 150 operations) that includes stack operations. There are also several assemblers available that will allow you to cross-assemble the code on a PC and load it into the 6502.

As a bonus for the students, because of its popularity, there should be a few programs in the wild that you can get for the architecture students to run after they build the processor. Of course, that means they'd have to implement the whole processor, but it also gives them the boost of making the processor that will run a "real" program off the Internet.

As a bonus for you, since you've already been using it for the assembly class, you already have the materials, lessons, and experience for the assembly class and can concentrate on building lessons for the design class.


Teaching Revision (Change) Control Systems In High School CS Classes I teach AP Computer Science A and game design classes at the high school level in Washington state (where "revision control systems" are a grade level expectation (GLE) for 11th and 12th grade - all of the classes are mixed grade level, but that is probably a discussion for another day). We use the game design classes as our "bait" to get kids interested in CS, but there are usually some pretty sharp and motivated kids in those classes.

I want the students to work on collaborative projects and many of them want an easy way to move their work back and forth between home and our lab. This, and having a way to make mistakes and then back out of them (and the state GLEs) are motivating me to teach them how to use a revision control system. I'm inclined towards Git and GitHub both because I have experience with them and because GitHub offers private repositories to schools.

Our intro level game design class uses Code.orgs Game Lab which has a minimal, but useful revision control system. In AP CS and the upper level game design class we use a JetBrains IDEA (IDEA and Rider respectively) which have support for a variety of revision control systems built in.

So the questions:

When does revision control rise to the level of a "needed understanding" for students?
What are essential skills with revision control tools?
What are best practices (or good sources for learning about them)?
What tools to teach? I'm comfortable with Git and GitHub, and they are widely used, but are they good teaching tools?
Command line vs. GUI vs. IDE integrated interface?
If you're a college CS teacher, what do you want your incoming students to know?

I agree with the CSTA Standards that revision control is an important skill by upper high school.  My school has a GitHub account and it is good for both revision practice and for using Agile boards for task management, which is an important methodology for students to know as they move to college.  I think there is value in either GUI or Command Line knowledge.

Here are some resources about Agile in Education:
https://www.agileineducation.org/examples.html

I like this resource for revision control:
https://betterexplained.com/articles/a-visual-guide-to-version-control/

The main ideas are backup/restore, synchronize (sharing resources with multiple people), tracking changes, sandboxes, branching, and merging.


When should concurrency and parallel multi-processing concepts be introduced? Given the current trends with Moore's law and computer systems design, where even the cheapest cell phones and Raspberry Pi's, etc., are multi-threaded multi-processors, and any gains in performance (per Watt, per dollar, etc.) seem to be heading towards even more concurrent hardware:

How early should the concepts of parallel computation be introduced in computer science education (as the almost required default form of actual programming practice)?

What are the minimum prerequisite concepts before the requirement of concurrent thinking be introduced?

If we don't introduce parallel/concurrent thinking early, our students can develop a sequential mindset that makes it hard for them to make the shift later. The rest of this is in the context of a college/university CS curriculum...

Multithreading can be discussed in CS1 if the students build GUIs, since the GUI needs its own thread to maintain responsiveness while the main thread is handling time-consuming GUI events.  But most GUI libraries do this multithreading for you, so the students don't have to do it themselves -- you can talk about what's going on under the surface, but the students don't gain any hands-on experience and it's unclear to me how much they take away if they don't have to do it themselves. But there are schools that take this approach.

We introduce students to multithreading in CS2 (Data Structures), using Just-In-Time pedagogy.  The basic idea is to give the students a problem that requires them to store a lot of data in a data structure (e.g., an organism's genome in a C++ vector or a Java ArrayList, or a really big image to be processed) -- enough data that processing the data sequentially takes 5-15 seconds.  This is an eternity for todays students and they get impatient waiting so long for their program to solve the problem.  We leverage that impatience and use it as motivation for introducing multithreading and parallel execution as a means of speeding up the program. We think the CS2 (Data Structures) course is the first time there is a natural motivation for introducing multithreading, since that's the first time you can store enough data to really motivate it.

Our CS3 course is an Algorithms course, so we continue the exposure there by introducing parallel versions of searching and sorting algorithms, graph algorithms, etc.

Our fourth course is Programming Languages, where we spend 1-2 weeks on languages that provide features for parallel / concurrent execution.  For example, we contrast languages that expect threads to communicate via shared memory (and the different mechanisms to synchronize those accesses: semaphores, locks, condition variables, monitors) with languages that have threads communicate via message passing (e.g., Erlang, Scala).

Our sixth course is OS & Networking, where spend several weeks exploring the implementation of the features needed to do all of this: threads, processes, semaphores, locks, condition variables, message-passing systems, etc.

The upshot is that parallel and concurrency topics are "sprinkled" throughout our curriculum, rather than being confined to a single course.  (We also offer a junior-senior elective course that focuses solely on parallel computing, so that students who want more can dig deeper into the subject.) That's one way to do it.


Computer Engineering student with Holes in my knowledge (i want to improve) I'm a computer engineering student, I definitely have my strengths and weaknesses like any other student. And, I would like to improve upon areas that I'm either struggling in or completely missed in my fundamental intro courses.

this year i realized that there are few gaps in my knowledge specifically when it comes to programming. I understand most concepts, but sometimes i notice that i can't implement some concepts into code on my own.

This is due to gaps in my knowledge. There were couple times when teachers in my intro programming classes didn't have time to cover all the fundamental materials  so they skipped content. I didn't realize how big of a problem this is, until now that i'm in higher classes.

I'm still doing fine, but i'm scared this will grow into a bigger problem. I frankly have so much homework and studies and i can't dedicate time to go and start from zero again, specially that i know most things but missed on few important concepts. The problem is, i'm not exactly sure what all the concepts that i missed on are.

How can i fill the gaps in my knowledge in timely and efficient way? please help me. I would like to take your advice, and study those old content during winter break.

I learn better by practicing problems and reading books, and i don't learn well from coding websites. Are there any work books that i can buy and practice with, preferably workbooks that cover solutions so i can compare my answers.

In particular, I have troubles converting algorithms from the textbook to source code in C++ and Java. Sometimes I struggle in implementing data structures such as queues/and stacks into C/C++ or java. I understand iterative programming, and i need to improve my understanding of recursive and dynamic programming techniques.

The obvious answer is to get a good textbook on Java data structures. Some are better than others and a few will mislead you. I find John Lewis to be trustworthy (and inexpensive as well).

What you are probably missing is the notion of encapsulation of things in classes and specification by interfaces, both essential to Java and specifically to your quest on algorithms. Some understanding of generics will also help you progress, but that is secondary to encapsulation and the idea of separating interface from implementation.

There are more advanced books on Algorithms, but the grounding, first, in building data structures and reaching the point where you can understand the java.util library is your current optimal path.

I would suggest using Java first, rather than C++ as it has fewer traps for the unwary. Java is built at a somewhat more abstract level than C++ and so provides a better way to think about higher level concepts.


What to gather feedback on? I'm doing small group tutoring for an undergraduate course next semester and I'd like to gather feedback from students to improve my skills.

What are some questions I should ask the students in order to get useful feedback?

I want to do this with a quick (anonymous) Google form at the end of each session, but I'm open to other ideas about how to collect data.

Take everything with a grain of salt - if they like you they'll tend to be kind in their evaluations. It's also really easy to have anonymous surveys that yield ridiculously positive results (see the "analytics" used by just about any after school, drop in, or summer CS program for examples - using questions like "are you more or less likely to take another CS course").

Whenever I do an anonymous eval I do a few things:

Figure out a way to make it anonymous but to also make sure everyone submits one. Once I wrote a system that they could audit that collected responses and emails then scrambled the answers and sent it to me with a list of who responded separately another time I had the students send the results to a trusted third party.
Ask the kids for the good and the bad. I tell them that even the worst teacher does some good and even the best does some things wrong. I tell them that it's also nice to see some positive and if I only asked and got the negative it would be just to depressing :-)
The bad is important so I know what to change but the good is also important so I know what to keep.
I tell the kids that saying something is bad is ok. Better is why it's bad but even better is a suggestion as to how to change it.
If possible you want to follow up with the kids a semester or year later (if not longer). The perspective of time can really change opinions.


Differentiating Inclusive from Exclusive Or How can I illustrate the difference between $\lor$ and $\oplus$ in a way that isn't just boring?  Are there fun ways to illustrate and provide practice for this small, yet key, distinction?

Play the “if you have brown hair stand up” game.

For the introductory lesson. We use this to introduce selection (if statements), and a little bit of boolean logic.

  “Stand up if you have got brown hair.”
  “Sit down.” look around “Stand up if you have blue eyes.”
  …
  With out asking them to sit down “Stand up if you …”
  Address why some people are still standing, are they correct [yes], or are the seated people correct [no]. Why? [because I did not ask them to sit].
  …
  “stand up if you have brown hair or you are …” (this is where we start to cover Boolean logic, I have only done and, or, not).

In another lesson you could add xor, nand, nor.

Xor examples

  “if you have blond hair or you have blue eyes stand up”
  “if you have blond hair xor you have blue eyes stand up”


How to teach algorithms: implementation or application? One unit of CS50 AP's curriculum focuses on three main sorting algorithms: bubble sort, selection sort, and insertion sort. There is also discussion of something more efficient like merge sort. One programming assignment has students write the code in C to each of the three "simpler" sorting algorithms. Students get clear pseudocode of how each works, but they are left to work out the code on their own.

In contrast I just started working through Princeton's excellent Algorithms course on Coursera (Algorithms, Part I). The first unit there focused on quick find, quick union, and weighted quick union. The algorithms -- both in pseudocode and in Java -- were given by the instructor; the programming assignment (Percolation) involved the correct use of weighted quick union. Rather than implement it, I just had to apply it with the provided class WeightedQuickUnionUF.

Similar to the Princeton course, the AP CS A curriculum teaches sorting algorithms but only use thereof, not direct implementation (e.g. students are not expected on the exam to write insertion sort from memory). Instead, students have to understand it and be able to trace through steps in the sorting process.

So there seem to be two approaches here (not limited to just sorting algorithms): teaching the challenge of coding an algorithm from scratch (via implementation) vs. giving students the algorithm to apply to a particular problem (via application).

Is there a significant benefit in having students attempt to implement an algorithm from scratch? If so, is this the more effective approach for teaching?

The answer here, as it seems to be so often, is "it depends." The courses you've compared are comparing apples to oranges. Which are you trying to make, apple juice, or orange juice? You have to select to version implementation or application, which best moves the lessons, and the students, toward the objectives and goals set for the course.

The Apples

Coursera (AP CS A): The students are provided the finished algorithms and expected to apply them properly to solve some larger problem. The emphasis is on solving the problem with the given tools, not creation of the tools. All the coding, by the student and supplied to the student, is done in Java.

Target

Java
Object-oriented methodology
Problem solving

Pros

The students have a firm foundation in Java and are ready for 2nd semester college courses employing Java
The students can understand, and use, the object-oriented programming paradigm common in most newer development models.

Cons

While students will have more to learn in Java before using it professionally, they will need to return to the beginning to switch to a different language.
The students will have a good grasp of using existing implementations of common algorithms, yet not have the skills to develop new algorithms to solve problems they don't know about yet.

The Oranges

CS50 AP (AP CSP): The discussion leads from comparing the algorithms to see how they do what they do, and probably the costs of doing it each way, to creating the code that will actually do that sort. The clear pseudo-code that they are given the programming assignment was presumably developed during the discussions of the algorithms, and is merely repeated in a concise format for them to convert to C code. They are learning how to conceptualize the objective, work through creating the algorithm and carry that into live code.

Target

Computational thinking

Pros

The student have a firm foundation for implementing new algorithms, as well as an understanding of how to apply current, and new, algorithms
The students are equipped with an understanding of how to apply computational thinking to solve new and unique problems not yet reduced to algorithms

Cons

The students may have used a language which is not used in later courses, so they will have learn a new language to continue with programming courses
-The students may not have been exposed to, or practiced much with, the object-oriented approach.


Does/should a CS education include information about responsible use of human subjects in research We had a question over at academia.se about what responsibility a PhD supervisor has for teaching students about the use of human subjects in research. In some fields it is obvious that a research methods course needs to touch on the ethical use of humans in research.

While some areas of computer science (e.g., theoretical computer science and compiler design) likely do not use human subjects, other areas may include the use of human subjects. As I am not an expert in CS, using Washington University research topics as a guide, AI, computational biology, computer graphics, data science, HCI, NLP, robotics, and ubiquitous computing all seem like they could involve the use of human subjects.

While most universities provide an IRB or similar to protect human subjects, if students are not taught about them, how will they know the issues. Do, and should, a general CS education include a component addressing the use of human subjects in research?

For example this question on academia.see is about a CS student that collected blood for testing imaging software.

I would mention it in any class in which it is relevant, such as User Experience or where A/B testing might be used to show different users different versions of a website and measure their behavior. Because such research is ubiquitous (consider Google's testing different shades of blue), Facebook was unprepared for the backlash against their emotional manipulation study.


Explaining basic html structure I am trying to think of a lesson plan about html, and I am looking for a good way to explain the concept of the structure of an html file.

I was wondering whether the subject would be better understood if I firstly described xml in general. What I had in mind is teaching a basic xml block:

<rootElement>
    <element withAttribute="that we can set" scndAttr="there can be more than 1 attribute">
        <subElement otherAttr="these can also have attributes" />
    </element>
</rootElement>

and then use this basic block to get into the subject, after which we veer off to html specific xmls.

The students are at a beginner's level, and HTML is the first technology with a structure like this that they will encounter, So this lesson is meant to introduce them to HTML.

So, is knowing the concept and basics of xml structure important and necessary for understanding html?

How did you begin to teach Java to your students? I bet you didn't start by showing them the Backus-Naur form that the Java parser follows. Instead, you probably introduced a simple "Hello, world" program, and slowly built on that with assignments and projects for the students to work on.

I'm sure you can see the parallel here—teaching XML as a prerequisite for HTML is not, in my opinion, a productive or helpful exercise. XML is a rather boring language; it doesn't do anything, so you don't get that instant feedback when you write some code, unlike in HTML, where you can see the webpage unfold as you add elements.

HTML is also simple enough that you can generally pick it up as you go along; explaining that you start an element with <tag> and end with </tag> should be simple enough, and any mistakes in the markup will be visible when you load the page.

As a general rule, if you want to teach [insert language here], you probably don't need to teach a different language first; teaching XML to make HTML easier probably won't give you the benefits you're expecting.

I'm rather partial to the typical "Hello, world" for HTML. Almost certainly, your students will spot that the title is "My First Webpage", and I imagine that they'll be able to guess
 with some guidance.

        <title>My First Webpage</title>

Hello, world!

The general structure should be obvious, and you can reinforce it with some tasks, such as:

  Add a paragraph (
) after the heading.
  Add this image: [insert image link here] using

I would expect that  would need some explanation, because it will be the first element with attributes, and it's self-closing, which is different to all the others.


Plagiarism checks for source code In one of my answers I elaborated on the way we do language-tailored plagiarism checks on student submissions:

  The general idea is to strip comments, whitespace, variable and function names, literals, and thus only keep the general structure of a program, i.e. parentheses, curly braces, semicolons, etc. (for C-like, that is). Then compare this 'hash' for all hand-ins, and when you find a match manually check if the programs look alike. For example, the hash of the program below would be something like #<>(,*){(;;--){("",);}}:

#include <stdio.h>
void repeat(int n, char *word) {
    for (; n; n--) {
        printf("%s\n", word);
    }
}

While this model has proven successful in the past, there are a few obvious ways to escape these plagiarism checks:

Moving functions around
Changing parameter order
Omitting / using { and } around single-line blocks

Fortunately, these are not the things most students think about (usually, they rename functions and variables / include comments). However, I am interested in improving this model or using something that already exists which would tackle these issues above as well - not only because I want to be able to detect plagiarism but also because I find this an interesting problem.

In particular, I am thinking about a system that would actually parse the programs and compare the abstract syntax trees for similarities. Does any such system exist?

I have been responsible for using performing and evaluating tools for detecting software plagiarism in my academic department.

There are several published review articles in the scholarly journals. One such report Culwin, MacLeod & Lancaster, 2001, UK JISC, "Source Code Plagiarism in UK HE
Computing Schools,
Issues, Attitudes and Tools" gives an overview.

Basically, there are published algorithms and methodologies you could implement yourself, open source software you can run locally, or an internet based service you can register and use.

One such tool that you can run locally is JPLAG from the University of Karlsruhe in Germany. This has several language syntax implemented, and as it is open source you can amend as desired.

The best online tool is MOSS from Stanford which is the one I ended up using.

If you wanted to research the various published techniques for detection, Google Scholar is a good source.


What is a good analogy for pass by value vs by reference? In general, there are two ways arguments can be passed to a function. Functions can either be passed a reference to an object, or the value of that object. This is something that my students often struggle to understand, and I struggle to explain.

What are some good analogies for pass by reference and pass by value? What are some pseudo-code (or real code) examples I could show that would function differently in a pass by reference language and a pass by value language?

This is already covered on Stack Overflow, but I'd like to get some answers more specifically about how to teach it and less about what the designation is.

Since I was tired of the easy IT examples which all revolved around sharing files and documents, I started using the following analogies to explain pass by value and by reference.

My cat ("Mr Doorknob") sometimes wanders off to my neighbour. They call him "Cirmi", but of course he is still the same cat. If they feed him, he comes home fat and satisfied, if their dog licks him, he comes home covered in saliva.
This is a bit like passing a variable by reference: they might give him a different name, but it is the same cat. Whatever is done to the passed cat in the neighbour's garden will be visible on the cat when he finally comes home. (I actually like this because it helps them understand the "different name thing".)

As for passing by value, my neighbours really liked my new sunshade. They asked me where I got it from, and they bought one themselves. It looked identical in the beginning, but theirs got pooped on by a bird. This, obviously, didn't affect mine, it is still as shiny and clean as it was.

Many things can be used as analogy for pass by reference: renting books from a library, and seeing the marks in it someone else made; lending some item to a friend, etc.
I find it harder to come up with real life examples for passing by value, but one example is photo copying course notes, or artists (or forgers) copying famous paintings.

So, lending someone my course notes VS letting them make a copy of my course notes, then see them pour coffee over the notes while they are learning from it - in case one, my originals are ruined, in case two, my originals are safe. (Instead of pouring coffee, we can have them add improvements/comments to the notes, to make it positive instead of negative).


How do you teach Theory of Automata / Formal Language Theory / Computation Complexity? i'm a new instructor & also new here.

How do you teach Theory of Automata / Formal Language Theory / Computation Complexity?

Is it theory only, or including programming? If theory only, how deep - for example, are they supposed to be able to prove, how deep? If programming, what kind?

It would be much appreciated if you can share your wisdom. If there're other similar threads, would appreciate it very much if you can share the link. I'm also still reading the threads here, and browsing the internet for the syllabus of other universities. I don't have any TA, and nobody to discuss about this course in my department (theoretical CS is mostly non-existent here, most focus on application).

Thank you very much.

Edit: I wonder how other professors/TAs managed to give programming assignments to their students, such as building a CYK algorithm-based parser, but they provided the parser/compiler/backbone (?).

The course is often theoretical, taught like a math course, which it is, actually. In fact, my daughter has a doctorate in Philosophy and this was one of her doctoral courses since it relates to Epistemology.

There is actually more material than can be covered in a single course, I think. Formal language theory could be introduced as part of a Languages and Compilers sequence to separate it out a bit. This is how I taught formal languages so as to motivate scanners and parsers.

Automata and Computability is quite a lot on its own.

There is a third way to teach the course, actually, which is to teach the insights, rather than going through the proofs. What does it all actually mean if you look at it from a bit of a distance. What does it mean for problems to be equivalent?

But if you want to have a course that includes programming, you should at least look at JFlap, which is a system for teaching the course and was developed by Susan Rodger at Duke. The system lets you simulate finite automata and can support either a theoretical or insight driven course.

There are a couple of old books, now somewhat hard to find, that I consider classics and excellent introductions. Both are by V. J. Rayward-Smith:

A First Course in Formal Language Theory

A First Course in Computability

These are both small books but are good for the basics and for generating insight. They are worth having, even if you don't use them as course texts.

There have been a lot of books published since I studied this subject. If I had to teach a complete course, the first book I would consider would be
Introduction to the Theory of Computation by Michael Sipser. I expect it would be clear and deep.


Computers are down; what's in your bag of tricks for teaching CS when they can't get on a computer? I'm guessing everyone here, high school teachers at least, have spent at least one period in the past year working with a class when you either don't have working computers or a working internet connection.

So what are you go to activities when the computers aren't working?

I've got a couple, but am curious what I'm missing.

Worksheets - I use 'em, but I don't really like 'em. I do keep a set of worksheets printed though just in case nothing is working. They're generic enough that it really doesn't matter what topic we're on. And they work well for emergency sub plans.

CS Unplugged - I 've got the count the dots activity printed out. One set on normal sized paper for me to demo with and a dozen sets printed on business cards for students to practice with.

Human Sorting - I line up the kids and we go over sorting algorithms.

I'm sure I'm missing some really good ideas. Let's hear them...

There are lots of great activities at CS Unplugged that do not require a computer. Excellent activities in their own right, you don't have to wait for the days when systems are out. Well worth exploring these resources.

This resource is provided by the Computer Science Department at the University of Canterbury, New Zealand, and shared under Creative Commons BY-NC-SA 4.0 licence.


Example for For vs While Loop (in Java) I'm looking for a set of concrete examples that illustrates good use cases of using a for vs a while loop for beginners. I feel that I have a good grasp on teaching them about these loops in the abstract (e.g., definite vs indefinite loops, how we apply those concepts in life), but I would also like to show two (hopefully somewhat contextually related) motivating programming examples - one where a for loop is more appropriate, and one where a while loop is. Obviously either type of loop can be used in either instance, but I would like to prompt students to think more about when to use one versus the other. Coming up with two good examples that are illustrative of this point is eluding me.

To further limit the options available, students only know about console I/O, String/int/double types/variables, conditionals, and while loops. We are using Java.

So, for example, if I wasn't so focused on finding something that beginners could implement, I would show that a good use of a while loop is for a robot that should always be listening for voice input from a user; this is a good use, because we don't know when (i.e., after how many iterations) we will stop listening for voice input. I would then contrast this with a robot parsing through transcriptions of user voice input to identify keywords and respond to them. I've considered trying to translate this into console I/O, but the use of looping to continuously look for console input lends itself somewhat better to do-while loops, which we'll cover next.

I realize my question is likely a rehash of what was asked here, but I wasn't happy with the answers. Answers on that post dealt more about the ordering of topics for teaching loops (e.g., while loops before for loops), or real-world motivating examples (e.g., while I'm not full, continue eating pizza). What I'm looking for is more in line with the later, but I would like to do something that translates well into code.

If I'm interpreting your question correctly you'd like real life examples that translate to code. Maybe something like the following.

You want to drive or ride your bike to the ice-cream shop a few miles away. You don't know how far it is exactly but you will recognize it when you get there (while), VS You want to ride your bike 15 miles out and then return and you have an odometer on the bike (for)
You want to shoot baskets until you have made 100 attempts (for) VS You want to shoot baskets until you have made 50 successful shots (while). Outside the US, substitute free kicks.
You want to write a 15 page paper on looping in Java (for) VS You want to work on your "looping in Java" paper until you are satisfied with the result (while).
You want to boil potatoes until a fork can be easily inserted (while) VS You want to boil potatoes for 11 minutes (for).

To translate these into code you need some imagined functions for the actual activities (void boilPotatoes()).

For some of them it is useful to discuss the empty case: you are already at the ice-cream shop, etc. For others, a discussion of "at least one iteration" might be useful to have.

If you want to include foreach in the game:

You want to polish all of your mom's teacups (foreach) VS You want to polish her ten most valuable teacups (for) VS You want to polish teacups until you run out of polish (while).


Best Git strategy for workshop code (starter -> end solution) I run web development coding workshops where  I give students a starting repo, then want to have a version for the final, finished "solution". Ideally students should not see the solution easily until I publicise it.

I wondered if others have got a good workflow for this? I've tried tags and branches, but not found something I'm really happy or confident with yet.

As far as I understood your question, you want two things:

Providing a reference solution that is not visible to the students until the course is done.
Having a way for your students to define a finished solution they can (probably only virtually) "hand in"1

Providing a reference solution

To achieve this, I would just create a repository containing the reference solution when the course is done and share the link with your students.

If you have the ability to create private repositories, you could use this to check that only your students have access to the reference solution (and not also the students of the course you give next year).

Defining a finished solution

Each student has their own working repository. As it's necessary that all of them start with a given initial set of files, they could create their repository by forking a "starter pack" repository you provide. If this wasn't required, they could just create a new empty repository on their own.

To mark a state as finished, I would use branches. You could for example require your students to create a solution branch in their repository once they are done.

Having everything in one namespace (optional)

Most Git hosters allow the creation of organizations or groups. If you want to, you could create one for each course you give. This organization would then contain the working repository of each student and the reference solution when the course is done.

This would provide an easier overview for you over your students' repositories.

1 After reading through your question another time, I guess I've misunderstood the question and you only asked for a solution for the first item in my list. I think I will nevertheless share my thoughts on both - maybe they can be helpful for you or any future visitor.


Need review of course content: Javascript History and Capabilities I am planning to make a free JavaScript online video series. The first chapter covers the Javascript history and its capabilities. Following is a transcript of the video.
I would like it to be reviewed by someone good at JavaScript. Check for the correctness, the accuracy of facts, and any other suggestions or improvements that might seem necessary. I would especially require scrutiny in the 'abilities' section of the script to see if the definitions hold true.

Javascript History and Capabilities

JavaScript was created at Netscape Communications by Brendan Eich and his team in 10 days, in May 1995.
Its syntax and functionality were inspired by Java, Scheme, and Self.

Javascript was first named as Mocha, later renamed as LiveScript.
LiveScript was again renamed to JavaScript to gain popularity as the 'younger brother' of Java

JavaScript was meant to manipulate web pages by modifying the DOM to show, hide or change content dynamically

Is used for online form submissions and animations.

It is the Defacto client-side scripting language of browsers, a popular choice on servers as well.

ECMAScript is a scripting language specification standardized by Ecma International, it is a set of guidelines to design a scripting language. JavaScript is an implementation of ECMAScript

Javascript is a scripting language since it is interpreted by browsers and there is no intermediate compiled code.
Modern browsers now use JIT compilers to 'semi compile' it in order to optimize its execution

Javascript is single-threaded to minimize complexities with concurrency

In browsers and servers Javascript codes are parsed (read) inside an environment called Javascript Engine.
Javascript engine compiles it to machine language and instructs the OS to execute the instructions

Some notable javascript engines are

V8 – in Chrome and Opera.
SpiderMonkey – in Firefox.
ChakraCore - in Microsoft Edge.
Nitro or SquirrelFish - in Safari

Abilities

can run multiple tasks simultaneously without blocking any of the tasks (Asynchronous)
can exchange data asynchronously with a server across a network (Fetch API or AJAX)
can react to user actions such as mouse click, keypress, etc (event handling)
can switch between tasks in a single-threaded execution (concurrency)
can make use of object-oriented concepts (prototype-based Object Model)
can manipulate DOM of the browser to change the display of the webpage
can store data locally on browsers (cookies, local storage, etc)

Restrictions placed in the browser for the sake of data safety

Does not provide low-level CPU and memory access
Cannot implicitly access files or OS functions
users need to explicitly provide file access by input tags as well as for input device access such as camera and microphone, cannot access other tabs of the browser.
It follows the 'same-origin policy' wherein javascript from one domain cannot access resources from a different        domain if it doesn't have a CORS header

Javascript running on the server side have full access to the file system, input devices, and OS functions. it does not follow      'same-origin policy'

Javascript Capabilities depend on the implementation of the javascript engine and the interfaces provided to it by the environment.

Other languages compile into javascript which is then parsed by javascript engines.
One such notable language is TypeScript which adds strict typing and object orientation.

I think this answer is the second derivative.
Maybe it depends on who are you are targeting with the course.  If it's someone who is just graduating from using a browser to writing something in the browser; the student will be completely lost.  If it's someone who has most of an undergraduate CS education, including a course on compilers; you are fine.
I'm teaching an introductory course on web tech right now at Ashesi University; and while my students have been programming in python for a while; have taken data structures your description would lose most of them.  Part of the answer depends on where you are going.  You may need to give some context on the history of the internet.  Especially with current college students; they are all digital natives who don't remember a time before browsers and cell phones; so I might start with some basics on the world wide web; and the problem JavaScript and its ilk were meant to solve.

In the beginning the web was focused solely on structured markup.
As MOSAIC (the first graphical web based browser built by a team at University of Illinois) transitioned to commercial products, notably Netscape's Navigator browser and Microsoft's Internet Explorer; there was a realization that tags themselves were not enough; and there was competition between commercial players in integrating scripting as part of the web; initially thought of as a way to provide more sophisticated animation as part of the page.
The language Java was emerging from Sun Microsystems (now part of Oracle) as a new, type safe and object oriented language derived from the language C's syntax.
Netscape embraced Java; and began writing much of their software in it.
JavaScript as a language has very little to do with Java the language other than sharing a name.  JavaScript is interpreted, is not type safe--that is it does not enforce checking that integers are integers, strings are strings, etc--and models many of it's best features from functional programming languages like Lisp.  Like Java it does use a C like syntax; and while it support objects, they are supported using prototypical--where object definition is implicit--rather than class inheritance as languages like Java and Python do where class definition is separate from object instantiation.

In my class we did a section on early internet evolution that put alot of this in context (one class; where I had guest speakers who worked on building early browsers...I'm a dinosaur too so I know other dinosaurs).
Then the other stuff is good to illustrate the difference.  Esp. with node one of the practical things to discuss is since it was an embedded language to start; alot of features people take for granted (say coming from Java) like packages and modules aren't part of the core engine.  Those had to be invented so that JavaScript could run in a REPL when node was introduced.


Learning fundamental differences between functional programming and Object Oriented Programming I've been trying to learn the differences between Functional Programming and OOP, but I can't seem to find a comparison of the two.

A Google search did not yield any chart or table showing such a comparison.

From the unclear Google search, however, I have come up with this:
OOP keeps actions and data encapsulated in objects, Functional Programming separates the two.

But that doesn't actually give a useful comparison of the usecases for each one.

So, my question is where might I find a thorough comparison between the two, which can explain which should be used for some kinds of tasks\projects? I'm looking for some explanation\comparison of various aspects of these paradigms.

The types of projects or tasks I am referring to are varied, but can be classified into: Computer Management (similar to what userscripts allow in browsers) and Utilities (units conversion, custom shell).

(off site resources are considered an answer, as well as answers giving such a comparison without an off site resource)

There are beautiful answers to this question already here, and I will not try to reiterate any of the ground that has already been covered.  However, something important that I have not seen here so far is that comparing OOP to FP is not actually terribly meaningful.  It's a bit like comparing glass (the material) to tables (the furniture).  They each have properties that can be explored, but even if discussions of these properties can help you learn about them, the comparison itself doesn't actually tell you much about either.  Glass tables exist, and have the properties of both.  Similarly, Scala, Clojure, and Swift are languages that are both functional and OO.

A more meaningful comparison for functional programming is imperative programming.  The most popular languages in the world right now are all imperative1.  Imperative languages focus on mutable values and states, and are historically based on Turing Machines.  Functional languages are all about function calls and immutable constants, and are historically based on Church's $\lambda$-Calculus.

The two mathematical systems were developed around the same time in order to solve the same question: what is fundamentally computable?  The Church-Turing Thesis, which was published before electronic computers existed, proved that the two systems were equally powerful, and further hypothesized that they could both compute any computable function, and that any sufficiently complex system could embody exactly this same computability power.

A more meaningful comparison for Object-Oriented programming would be... well, nothing.  The Object-Oriented philosophy, which is about grouping data with functions that govern that data, can be applied to any programming paradigm.  Object-Oriented programming is all about the scope and membership of functions and data.  It doesn't matter if the data is mutable, if the order of operations is defined, how data is stored, whether functions are mutable... if we are creating instances of data that are bundled with their own functions, the we have the kernel of object-oriented programming.

1 - Only if you discount Excel, which is actually a light functional programming language, and is almost certainly used by many more people than any other programming language on earth.


Assignments for Introductory Level Processing I am designing an introductory level programming class to be taught using Processing this summer. I have only four weeks and 90 minutes a day with students. Given my student demographic (middle schoolers), I am not anticipating getting much beyond the basics of the coordinate system, basic color options (stroke, fill, RGB values), variables, and loops. Since it will have more of a summer camp feel (i.e. fun, no homework), I want the approach to be engaging and hands-on. Rather than try to introduce a lot of programming concepts, I want students to have a portfolio of cool designs they have made by the time the class ends.

Here's the current list of projects I have slated for our four weeks:

Use three ellipses to make a Mickey Mouse silhouette (simple, but will require much iteration to perfect coordinate placement)
Create a basic sketch of a house (imagine those elementary school simple triangle-topped rectangles with square windows and a chimney...something like that)
Design a Lego family (based on this UW assignment)
Explore logo design through both redesigning an existing logo and creating an original logo (based on this UW assignment)

These four will probably culminate in some sort of original creative project as a synthesis of all the concepts we will study.

As I'm wrapping up my design of this course, I'd like to get input on these and any other simple, engaging assignments in Processing. What other beginner-level assignments in Processing would interest a student new to programming?

I did a 4 half day "camp" for two high school girls a couple summers ago. We spent the first two days doing Processing programs. Etch-A-Sketch and Tron are a couple good assignments for beginners. The Etch-A-Sketch simulation leads nicely into making a game based on the light cycle scene in the movie Tron.

Here is some information about what we did in the camp


Subtopics to cover within Karnaugh Maps I'm adding a bit about k-maps to my processors course, but being unfamiliar with them until now, I want to check that I am covering the correct things.  Here is what I am currently covering:

How k-maps can be created and read (up through 4 variables -- I have decided to skip the 5th variable for now)
The importance of the funny ordering in the axis ($00$, $01$, $11$, $10$) as a way to ensure that only one bit must be transformed to arrive at any neighboring position
To derive expressions from k-maps, rectangles of 1s can be of size 1, 2, 4, or 8 only.
How to actually derive an expression from a k-map
How to derive expressions from k-maps when there are undefined regions within the k-map.
Using k-maps to derive a Sum of Products (a.k.a. Disjunctive Normal Form) and a Product of Sums (Conjunctive Normal Form)
The inverse relationship between the size of a rectangle and the number of variables that define it.
Spotting xor values (perhaps I don't need this?  It doesn't seem much emphasized in materials I've found, since they mostly focus on finding SoP and PoS)
k-maps wrap around, so you can make a rectangle that starts on the left edge and wraps leftwards to the right edge, or from the top and wrap upwards to the bottom.

So, should I skip xor?  Is there something I should add?  Am I covering the right things?

I am teaching part of a Maths module that includes boolean logic- the assessment included creating digital circuits, labelling each point to derive the final expression, applying boolean logic (De Morgens etc) to the expression to minimise the term (which is by far the most difficult part for learners), creating the truth table, SOP and POS, creating the K-Map and deriving the expressions, and creating the minified circuit.
After explaining the logic of each of the gates, they build some circuits using an emulator of sorts. As it happens two of the circuits are equivalent, and they result in an XOR function.  Learning point 1- XOR is useful as it can replace a bunch of other gates.
As an aside, XOR could be used to rebuild a drive bit level
HD1: 0110
HD2: 1100
HD3: 1010 (HD1 Xor HD2)

so if any one drive is destroyed, the data can be rebuilt- e.g. HD2 gets fried- rebuild new drive H4
HD1: 0110
HD3: 1010
HD4: 1100

It's an interesting and pretty cool application of XOR.
In practise XOR can yield some nice circuit reduction but learners do tend to find it difficult using XOR in minimising.
In terms of the importance if minimising, I look at the reduction in complexity and the real-life reduction in cost- number of gates and thus the number of chips, board space and layout time.
Here is a completed labelled circ from a previous assignment completed in Logisim:

Now, this can be reduced to 2 NOT gates and one OR. I should 'warn' that Logisim can generate the minified (SOP or POS) term, the K-Map and terms and generate circuits as well- which might be more than you want it to do.  At worst you could use it for creating some useful examples.

Here's a board from the 1970s. It's hard to make out any gates but there is a 74LD274 (3-input NOR gates) on there- hard to read. Given that the hardware "is" the software to a large degree here, the importance of reducing complexity and chip count was important. As already pointed out- it's not as important these days, but application of logical thought is just as important in software design.  An appreciation of the complexity implemented in hardware design is important, I think.
I hope this might help with linking these elements together with K-Maps, since I suspect that you also cover these other topics.  As to how much focus you place on each part, you'll have to decide how much importance you place on each.  I think the outline of sub-topics is pretty good.


Are userscripts a good teaching tool? What is a User Script?
Useful tasks like improving layout, fixing bugs, automating common tasks and adding new functions can all be done by userscripts. More complicated userscripts can create mash-ups by combining information from different websites or embedding new data into a web page, e.g. to add reviews or price comparisons to a shopping website.
Source: https://github.com/OpenUserJs/OpenUserJS.org/wiki/Userscript-beginners-HOWTO#what-is-a-user-script
A user script is programming that modifies the appearance or behavior of an application. A user script for a Web site, for example, can customize the way that content will display in the host browser.
Source: http://whatis.techtarget.com/definition/user-script

I'm planning out a curriculum for my web development class next year, and based on a comment by Sean Houlihane I realized that userscripts could be useful as a teaching tool so that students can see results immediately, and actually make use of their front-end skills as soon as they know the basics.
Before I would introduce my students to this, they'd have to understand the basics of HTML/CSS/JS. If my students already have basic knowledge, how useful could userscripts be as a teaching tool and what are some ways in which I could use them?
Some potential issues that I foresee are:

It'll be complicated. For a major website, the stylesheet could be thousand LoC.
Minification. Especially for JS. It makes it very challenging to modify existing code if it has been minified. Even when re-prettified, it can still have terrible variable and method naming.

Working around these issues, what are some uses for userscripts as a teaching tool and in the classroom?

I think there's one step between knowledge of HTML/CSS and writing userscripts: knowledge of Developer Tools in Chrome, especially the "Elements" tab. One demonstration students loved seeing was when I "changed" the school website. I simply right-clicked, selected "Inspect", and modified the text. I had to explain to students that I didn't really change the page but that I modified it locally and could "restore" it by refreshing, but it was a lasting demonstration, something they continued to bring up throughout the semester. (This demo also relates to what I said here about the value of CodePen because you can see your work live.)

Even if there are thousands of LoC, you can get right to where your element is and see the entire path down the "tree" to this element. One fun demonstration is to show students how to "delete" a pop-up from a site or remove an ad or some other obstruction/intrusion by inspecting the page to "search and destroy" what you want to get rid of.

Consider Bloom's taxonomy here. You have an opportunity to move up the ladder as follows: Comprehension/Knowledge (basic HTML/CSS) --> Application/Analysis (Developer Tools/Inspect) --> Synthesis/Creation (Userscripts). This progression is important to keep in mind so as to adequately prepare students for creating something meaningful of their own, and I think the study of how popular sites are structured will aid in this process. Hacking away for fun at a page may give them an idea for what would be cool to script themselves.

The teaching benefit is such that you can unleash students' seemingly unlimited creativity as they write helpful scripts for their own personal browsing experience. Yet, as you note, it does not come without challenges and must be approached methodically.


Resource recommendations for teaching OOP via a practice-oriented example I intend to teach some OOP methodology but everywhere I look, there are only syntethic examples and elaborations of various concepts of the OOP world (for example: what is inheritance, how to use interfaces).

Like this or this.

What I'm looking for is a tutorial of how to solve a "real-world" problem (can be fictious) but with all (or most of) the steps of these:

How to analyze the problem?
What are the objects?
What should be taken care of?
What classes should be created?
What pattern is recommended?

I found a good book online but it is way too detailed to be a quick guidance - though not a bad start. Nevertheless, I'm looking for a shorter and more practice-oriented approach.

As you can see, I'd like to have a tutorial that teaches OOP as a whole and not its parts.

The students are mostly beginners but trying to use a wide range of OOP concepts - they have a few months of experience.

Do you know any example that has this kind of tutorial structure?

I'm currently teaching OOP using Python 3 Object-oriented Programming by Dusty Philips. Find it on Packt or Amazon.

It's a practitioners book, it covers a bit more than just OOP including some unnecessary bits if you ask me (like concurrency). I've found it works out well when combined with a few other sources like Effective Python and some online materials on design patterns. If you follow it page by page I find it a bit too much focussed on Python details and not as much on the general OOP principles.

I think that in most cases you'll have to make up your own curriculum and fill it with bits and pieces from books you like :) There is rarely a perfect fit.


What language best prepares a high school student for a STEM undergraduate major? I intend to lead a nephew through the exercises of sequence, selection and iteration via Python.  I also intend to introduce hardware sensors for data collection.  If there is a better choice  (I learned via C++ and embedded op code programming), for a high school student, I would be interested in understanding other options.  I have minimal experience with Python, however, I have had success with barcode readers, databases, string processing using Python.

Which programming language best prepares high school students for a STEM college major and why? Any STEM: not necessarily a CS or even a EE major.

I would like the student to master the fundamentals:

sequence
selection
iteration
utilizing library functions

The student should master these fundamentals so that he / she can search and recognize these concepts in another language (MATLAB, Ada, C, Smalltalk, etc.)

The choice of language is important in the sense that one must consider the audience and balance the need for simplicity (from the standpoint of 14 year old) and pedagogical quality: as a stepping stone to future  STEM problem solving activities.

Reasons for my initial selection of Python include my observation that MIT is teaching statistics, which assumes fluency in Python.  Other reasons include a large number of Python libraries to support Raspberry Pi sensors and boards.

If you are an instructor at the university level, please state this in your reply.

There isn't a best language, other than the language that you know well and can use for modeling things. Python is good. And it is reasonably straightforward for a young beginner.

Don't fall into the trap of thinking that a lot of languages learned superficially is valuable. It isn't and can lead you astray.

But the things you list aren't enough. The big idea of modern computing languages is "abstraction". Object oriented languages like Python do a pretty good job creating values that have sensible behavior that can be composed into programs.

In the US, a CS program is more likely to use Java than other languages, though it isn't universal. Another good language is Scheme, but with a C++ background you might have a harder time teaching the essence of it.

And, don't fall into the trap of teaching Python as if it were C++ with more words. Each language has a mental model that is worth the effort to learn.


Could you recommend books on concurrent programming? I am self-learning concurrent programming. I have some experience with concurrent programming. Have self learned OS and programming.

There are both programming languages and libraries that provide concurrent programming facilities.
I would like to learn about concurrent programming  at OS and library levels (e.g. multithreading, multiprocessing, spin locks, semaphore, ...) and language level (e.g. monitor, future, promise, channels, conditional critical regions, Coroutine, ...). For the specific topics,  I am referring to sections "Models",   "Prevalence" and "Languages supporting concurrent programming" in https://en.wikipedia.org/wiki/Concurrent_computing and also concurrency patterns.

I would like to learn at conceptual as well as specific language levels.

Could you recommend some books which explain the different approaches at a concept level? It is good for such books to have  specific languages and libraries as examples, but not necessarily especially if the books you recommend are classic but not contemporary.
Could you also recommend which specific languages and libraries and books on specific languages and libraries? For specific languages, I am currently interested in functional languages (such as Scala, Haskell, OCaml ...), Python, C#, Java, C/C++ and Go.

Academic books (text books, survey) and professional/practical books are both welcome.

Concurrent programming is easy, synchronisation is hard.
Have a look at this video for an alternative to synchronisation: https://www.youtube.com/watch?v=2yXtZ8x7TXw
When you have to synchronize
Use easy (High level) synchronization. see:

Scoop from Eiffel.
Transactions
Pipelines / message passing
coroutines (for when you don't need parallelisation)

See also no lock / zero lock structures: Most pipes that are thread safe use locking. Or are not thread safe, and expect the user to do the locking. However it is possible to get thread safe zero lock queues. There rely on a few atomic instructions. (I prefer the name minimal lock, because the atomic instructions do locking).
Only use low-level synchronization to implement high-level synchronisation.
If you need synchronisation, and if you do not have high-level synchronisation, then find a good library that implements high-level synchronisation, using the existing low-level synchronisation.
Don't write it your self, except as an exercise (and do to it as an exercise, it is fun and you will learn a lot), as it is very hard and you will get it wrong.


To what extent should UML be covered in the context of a degree? As part of my Computer Science degree, we covered UML in quite a bit of depth as part of a software engineering module. Whilst some parts did seem useful, a lot of it was interesting but not very practical. The specification itself was also not very accessible when I tried to read it.

With that said, I've never come across UML being used a lot in the context of an actual software engineering role (perhaps with the exception of sequence diagrams to model protocols). Sometimes a vaguely UML-ish class diagram might be drawn on the whiteboard, but it's very informal.

Assuming that most CS degrees will incorporate some amount of software engineering theory alongside the usual computation theory and data structures etc. style modules, to what extent (if any) should UML be covered?

From my software engineering experience.

Some of it is useful some is not. It was put together by a committee of organisations that had a product to sell. (state machines got in there because a committee member had a state-machine editor.) A lot of other useful stuff was missed out.

Take what is useful, leave the rest, and use stuff from elsewhere.

There is nothing unified about it. I have used mainly class diagrams, some dataflow (I think it may be called), but as you say not too much formality. We never passed them through a linter. At one time we were drawn in to using them to create code. This was an expensive lesson.

Most of the diagrams (may be all) existed before the UML. I tell my pupils that some of the diagrams are useful, but also look else where. I tell them which ones I have found useful. And I tell them what I have said here: there is nothing special about the UML (or the process of collecting together, arbitrarily, some diagrams notations).


Good datasets for intro CS courses? What are engaging sources of data with which students can explore, develop questions, analyze, and draw conclusions in an intro CS course? I'm looking for flat files like XLSX or CSV, or relational databases in an environment that permits selection and export of a flat file.

Kelly Powers asked (nearly) this question in the CSTA-members listserv in May 2017 and got 14 answers in a couple of days, which I'll consolidate and extend in an answer here.

I'm going to clean this up later, but am posting the verbatim work of the CSTA members so others can chime in with additional bullets. I'm aiming to have one resource per bullet: Resources name, link, annotation, example ideas for projects

How about CSV Data Sets at https://vincentarelbundock.github.io/Rdatasets/datasets.html
Maybe there’s something there which would appeal to MS kids. (Joe Kmoch)
Look at the Mondial database, supposedly based on the CIA's World Fact Book. (https://www.dbis.informatik.uni-goettingen.de/Mondial/) It's in various  formats other than CSV (various relational databases, XML, etc)  but should easily be exported to CSV form ( see http://www.convertcsv.com/sql-to-csv.htm) . It's got dozens of relations, and is sizable enough so that you really do need to query it via a program to answer questions. (Doug H)
There are some links on my BigData webpage ( under #4.) that could be a lot of fun
https://sites.google.com/a/pgcps.org/livecode/big-data/bigdata---projects (Cyril Pruszko PGCPS)
I had fun in the past using First Fleet. See firstfleet.uow.edu.au (Andrew Williams and Simon Carter)
Titanic passenger lists (Simon Carter)
Census at School asks lots of different questions of hundreds of thousands of U.S. students and has data by grade and state. My students have used the data for linear regression and chi-square tests. (Andrea DePaolo)CensusAtSchool data works well with middle schoolers. I had 7th graders measure their height and armspan and add their own data to the CensusAtSchool's set using a googlesheet. (BB)
In the UK, publicly accessible historic weather data is useful and offers some lovely cross curricular links to science, maths and geography: http://www.metoffice.gov.uk/public/weather/climate-historic/
I think something rather more comprehensive in the US is available here: https://www.ncdc.noaa.gov/cdo-web/datasets (Miles Berry)
https://www.data.gov/  (Ty Davis)
Wikipedia has some extractable data https://www.tableau.com/about/blog/2016/2/excavating-data-gems-wikipedia-50966
(Ken Price in Tasmania)
Tuva labs tuvalabs.com (Jon Mannion) is an entire data exploration environment with curriculum and a browser-based interface that allows students to drag various variables from a data set onto axes, akin to SPSS or Fathom.
http://stats.oecd.org/ has some OECD datasets
(Ken Price in Tasmania)
Google also has a Public Data Directory at https://www.google.com/publicdata/directory and a data exploring tool.
(Ken Price in Tasmania)
What about Bart, A. C., Whitcomb, R., Kafura, D., Shaffer, C. A., & Tilevich, E. (2017, March). Computing with CORGIS: Diverse, Real-world Datasets for Introductory Computing. In Proceedings of the 2017 ACM SIGCSE Technical Symposium on Computer Science Education (pp. 57-62). ACM.
CORGIS Datasets Project
https://think.cs.vt.edu/corgis/  (Francesco Maiorana)

Here are some additional links from my bookmarks

The KDD Cup is an ~annual competition for the public, aimed at grad students and professionals. Past year's competitions are on the website, usually with the data, and middle schoolers could use the data for easier tasks than the KDD Cup challenge posed.
Kaggle is akin to and overlapping the KDD Cup.
Teenagers like music. The Million Song Data set could be used to compare song length by artist, for example.
An image makes for a nice large data set and motivates students to understand nested loops, conditionals, the accumulator pattern, and the best-so-far pattern. I have students pick their own image and decide upon their own task for data analysis (e.g., range of brightness or number of pixels that meet a color criterion) and manipulation (e.g. change brightish yellows to magenta.)
CODAP, the Common Online Data Analysis Platform. A project of the Concord Consortium, led by the person who led development of Fathom, a stats software for K-12.
I wish there was a women's basketball version of this set of links:

NFL plays in CSV: http://archive.advancedfootballanalytics.com/2010/04/play-by-play-data.html
News article about Big Data in sports, reading across the curriculum: https://blogs.wsj.com/cio/2013/02/06/big-data-in-big-sports/
Programmers' discussion thread about handling football data: https://news.ycombinator.com/item?id=5002974

The Social Security Administration offers CSV files of name frequencies by birth gender and year. State-level files are also available by gender and year.
The UC Irvine Center for Machine Learning and Intelligent Systems has the Motherlode Machine learning repository of datasets. You can search by domain (e.g. life science), by the data set size, or by the type of task students would typically do with that data.
GapMinder has raw data files of World Health Organization data as well as an online tool for exploring the data along with interesting examples.
Exoplanets databases
The Current Population Survey (CPS) asks 60,000 U.S. households each  month about income and employment. You can download CPS data tables and can create your own table with the CPS table creator
A similar question on Quora
Earthquakes From USGS, https://earthquake.usgs.gov/earthquakes/map/ allows the user to filter earthquakes by location, date, and magnitude and download a CSV. The website has built-in geographic visualization. (Contributed to PLTW CS Principles course by Nathan Nolte)