Wednesday, October 3, 2018

Code & Coffee for October 3, 2018

Here is what you missed:

What is a `trie` and the genesis of this insomnia driven tweet:
A lot more about `tries`  pretty sure Othelle was thinking I fell off the deep end.

A review of linked list traversal.

A potential match opportunity for a searching developer and an empty position (I really hope there is more to talk about on this front soon)

We also talked about
Spring boot:

Programming interviews, specifically “Programming Interviews Exposed”:

$20-ish on Amazon:

The Cormen “Introduction to Algorithms” book:
I don't have this one yet, but do have the Sedgewick and Skiena books and we compared and contrasted those.

On the topic of algorithms, this is on my reading list:  it looks really interesting, and looks like does an interesting job of drawing parallels between algorithms and real life experiences.  If you decide to check it out, please let me know what you think of it.

Up next week:
I am developing some sorting games that we can try out, would be interesting to get some feedback to see if they seem useful and warrant further development.
Perhaps a presentation on linked list traversal?
Also open to suggestions

Wednesday, September 19, 2018

Code and Coffee September 19, 2018

Here in Grand Rapids a few of us regularly get together over coffee and talk about code.

 Here is a report that I sent back to our slack group to tell about what we did and I thought it might be good to share it here so I can point people somewhere when they ask what it is about:

 Code & Coffee was pretty epic this morning. I talked so much it took nearly three hours to finish my sandwich. The theme of today turned out to be Algorithms. We started talking about, and ACE editor which somehow go onto the topic of algorithms which it turns out we have both been brushing up on in the last few weeks.

We did light coverage a couple of sorting algorithms insertion and selection sorts) going through my notes and a run through of each on some sample data. Talked about the runtime ( O(n^2) ) then we talked about other sorting including 3 way quick sort which can get to linearithmic time with certain (likely) key distributions. (Also quick sort works well with modern caching architectures which is a free bonus performance boost)

 Then we wandered off into linked lists and doubly linked lists, heaps and binary search trees. Finishing up with finding the middle of a linked list in one pass. All in all it was a good discussion @Othelle allowed me to practice talking about the things made notes on and hopefully it was at least entertaining for him if not educational too.


