Skip to content

Commit da7945c

Browse files
committed
Hobby sdk post.
1 parent d210891 commit da7945c

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

content/posts/go-without-generics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tags:
66
- go
77
- gowestconf
88
- conference
9+
- beam
910
categories:
1011
- Dev
1112
- Talks

content/posts/hobby-sdk-01.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: "My Hobby Beam Go SDK"
3+
date: 2024-10-20T21:57:18-07:00
4+
tags:
5+
- generics
6+
- go
7+
- beam
8+
categories:
9+
- Dev
10+
- Talks
11+
- Hobby SDK
12+
---
13+
14+
I just made github.com/lostluck/beam-go public, having migrated the code out of
15+
my experimental directory.
16+
17+
I'm going to write about this a lot, but I have come to the conclusion I can't
18+
write about it all at once. So it's going to come in little bits and bursts.
19+
In particularly motivations, and different design decisions that don't have
20+
a great place in the documentation as it is.
21+
22+
And then I can do fun things, like have a conversation with a friendly question
23+
asker.
24+
25+
# Why do a Beam SDK for a hobby?
26+
27+
Well, sometimes I can't work on things that scratch the right itch for my day
28+
job. In this case in solving certain problems for the Go SDK itself.
29+
If you aren't trying things out, you won't be adding those attempts to your
30+
toolchest for other situations in the future.
31+
32+
Ultimately, it started because I wanted to play more with [Go Generics](https://go.dev/doc/tutorial/generics)
33+
in the context of data processing in Go. In particular, could we make a better
34+
SDK with them than the current version?
35+
36+
Also, when I started this, I was already making the [Beam Prism runner](https://beam.apache.org/documentation/runners/prism),
37+
not only to solve problems, but also to learn how to make a Beam runner, and
38+
better understand the Beam model itself. Developing a new SDK felt natural for it.
39+
40+
# Don't you do this for your day job?
41+
42+
Yes and no. I do work on improving the main Beam Go SDK for work, but there are
43+
some things that are more important to work on sometimes.
44+
45+
You could argue that authoring a new SDK is in scope for some work I have about
46+
writing an opinionated guide on how to write a Beam SDK. Right now, it's too
47+
hard to start one, and unless you're already an expert on Beam, you won't know
48+
what mistakes not to make. In that sense, I'm making mistakes so future folks
49+
don't have to.
50+
51+
Right now the best improvement to the Go SDK is making it able to run locally.
52+
We're doing that with the Prism runner, and extending that work to other SDKs,
53+
for a more consistent Beam experience. Fast, Local, iterative development is so
54+
useful you know?
55+
56+
# Any other reasons?
57+
58+
I wanted to gain experience with try out other features of Go, like handling
59+
vanity URLs, running a github project, managing github actions, and being otherwise
60+
a good citizen of the Go package ecosystem. All those are transferable skills,
61+
while also being useful for work, without being work.
62+
63+
The hobby SDK's documentation and package lives at `lostluck.dev/beam-go`, which
64+
I could neatly handle within this Github Pages based website. It was important
65+
to me that https://lostluck.dev/beam-go would go to the GoDoc.
66+
(Nate Finch's [old guide for Go Package vanity URLs with hugo](https://npf.io/2016/10/vanity-imports-with-hugo/) still works nicely!)
67+
68+
You can read the docs all day long, but nothing beats trying it out yourself to
69+
figure out how it works.
70+
71+
# That's Really All?
72+
73+
...
74+
75+
Honestly? The current Go SDK has some issues, largely due to when it was designed
76+
with respect to Go at the time. But some things can't be fixed without making
77+
breaking changes, or doing a tremendous amount of work to rewrite things without
78+
doing that, or adding significantly more code to maintain.
79+
80+
I go into that a little bit with my talk at Beam Summit 2024.
81+
[Beam SDKs don't have to look the same](https://beamsummit.org/sessions/2024/beam-sdks-don-t-have-to-look-the-same/).
82+
Go there for a summary, slides, and the video!
83+
84+
Ultimately, by having it separate from mainline Beam, the expectations are lower
85+
and there's more freedom to experiment with it.
86+
87+
# So how did this hobby SDK start?
88+
89+
I wanted to see what an alternative Beam Go could look like, and see how hard it
90+
would be to make generic KV's (Key Value Pairs) in Go. There's no type compile time
91+
erasure, covariance, or contravariance so how do you make sure you can encode or
92+
decode things.
93+
94+
I wanted to answer questions like "Do we need to have lifecycle methodes like that?",
95+
"Can we get type safe pipeline construction?", "Can coders be less annoying?",
96+
"Would generics reduce per element overhead?", "Can we avoid pre-registering DoFns and types", etc.
97+
They go on.
98+
99+
One thing lead to another, and more questions were asked, and I needed to write
100+
more code to get to the point I could answer them.
101+
102+
# What's next?
103+
104+
Next is that I'm going on a long vacation. Maybe I'll work on this a bit, maybe not.
105+
106+
Maybe I'll write about the SDK a bit during the vacation, maybe not.
107+
108+
What's for certain though is that you can look at the code, and if you see potential
109+
beyond the current obvious faults, maybe provide some feedback?
110+
111+
No idea how I'll collect that for the moment. Maybe I'll make a feedback form.
112+
In the meantime, reach out to me on [Bluesky](https://bsky.app/profile/lostluck.dev).
113+
114+
I only have the wordcount example for now. Most things reduce to wordcount TBH.
115+
116+
https://github.com/lostluck/beam-go/blob/main/examples/wordcount/wordcount.go#L40
117+
118+
The IOs are going to change for sure, among other breaking changes. Beam SDK's
119+
don't need to be that big, but there is a lot involved in making one, but not
120+
nearly as much as the Beam repo makes it out to be.

0 commit comments

Comments
 (0)