5 ms·
What language is the tutorial in?
by sfc32 3y ago
What language is the tutorial in?
- efficax 3y agothe book uses golang
- throw10920 3y agoInteresting choice. I'd think that as the context is "As many of today’s (2023+) coders do not have a formal CS/SE education" and the goal is education, a more popular language like Javascript or Python (or, heck, even PHP[1] /s) would be used, instead. I've taken a look at Go, and while it does seem pretty approachable, it's definitely not nearly as common as Python/JS, and it's always significantly harder for me to learn a new concept when the examples are also in a language I'm unfamiliar with. Maybe that's just me, though. [1] https://survey.stackoverflow.co/2022/#most-popular-technologies-language https://survey.stackoverflow.co/2022/#most-popular-technolog...
- switchbak 3y agoDatabases really do push runtimes in such a way that I think it makes sense to urge folks to use a system level language, or something close to it. In particular it'd be hard to cover concurrency (and parallelism) properly using vanilla CPython or JS, and I think that would impinge on the lessons learned. That said, it'd be an interesting read on how to make a DB in pure Python.
- vira28 3y agoyou may be interested in this https://github.com/avinassh/py-caskdb https://github.com/avinassh/py-caskdb
- eatonphil 3y agoI don't normally think of Node and CPython as in the same performance bracket. Regardless, you can do some crazy things in Node. See these notes about Node and MySQL: https://github.com/tigerbeetledb/tigerbeetle/blob/main/docs/HISTORY.md https://github.com/tigerbeetledb/tigerbeetle/blob/main/docs/...
- deleted 3y ago[deleted]
- switchbak 3y agoIn this context I meant that the parallelism primitives are different than what you'll get in a systems level language, which might make teaching those parts unnecessarily awkward and probably the concepts less translatable to other runtimes. For sure they've got different performance profiles. Very impressive what your group was able to do with Node, and continuing on with Zig. It's got me interested in learning more.
- wjholden 3y agoI could be wrong, but my perception is that Go is so opinionated that you'll either write idiomatic Go or use another language. So, from that perspective there's some goodness in using Go as a learner's systems language.
- sk0g 3y agoIt's opinionated, but it's not _that_ opinionated IMO. You can write awkward Java, shiny C, or whatever idiomatic Go is. Most people I worked with were from .net/Java worlds, and learned just about enough Go to be able to subject others to their coffee bean ideologies. There's somethings the compiler will fail on like unused variable and the likes, but for the most part you need added static analysis and style checking -- some of which ships with the Go compiler.
- iknownothow 3y agoI'm a data engineer and I only know Python. It appears Golang hits a sweetspot on many metrics such as performance, parallelism, ease of use etc and since 2016 there's been a lot of new data products and tools written in Golang. So it makes sense to me that the book would use a popular language for the domain.
- jandrewrogers 3y agoI think Go is a pretty good choice for the purpose. It balances high-level ease of use and learning curve with decent access to the system-y parts of coding that are so important to databases. What you learn to do in Go will translate reasonably well to a true systems language if the user wanted to take database engine design to the next level. Languages like Python or Javascript are so far removed from the system-y side of programming that the way you would implement the concepts in those languages would not translate to the way you would actually build a "real" database which is I think the purpose of the book. I think the objective isn't to teach the abstract concepts but how those concepts are expressed in real systems.
- macintux 3y agoIt’s interesting that it doesn’t seem to actually say that anywhere.
- vira28 3y agowrite on the introduction it says https://build-your-own.org/database/00a_overview https://build-your-own.org/database/00a_overview Or if you see any chapter you can literally see Go code.
- macintux 3y agoYou're right, I missed the one place in the introduction where it mentions Golang. Other than the "if err != nil" I wouldn't have recognized the code samples. Go's error handling is a big reason I've never taken a closer look.
- bsaul 3y agonever understood the issue with go error handling. As soon as you start dumping exceptions as a valid error forwarding mechanism ( which seems like a totally acceptable design decision), you end up manually having to check every call you make that can raise an error, on each line. I don't really see any alternative. It also makes you carefully think about how you plan on managing errors in your codebase, which also seems like a very sane thing to enforce.
- ikiris 3y agopeople who aren't used to actually handling their errors get annoyed at typing return err all the time. They'd prefer an easier way to not bother dealing with them with them without outright ignoring them via _
- alpaca128 3y agoI'd get annoyed too, because I know there are much simpler alternatives. Language design should encourage doing things right by making it more convenient than the shortcuts. In Rust that entire check can be a single "?" symbol. How much syntactic sugar is too much is a matter of preference, but I personally think that properly handling all errors without syntactic sugar turns into an unreadable mess because there's just a lot of things which could go wrong.
- freedomben 3y agoIndeed. The Redis book was C/C++ so I was hopeful that this one would be as well. Given that database essentials are so closely tied to system calls, I would have hoped for a language that doesn't abstract them away. At least in the first fsync() call, the author does explicitly mention that `fp.Sync()` ends up invoking `fsync` system call, but as someone who has no intention of returning to Golang I'd rather not have to add complexity by requiring me to build and maintain a mental map of Golang calls to syscalls (the worst kind of abstraction layer IMHO: leaky and unnecesary).