Somewhere along the line we talked about Conway’s Game of Life
here are two implementations I did (one only gets partial credit:  (in C# partially done, check the commits for the interesting bit of this)  (in C for Arduino, code on request if I can find it back)

Also my (one) post for last year was a somewhat related topic:

Thursday, October 26, 2017

Tail Recursion considered harmful?

Some time back, someone told me that tail recursion is a lot like using a 'goto' this makes a lot of sense when you think about it. Tail recursion is an optimization that can happen when a function is calling itself as and returning the result as it's return. This allows the system to skip creating a new frame on the stack and makes life a little easier when fiddling with limited stack while doing embedded work.

An example might help:

So the code compiles and both do what it looks like they do. What's the big deal? And isn't 'goto' bad?  Everyone knows it right? What about that famous paper and everything.  It sure looks like recursion is just a fancy way to do a goto.

Lets dig into it a little:

First we should look at the paper... more than just the title of course but first we can focus on the title.  Kind of an interesting thing happened with the title.  The writer of the paper did not chose it the editor of the publishing journal did. Turns out the original title was "A case against the goto statement."

To the editor, this title was not quite right so he changed it to: "Go To Statement Considered Harmful." Sounds like clickbait to me. Oh, wait, it is. Turns out that way before 'clickbait' was a thing people had to sell the news (that is convince people to part with hard earned money for a physical paper, how quaint.)

According to my hastily googled up source; 1949 gave us this: "Rent Control Controversy / Enacting Now of Hasty Legislation Considered Harmful" sounds exciting right? That is from the national news.  It looks like the "Go To" title started a bit of a theme in CS articles: "Global variables considered harmful" and "The letter O considered harmful."

Global variables I can see, and wish that the message got out more on that, but really, the letter O? (Let me tell you it was a real problem, 0 and O didn't always look so different. In fact my typewriter doesn't even have a zero, gotta use the O to make a zero so yeah the problem is real.  See also l and 1 bet you have to squint to figure out which is 'ell' and which is 'one', 1 would tell you but 1 already forgot. (Are we sure computers use Ones and Zeros or do they use Ohs and Ells?))

If Dijkstra's title is where you stopped reading, you better try again... wait if you stopped at Dijkstra's title how did you get this far in this silly little blog post?  Doesn't matter!  Go read the rest of Dijkstra's article it is only a few pages:

Hmm, interesting.  That was published in 1968 in case you missed that detail.  They sure knew a lot back then. 

What I got from it is the article is that Goto causes serious issues with being able to tell how we got to where we are in a program. We call a stack trace now but only because we can walk the stack and know there wasn't any funny business. 

My little trick above is a bit of an illusion.  When you start allowing stuff like that people become a little immune to goto and will let it slip in other places, then pandemonium.

I was wondering what it would be like if the paper had retained it's original title. Would it have gained traction and would goto have been effectively banished as it is today? We may never know unless we were able to shift into the parallel universe where it was not banned.

Well, I traveled to that parallel universe.  There are companies that run custom home grown software written in BASIC.  Yes, that BASIC:

10 print "hello world"
20 goto 10

Yes, THAT BASIC.  I took on some work there and let me tell you it sure was interesting.  On one hand BASIC grew in the last many years since I learned it first and the flavor they are using has some features that effectively allow you to not use that basic. The client didn't get the message.  So yes, if the title had remained "A case against the goto statement.", we might all have been doomed to live in this weird parallel universe.

Who was the masked stranger that saved us all from certain doom? No mask and not a stranger it is Niklaus Wirth. (Europeans call him by name, Americans by value (his joke, not mine))

If you have not heard of him, please look him up.  He was instrumental in creating Pascal, Modula, Oberon programming languages.  Also EBNF can be traced back to him along with "Railroad Diagrams" (aka Syntax Diagrams)

Is Goto harmful

Maybe, maybe not. Did Dijkstra formulate a case against it, yes I think definitely.  Goto is going to be there at a low level but hidden away by tools of a more civilised age.

Is Tail Recursion harmful?

I think that is the wrong question.  I think the real question is: Is Tail Recursion the same as using a Goto?  Which I think the answer is no. Earlier today I thought maybe they were the same, after thinking and reading Dijkstra's article again which calls recursion in place of goto I am more convinced that goto can go.

Gotos replacing tail recursion are a gateway to mass hysteria. Gotos everywhere, jumping into the middle of a function with no way to know how you got there or where you came from.  Sounds like I am exaggerating, maybe I am, but not by much (been there and done that it's not pretty.)

Links to more on this:

What I find most interesting about this is the link between Dijkstra and Wirth, not something I usually think about. Nobody works in a vacuum and this is one instance that highlights the collaboration in an interesting way. 

It really is fun looking into some of the history behind what we do. With the history so recent I wonder why it is not purposefully studied more.

One last thing:

I had trouble deciding on the title for this the alternate is

"Considered Harmful" Considered Harmful  ... see what I did there?  A little recursion in the title.  Let me know in the comments which title you would have picked.

You can also read about this here: Tail Recursion considered harmful?

Wednesday, January 22, 2014

GR Testers lightning talk notes

Notes from my GR Testers lightning talk:

Tuckman's stages of group development.

- Form
- The team forms and comes together initially
- Initial period of politeness while forming
- "Honeymoon" period
- Storm
- Personalities come out
- Conflict arise over differing ideals
- Roles within the teams are being sorted out
- Norm
- A mutual plan converges and forms
- Relaxing of individual ideals

- Perform
- Able to get a job done smoothly and efficiently
- Communication barriers a reduced

- Stages
- Not all teams get to each step
- Sometimes there is reversion to earlier stages
- Later an "Adjourning" stage was added, but it does not rhyme so we don't say it.
- Team manager role adjusts greatly through the stages of development
- One of the common by-products is one of the team members is ready to become a team manager the team and the old manager will restart the process with a new team. Some managers fear this, but it is a natural and key part of creating high performing teams.

- Links:

Friday, October 25, 2013

Code and Coffee in Grand Rapids, Michigan

Coming soon to Grand Rapids: "Code & Coffee"

What is it?  Just something fun to do in the morning before real work kicks in. Get together and write some code, pair up, or just chat and solve problems.  For more information see:

The first round of Code & Coffee will be on Thursday October 31, 2103 at 7:00 am at "Tim Hortons" on Fulton.

Tim Hortons900 Fulton St, West
Grand Rapids, MI 49504

Hope to see you there.

Tuesday, November 20, 2012

Kata battles: Toolset edition

I was fiddling with the Coin Changer Kata, an exercise meant to build skill through repetition.  It turns out that a Code Kata is also an interesting way to compare toolsets.  I was working in two very different languages with different environments.  We will give the languages a little anonymity in order to delay judgement.

The first language I tried is a runtime interpreted language, scripting language if you will.  The environment I used was very light: Vim, a simple testing framework and the interpreter.  It took a little time to get setup and become accustom to the testing style but not long.  The biggest problems I had were with unfamiliarity with the language with checking a list of value.  The red, green, refactor cycle was smooth and fast.  The tests would run super fast so I could write a test, watch it fail, make it pass faster than I can.  The environment was not the bottleneck.  A good setup for increasing skill.

The second language is a compile it then run it language.  Compiled programs are faster right?  Not from what I experienced last night.  The environment is much heavier.  Full IDE, everything is build in.  A simple key combination and the whole project will build.  Automatic completion of nearly everything. Really a cool system, after you download and install all it.  And pay for it if you want even more features.  And pay more for it if you want EVEN MORE features.  So I get the IDE up and runnning.  Start a new project.  Start a test project.  Realize I have no test framework.  Install the test framework we use at work and get going.  And get stuck.  I can no longer build because the test runner has files open that the IDE needs to overwrite.  At this point I decide I need the refactoring tool we have at work.  The refactoring tool comes with a test runner that I like a lot better, but the at home budget dictates that the tool will have to wait.  So I do what we all do when we get stuck.  Google said I need to enable a service on the host computer.  Ok, still does not work.  Restart test runner, no go. Restart IDE and we are in business.  Write a  Make it pass......... green.  Not time to refactor yet, there is barely any code.  Just enough code to make the test pass in fact.  And good thing we don't have to refactor it takes too long to run the tests.  A few more red and green cycles and I have run out of time.  It take FOREVER to run the tests, and I don't even have to do anything to run them they automatically kick off each time I build.  This is not TDD at its best.  This is not fun.  This is not over.  I know I can get a better setup.  It will just take a little tweaking and fiddling.  I am willing to do that because I know there is a better way.

How many people have tried this TDD thing and become frustrated with a lousy environment?  How many people have been totally turned off to TDD because of issues like this?

Anyway stay tuned to find out how I improve the environment.  I will be benchmarking the before and after times for a whole Kata and also test run times.  I hope to end up with an environment that will let me focus on improving skill rather than de-focus and wander off while my tests are trying to run.

Friday, September 16, 2011

Resistance is not futile.

Resistance is not futile, no matter what that infamous collective would have you believe.  This is just their propaganda machine lowering the resistance of their foes.

Hang in me, you get a couple short paragraphs of electronics context before the good stuff.

What is resistance?  In the world of electronics, it is an inverse measure of the conductivity of a material.  It is measured in "Ohms."  Conductivity is measured in "Mhos" how cute.  Resistors are electrical devices that are created to give a specific resistance within a specified tolerance.  Resistores are available ranging from milliOhms to MegOhms, quite a few orders of magnitude.  Resistors are critical to the proper operation of nearly every electronic device, gadget and system we use on a daily basis.

There is one electrical system where any resistance is extremely detrimental to proper operation.  The starter motor on a car.  One ohm of resistance will cause the entire system to fall on its face.  Such a little amount of resistance, how does this happen?  Lets take a super quick hopefully painless look at Ohms Law.  E=I*R.  E is the Voltage drop across a conductor, I is the current flowing through, R is the resistance.  In a car starter the object is to get as much power from the battery to the starter as possible.  so if we have one Ohm of resistance how much power will that steal from the system?  We can figure this out from some things we know.  A typical car starter will draw 100-200 amps while starting the car, we will go with 100 amps.  Drawing 100 amps through a 1 ohm resistor will drop voltage by 100 volts (I think this would use up approximately 1.21 jigawatts.)  Oh we start from 12 volts.  Thats where things get complex.  Lets go with one tenth of an Ohm of resistance, now we are only dropping 10 volts.  Leaving 2 volts for the starter. We need another equation P=I*E, the PIE equation (makes me hungry) Power = Current * Voltage.  That gives 1000 watts going to the resistance and 200 watts left for the starter.  Guess what?  The car is not going to start!  Where does this resistance come from?  Usually loose battery terminals or corrosion somewhere, been there done that.

Good you made it through the mumbo jumbo.  How does this apply to you?

Resistance can come in many forms and in many places.  Office place resistance, boss says prepare the TPS reports, it is natural to respond with a little resistance.  This is a low current request, so even a lot of resistance will not generate a lot of wasted effort or extra heat.  Two year old resistance, ask any two year old to do anything, will will find out what two year old resistance is.  Teenager resistance, see two year old resistance.

At times resistance is a good thing.  We are assigned a test and hesitate to do it.  We mull it over and eventually decide on the best course of action and the product is better for the resistance.

Some times resistance is very bad.  A high current system must transfer as much power to the end result as possible.  Like a car starter any resistance is likely to stop the entire project dead in its tracks.  A business startup is like this as much energy as possible needs to transfer to the end product.  A little corrosion in the line, such as an uncooperative business partner, non-availability of food money or stiff regulations.  Will make it very difficult to get started. 

Resistors when connected in parallel lower the over all system resistance.  If you see a system where someone is being a resistor you can choose to short-circuit the system to make things happen.  You see where someones lack of experience is slowing down a project and you pitch in.  This is something to feel good about.  It is also a time to be careful.  Like a two year old that will not learn to tie his shoes if you keep doing it for him, people will keep needing a bailout if you keep bailing them out.  I think this is where the old saying about giving fish and teacking how to fish applies.

At times people will be the resistance on purpose, and out of spite.  Please try to recognize if you are doing this yourself, please try to help people along if possible, or at least to not cause them resistance along the way.

If you want more on this let me know, I have some thoughts on internal resistance.

Thanks for reading,