mackuba,
@mackuba@martianbase.net avatar

It's insane that I can have a conversation with this thing and in a few moments and a few back and forths build a working program in a language I know nothing about (I don't know Go)… don't tell me this isn't huge 😳

You: One modification - this current code counts all matches of all regexps against the text. So if one line of text matches two or more regexps, it will be counted as 2 or more. I want a given line of text to only be counted once if it matches
You: What's the command to compile this to a binary? ChatGPT: To compile a Go program to a binary, you can use the go build command followed by the name of the Go file you want to compile. If you want to specify the output binary name, you can use the -o flag followed by the desired name. Assuming your Go file is named main.go, you can compile it to a binary named my_program like this: You: Looks like
You: Great, that works 👍 Is there some way to compile this program in "release mode", with a more optimized version or something? ChatGPT: Yes, you can compile your Go program in release mode with optimizations using the go build command with the -ldflags flag set to -s -w, and the -trimpath flag set to remove the build path from the resulting binary. Here's the command to compile your program in release mode: You: I mean, not optimizations for binary size, but optimizations to make it faster? ChatGPT: Ah, I see! In Go, optimization for speed primarily comes from the compiler's default optimizations, and there isn't a direct flag to enable additional optimizations beyond what the compiler already does. However, there are some general principles you can follow to improve the performance of your Go program: Profiling: Use Go's profiling tools (go test -cpuprofile, go tool pprof, etc.) to identify bottlenecks in your code and optimize them. Profiling helps you understand (…)

ahapen,
@ahapen@mas.to avatar

@mackuba No, it isn't. No wonder the quality of software is getting worse and worse.

mackuba,
@mackuba@martianbase.net avatar

@ahapen Well, I'm sure that my first ever program in Go would be of much better quality if I wrote it completely by myself…

zygoon,
@zygoon@fosstodon.org avatar

@mackuba but ioutil is deprecated :-)

mackuba,
@mackuba@martianbase.net avatar

@zygoon Hey, it compiled and works :p

klausman,
@klausman@mas.to avatar

@mackuba I have asked various LLMs for Go code in the past and every single time, there were at a minimum subtle bugs (off-by-one errors, using the stdlib wrong), and sometimes, they would hallucinate libraries that don't exist, combine them in ways that don't work etc etc. You got lucky here --- probably. How many edge and corners have you tested? That is what worries me about people using LLMs to create programs.

mackuba,
@mackuba@martianbase.net avatar

@klausman yeah you definitely need to watch what it's doing, and probably I'd get more problems with longer code - it works as long as you can understand the generated code and notice when something isn't right, even if it's an unfamiliar language

mackuba,
@mackuba@martianbase.net avatar

@klausman but I've managed to use it to translate Ruby code to: Python, Perl, PHP, Crystal, Swift, Rust and Go, and out of these I only know Ruby and Swift well and have used Python and PHP in the past. https://github.com/mackuba/regexp-benchmark

  • All
  • Subscribed
  • Moderated
  • Favorites
  • golang
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines