How I Wrote 10K Lines of Go in a Weekend

  Рет қаралды 2,241

Google TechTalks

Google TechTalks

Күн бұрын

Пікірлер: 7
@wolpumba4099
@wolpumba4099 4 ай бұрын
*Summary* * *(**0:17**)* *Goal:* Tom Payne needed a Go library to generate SVG (Scalable Vector Graphics) files for a weekend project. He wasn't satisfied with existing libraries that used inefficient and messy string formatting for XML generation. * *(**0:44**)* *The Challenge:* The SVG specification is extensive, with numerous elements and attributes. Manually writing code for each would be tedious and error-prone. * *(**2:28**)* *Solution: Code Generation!* He opted to automatically generate the majority of the Go code using templates and the SVG specification. * *(**2:31**)* *Process:* * *(**2:33**)* *Structured Data:* He extracted key information about SVG elements and attributes from the specification and organized it into a YAML file. * *(**2:45**)* *Templates:* He created Go text templates to define the structure of the generated code. * *(**2:51**)* *Generation Program:* A custom Go program reads the YAML data, applies it to the templates, and outputs the generated Go code. * *(**2:58**)* *Formatting:* `gofmt` (or `go fmt`) ensures the generated code is properly formatted. * *(**3:05**)* *Iteration:* This process allows for easy iteration on the API design by modifying the template. * *(**10:22**)* *Benefits of Code Generation:* * *(**10:40**)* *Full Coverage:* Ensures all elements and attributes of the SVG spec are included in the library. * *(**10:57**)* *Rapid API Iteration:* Simplifies making changes to the overall design and structure of the code. * *(**11:43**)* *Handles Edge Cases:* Allows for manual tweaks or exceptions where the specification is inconsistent. * *(**11:58**)* *Standard Library Reliance:* The solution leverages Go's built-in tools (text/template, go/format, go generate) without external dependencies. * *(**8:16**)* *Other Examples:* Tom also showcased how he applied this code generation approach to other projects involving KML (Keyhole Markup Language) and C library bindings. *In essence, code generation allowed him to create a comprehensive and well-structured SVG library quickly and efficiently, avoiding manual coding for hundreds of elements and attributes.* I used Google Gemini 1.5 Pro exp 0801 to summarize the transcript. Cost (if I didn't use the free tier): $0.0419 Time: 29.63 seconds Input tokens: 9204 Output tokens: 924
@Jaziry
@Jaziry 4 ай бұрын
How did you pass the the transcript to Gemini?
@wolpumba4099
@wolpumba4099 4 ай бұрын
@@Jaziry I manually copied the transcript from youtube. I call gemini twice, once to make the summary and a second time to add timestamps. I uploaded a screencast titled "KZbin video summarizer" to my channel.
@krux02
@krux02 4 ай бұрын
If you actually follow these instructions, you will find out how horrible, vague and out of date specifications often are. But it's a good approach.
@AFPinerosG
@AFPinerosG 4 ай бұрын
This is something that enterprise languages have had for quite a while, right? Transforming UML into code.
@krux02
@krux02 4 ай бұрын
It's not the same, it's code generation from a spec that someone else wrote, but not made for code generation.
@goovalenasi
@goovalenasi 4 ай бұрын
کمک به تغبلیغ کننده خیلی بهتر بود مالک تعبلیغ راهنمایی میکرد
Why I’m Switching To Go in 2024
8:10
Awesome
Рет қаралды 100 М.
Why is everyone LYING?
7:56
NeetCodeIO
Рет қаралды 374 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Someone improved my code by 40,832,277,770%
28:47
Stand-up Maths
Рет қаралды 2,7 МЛН
Linus Torvalds: Speaks on Hype and the Future of AI
9:02
SavvyNik
Рет қаралды 273 М.
Event-Driven Architecture (EDA) vs Request/Response (RR)
12:00
Confluent
Рет қаралды 179 М.
Supply Chain Security with Go
30:32
Google TechTalks
Рет қаралды 778
I'm Coming Around To Go...
21:33
Theo - t3․gg
Рет қаралды 124 М.
Real 10x Programmers Are SLOW To Write Code
14:51
Thriving Technologist
Рет қаралды 69 М.
Programming's Greatest Mistakes • Mark Rendle • GOTO 2023
51:24
GOTO Conferences
Рет қаралды 99 М.
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 130 М.
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН