4 ms·
Why would a pedagogical project choose JavaScript of all languages? Unless the project specifically needed to leverage features of the language, or a web brows
by dymk 8y ago
Why would a pedagogical project choose JavaScript of all languages?
Unless the project specifically needed to leverage features of the language, or a web browser, it's an incredibly poor choice for building anything with well maintained abstractions. Or anything at all ready, when the language is covered in warts.
I imagine the author hasn't yet discovered for themselves why it's a poor choice, given only a key-value store has been implemented (using JSON.stringify, no less)
- gtowey 8y agoThis was my thought as well. I'm curious to know if the author has previous experience building actual databases or if this is a case of follow-along-while-I-figure-this-out.
- interesthrow2 8y ago> Why would a pedagogical project choose JavaScript of all languages? I don't think the JS part is the issue. Node.js does I/O, files and co. The issue is that the article doesn't teach how to build a database at all. It doesn't explain how to efficiently persist and fetch data from a file, indexing strategies with trees, concurrent file access,locking, basic transaction... that's what I expect from a tutorial about how to build a basic DB system.
- dymk 8y agoPlenty of languages do I/O, files, and co. Why choose a language plagued with warts and a half-baked ecosystem for something pedagogical? A language with all sorts of peculiarities from the '95 browser era, and not at least leverage browser technology? A language which gives you very non-interesting coarse control over resource, and has no concept of parallelism?
- raxxorrax 8y agoEasy access and fast results. Learning isn't about creating the best possible implementation. Python wpuld have been another suggestion from me personally. What language would you have used? A lot of people without a formal educational background start with established scripting languages. I you handle data, chances are that you will get in contact with javascript at some point. Using coffeescript or typescript would be a worse choice for learning, even if they counter some disadvantages of the base language in question.
- rodw 8y agoMoreover, Node.js's non-blocking, single-threaded nature is great for the kinds of plumbing that things web services and related applications require (The stuff we used to call "database-to-web" applications -- i.e., fetch some content from a data-store and render it and/or accept some content from a client and store it) but seems like a pretty poor match for disk I/O and CPU-bound applications like a database. And I'm saying this as someone that's actually a big fan of JavaScript and that does a fair amount of enterprise-scale work with it. EDIT: I meant to add: But, I think this might be beside the point. If you are looking for a language than a large number of people can more-or-less read and write, JS is a pretty good choice. If your objective is teachablity/readability rather than production-quality performance or capabilities, I think JS is probably on the short-list of candidate languages. I can't find the quote offhand but I think Douglas Crockford or someone like that described JavaScript as "the only language people feel comfortable using without learning the syntax". (This was especially true prior to server-side applications like Node.js, when JS was largely considered a toy-like language for scripting basic input validations). If nothing else, this makes JS a reasonable "executable pseudo-code"--something practically any programming can read and probably most can execute.
- codezero 8y agoJavaScript is extremely accessible and the warts can easily be worked around. I spent a lot of my life being a JavaScript hater and after working with it for four years I can definitely see how it is really a simple starting point for a lot of concepts. Sure it has warts. What doesn’t? Have you worked with a JS language for any extended period of time? What about that made you not even want to consider it for anything? I’m really curious, I’m not trying to set you up - I’m really not exeperienced enough to do so :) Edit: to be clear because of general curiosity and because I hate bringing work home, most side projects I work on are in some other language.
- dymk 8y ago> and the warts can easily be worked around Not really. The author doesn't leverage any kind of static typesystem, which would at least mitigate some of the warts. He's chosen Node.js instead of leveraging the browser, so no free visualization layer for doing anything interesting with, unfortunately. > Have you worked with a JS language for any extended period of time? Most of my day job is working in a really, really big Javascript codebase. I can say with confidence that the language is something that we're absolutely stuck with, and I still have no idea why somebody would implement a pedagogical database with it (well, then again, they haven't; they've implemented a key-value store, which is trivial). To offer an alternative, they could have chosen something boring but everywhere like Java, which is just as accessible to those with less experience. Then they'd have the possibility of doing fine-grained parallelism, file access, designing abstractions that fit within a statically typed language.
- primitivesuave 8y agoThis was my thought exactly. For many high school and university students in the US, Java is their first language and introductory courses usually deal in unsatisfying toy applications. I could imagine a great primer into building a database that introduces all kinds of interesting computer science concepts as well as practical programming techniques (e.g. organizing a project as it grows).
- codyb 8y ago