• Home
  • About
    • About The Coder
    • Language List
  • The Rules
    • Rule #1: Clarity Trumps Everything
    • Rule #2: Source Code is for Humans
    • Rule #3: Don’t Ignore Warnings
    • Rule #4: Comment As You Go!
    • Rule #5: Always Use Parentheses
  • CS-101
  • Python-101
  • Guestbook

The Hard-Core Coder

~ I can't stop writing code!

The Hard-Core Coder

Category Archives: CS101

Programming basics.

Rule #5: Always Use Parentheses

19 Sunday Apr 2020

Posted by Wyrd Smythe in CS101

≈ 1 Comment

Tags

code clarity, computer programming, operator precedence, order of operations, parentheses, readable code, software design

Enough stories, time for a new rule. Which is to always use parentheses in all except the simplest of math expressions. Languages have a precedence protocol, so the compiler can figure it out, but human readers may be confused.

As always, the underlying motivation involves code clarity for other humans reading the source code — the most important rule of all.

Continue reading →

The Eight Queens

23 Sunday Jun 2019

Posted by Wyrd Smythe in CS101, Fun, Python

≈ Leave a comment

Tags

computer code, Python code

There’s a fairly simple puzzle, called The Eight Queens, that I’ve long favored as a project for first semester CS students. The problem is simple enough for a beginner to tackle, yet also interesting enough to be engaging. (And just tricky enough to be a nice beginner challenge.)

Due to a discussion on my other blog, I dug out an old Python implementation I had, and, after looking at it, I thought it might be worth writing a post about. If nothing else, as I said, the problem is interesting enough to be engaging.

Continue reading →

Full Adder Redux

14 Tuesday May 2019

Posted by Wyrd Smythe in CS101

≈ Leave a comment

Tags

full adder, logic circuit, modeling, NOR gate, Python code, simulation, truth table

I’m returning to the full-adder logic circuit modeling to present the code for a version that tries to capture the timing of the signals.

The goal is to take a closer look at the intermediate states of the adder as signals trickle through it.

Continue reading →

Full Adder Sim V2.0

08 Wednesday May 2019

Posted by Wyrd Smythe in CS101

≈ 1 Comment

Tags

full adder, logic circuit, modeling, NOR gate, Python code, simulation, truth table

This is the third post in the Full Adder series. The first post explored ways to code the abstract model of a full-adder. The second post explored one way to code a simulation of a physical system (where the models are of the components of the system).

This post explores another gate-based model, but one with only one type of gate. This simulation is close to being transistor-level.

Continue reading →

Full Adder Simulation

07 Tuesday May 2019

Posted by Wyrd Smythe in CS101

≈ 1 Comment

Tags

full adder, logic circuit, modeling, Python code, simulation, truth table

In the last post, I explored different ways to model the logic of a full-adder. In this post I’ll explore a model of a physical instance of a full-adder — a model that simulates physical reality.

Because a full-adder is, at root, a mathematical expression, various software models can accomplish the same results. Models are abstractions, so the only thing a model can simulate perfectly is another model.

Continue reading →

Full Adder Code

05 Sunday May 2019

Posted by Wyrd Smythe in CS101

≈ 2 Comments

Tags

finite state machine, FSA, FSM, full adder, half adder, Python code, state engine, state table, truth table

I was involved in a debate recently about whether a full adder logic circuit is a computer. The computer science answer is: “No, not as we define a computer.”

I plan to address that answer in detail on my main blog. Here I wanted to show some of the different ways a full adder can be modeled and implemented.

Continue reading →

Iteration versus Recursion

19 Monday Dec 2016

Posted by Wyrd Smythe in CS101

≈ Leave a comment

Tags

computer language, computer languages, computer programming, computer science, GOTO statement, iteration, language design, loop statements, programming language, recursion

When it comes to what makes a computer (or any other) language a programming language, there are three characteristics usually required:

  1. Saving state (variables)
  2. Selecting a code path (if-then)
  3. Iteration or recursion (or equivalent)

This post is just a brief note (for a friend) about the third item and why it allows three distinct options.

Continue reading →

The Thing About Constants

16 Tuesday Aug 2016

Posted by Wyrd Smythe in CS101

≈ Leave a comment

Tags

constants, defined values, global constants, literal values, literals, named constants, named values, numerical constants, P.J. Plauger, string constants

Along with “always use less-than” is another great piece of always advice, except this one is a prohibition, a never rather than an always (same thing, really, from a programmer’s point of view).

It has to do with never having literal values embedded in your code!

Continue reading →

Counting From Zero

08 Monday Aug 2016

Posted by Wyrd Smythe in CS101

≈ Leave a comment

Tags

Edsger Dijkstra, EWD831, greater-than, indexing, integer ranges, less-than, zero, zero indexing

In his brief 1982 essay (EWD831), computer science giant Edsger Dijkstra examines a topic that (inappropriately, as it turns out) vexes some programmers: Why in the world do computer people count starting at zero? Everyone knows that counting starts at one!

As it turns out, there are two very good reasons for counting from zero!

Continue reading →

What is a “Programming” Language?

06 Saturday Aug 2016

Posted by Wyrd Smythe in CS101

≈ Leave a comment

Tags

computer language, computer languages, computer programming, computer science, language design, programming language, Turing complete

Back in the post HTML is not a programming language! I brought up the three properties required by a programming language. A discussion recently got me thinking about it again. This post is just some notes on those thoughts…

Continue reading →

← Older posts
Newer posts →
Follow The Hard-Core Coder on WordPress.com

The Posts

  • Python String Translate
  • The Last Bug
  • Regular Expressions
  • Bits Bytes Chips Clocks
  • Loving the Lambda
  • Failure Tales
  • Naming Things (redux)
  • Calculating Entropy (in Python)
  • Building a Turing Machine
  • Python Tokenize

The Topics

  • Blog (4)
  • CS101 (35)
  • Fun (27)
  • Interesting (1)
  • Opinion (12)
  • Python (24)
  • Stories (15)

The Month

March 2023
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Oct    

The Past

Posts

RSS Feed

Comments

RSS Feed

Enter your email address to follow The Hard-Core Coder and get email when there is a new post.

The Main Blog

Visit Logos con carne

Lots of wyrds... with meat!

The Author

Wyrd Smythe

Wyrd Smythe

The canonical fool on the hill watching the sunset and the rotation of the planet and thinking what he imagines are large thoughts.

View Full Profile →

Create a website or blog at WordPress.com

  • Follow Following
    • The Hard-Core Coder
    • Already have a WordPress.com account? Log in now.
    • The Hard-Core Coder
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar