Strongly Typed Data Structures in Go
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Strongly Typed Data Structures in Go

on

  • 366 views

Talk from the Go Boston meetup on 4/16/2013

Talk from the Go Boston meetup on 4/16/2013

Statistics

Views

Total Views
366
Views on SlideShare
366
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Strongly Typed Data Structures in Go Presentation Transcript

  • 1. Strongly Typed Data Structures in GoNate FinchCurrently employed by Advent Software13 years as a developerMainly C++/C#Startups & Enterprise Software
  • 2. Go doesnt have generics● Sure it does – array, slice, map, channel● But...● No user-created generic data structures● No generic functions
  • 3. Do we even need them?● Built-in containers solve a lot of problems– Dictionary, set, stack, list● But not all:– Left Leaning Red Black Tree– Heap– etc
  • 4. Interface{} to the rescue?● No!● What are we, barbarians?● STOGTFO (Strongly Typed Or Get The F Out)– Thats a technical term● Compile-time type safety● Refactoring● Static code analysis
  • 5. Is there another way?● Yes!● Have you seen package sort?● We can do the same thing for data structures● Index as a generic pointer● Comparison function using indices
  • 6. Generic Trees● The algorithmic code is generic● A few lines creates a new wrapper aroundyour data container● No casts, no Interface{}● 36 LOC (incl. comments) for a new tree
  • 7. Where do we go from here?● This method can be used for other datastructures● Similar methods can be used for other needs.● Slice indices, map keys, both can be used forgenericizing. (not to be confused with jazzercizing)
  • 8. Questions?Code is on github:https://github.com/natefinch/treehttps://github.com/natefinch/treesampleslides will be posted to G+ after the meeting