Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Activity for Lundin‭

Type On... Excerpt Status Date
Comment Post #291371 Except the application layer programmer typically won't have a clue about how the various containers are implemented internally. Which has always been a big problem with C++, `std::string` or `std::vector` silently using heap allocation etc. And if you don't know how they are implemented, you can't k...
(more)
8 days ago
Comment Post #291371 It's the same kind of argument as why computer scientists are _still_ being all smug about binary search over brute force linear iteration, even though in many situations, the latter is probably way faster on modern computers. Algorithm theory has not quite kept up with computer hardware development ...
(more)
8 days ago
Comment Post #291371 Now of course, the standard doesn't mandate how things are implemented "backstage". There's probably no good performance reason why a lot of things like `std::set` or `std::map` wouldn't be implemented as some sort of C style arrays. Namely because on most systems, arrays have superior performance fo...
(more)
8 days ago
Comment Post #291342 Hi there. As per the current scope of this site https://software.codidact.com/help/on-topic, embedded systems questions are off-topic and should be asked on https://electrical.codidact.com/ instead. But before posting there, your question should ideally be self-contained, as in don't link an entire G...
(more)
13 days ago
Comment Post #291310 Some would probably disagree and saying that "pointers are dangerous". However, if the programmer can't even write correct code for iterating over a linear sequence of data, then what correct code _can_ they write... It way easier to write than to implement some manner of iteration template monstrosi...
(more)
19 days ago
Comment Post #291310 The language design mistake from there was to enforce this unison iterator interface to all classes, even those that do not benefit from it what-so-ever. That's poor OO design of the language itself - proper OO would distinct from containers which are "linear" and those who aren't. There's no reason ...
(more)
20 days ago
Comment Post #291310 "However, while writing this code, I couldn't help but notice that I am essentially writing a wrapper around pointer arithmetic." Indeed. When writing C++, one often comes to the conclusion "WTF am I even doing, this is nothing but bloated meta programming". In many cases, an `iterator` is nothing b...
(more)
20 days ago
Comment Post #291199 @#78383 The header is the exposed part to the caller so you could write documentation there regarding how to tweak them. The caller shouldn't mess with the .c file. Optionally you could have the memory pool itself take these as input parameters to an init function. But most often we want the size to ...
(more)
about 1 month ago
Comment Post #281518 @#80520 Then you might agree with the posted answer... "memcpy is always preferred when you know the size in advance. It's always faster than strcpy. It is safe and portable."
(more)
about 1 month ago
Comment Post #291199 @#80468 Start with the OO design. What use-cases are there and what makes sense to turn into classes? Is "door" a central thing to your application, to the point where it needs an abstraction layer. Or do you rather benefit of having abstraction layers on a much lower level, just above the ADC or GPI...
(more)
about 1 month ago
Comment Post #291195 I know that I'm the one who lead you here, but just a note for the future that embedded systems programming questions normally goes to https://electrical.codidact.com/. But your question is all about software design and without much in the way of embedded systems aspects (save for how to allocate obj...
(more)
about 1 month ago
Comment Post #291175 Indeed. I could answer this from a general programming perspective, but not from a PHP-specific perspective. Mostly it is about program design no matter language. But different languages have different scope rules and namespace rules, meaning that it may be more or less serious namespace pollution in...
(more)
about 1 month ago
Comment Post #291112 @#64656 The whole point is that program design-wise input sanitation should happen at the point where input is taken. And if that part is done correctly, strcpy is safer than strncpy. And memccpy is arguably a bit safer too since it has no misleading `str` prefix.
(more)
about 1 month ago
Comment Post #291112 I hope you don't mind that I now posted a complementary answer. The fight against `strncpy` is kind of a pet peeve of mine, see :)
(more)
about 2 months ago
Comment Post #291112 strncpy should pretty much never be used since it was never intended to be a function used on null terminated C strings. See [Is strcpy dangerous and what should be used instead?](https://software.codidact.com/posts/281518). In this case you added the null terminator manually, but people tend to forg...
(more)
about 2 months ago
Comment Post #290885 I don't use this feature, so I'll refrain from posting an answer. But there's a panel to the right "subscribe by email" where you can sign up and then supposedly it gets added to a list below your account -> Preferences -> Manage Email Subscriptions. Seems a bit crude though, I'm not sure if you can ...
(more)
3 months ago
Comment Post #290878 @#78383 Everything that's related to the actual trie implementation should sit alone in one .h/.c pair, without unrelated stuff like test cases and main(). You could also consider some manner of source code prefix for the public API functions, like for example having every function start with `trie_`...
(more)
3 months ago
Comment Post #290316 @#53937 `stdin` is not necessarily a macro. C17 7.21.1: "`stdin` ... "which are expressions of type ‘‘pointer to FILE’’". You can't `#undef` expressions.
(more)
4 months ago
Comment Post #290488 Otherwise, I'm not opposed of having this migrated to Power Users if it fits better there.
(more)
4 months ago
Comment Post #290488 @#36396 Oh don't get me started on two factor authentication... it might just be the dumbest invention of this millennium. Chances of some mysterious hacker taking an interest in my little account at some site: non-existent. Chances of me misplacing/breaking/changing my phone: very high. I've alr...
(more)
4 months ago
Comment Post #290488 @#64277 I don't really see how anyone without software security knowledge would be able to answer this. It takes a programmer simply to understand the number of combinations enabled in the symbol table.
(more)
4 months ago
Comment Post #290316 On the other hand I don't understand the C rationale to make these macros either. If the intention was to allow evil things like `#ifdef stdin #undef stdin #endif #define stdin something_else` then it wouldn't be wise to use `stdin` as the name for the internal variable.
(more)
5 months ago
Comment Post #290316 As per your last code example, it would be fine for the library to name the variable `extern FILE *stdin;` and then do `#define stdin stdin`. This would still enable stuff like `#ifdef stdin` - it doesn't "flip off" any original intent. Why they didn't do that in the unknown standard lib mentioned, I...
(more)
5 months ago
Comment Post #290314 This requires digging into the specific library implementation - you don't mention which one - in search of a rationale or naming conventions. Without knowing that, the question cannot be answered. Though open source code bases in general tend to be quite irrationally written and do not necessarily f...
(more)
5 months ago
Comment Post #290215 @#53937 That's correct. The syntax for calling a function-like macro contains commas in itself so we can't pass comma operator arguments without surrounding the argument with parenthesis. The formal syntax is _identifier-list:_ which can either be _identifier_ or _identifier-list_ `,` _identifier_.
(more)
6 months ago
Comment Post #290043 While questions about bash scripts are on-topic here, I think we expect such questions to mainly focus on the script itself, such as "here is my bash script for x, what's wrong with it." Maybe consider posting this at [Linux Systems](https://linux.codidact.com/) instead - I suspect it is a more suita...
(more)
7 months ago
Comment Post #290007 @#65944 If you have a "missing braces" bug, you can pretty much immediately tell if it was intentional, most often you got fooled by the indention. At the same time it is very hard to come up with a rationale for why you would _skip_ braces. ("I don't like typing" ought to be the worst rationale ever...
(more)
7 months ago
Comment Post #289415 I would guess that the gcc rationale is rather the one from 6.2.6.1 "When a value is stored in an object of structure or union type, including in a member object, the bytes of the object representation that correspond to any padding bytes take unspecified values.51)" Where the foot note says: "Thus,...
(more)
7 months ago
Comment Post #289415 @#53937 That seems like an unreasonable interpretation. The whole purpose of initializing something "as if it has static storage duration" with `{0}` is that the object may then potentially get allocated in .bss (rather than .data), which leads to faster initialization. Any implementation doing a sel...
(more)
7 months ago
Comment Post #290007 In fact the whole problem with SO's "opinion-based" close reasons is that they think that good program design is a matter of personal, subjective opinions. It is not that, it is not art. There are correct ways proven in use, such as object-orientation which has proven to be the best known way to desi...
(more)
7 months ago
Comment Post #290007 The point is that certain ways of writing programs are bad and it can be proven scientifically, beyond opinions and personal believes. You take a misbehaving program and track down the root cause. If you do that a million times on a million programs, bad practices emerge as hard evidence. For example...
(more)
7 months ago
Comment Post #278658 @#53937 That seems to be a common misconception. 6.3.2.3 always said "An integer constant expression with the value 0, or such an expression cast to type void *, is called a _null pointer constant_." With a foot note saying that NULL is a null pointer constant. What's implementation-defined about NUL...
(more)
7 months ago
Comment Post #289415 @#53937 Stop reading fishy blogs (JeanHeyd Meneide? he should know better) and instead read the mentioned part in C17 6.7.9 §10 (C23 6.7.10 §11) regarding implicit initialization of variables with static storage duration. It clearly states "if it is an aggregate, every member is initialized (recursiv...
(more)
7 months ago
Comment Post #281519 A rose by any other name... :) My post does mention `strlcpy` as an equivalent alternative though.
(more)
7 months ago
Comment Post #289415 And why should I care about some fiasco project for Linux made in the 90s where some open source people said "lets make _our_ way the standard way" then try to market that crap as some "standard for OS", while at the same time blatantly ignoring ISO C90 and every version of C ever released later. Als...
(more)
7 months ago
Comment Post #289415 @#53937 Please don't get me started on POSIX... POSIX isn't even compatible with conforming ISO C. A conforming implementation is not allowed to break the behavior of a strictly conforming program. By spewing non-standard identifiers inside standard headers, that's exactly what POSIX does. Which ...
(more)
7 months ago
Comment Post #289415 And to be pedantic, nothing is ever initialized to `NULL` but to a null pointer. For confusion between `NULL` and null pointers, check out: [What's the difference between null pointers and NULL?](https://software.codidact.com/posts/278657)
(more)
7 months ago
Comment Post #289415 @#53937 There is no difference. `0` is a null pointer constant. What applies during initialization of pointers is the rules of assignment C17 6.5.16: "- the left operand is an atomic, qualified, or unqualified pointer, and the right is a null pointer constant;". For incomplete initialization lists, 6...
(more)
7 months ago
Comment Post #289415 @#53937 The difference is in the expectations. Nobody expects `memccpy` to null terminate a string - why would it? It is as low level as it goes - it knows nothing about strings. Whereas plenty of people expects `strncpy` to do so, even though that function was not intended to be used for null termin...
(more)
7 months ago
Comment Post #281519 @#53937 Unfortunately that doesn't standardize other OS flavours like `strcpy_s`, which would have been the version blessed by the actual C standard if not for the "Annex K bounds-checking" fiasco. I don't think Annex K has changed as per C23 either.
(more)
7 months ago
Comment Post #289985 ""Teaching to fish" is strongly encouraged in answers. So explaining how to solve the problem, rather than just giving the solution." Well what you describe is rather "teaching how to fish along with the free fish is strongly encouraged" - I completely agree, personally I always try to do this. Along...
(more)
7 months ago
Comment Post #289985 "Askers are gently guided with edit requests and comments, not downvotes without an explanation of what's wrong" Well this is a culture thing more than a on-topic/off-topic thing. Another category won't solve that. Since day 1 of Codiact, I have been pushing for a different approach than SO - summari...
(more)
7 months ago
Comment Post #289985 "Askers are encouraged to provide all necessary data, ideally MWEs, and no more " Already the case in the main Q&A category as well.
(more)
7 months ago
Comment Post #289985 "Any type of debugging question is welcome, no matter how localized or specific" This is pretty much already the case. When you have a bug which you can't find, you don't know the cause. It can be anything from an embarrassing typo to an intricate compiler bug or anything in between.
(more)
7 months ago
Comment Post #290007 "Software development is an art, not a science" Yeah we all went through that naive phase at some point. It is not art, it is a craft and it is engineering. You can apply population studies on source code and then conclude what practices that lead to bugs. This was already done in the 1990s by Les H...
(more)
7 months ago
Comment Post #289709 @#65944 Unless you can provide some evidence of that, it kind of sounds like yet another wild conspiracy theory... Unless you think $$$ is an ideology; Google and SE probably have that much in common.
(more)
7 months ago
Comment Post #289828 @#61308 Sorry but that is uninformed. Look, I work with electronics design - I have been involved in many battery pack and charger designs, including writing firmware for one in place of a BMS. I have seen malfunctioning NiMH and Li/Ion batteries burn up several times, due to malfunctioning, polarity...
(more)
7 months ago
Comment Post #289828 @#61308 Here I'm trying to picture what a layman _would imagine_ a short circuit to be. For example how I used the term myself, before I started working in the electronics industry. Think of some robot in sci/fi fiction having a malfunction, the others characters will often say something like "he has...
(more)
7 months ago
Comment Post #289831 @#53410 Except actual short circuits aren't often conditional. It's a poor analogy for that reason as well.
(more)
7 months ago
Comment Post #289837 I'm not sure if the last AND gate analogy is relevant. These work with 2 or more inputs that are evaluated simultaneously at the edge of a clock pulse, whereas software has to evaluate each operand one at a time. And there is hopefully no such thing as a short circuit anywhere in sight when dealing w...
(more)
7 months ago