Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

A picture book written in C code

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Everyone!

I'm in the process of writing an educational/fun coding book in the form of a picture book. The code (simple full C programs) represents situations in the story and the illustrations next to the code show the situations. It's called *A Day in Code* and I'm planning to launch it on Kickstarter.
This is my landing page: https://www.dayincode.com
I also have a Kickstarter pre-launch page: https://www.kickstarter.com/projects/914595512/a-day-in-code

Would you be interested in this book? I'd be happy to hear any feedback. Thank you!
 
Marshal
Posts: 68899
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch I shall add your post to our C forum

That is a novel idea Unfortunately the page you showed includes code constructs I warn against frequently, == open. I think (not sure) that such use of the == operator is worse in C than in Java┬«.
 
S Esken
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the delayed response, I missed the notification. Thank you for the comment! What do you see as wrong with " == open " ? I've never heard that before...
 
Campbell Ritchie
Marshal
Posts: 68899
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is unnecessary; you can simply write if (cupcakeBox) ...
It is error‑prone if you write if (cupcakeBox = open) ...
In fact some people recommend to reverse the order of the operands if (open == cupcakeBox) ... That reads awkwardly, but is not error‑prone.
Your code there also lack any action for closing the box:-Of course, think how nicely the code would read if you renamed the variables to boxIsOpen or similar
 
S Esken
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to make the code more readable for beginners, as well as teaching the #define directive. I understand your point about making the code optimal and I know if(cupcakeBox) is the same as if(cupcakeBox == 1), but the latter option, in this case, if(cupcakeBox == open), translates into English better Thanks for pointing it out.

I just understood your other point...this code is a representation of a situation at a single point in time, so the seagulls aren't eating forever...
 
Campbell Ritchie
Marshal
Posts: 68899
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately here it seems that showing the #define construct and robust code conflict with each other. Just as seagulls are a conflict. Not far from here, you can see notices prohibiting people from feeding gulls otherwise they become habituated to human food (as opposed to the slimy invertebrates or stunned fish they naturally eat) and become positively aggressive towards people.
 
S Esken
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it also teaches an important life lesson- don't leave your food unattended at the beach.
 
Campbell Ritchie
Marshal
Posts: 68899
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, this shows what can happen.
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic