How to design a cloze test for a programming language?
I don't think that an entire Cloze test is practical, and in any case, it does not assess deep understanding well.  

One problem with longer Cloze examples is that they force the student not only to understand the goal, but also your particular implementation, which will often feel quite foreign to them, even if they are strong students.  A further problem with Cloze-style is that, the more blanks you leave, the more possible combinations of correct answers you leave.

I once had a student fill in a top portion, meant to initialize a variable prior to a loop, with a correct lambda statement that solved the overall problem, and then fill in the following loop fill-ins in such a way as to make sure the loop never entered.  The solution was a good one, so it received full credit.

I use a mix of problem types on my exams. Short Cloze-style questions can address syntactic understanding and the ability to accomplish very basic operations, such as identifying three compatible statements to put in a for loop to
look through an array.

Multiple choice questions are good at making sure that particular distinctions are being made. I use these to isolate what I call "cognitive traps".

Coding exercises are, indeed, hard to grade, but they are also necessary for testing whether everything can be pulled together.

If you need to bring down the grading time, you may want to consider keeping the examples short and making AP-style code rubrics, as they can make the grading far easier.