From the AskProgramming community on Reddit
https://www.reddit.com/r/programming/comments/1pr8u7j/from_the_askprogramming_community_on_reddit/
submitted by /u/maniiso (https://www.reddit.com/user/maniiso)
[link] (https://www.reddit.com/r/AskProgramming/comments/1pr8t48/starting_to_learn_python/?share_id=eM5VEISHfHRwZUyJr0yte&utm_content=1&utm_medium=ios_app&utm_name=ioscss&utm_source=share&utm_term=1) [comments] (https://www.reddit.com/r/programming/comments/1pr8u7j/from_the_askprogramming_community_on_reddit/)
https://www.reddit.com/r/programming/comments/1pr8u7j/from_the_askprogramming_community_on_reddit/
submitted by /u/maniiso (https://www.reddit.com/user/maniiso)
[link] (https://www.reddit.com/r/AskProgramming/comments/1pr8t48/starting_to_learn_python/?share_id=eM5VEISHfHRwZUyJr0yte&utm_content=1&utm_medium=ios_app&utm_name=ioscss&utm_source=share&utm_term=1) [comments] (https://www.reddit.com/r/programming/comments/1pr8u7j/from_the_askprogramming_community_on_reddit/)
The Development Process to Build a Fuel Delivery App
https://www.reddit.com/r/programming/comments/1pr9j5x/the_development_process_to_build_a_fuel_delivery/
submitted by /u/HiShivanshgiri (https://www.reddit.com/user/HiShivanshgiri)
[link] (https://www.techanicinfotech.com/fuel-delivery-app-development) [comments] (https://www.reddit.com/r/programming/comments/1pr9j5x/the_development_process_to_build_a_fuel_delivery/)
https://www.reddit.com/r/programming/comments/1pr9j5x/the_development_process_to_build_a_fuel_delivery/
submitted by /u/HiShivanshgiri (https://www.reddit.com/user/HiShivanshgiri)
[link] (https://www.techanicinfotech.com/fuel-delivery-app-development) [comments] (https://www.reddit.com/r/programming/comments/1pr9j5x/the_development_process_to_build_a_fuel_delivery/)
How my knowledge in other subdomains in Software Engineering united to exponentially increase MLOps potential
https://www.reddit.com/r/programming/comments/1prdbkt/how_my_knowledge_in_other_subdomains_in_software/
submitted by /u/innatari (https://www.reddit.com/user/innatari)
[link] (https://thenukaovin.medium.com/how-mlops-turned-my-breadth-into-a-strength-68b03c25ceb6) [comments] (https://www.reddit.com/r/programming/comments/1prdbkt/how_my_knowledge_in_other_subdomains_in_software/)
https://www.reddit.com/r/programming/comments/1prdbkt/how_my_knowledge_in_other_subdomains_in_software/
submitted by /u/innatari (https://www.reddit.com/user/innatari)
[link] (https://thenukaovin.medium.com/how-mlops-turned-my-breadth-into-a-strength-68b03c25ceb6) [comments] (https://www.reddit.com/r/programming/comments/1prdbkt/how_my_knowledge_in_other_subdomains_in_software/)
GPU Accelerated Data Structures on Google Colab
https://www.reddit.com/r/programming/comments/1prdkhw/gpu_accelerated_data_structures_on_google_colab/
submitted by /u/DataBaeBee (https://www.reddit.com/user/DataBaeBee)
[link] (https://leetarxiv.substack.com/p/gpu-accelerated-data-structures-on) [comments] (https://www.reddit.com/r/programming/comments/1prdkhw/gpu_accelerated_data_structures_on_google_colab/)
https://www.reddit.com/r/programming/comments/1prdkhw/gpu_accelerated_data_structures_on_google_colab/
submitted by /u/DataBaeBee (https://www.reddit.com/user/DataBaeBee)
[link] (https://leetarxiv.substack.com/p/gpu-accelerated-data-structures-on) [comments] (https://www.reddit.com/r/programming/comments/1prdkhw/gpu_accelerated_data_structures_on_google_colab/)
[D] Awesome Production Machine Learning - A curated list of OSS libraries to deploy, monitor, version and scale your machine learning
https://www.reddit.com/r/programming/comments/1prdrb3/d_awesome_production_machine_learning_a_curated/
submitted by /u/axsauze (https://www.reddit.com/user/axsauze)
[link] (https://github.com/EthicalML/awesome-production-machine-learning/) [comments] (https://www.reddit.com/r/programming/comments/1prdrb3/d_awesome_production_machine_learning_a_curated/)
https://www.reddit.com/r/programming/comments/1prdrb3/d_awesome_production_machine_learning_a_curated/
submitted by /u/axsauze (https://www.reddit.com/user/axsauze)
[link] (https://github.com/EthicalML/awesome-production-machine-learning/) [comments] (https://www.reddit.com/r/programming/comments/1prdrb3/d_awesome_production_machine_learning_a_curated/)
Google's boomerang year: 20% of AI software engineers hired in 2025 were ex-employees
https://www.reddit.com/r/programming/comments/1prgwty/googles_boomerang_year_20_of_ai_software/
submitted by /u/washedFM (https://www.reddit.com/user/washedFM)
[link] (https://www.cnbc.com/2025/12/19/google-boomerang-year-20percent-ai-software-devs-hired-2025-ex-employees.html) [comments] (https://www.reddit.com/r/programming/comments/1prgwty/googles_boomerang_year_20_of_ai_software/)
https://www.reddit.com/r/programming/comments/1prgwty/googles_boomerang_year_20_of_ai_software/
submitted by /u/washedFM (https://www.reddit.com/user/washedFM)
[link] (https://www.cnbc.com/2025/12/19/google-boomerang-year-20percent-ai-software-devs-hired-2025-ex-employees.html) [comments] (https://www.reddit.com/r/programming/comments/1prgwty/googles_boomerang_year_20_of_ai_software/)
Tech Talk: Improving Window Resize Behavior | Electron
https://www.reddit.com/r/programming/comments/1prhpef/tech_talk_improving_window_resize_behavior/
submitted by /u/mitchchn (https://www.reddit.com/user/mitchchn)
[link] (https://www.electronjs.org/blog/tech-talk-window-resize-behavior) [comments] (https://www.reddit.com/r/programming/comments/1prhpef/tech_talk_improving_window_resize_behavior/)
https://www.reddit.com/r/programming/comments/1prhpef/tech_talk_improving_window_resize_behavior/
submitted by /u/mitchchn (https://www.reddit.com/user/mitchchn)
[link] (https://www.electronjs.org/blog/tech-talk-window-resize-behavior) [comments] (https://www.reddit.com/r/programming/comments/1prhpef/tech_talk_improving_window_resize_behavior/)
Modeling Large Codebases as Static Knowledge Graphs: Design Trade-offs
https://www.reddit.com/r/programming/comments/1priv8c/modeling_large_codebases_as_static_knowledge/
<!-- SC_OFF -->When working with large codebases, structural information such as module boundaries, dependency relationships, and hierarchy is often implicit and hard to reason about. One approach I’ve been exploring is representing codebases as static knowledge graphs, where files, modules, and symbols become explicit nodes, and architectural relationships are encoded as edges. This raises several design questions: - What information is best captured statically versus dynamically? - How detailed should graph nodes and edges be? - Where do static representations break down compared to runtime analysis? - How can such graphs remain maintainable as the code evolves? I’m interested in hearing from people who have worked on: - Static analysis tools - Code indexing systems - Large-scale refactoring or architecture tooling For context, I’ve been experimenting with these ideas in an open-source project, but I’m mainly interested in the broader design discussion. <!-- SC_ON --> submitted by /u/codevoygee (https://www.reddit.com/user/codevoygee)
[link] (https://github.com/yunusgungor/knowgraph) [comments] (https://www.reddit.com/r/programming/comments/1priv8c/modeling_large_codebases_as_static_knowledge/)
https://www.reddit.com/r/programming/comments/1priv8c/modeling_large_codebases_as_static_knowledge/
<!-- SC_OFF -->When working with large codebases, structural information such as module boundaries, dependency relationships, and hierarchy is often implicit and hard to reason about. One approach I’ve been exploring is representing codebases as static knowledge graphs, where files, modules, and symbols become explicit nodes, and architectural relationships are encoded as edges. This raises several design questions: - What information is best captured statically versus dynamically? - How detailed should graph nodes and edges be? - Where do static representations break down compared to runtime analysis? - How can such graphs remain maintainable as the code evolves? I’m interested in hearing from people who have worked on: - Static analysis tools - Code indexing systems - Large-scale refactoring or architecture tooling For context, I’ve been experimenting with these ideas in an open-source project, but I’m mainly interested in the broader design discussion. <!-- SC_ON --> submitted by /u/codevoygee (https://www.reddit.com/user/codevoygee)
[link] (https://github.com/yunusgungor/knowgraph) [comments] (https://www.reddit.com/r/programming/comments/1priv8c/modeling_large_codebases_as_static_knowledge/)
Sergey Brin, on whether students should pick Computer Science in 2026
https://www.reddit.com/r/programming/comments/1prlib8/sergey_brin_on_whether_students_should_pick/
submitted by /u/Frequent-Football984 (https://www.reddit.com/user/Frequent-Football984)
[link] (https://youtu.be/YhxROT5FglI?si=KlFxDK61rXqJ6grz) [comments] (https://www.reddit.com/r/programming/comments/1prlib8/sergey_brin_on_whether_students_should_pick/)
https://www.reddit.com/r/programming/comments/1prlib8/sergey_brin_on_whether_students_should_pick/
submitted by /u/Frequent-Football984 (https://www.reddit.com/user/Frequent-Football984)
[link] (https://youtu.be/YhxROT5FglI?si=KlFxDK61rXqJ6grz) [comments] (https://www.reddit.com/r/programming/comments/1prlib8/sergey_brin_on_whether_students_should_pick/)
What do people love about Rust?
https://www.reddit.com/r/programming/comments/1prm89i/what_do_people_love_about_rust/
submitted by /u/steveklabnik1 (https://www.reddit.com/user/steveklabnik1)
[link] (https://blog.rust-lang.org/2025/12/19/what-do-people-love-about-rust/) [comments] (https://www.reddit.com/r/programming/comments/1prm89i/what_do_people_love_about_rust/)
https://www.reddit.com/r/programming/comments/1prm89i/what_do_people_love_about_rust/
submitted by /u/steveklabnik1 (https://www.reddit.com/user/steveklabnik1)
[link] (https://blog.rust-lang.org/2025/12/19/what-do-people-love-about-rust/) [comments] (https://www.reddit.com/r/programming/comments/1prm89i/what_do_people_love_about_rust/)
Launching Remy
https://www.reddit.com/r/programming/comments/1pry78w/launching_remy/
<!-- SC_OFF -->Hey everyone — I’ve been working on a consumer app called Remy that’s meant to help in the moment when an alcohol craving hits. Most sobriety apps focus on tracking days or staying sober long-term. Remy is different — it’s designed for the day-to-day moments where you actually feel the urge to drink and need something right then to get through it. When a craving hits, you open the app and use: • Short grounding exercises (like urge surfing) • Simple games to distract and ride out the craving • An AI character (Remy) that gives personalized motivation based on your goals, stressors, and usual trigger times The idea is to reduce the intensity of the craving long enough for it to pass. It’s a mobile app (App Store launch soon — finishing up a few things), and I built it myself using Lovable and ElevenLabs for voice. I’m steadily adding more exercises and games, and I’m looking for early users / beta testers who are open to giving honest feedback — what works, what doesn’t, and what would make this actually useful. Let me know if you want to test it out and I will add you as a user. <!-- SC_ON --> submitted by /u/remy-the-fox (https://www.reddit.com/user/remy-the-fox)
[link] (https://remy-the-fox.lovable.app/) [comments] (https://www.reddit.com/r/programming/comments/1pry78w/launching_remy/)
https://www.reddit.com/r/programming/comments/1pry78w/launching_remy/
<!-- SC_OFF -->Hey everyone — I’ve been working on a consumer app called Remy that’s meant to help in the moment when an alcohol craving hits. Most sobriety apps focus on tracking days or staying sober long-term. Remy is different — it’s designed for the day-to-day moments where you actually feel the urge to drink and need something right then to get through it. When a craving hits, you open the app and use: • Short grounding exercises (like urge surfing) • Simple games to distract and ride out the craving • An AI character (Remy) that gives personalized motivation based on your goals, stressors, and usual trigger times The idea is to reduce the intensity of the craving long enough for it to pass. It’s a mobile app (App Store launch soon — finishing up a few things), and I built it myself using Lovable and ElevenLabs for voice. I’m steadily adding more exercises and games, and I’m looking for early users / beta testers who are open to giving honest feedback — what works, what doesn’t, and what would make this actually useful. Let me know if you want to test it out and I will add you as a user. <!-- SC_ON --> submitted by /u/remy-the-fox (https://www.reddit.com/user/remy-the-fox)
[link] (https://remy-the-fox.lovable.app/) [comments] (https://www.reddit.com/r/programming/comments/1pry78w/launching_remy/)
200+ Free Online Developer Tools
https://www.reddit.com/r/programming/comments/1prz54v/200_free_online_developer_tools/
submitted by /u/InterestingCook3725 (https://www.reddit.com/user/InterestingCook3725)
[link] (https://tools.geeksprep.com/) [comments] (https://www.reddit.com/r/programming/comments/1prz54v/200_free_online_developer_tools/)
https://www.reddit.com/r/programming/comments/1prz54v/200_free_online_developer_tools/
submitted by /u/InterestingCook3725 (https://www.reddit.com/user/InterestingCook3725)
[link] (https://tools.geeksprep.com/) [comments] (https://www.reddit.com/r/programming/comments/1prz54v/200_free_online_developer_tools/)
Performance Excuses Debunked - Also, many examples of successful rewrites
https://www.reddit.com/r/programming/comments/1przcvj/performance_excuses_debunked_also_many_examples/
submitted by /u/grauenwolf (https://www.reddit.com/user/grauenwolf)
[link] (https://www.computerenhance.com/p/performance-excuses-debunked) [comments] (https://www.reddit.com/r/programming/comments/1przcvj/performance_excuses_debunked_also_many_examples/)
https://www.reddit.com/r/programming/comments/1przcvj/performance_excuses_debunked_also_many_examples/
submitted by /u/grauenwolf (https://www.reddit.com/user/grauenwolf)
[link] (https://www.computerenhance.com/p/performance-excuses-debunked) [comments] (https://www.reddit.com/r/programming/comments/1przcvj/performance_excuses_debunked_also_many_examples/)
A systematic framework to eliminate all UB from C++
https://www.reddit.com/r/programming/comments/1ps0m3w/a_systematic_framework_to_eliminate_all_ub_from_c/
<!-- SC_OFF -->This is a high-level interesting on-going paper about how C++ plans to improve safety. This includes strategies: feature removal refined behaviour erroneous behaviour insertion of runtime checks language subsetting (via profiles, probably) the introduction of annotations the introduction of entirely new language features The paper takes into account that C++ is a language that should keep compiling with older code but should do it with newer code in a safer way (via opt-ins/outs). <!-- SC_ON --> submitted by /u/germandiago (https://www.reddit.com/user/germandiago)
[link] (https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3100r5.pdf) [comments] (https://www.reddit.com/r/programming/comments/1ps0m3w/a_systematic_framework_to_eliminate_all_ub_from_c/)
https://www.reddit.com/r/programming/comments/1ps0m3w/a_systematic_framework_to_eliminate_all_ub_from_c/
<!-- SC_OFF -->This is a high-level interesting on-going paper about how C++ plans to improve safety. This includes strategies: feature removal refined behaviour erroneous behaviour insertion of runtime checks language subsetting (via profiles, probably) the introduction of annotations the introduction of entirely new language features The paper takes into account that C++ is a language that should keep compiling with older code but should do it with newer code in a safer way (via opt-ins/outs). <!-- SC_ON --> submitted by /u/germandiago (https://www.reddit.com/user/germandiago)
[link] (https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3100r5.pdf) [comments] (https://www.reddit.com/r/programming/comments/1ps0m3w/a_systematic_framework_to_eliminate_all_ub_from_c/)
An information funnel to automate performance reviews
https://www.reddit.com/r/programming/comments/1ps1w1l/an_information_funnel_to_automate_performance/
submitted by /u/strategizeyourcareer (https://www.reddit.com/user/strategizeyourcareer)
[link] (https://strategizeyourcareer.com/p/performance-review-season-is-here) [comments] (https://www.reddit.com/r/programming/comments/1ps1w1l/an_information_funnel_to_automate_performance/)
https://www.reddit.com/r/programming/comments/1ps1w1l/an_information_funnel_to_automate_performance/
submitted by /u/strategizeyourcareer (https://www.reddit.com/user/strategizeyourcareer)
[link] (https://strategizeyourcareer.com/p/performance-review-season-is-here) [comments] (https://www.reddit.com/r/programming/comments/1ps1w1l/an_information_funnel_to_automate_performance/)
Greenmask + MySQL: v1.0.0b1 beta now available
https://www.reddit.com/r/programming/comments/1ps2sgt/greenmask_mysql_v100b1_beta_now_available/
submitted by /u/anyweny (https://www.reddit.com/user/anyweny)
[link] (https://github.com/GreenmaskIO/greenmask/releases/tag/v1.0.0b1) [comments] (https://www.reddit.com/r/programming/comments/1ps2sgt/greenmask_mysql_v100b1_beta_now_available/)
https://www.reddit.com/r/programming/comments/1ps2sgt/greenmask_mysql_v100b1_beta_now_available/
submitted by /u/anyweny (https://www.reddit.com/user/anyweny)
[link] (https://github.com/GreenmaskIO/greenmask/releases/tag/v1.0.0b1) [comments] (https://www.reddit.com/r/programming/comments/1ps2sgt/greenmask_mysql_v100b1_beta_now_available/)
PatchworkOS Is a From-Scratch OS That Follows 'Everything Is a File' More Strictly than UNIX: An Overview of Sockets, Spawning Processes, and Notes (Signals)
https://www.reddit.com/r/programming/comments/1ps3he5/patchworkos_is_a_fromscratch_os_that_follows/
<!-- SC_OFF -->PatchworkOS (https://github.com/KaiNorberg/PatchworkOS) strictly follows the "everything is a file" philosophy in a way inspired by Plan9, this can often result in unorthodox APIs that seem overcomplicated at first, but the goal is to provide a simple, consistent and most importantly composable interface for all kernel subsystems, more on this later. Included below are some examples to familiarize yourself with the concept. We, of course, cannot cover everything, so the concepts presented here are the ones believed to provide the greatest insight into the philosophy. Sockets The first example is sockets, specifically how to create and use local seqpacket sockets. To create a local seqpacket socket, you open the /net/local/seqpacket file. This is equivalent to calling socket(AF_LOCAL, SOCK_SEQPACKET, 0) in POSIX systems. The opened file can be read to return the "ID" of the newly created socket which is a string that uniquely identifies the socket, more on this later. PatchworkOS provides several helper functions to make file operations easier, but first we will show how to do it without any helpers: fd_t fd = open("/net/local/seqpacket"); char id[32] = {0}; read(fd, id, 31); // ... do stuff ... close(fd); Using the sread() helper which reads a null-terminated string from a file denoscriptor, we can simplify this to: fd_t fd = open("/net/local/seqpacket"); char* id = sread(fd); close(fd); // ... do stuff ... free(id); Finally, using use the sreadfile() helper which reads a null-terminated string from a file from its path, we can simplify this even further to: char* id = sreadfile("/net/local/seqpacket"); // ... do stuff ... free(id); Note that the socket will persist until the process that created it and all its children have exited. Additionally, for error handling, all functions will return either NULL or ERR on failure, depending on if they return a pointer or an integer type respectively. The per-thread errno variable is used to indicate the specific error that occurred, both in user space and kernel space (however the actual variable is implemented differently in kernel space). Now that we have the ID, we can discuss what it actually is. The ID is the name of a directory in the /net/local directory, in which the following files exist: data: Used to send and retrieve data ctl: Used to send commands accept: Used to accept incoming connections So, for example, the sockets data file is located at /net/local/[id]/data. Say we want to make our socket into a server, we would then use the ctl file to send the bind and listen commands, this is similar to calling bind() and listen() in POSIX systems. In this case, we want to bind the server to the name myserver. Once again, we provide several helper functions to make this easier. First, without any helpers: char ctlPath[MAX_PATH] = {0}; snprintf(ctlPath, MAX_PATH, "/net/local/%s/ctl", id) fd_t ctl = open(ctlPath); const char* str = "bind myserver && listen"; // Note the use of && to send multiple commands. write(ctl, str, strlen(str)); close(ctl); Using the F() macro which allocates formatted strings on the stack and the swrite() helper that writes a null-terminated string to a file denoscriptor: fd_t ctl = open(F("/net/local/%s/ctl", id)); swrite(ctl, "bind myserver && listen") close(ctl); Finally, using the swritefile() helper which writes a null-terminated string to a file from its path: swritefile(F("/net/local/%s/ctl", id), "bind myserver && listen"); If we wanted to accept a connection using our newly created server, we just open its accept file: fd_t fd = open(F("/net/local/%s/accept", id)); /// ... do stuff ... close(fd); The file denoscriptor returned when the accept file is opened can be used to
https://www.reddit.com/r/programming/comments/1ps3he5/patchworkos_is_a_fromscratch_os_that_follows/
<!-- SC_OFF -->PatchworkOS (https://github.com/KaiNorberg/PatchworkOS) strictly follows the "everything is a file" philosophy in a way inspired by Plan9, this can often result in unorthodox APIs that seem overcomplicated at first, but the goal is to provide a simple, consistent and most importantly composable interface for all kernel subsystems, more on this later. Included below are some examples to familiarize yourself with the concept. We, of course, cannot cover everything, so the concepts presented here are the ones believed to provide the greatest insight into the philosophy. Sockets The first example is sockets, specifically how to create and use local seqpacket sockets. To create a local seqpacket socket, you open the /net/local/seqpacket file. This is equivalent to calling socket(AF_LOCAL, SOCK_SEQPACKET, 0) in POSIX systems. The opened file can be read to return the "ID" of the newly created socket which is a string that uniquely identifies the socket, more on this later. PatchworkOS provides several helper functions to make file operations easier, but first we will show how to do it without any helpers: fd_t fd = open("/net/local/seqpacket"); char id[32] = {0}; read(fd, id, 31); // ... do stuff ... close(fd); Using the sread() helper which reads a null-terminated string from a file denoscriptor, we can simplify this to: fd_t fd = open("/net/local/seqpacket"); char* id = sread(fd); close(fd); // ... do stuff ... free(id); Finally, using use the sreadfile() helper which reads a null-terminated string from a file from its path, we can simplify this even further to: char* id = sreadfile("/net/local/seqpacket"); // ... do stuff ... free(id); Note that the socket will persist until the process that created it and all its children have exited. Additionally, for error handling, all functions will return either NULL or ERR on failure, depending on if they return a pointer or an integer type respectively. The per-thread errno variable is used to indicate the specific error that occurred, both in user space and kernel space (however the actual variable is implemented differently in kernel space). Now that we have the ID, we can discuss what it actually is. The ID is the name of a directory in the /net/local directory, in which the following files exist: data: Used to send and retrieve data ctl: Used to send commands accept: Used to accept incoming connections So, for example, the sockets data file is located at /net/local/[id]/data. Say we want to make our socket into a server, we would then use the ctl file to send the bind and listen commands, this is similar to calling bind() and listen() in POSIX systems. In this case, we want to bind the server to the name myserver. Once again, we provide several helper functions to make this easier. First, without any helpers: char ctlPath[MAX_PATH] = {0}; snprintf(ctlPath, MAX_PATH, "/net/local/%s/ctl", id) fd_t ctl = open(ctlPath); const char* str = "bind myserver && listen"; // Note the use of && to send multiple commands. write(ctl, str, strlen(str)); close(ctl); Using the F() macro which allocates formatted strings on the stack and the swrite() helper that writes a null-terminated string to a file denoscriptor: fd_t ctl = open(F("/net/local/%s/ctl", id)); swrite(ctl, "bind myserver && listen") close(ctl); Finally, using the swritefile() helper which writes a null-terminated string to a file from its path: swritefile(F("/net/local/%s/ctl", id), "bind myserver && listen"); If we wanted to accept a connection using our newly created server, we just open its accept file: fd_t fd = open(F("/net/local/%s/accept", id)); /// ... do stuff ... close(fd); The file denoscriptor returned when the accept file is opened can be used to
send and receive data, just like when calling accept() in POSIX systems. For the sake of completeness, to connect the server we just create a new socket and use the connect command: char* id = sreadfile("/net/local/seqpacket"); swritefile(F("/net/local/%s/ctl", id), "connect myserver"); free(id); Documentation (https://kainorberg.github.io/PatchworkOS/html/df/d65/group__module__net.html) File Flags? You may have noticed that in the above section sections the open() function does not take in a flags argument. This is because flags are directly part of the file path so to create a non-blocking socket: open("/net/local/seqpacket:nonblock"); Multiple flags are allowed, just separate them with the : character, this means flags can be easily appended to a path using the F() macro. Each flag also has a shorthand version for which the : character is omitted, for example to open a file as create and exclusive, you can do open("/some/path:create:exclusive"); or open("/some/path:ce"); For a full list of available flags, check the Documentation (https://kainorberg.github.io/PatchworkOS/html/dd/de3/group__kernel__fs__path.html). Permissions? Permissions are also specified using file paths there are three possible permissions, read, write and execute. For example to open a file as read and write, you can do open("/some/path:read:write"); or open("/some/path:rw"); Permissions are inherited, you can't use a file with lower permissions to get a file with higher permissions. Consider the namespace section, if a directory was opened using only read permissions and that same directory was bound, then it would be impossible to open any files within that directory with any permissions other than read. For a full list of available permissions, check the Documentation (https://kainorberg.github.io/PatchworkOS/html/dd/de3/group__kernel__fs__path.html). Spawning Processes Another example of the "everything is a file" philosophy is the spawn() syscall used to create new processes. We will skip the usual debate on fork() vs spawn() and just focus on how spawn() works in PatchworkOS as there are enough discussions about that online. The spawn() syscall takes in two arguments: const char** argv: The argument vector, similar to POSIX systems except that the first argument is always the path to the executable. spawn_flags_t flags: Flags controlling the creation of the new process, primarily what to inherit from the parent process. The system call may seem very small in comparison to, for example, posix_spawn() or CreateProcess(). This is intentional, trying to squeeze every possible combination of things one might want to do when creating a new process into a single syscall would be highly impractical, as those familiar with CreateProcess() may know. PatchworkOS instead allows the creation of processes in a suspended state, allowing the parent process to modify the child process before it starts executing. As an example, let's say we wish to create a child such that its stdio is redirected to some file denoscriptors in the parent and create an environment variable MY_VAR=my_value. First, let's pretend we have some set of file denoscriptors and spawn the new process in a suspended state using the SPAWN_SUSPENDED flag fd_t stdin = ...; fd_t stdout = ...; fd_t stderr = ...; const char* argv[] = {"/bin/shell", NULL}; pid_t child = spawn(argv, SPAWN_SUSPENDED); At this point, the process exists but its stuck blocking before it is can load its executable. Additionally, the child process has inherited all file denoscriptors and environment variables from the parent process. Now we can redirect the stdio file denoscriptors in the child process using the /proc/[pid]/ctl file, which just like the socket ctl file, allows us to send commands to control the process. In this case, we want to use two commands, dup2 to redirect the stdio file denoscriptors and close to close the unneeded file denoscriptors. swritefile(F("/proc/%d/ctl", child), F("dup2 %d 0 && dup2 %d 1 &&
dup2 %d 2 && close 3 -1", stdin, stdout, stderr)); Note that close can either take one or two arguments. When two arguments are provided, it closes all file denoscriptors in the specified range. In our case -1 causes a underflow to the maximum file denoscriptor value, closing all file denoscriptors higher than or equal to the first argument. Next, we create the environment variable by creating a file in the child's /proc/[pid]/env/ directory: swritefile(F("/proc/%d/env/MY_VAR:create", child), "my_value"); Finally, we can start the child process using the start command: swritefile(F("/proc/%d/ctl", child), "start"); At this point the child process will begin executing with its stdio redirected to the specified file denoscriptors and the environment variable set as expected. The advantages of this approach are numerous, we avoid COW issues with fork(), weirdness with vfork(), system call bloat with CreateProcess(), and we get a very flexible and powerful process creation system that can use any of the other file based APIs to modify the child process. In exchange, the only real price we pay is overhead from additional context switches, string parsing and path traversals, how much this matters in practice is debatable. For more on spawn(), check the Userspace Process API Documentation (https://kainorberg.github.io/PatchworkOS/html/d1/d10/group__libstd__sys__proc.html#gae41c1cb67e3bc823c6d0018e043022eb) and for more information on the /proc filesystem, check the Kernel Process Documentation (https://kainorberg.github.io/PatchworkOS/html/da/d0f/group__kernel__proc.html). Notes (Signals) The next feature to discuss is the "notes" system. Notes are PatchworkOS's equivalent to POSIX signals which asynchronously send strings to processes. We will skip how to send and receive notes along with details like process groups (check the docs for that), instead focusing on the biggest advantage of the notes system, additional information. Let's take an example. Say we are debugging a segmentation fault in a program, which is a rather common scenario. In a usual POSIX environment, we might be told "Segmentation fault (core dumped)" or even worse "SIGSEGV", which is not very helpful. The core limitation is that signals are just integers, so we can't provide any additional information. In PatchworkOS, a note is a string where the first word of the string is the note type and the rest is arbitrary data. So in our segmentation fault example, the shell might produce output like: shell: pagefault at 0x40013b due to stack overflow at 0x7ffffff9af18 Note that the output provided is from the "stackoverflow" program which intentionally causes a stack overflow through recursion. All that happened is that the shell printed the exit status of the process, which is also a string and in this case is set to the note that killed the process. This is much more useful, we know the exact address and the reason for the fault. For more details, see the Notes Documentation (https://kainorberg.github.io/PatchworkOS/html/d8/db1/group__kernel__ipc__note.html), Standard Library Process Documentation (https://kainorberg.github.io/PatchworkOS/html/d1/d10/group__libstd__sys__proc.html) and the Kernel Process Documentation (https://kainorberg.github.io/PatchworkOS/html/da/d0f/group__kernel__proc.html). But why? I'm sure you have heard many an argument for and against the "everything is a file" philosophy. So I won't go over everything, but the primary reason for using it in PatchworkOS is "emergent behavior" or "composability" whichever term you prefer. Take the spawn() example, notice how there is no specialized system for setting up a child after it's been created? Instead, we have a set of small, simple building blocks that when added together form a more complex whole. That is emergent behavior, by keeping things simple and most importantly composable, we can create very complex behavior without needing to explicitly design it. Let's take another example, say you
wanted to wait on multiple processes with a waitpid() syscall. Well, that's not possible. So now we suddenly need a new system call. Meanwhile, in an "everything is a file system" we just have a pollable /proc/[pid]/wait file that blocks until the process dies and returns the exit status, now any behavior that can be implemented with poll() can be used while waiting on processes, including waiting on multiple processes at once, waiting on a keyboard and a process, waiting with a timeout, or any weird combination you can think of. Plus its fun. <!-- SC_ON --> submitted by /u/KN_9296 (https://www.reddit.com/user/KN_9296)
[link] (https://github.com/KaiNorberg/PatchworkOS) [comments] (https://www.reddit.com/r/programming/comments/1ps3he5/patchworkos_is_a_fromscratch_os_that_follows/)
[link] (https://github.com/KaiNorberg/PatchworkOS) [comments] (https://www.reddit.com/r/programming/comments/1ps3he5/patchworkos_is_a_fromscratch_os_that_follows/)
Rust and the price of ignoring theory - one of the most interesting programming videos I've watched in a while
https://www.reddit.com/r/programming/comments/1ps6of3/rust_and_the_price_of_ignoring_theory_one_of_the/
submitted by /u/ThisIsChangableRight (https://www.reddit.com/user/ThisIsChangableRight)
[link] (https://www.youtube.com/watch?v=1iPWt1gvT_w) [comments] (https://www.reddit.com/r/programming/comments/1ps6of3/rust_and_the_price_of_ignoring_theory_one_of_the/)
https://www.reddit.com/r/programming/comments/1ps6of3/rust_and_the_price_of_ignoring_theory_one_of_the/
submitted by /u/ThisIsChangableRight (https://www.reddit.com/user/ThisIsChangableRight)
[link] (https://www.youtube.com/watch?v=1iPWt1gvT_w) [comments] (https://www.reddit.com/r/programming/comments/1ps6of3/rust_and_the_price_of_ignoring_theory_one_of_the/)