For intro-level CS courses, neither one works all that well. You can do that in more advanced (but still undergraduate) courses, but for beginner-level you IMHO need the feedback loop of regular homework. It doesn't have to be strictly graded, but it basically has to be there and at least some enforcement for it actually being done (e.g. handing in homework is required, but it's not a problem if it is doesn't actually work).
Coming up with hundreds of different small projects to e.g. get people to understand pointers isn't very realistic, and if you only test them in exams you're missing critical feedback both for the teachers and the students before it is too late.
Assess the homework, give them a grade on it but don't have it factor into their final grade at all. Just let the exams / big projects take care of that.
If you're regularly failing your homework, it probably means you won't be ready for the exam that actually counts. Which should be enough feedback
having been both a TA and a student, i think this idea is entirely too optimistic. "optional" problem sets can work well in graduate and advance undergraduate courses, but for the bulk of students in the intro/intermediate courses, homework that doesn't get graded for accuracy may as well not exist. i certainly didn't do it, and when the CS department decided to grade homework on completion only, i saw student attendance of my office hours immediately drop to zero.
ultimately, you cannot just expect college students to make reasoned decisions based on the way you set up the course. you need to arrange the course in a way that incentivizes them to keep up at every step.
That's the conventional wisdom in America, certainly. And yet my undergraduate degree (maths at Cambridge) was 100% assessed by end-of-year exams and it worked fine.^
Did I stay up with the classes? Well, not always — some of them I caught up during breaks. (That's the advantage of end-of-year not end-of-semester exams, too.) But did I know the material by exam time? Yes.
But look, more generally, you say you have to "incentivize" students to keep up but I think we agree that it's in their long-term interest to keep up with or without graded homework, so we're talking about behaviourist incentives not rationalist incentives here. And with that admitted you have to consider that there's broad scope for other ways to incentivize than through GPA consequences. (I mean, hand out candy, or pizza, or Pokémon, or porn, or whatever this year's students are into, you can probably think of a much better ideas than these.)
^Unless you were that one kid who had mono during finals week. But that's a different issue.
I think me editing overlapped your comment: yes, that's an option, and I guess then you do not have to care about plagiarism so much. There probably still should be some effort against it though.
Coming up with hundreds of different small projects to e.g. get people to understand pointers isn't very realistic, and if you only test them in exams you're missing critical feedback both for the teachers and the students before it is too late.