Reddit Programming
211 subscribers
1.22K photos
124K links
I will send you newest post from subreddit /r/programming
Download Telegram
<!-- SC_OFF -->Dear r/programming (https://www.reddit.com/r/programming) community, I'd like to discuss my solution to a common challenge many teams encounter. These teams work on their projects using PostgreSQL for the database layer. Their tests take too long because they run database migrations many times. If we have many tests each needing a new PostgreSQL database with a complex schema, these ways of running tests tend to be slow: Running migrations before each test (the more complex the schema, the longer it takes) Using transaction rollbacks (this does not work with some things in PostgreSQL) One database shared among all the tests (interference among tests) In one production system I worked on, we had to wait 15-20 minutes for CI to run the test unit tests that required isolated databases. Using A Template Database from PostgreSQL PostgreSQL has a powerful feature for addressing this problem: template databases. Instead of running migrations for each test database, we create a template database with all the migrations once. Create a clone of this template database very fast (29ms on average, regardless of the schema's complexity). Give each test an isolated database. Go implementation with SOLID principles I used the idea above to create pgdbtemplate. This Go library demonstrates how to apply some key engineering concepts. Dependency Injection & Open/Closed Principle // Core library depends on interfaces, not implementations. type ConnectionProvider interface { Connect(ctx context.Context, databaseName string) (DatabaseConnection, error) GetNoRowsSentinel() error } type MigrationRunner interface { RunMigrations(ctx context.Context, conn DatabaseConnection) error } That lets the connection provider implementations pgdbtemplate-pgx and pgdbtemplate-pq be separate from the core library code. It enables the library to work with various database setups. Tested like this: func TestUserRepository(t *testing.T) { // Template setup is done one time in TestMain! testDB, testDBName, err := templateManager.CreateTestDatabase(ctx) defer testDB.Close() defer templateManager.DropTestDatabase(ctx, testDBName) // Each test gets a clone of the isolated database. repo := NewUserRepository(testDB) // Do a test with features of the actual database... } How fast were these tests? Were they faster? In the table below, the new way was more than twice as fast with complex schemas, which had the largest speed savings: (Note that in practice, larger schemas took somewhat less time, making the difference even more favourable): Scenario Was Traditional Was Using a Template How much faster? Simple schema (1 table) ~29ms ~28ms Very little Complex schema (5+ tables) ~43ms ~29ms 50% more speed! 200 test databases ~9.2 sec ~5.8 sec 37% speed increase Memory used Baseline 17% less less resources needed Technical aspects beyond Go The core library is designed to be independent of the driver used. Additionally, it is compatible with various PostgreSQL drivers: pgx and pq Template databases are a PostgreSQL feature, not language-specific. The approach can be implemented in various programming languages, including Python, Java, and C#. The scaling benefits apply to any test suite with database requirements. Has this idea worked in the real world? This has been used with very large setups in the real world. Complex systems were billing and contracting. It has been tested with 100% test coverage. The library has been compared to similar open-source Go projects. Github: github.com/andrei-polukhin/pgdbtemplate (https://github.com/andrei-polukhin/pgdbtemplate) The concept of template databases for testing is something every PostgreSQL team should consider, regardless of their primary programming language. Thanks for reading, and I look forward to your feedback! <!-- SC_ON --> submitted by /u/Individual_Tutor_647 (https://www.reddit.com/user/Individual_Tutor_647)
Auto-documentation with a local LLM
https://www.reddit.com/r/programming/comments/1nsr4l7/autodocumentation_with_a_local_llm/

<!-- SC_OFF -->I found that any time a code file gets into the 1000+ lines size, Github CoPilot spends a long time having to traverse through it looking for the functions it needs to edit, wasting those precious tokens. To ease that burden, I decided to build a python script that recursively runs through your code base, documenting every single file and directory within it. These documents can be referenced by LLM's as they work on your code for information like what functions are available and what lines they are on. The system prompts are currently geared towards providing information for an LLM about the file, but they could easily be tweaked to something like "Summarize this for a human to read". Most importantly, each time it is run it only updates documentation for files/directories that had changes made to them, meaning you can easily keep the documentation up to date as you code. The LLM interface is currently pointing at a local Ollama instance running Mistral, that could be updated to any local model or go ahead and figure out how to point that to a more powerful cloud model. As a side note I thought I was a tech bro genius who would coin the phase 'Documentation Driven Development' but many beat me to that. Don't see their tools to enable it though! <!-- SC_ON --> submitted by /u/St0necutt3r (https://www.reddit.com/user/St0necutt3r)
[link] (https://github.com/MarkHauen/Documenatron) [comments] (https://www.reddit.com/r/programming/comments/1nsr4l7/autodocumentation_with_a_local_llm/)
How should I get into programming?
https://www.reddit.com/r/programming/comments/1nst9ah/how_should_i_get_into_programming/

<!-- SC_OFF -->I’ve been coding with scratch on and off for the past ~4-5 years, but I really want to try to buckle down and make a full, cool game on like unity or UE or something. How should I go about doing that? I did take a coding class last year for python, so i kind of know the basics, but I really wanna give it a real try. Any tips? <!-- SC_ON --> submitted by /u/No-Subject-619 (https://www.reddit.com/user/No-Subject-619)
[link] (http://wikipedia.com/programming) [comments] (https://www.reddit.com/r/programming/comments/1nst9ah/how_should_i_get_into_programming/)
Why Python is the Best Programming Language to Learn as a Beginner?
https://www.reddit.com/r/programming/comments/1nsun8r/why_python_is_the_best_programming_language_to/

<!-- SC_OFF -->I want to write blog posts regarding Python, ML and DL, and this is my first blog post. Do you guys think i should do this long term? also appreciate some support !! he he <!-- SC_ON --> submitted by /u/Successful-Ad2549 (https://www.reddit.com/user/Successful-Ad2549)
[link] (https://noobsplitsnews.blogspot.com/2025/09/why-python-is-best-programming-language.html) [comments] (https://www.reddit.com/r/programming/comments/1nsun8r/why_python_is_the_best_programming_language_to/)
I turned years of programming & IT absurdities into a satirical “dictionary” — AMA (indie published, out Sept 30, here till Oct 5)
https://www.reddit.com/r/programming/comments/1nsuqdw/i_turned_years_of_programming_it_absurdities_into/

<!-- SC_OFF -->Hey r/programming (https://www.reddit.com/r/programming), After a decade in tech, I did the only reasonable thing: collected all the jargon, Agile rituals, corpoland buzzwords, startup chaos, and AI hype… and turned them into a book-length satire. Think of it as a dictionary of survival for anyone who’s ever sat through a sprint planning that felt like group therapy, or watched a manager rename “bugs” into “undocumented features.” The book officially launches September 30th, and I went the full self-publishing route (handled everything myself except for layout/graphics, which I outsourced to a DTP specialist). I’ll be answering questions here all week until Oct 5 (longer if needed). Happy to chat about: Programming culture absurdities that made it into the book What it’s like to translate IT jargon into satire Indie publishing as a developer side quest Or just your favorite “WTF moment” from code reviews, deploys, and daily standups AMA! <!-- SC_ON --> submitted by /u/Inevitable-Field-501 (https://www.reddit.com/user/Inevitable-Field-501)
[link] (http://www.adamkorga.com/) [comments] (https://www.reddit.com/r/programming/comments/1nsuqdw/i_turned_years_of_programming_it_absurdities_into/)
My early years as a programmer: 1997-2002
https://www.reddit.com/r/programming/comments/1nsx4o8/my_early_years_as_a_programmer_19972002/

<!-- SC_OFF -->I am a software industry veteran of soon to be 20 years. Here is part one of a series of blog posts where I share my journey in tech starting as a teenager in the late 90s starting on a graphing calculator. How did you get your start in programming? <!-- SC_ON --> submitted by /u/jkndrkn (https://www.reddit.com/user/jkndrkn)
[link] (https://mediumsecond.com/lost-at-the-beginning/) [comments] (https://www.reddit.com/r/programming/comments/1nsx4o8/my_early_years_as_a_programmer_19972002/)
just nuked 120+ unused npm deps from a huge Nx monorepo
https://www.reddit.com/r/programming/comments/1nsymn6/just_nuked_120_unused_npm_deps_from_a_huge_nx/

<!-- SC_OFF -->just nuked 120+ unused npm deps from a huge Nx monorepo using Knip. shaved a whole minute off yarn install. wrote up the whole process, including how to avoid false positives. if you got npm bloat, this is for you <!-- SC_ON --> submitted by /u/Beautiful_Spot5404 (https://www.reddit.com/user/Beautiful_Spot5404)
[link] (https://johnjames.blog/posts/cleaning-house-in-nx-monorepo-how-i-removed-120-unused-deps-safely) [comments] (https://www.reddit.com/r/programming/comments/1nsymn6/just_nuked_120_unused_npm_deps_from_a_huge_nx/)
The easiest way to keep code and docs synced
https://www.reddit.com/r/programming/comments/1nsysen/the_easiest_way_to_keep_code_and_docs_synced/

<!-- SC_OFF -->One problem about coding and documentation is keeping your docs up-to-date, no developers likes documentation. Or even worse, knowing which and what parts out of thousands of docs to update. We are launching Drift AI soon. With every push to your main branch, we retrieve relevant documents, highlight and suggest edits to outdated parts, and tag the right engineer to approve the edits. No new platforms, we directly integrate with Confluence and everything is done in Confluence. You can grab your early access spot if you find this useful for you or your team. <!-- SC_ON --> submitted by /u/khalidd877 (https://www.reddit.com/user/khalidd877)
[link] (https://driftai.framer.website/) [comments] (https://www.reddit.com/r/programming/comments/1nsysen/the_easiest_way_to_keep_code_and_docs_synced/)
[JS/TS] For those who made a reactive library before, how to deal with reconciliation on array ordering.
https://www.reddit.com/r/programming/comments/1nszt1m/jsts_for_those_who_made_a_reactive_library_before/

<!-- SC_OFF -->I'm doing a small reactive library ( no VDOM, direct manipulation and quite "mechanical" as it will be used for a generator later but still ergonomic enough to write by hand ) for fun and learning purpose, to learn how a reactive library works and also later how a compiler and generator works. So the first step I'm tackling is the actual reactive library, for now I got to a point where I think it works well and has hierarchy and cleanups when it is supposed to, and I made 2 small helpers for control ( when and each ) but, as of now the each does not care about ordering and I'm not sure how would it be able to change the order tbh, at least not right now. So for anyone that did one, how did you do it? EDIT: I changed so any control part is now tied with the dom and are less generic, I made each work in a way that nodes can be reused and using the dom to reorder with a list. Obs: there is a bug where if you try to add another item to the array that has the same key it does not get added because it thinks the component already exist. <!-- SC_ON --> submitted by /u/Gustavo_Fenilli (https://www.reddit.com/user/Gustavo_Fenilli)
[link] (https://github.com/fenilli/nero/blob/main/lib/runtime/control.ts) [comments] (https://www.reddit.com/r/programming/comments/1nszt1m/jsts_for_those_who_made_a_reactive_library_before/)
a good quality code?
https://www.reddit.com/r/programming/comments/1ntbea5/a_good_quality_code/

<!-- SC_OFF -->this is my first "algorithm" so any advice would be really useful, thank you <!-- SC_ON --> submitted by /u/Muhammed_FpI (https://www.reddit.com/user/Muhammed_FpI)
[link] (https://github.com/Naikhm/3EquationsSolver) [comments] (https://www.reddit.com/r/programming/comments/1ntbea5/a_good_quality_code/)
GTranslate - Translations at the speed of tought
https://www.reddit.com/r/programming/comments/1ntc2f4/gtranslate_translations_at_the_speed_of_tought/

<!-- SC_OFF -->GTranslate - Translate at the speed of tought An open-source, modern and convenience cross-platform application for translations at the speed of thought. Built with Rust Tokio Features Translate text to and from any language Secure auto-updater System Tray & Auto start on boot Available to Windows (MSI) MacOS Linux (beta, due to some Tauri limits) Install (https://gtranslate.app/) Source code (https://github.com/z3ntl3/gtranslate-app) <!-- SC_ON --> submitted by /u/Budget-Bicycle4121 (https://www.reddit.com/user/Budget-Bicycle4121)
[link] (https://gtranslate.app/) [comments] (https://www.reddit.com/r/programming/comments/1ntc2f4/gtranslate_translations_at_the_speed_of_tought/)
This is actually a really good free workshop
https://www.reddit.com/r/programming/comments/1ntcenk/this_is_actually_a_really_good_free_workshop/

<!-- SC_OFF -->Free 80-minute online workshop called 'How to Understand the Value of Your Code' It covers: Frameworks to measure feature impact How to avoid drowning in meaningless metrics Practical tactics you can apply right away It’s interactive, led by an industry expert, and completely free. Good if you’ve ever had to explain why your team’s work matters to stakeholders. <!-- SC_ON --> submitted by /u/HDev- (https://www.reddit.com/user/HDev-)
[link] (https://leaddev.com/event/how-to-understand-the-value-of-your-code) [comments] (https://www.reddit.com/r/programming/comments/1ntcenk/this_is_actually_a_really_good_free_workshop/)