Programming Leftovers
-
Tony Finch ☛ getopt() but smaller
But the description of lexopt made me think getopt() could be simpler. The insight is that the string of options that you have to pass to getopt() is redundant with respect to the code that deals with the return values from getopt(). What if you just get rid of the options string?
I thought I would try it. Turns out, not much is lost in getting rid of the options string, and a few things are gained.
My new code is half the size or less of getopt(), and has more functionality. I’m going to show how how this was done, because it’s short (ish), not because it is interesting. Then I’ll try to tease out a lesson or two.
-
Fabian “ryg” Giesen ☛ Exact UNORM8 to float
GPUs support UNORM formats that represent a number inside [0,1] as an 8-bit unsigned integer. In exact arithmetic, the conversion to a floating-point number is straightforward: take the integer and divide it by 255. 8-bit integers are for sure machine numbers (exactly represented) in float32 and so is 255, so if you’re willing to do a “proper” divide, that’s the end of it; both inputs are exact, so the result of the division is the same as the result of the computation in exact arithmetic rounded to the nearest float32 (as per active rounding mode anyway), which is the best we can hope for.
-
Aleksandar Vacić ☛ Objective-C framework callbacks in Swift 6 · aplus.rs
After upgrading all my active projects to Swift 6 language mode, I was bound to encounter some head-scratching edge cases. One of the weirdest ones was this runtime crash: [...]
-
Rlang ☛ Testing Data with If and Else If in C
In C programming, the ability to make decisions and control the flow of a program is essential. One of the most fundamental ways to do this is by using conditional statements like if and else if. These statements allow you to test data and execute different blocks of code based on the outcome of those tests. In this article, we’ll explore how to use if and else if statements effectively, along with an overview of relational operators in C.
-
[Repeat] Tedium ☛ Election Post-Mortem: Know What You Control
I opened up a code window, and started working on some nagging bugs in the redesign I’m working on. Within an hour, I fixed two of the biggest nags I had been facing—both involving some pretty messy logic. I always find this to be a great way to solve code problems: If something is really broken, set it aside and pick it back up later. Sometimes, yak-shaving is simply worth it.
This code was admittedly trying to do something complex, and when it was busted I could not for the life of me figure it out. It was just not correctly loading at all in some cases, and in others, it was glitching out in a way that looked wrong. But in the midst of all the heart-wrenching drama, I worked on a bit of refactoring, and the result now works as one would expect.
-
[Old] University of Colorado Boulder ☛ Coding best practices — Research Computing University of Colorado Boulder documentation
Programmers employ numerous tactics to ensure readable and organized code. These include:
1. using naming conventions for variables;
2. placing whitespace, indentations and tabs within code;
3. adding comments throughout to aid in interpretation.
In this tutorial we will examine these concepts.
-
Net2 ☛ 8 Programming Languages that Every Teachie Should Master
By Andrew B.Mazur – When you must choose among existing programming languages, it should not be either one or another because the most important is to learn the basics of coding by taking enough time to practice.
-
Rlang ☛ Embedding R/exams Exercises as Forms in R/Markdown or Quarto Documents
Introduction to the new exams2forms package for including quizzes or individual questions from dynamic exercise templates into rmarkdown or quarto documents, e.g., for self-paced learning and self-assessment.
-
KDAB ☛ Delivering Software Updates: The Last Mile of Product Development
Shipping your product to customers is where some real challenges in software development begin. Once it lands in customers’ hands, delivering the expected and necessary software updates can be a complicated task. Here’s a breakdown of some key considerations to keep your product, and your customers, running smoothly, even after your product has shipped.
-
Medevel ☛ Top 11 Open-Source UI Frameworks for Next.js and React
When building a React-based application with Next.js, selecting the right UI (User Interface) framework can make a significant difference in the development process and the final product.
UI frameworks provide pre-built components, styling options, and design patterns that can speed up development, ensure consistency, and enhance the user experience.
-
Shell/Bash/Zsh/Ksh
-
[Old] Jason Nochlin ☛ 6 Techniques I Use to Create a Great User Experience for Shell Scripts
Gunnar quickly became overwhelmed being the (unpaid) evaluator of a constant stampede of entries. I jumped in to help him automate the evaluation steps with a shell script and received the above testimonial from Gunnar at his Javazone talk (check it out to hear all about the performance techniques used in the challenge: "# 1BRC–Nerd Sniping the Java Community - Gunnar Morling").
Here are 6 techniques I used in the #1BRC shell script to make it robust, safe and fun for Gunnar to use: [...]
-
-
Rust
-
Rust Blog ☛ The Rust Programming Language Blog: Surveillance Giant Google Summer of Code 2024 results [Ed: Rust is still financially possessed by GAFAM]
As we have previously announced, the Rust Project participated in Google Summer of Code (GSoC) for the first time this year. Nine contributors have been tirelessly working on their exciting projects for several months. The projects had various durations; some of them have ended in August, while the last one has been concluded in the middle of October. Now that the final reports of all the projects have been submitted, we can happily announce that all nine contributors have passed the final review! That means that we have deemed all of their projects to be successful, even though they might not have fulfilled all of their original goals (but that was expected).
-
Rust Blog ☛ The Rust Programming Language Blog: gccrs: An alternative compiler for Rust
gccrs
is a work-in-progress alternative compiler for Rust being developed as part of the GCC project. GCC is a collection of compilers for various programming languages that all share a common compilation framework. You may have heard aboutgccgo
,gfortran
, org++
, which are all binaries within that project, the GNU Compiler Collection. The aim ofgccrs
is to add support for the Rust programming language to that collection, with the goal of having the exact same behavior asrustc
. -
Rust Weekly Updates ☛ This Week In Rust: This Week in Rust 572
Hello and welcome to another issue of This Week in Rust!
-