The Big Programming Thread - Page 829
Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
Hanh
146 Posts
| ||
Nesserev
Belgium2760 Posts
| ||
Svazila
1 Post
| ||
Blisse
Canada3710 Posts
On January 19 2017 12:29 Nesserev wrote: Started reading the 'Modern C' book that was linked by Biolunar + Show Spoiler [a few pages back] + On January 03 2017 20:37 Biolunar wrote: This might be too hard if you have no programming experience, but if you do, use this: http://icube-icps.unistra.fr/index.php/File:ModernC.pdf This book focuses on how to avoid many of C’s pitfalls and teaches many good habits that are not possible in older versions of the language. What's your opinion on using the 'array notation' for passing arrays as arguments to functions in C/C++? On page 13-14, the book recommends the array notation, naming readability and (what comes down to) documentation as reasons. On the other hand, it obfuscates what's really going on (it's just a pointer in the end, and you probably need to pass an extra size_t anyway), and seems to lead to obscure/hard-to-find bugs. Anything I missed? Not always right to quote Linus but here's his thoughts. https://lkml.org/lkml/2015/9/3/428 static bool rate_control_cap_mask(struct ieee80211_sub_if_data *sdata, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, u32 *mask, u8 mcs_mask[IEEE80211_HT_MCS_MASK_LEN]) ... for (i = 0; i < sizeof(mcs_mask); i++) the "sizeof(mcs_mask)" is _shit_. Since array arguments don't actually exist in C, it is the size of the pointer, not the array. The first mistake makes the bug look like reasonable code. ... I realy want people to take a really hard look at functions that use arrays as arguments. It really is very misleading, even if it can look "prettier", and some people will argue that it's "documentation" about how the pointer is a particular size. But it's neither. It's basically just lying about what is going on, and the only thing it documents is "I don't know how to C". Misleading documentation isn't documentation, it's a mistake. I've never seen the array notation in production code so I'd never use it. My coding conventions and/or abstractions make it clear enough what's going on, i.e. arr and arrLength as param names, or passing structs with size members. | ||
Biolunar
Germany224 Posts
On January 19 2017 12:29 Nesserev wrote: Started reading the 'Modern C' book that was linked by Biolunar + Show Spoiler [a few pages back] + On January 03 2017 20:37 Biolunar wrote: This might be too hard if you have no programming experience, but if you do, use this: http://icube-icps.unistra.fr/index.php/File:ModernC.pdf This book focuses on how to avoid many of C’s pitfalls and teaches many good habits that are not possible in older versions of the language. What's your opinion on using the 'array notation' for passing arrays as arguments to functions in C/C++? On page 13-14, the book recommends the array notation, naming readability and (what comes down to) documentation as reasons. On the other hand, it obfuscates what's really going on (it's just a pointer in the end, and you probably need to pass an extra size_t anyway), and seems to lead to obscure/hard-to-find bugs. Anything I missed? Every C programmer should know what array to pointer decay is. Array notations in function declarations are just eye candy. Just follow your own intuition. I am starting to use the following convention:
That book also uses VLAs for array parameters which I don’t use. Ever. | ||
spinesheath
Germany8679 Posts
On January 19 2017 11:10 Hanh wrote: Virtual dispatch is slower in many cases. Consider that an indirect call cannot be predicted nor inlined. Some benchmarks have found a difference of 7 x in favor of static calls. Of course a virtual dispatch is slower than a static call. But virtual dispatch is not necessarily slower than a conditional. Especially if there are many branches or the comparision is complex, like a string comparision. | ||
Hanh
146 Posts
| ||
Blisse
Canada3710 Posts
On January 19 2017 20:30 Biolunar wrote: Every C programmer should know what array to pointer decay is. Array notations in function declarations are just eye candy. Just follow your own intuition. I am starting to use the following convention:
That book also uses VLAs for array parameters which I don’t use. Ever. The problem with the static keyword and the array notation is it still looks like sizeof(param) will return N instead of sizeof(T*), even if you're familiar with the array decay. In C I think it's super important to practice defensive programming, which is to avoid situations like this, as per the Linus example I linked previously. Or I may be misreading your convention, in which case why use a param array instead of the param directly? I've never seen a param array like that. That looks like a typecasting error prone nightmare? | ||
BlueRoyaL
United States2493 Posts
I've been thinking of starting to blog again about programming stuff. I had set one up a couple years ago that's titled "Finally Working", with the sub text "thank god it compiled". At the time I thought it was funny, and i wouldnt mind continuing to use it. But from your professional standpoint, does it seem a little weird or offsetting? As in, if you were some recruiter and happened to be on the page, would it bother you that the creator used the line "thank god it compiled", possibly indicating some level of ineptitude in programming? I might just be overthinking this, any thoughts? | ||
Blisse
Canada3710 Posts
On January 20 2017 14:57 BlueRoyaL wrote: Hey guys, I have a (semi) silly question, just want to get your opinions. I've been thinking of starting to blog again about programming stuff. I had set one up a couple years ago that's titled "Finally Working", with the sub text "thank god it compiled". At the time I thought it was funny, and i wouldnt mind continuing to use it. But from your professional standpoint, does it seem a little weird or offsetting? As in, if you were some recruiter and happened to be on the page, would it bother you that the creator used the line "thank god it compiled", possibly indicating some level of ineptitude in programming? I might just be overthinking this, any thoughts? In my opinion no one would care if you had more than 3 non-insignificant blog posts. | ||
RoomOfMush
1296 Posts
On January 20 2017 14:57 BlueRoyaL wrote: Hey guys, I have a (semi) silly question, just want to get your opinions. I've been thinking of starting to blog again about programming stuff. I had set one up a couple years ago that's titled "Finally Working", with the sub text "thank god it compiled". At the time I thought it was funny, and i wouldnt mind continuing to use it. But from your professional standpoint, does it seem a little weird or offsetting? As in, if you were some recruiter and happened to be on the page, would it bother you that the creator used the line "thank god it compiled", possibly indicating some level of ineptitude in programming? I might just be overthinking this, any thoughts? I wouldnt care. But how useful this information is to you I dont know. | ||
Acrofales
Spain17185 Posts
On January 20 2017 14:57 BlueRoyaL wrote: Hey guys, I have a (semi) silly question, just want to get your opinions. I've been thinking of starting to blog again about programming stuff. I had set one up a couple years ago that's titled "Finally Working", with the sub text "thank god it compiled". At the time I thought it was funny, and i wouldnt mind continuing to use it. But from your professional standpoint, does it seem a little weird or offsetting? As in, if you were some recruiter and happened to be on the page, would it bother you that the creator used the line "thank god it compiled", possibly indicating some level of ineptitude in programming? I might just be overthinking this, any thoughts? If your blog is useful, the title doesn't matter. If your blog is useless/bad, the least you have to worry about is choosing a funny title. In other words, if your blog sucks, don't show it to your future employer. If it is good, add it to your CV. In either case, don't worry about the title. | ||
Djagulingu
Germany3605 Posts
On January 20 2017 14:57 BlueRoyaL wrote: Hey guys, I have a (semi) silly question, just want to get your opinions. I've been thinking of starting to blog again about programming stuff. I had set one up a couple years ago that's titled "Finally Working", with the sub text "thank god it compiled". At the time I thought it was funny, and i wouldnt mind continuing to use it. But from your professional standpoint, does it seem a little weird or offsetting? As in, if you were some recruiter and happened to be on the page, would it bother you that the creator used the line "thank god it compiled", possibly indicating some level of ineptitude in programming? I might just be overthinking this, any thoughts? Yes you're overthinking. As long as your content is halfway decent, the single worst thing the recruiter could think about that title is "Good thing this dude is not a comedian or some shit". | ||
Manit0u
Poland17045 Posts
| ||
BlueRoyaL
United States2493 Posts
On January 20 2017 22:08 Manit0u wrote: Will this blog be only about compiled languages? Not necessarily. I was mainly a sysadmin back when i created it, but since then i've pivoted and work as a dev on the full stack. There might occasionally be something about frontend stuff as well. | ||
phar
United States1080 Posts
| ||
Manit0u
Poland17045 Posts
User was warned for this post | ||
Hanh
146 Posts
| ||
Deleted User 101379
4849 Posts
On January 25 2017 11:18 Hanh wrote: Yeah, it's amazing that someone can take something that was available for years and present it as new. The whole programming sector ist moving in circles. Every few years a "new thing" appears, gets replaced by something better which gets replaced by something more advanced which then gets replaced by another "new Thing" - which is pretty much the same thing everything started with, just with a fancier name. Programmers are experts in reinventing wheels and calling them "best new things that change everything". | ||
Manit0u
Poland17045 Posts
| ||
| ||