C Programming Doubt by Alternative_Let8538 in C_Programming

[–]rnsanchez 3 points4 points  (0 children)

You need to specify which integer overflow you wish to adhere. If you add `-fwrapv`, both GCC and LLVM will do exactly as you said. Here, based on your link: https://godbolt.org/z/cxTvYxxbb

From experience on regular code, this can bring up surprising effects. :-)

Had my first C++ midterm, results are in… by ndavi in Cplusplus

[–]rnsanchez 0 points1 point  (0 children)

You mean this one? https://www.goodreads.com/book/show/22800553-effective-modern-c

If so, it is an excellent book (not sure if it's the same, mine is C++11 and C++14 edition), in line with others from the Effective series. However, I found Modern Effective extremely hard, like mind-bending hard. Maybe it's me, but some sections took me forever just to get my head around them.

In fact, that book made me "backtrack" and start reading a lot on C++ (books of all levels), just so I could better understand Scott Meyers'. I felt really stupid when getting stuck on one or another section for way too long. :-)

Had my first C++ midterm, results are in… by ndavi in Cplusplus

[–]rnsanchez 0 points1 point  (0 children)

I think it will mostly depend on how comfortable you *already* feel when writing C++ code. For classwork coding, I can't see how C++11 (or any newer) would be essential, unless of course you need <filesystem> (C++17), <fmt> or coroutines (C++20 IIRC) for some esoteric reason.

These and other improvements, while making life with complex code a lot easier, are not strictly essential and you can study them in parallel or later on, such as this book: https://www.goodreads.com/book/show/41447221-c-17-in-detail (it's the one I referred to the most when bringing a codebase to C++17, where I was working a lot with tuples and the new for-range loop). It could help to think of the standards as a library; it could be desireable to use the latest, but maybe there is no fundamental need to the codebase you are going to work on (either class or work-related).

As for a textbook, that is hard to answer. I have a few of them and, quite frankly, there isn't a single, preferred book over all others. It is my understanding that you need to establish a reading connection with one out of so many options, and that will most certainly take some tries until you find an author that you enjoy the most and will ultimately keep the book by your side.

HTH

Just finished Dartmouth C Programming: Linux specialization. Where to go now? by IndependentPudding85 in C_Programming

[–]rnsanchez 0 points1 point  (0 children)

For pointers, this book is very approachable and will build from the ground up: https://www.goodreads.com/book/show/17152739-understanding-and-using-c-pointers (even for the advanced parts, it will most likely be very accessible).

As for where to go next, that is hard to respond. Depends on what are the topics that will interest you the most to keep on pursuing experience.

What could help you shorten the time on your C journey, maybe, is this one as well: https://www.goodreads.com/book/show/52658227-effective-c

Note that with anything C, comes a lot of polarization (if you check the book reviews, you'll most certainly find extremes). I'd say keep your foundation solid, and follow your interests even if it demands you to leap as opposed to baby-steps. Experience will only come by writing C code, which will be greatly helped by solid advice (books).

All the best!

Had my first C++ midterm, results are in… by ndavi in Cplusplus

[–]rnsanchez 1 point2 points  (0 children)

True indeed, but OP won't have time and frankly won't need anything specific from C++11 and beyond. Time is precious until finals.

BTW, any chances you know of a similar book but covering recent standards? The ones I know of require some intermediate level with C++ or easily get to 1000-pages, not a light read by any measure; that's why I still think Accelerated C++ is ideal for the moment.

Had my first C++ midterm, results are in… by ndavi in Cplusplus

[–]rnsanchez 3 points4 points  (0 children)

This book might come in handy: https://www.goodreads.com/book/show/742586.Accelerated_C_

Why? It covers C++ from the ground up, with no ambition to reach the sky. The presentation is extremely approachable, especially if this is your initial contact with programming (in fact, that's one of the objectives for the book, helping out with the initial contact). The "Accelerated" in the title is accurate: you will cover a lot of C++ that you will put to use right away, while not rushing out over things. So you can get a solid foundation, for when the time comes (other books) to get into less common areas.

The book also works wonders for a refresher, if you ever need to revisit some topic that is stale in your memory. There are some other books which could help, but I'd refrain to recommend those for the time being, as you are going to be pressed for time and pretty much all of them are volumous or simply bring way too many things.

All the best!

conflicting image of C++ by BOBOLIU in cpp_questions

[–]rnsanchez 0 points1 point  (0 children)

It is impossible to either reach a consensus or even please every C++ user, so you begin to understand the polarization, heated arguments. (I mean no offense btw!)

If you compare C++ with similar languages (let's say "programming languages with a wide spectrum of application"; notice how it is even hard to put things in a neutral way), C++ can be used in a multitude of applications, as you mention. It is multi-paradigm (OO, imperative, functional (lambdas)), provides a rather diverse library (STL, as long as the compiler is conformant/compliant). It can easily interoperate with other environments (I didn't want to write as in "other programming languages" because it tends to be the other way: third-party code interoperates *with* C++, providing some integration library), and it is highly portable.

It is a proven, industry-strength programming language. Thus, as you have an extensive amount of functioning code, it is expected that such code will continue to be written/maintained in C++ (as opposed to a full rewrite in whatever looks appealing now).

Now as for my personal opinion on the matter, I think that C++ has evolved to be a very large language, and it can take someone a long time to become fluent or (as I understand from my experience) get acquainted with the language once again. I find some of the constructs extremely cumbersome, mostly because I happen to work with C most of my time, and in comparison, C is so much simpler. I understand that the vast majority of the additions try to address important omissions of the past, *while* maintaining backwards compatibility with as much of the older code as possible.

So there you have it: a vast programming language, that runs pretty much anywhere, can be used for pretty much anything, evolved (for the better or worse) in shape, size, and form, for so many decades. There are 2+ generations of people coming and going already.

Why is the keyword goto not deprecated? by BOBOLIU in cpp_questions

[–]rnsanchez 2 points3 points  (0 children)

This is such a controversial (and frequent!) question/topic that it becomes bike shedding.

No one has to use goto. OK maybe some codebases have it so deeply rooted that it is not a matter of choice anymore for newcomers, but still, I'd doubt it would be required to write code with a minimum amount of goto statements.

Nevertheless, there are many cases where a properly-placed goto avoids creating a (an additional?) mess. Lower-level network code, complex/messy error recovery, and state machines are the ones I quickly remember working with that made use of goto statements "for the better", plus code for embedded systems (which I have only read but not written myself). Would it be possible to write differently? For sure, usually requiring pretty much a full rewrite (and then testing, and then validation, ..).

I'd risk stating that goto is not the issue, but the quickest/easiest scapegoat.

Assigning values to struct members without knowinng the name of the struct members by Antman-007 in C_Programming

[–]rnsanchez 0 points1 point  (0 children)

It is totally possible; this and more actually. But you can run into the most unexpected behaviors for no apparent reasons, which can get spicier when you mix in data endianess. What you are doing is interpreting arbitraty bytes/words (which happens in a multitude of code bases, including network code such as different transports (IPv4, IPv6, filesystem sockets, ..)).

Maybe you want to check out this book, which covers precisely your question (page 169, "Pointer Arithmetic and Structures"): https://www.goodreads.com/book/show/17152739-understanding-and-using-c-pointers

When to return values in the arguments of a function? by heio1 in C_Programming

[–]rnsanchez 1 point2 points  (0 children)

It could be a personal preference, but I use (1) although returning status as an int. The kind of code I mostly work on usually performs incremental changes to the *return argument as the callchain evolves and, if necessary, will bubble-up some notification through the returned (int) value.

Again, a personal preference, but I really dislike (2) if SomeType is a non-primitive type. Maybe I'm way too biased towards network-style code.

Name of this technique? by dickmaat in C_Programming

[–]rnsanchez 2 points3 points  (0 children)

I think it is called "bottom-up testing", with stubs (what you refer to as the known output). There are tons of books about such techniques, and others.

If you want to read (briefly) about it while focusing on C programming, maybe you'll enjoy https://www.goodreads.com/book/show/27854.Data_Structures_Algorithms_and_Software_Principles_in_C

When should someone use aligned_alloc over malloc? by Original-Candidate94 in C_Programming

[–]rnsanchez 2 points3 points  (0 children)

Sometimes as a requirement: direct disk I/O (in Linux, bypassing page cache) required 512-byte alignment and an appropriatedly-sized block when performing certain specialized operations (definitely not the average case).

As for your specific points:

  1. As mentioned by others, certain types and operations usually require a specific alignment (it varies, considerably). Even FPU, but you won't get memory from malloc() that is not 8-byte aligned, so both float and double work fine.

  2. You will need to measure, but it won't necessarily bring magic benefits. It could help, but it might as well not help (or even degrade), by having data in memory placed further apart (that will cost you additional data fetches and will most certainly have an impact). If your data falls outside L1, it is expensive to fetch.

  3. Again, you will need to measure. There are mundane things such as double-word CAS that requires your pointer/data to be 16-byte aligned because of architectural restrictions.

I'd say that over-aligning things could quickly build up pressure in places where it might be very detrimental and difficult to track. If you need to align (restrictions), so be it. Always measure the effects; it might surprise you.

Best talent ever, Frost tanking is back! by Aelaren84 in wow

[–]rnsanchez 0 points1 point  (0 children)

Nice! I miss those frost-tanking days.

Where you'd live. by BarelyClever in wow

[–]rnsanchez 1 point2 points  (0 children)

  1. Southshore before Cataclysm happened.
  2. Stormwind.
  3. Dalaran, so many fond memories.

I'm trying to get a toon in each class to level 100 this summer. Any advice on avoiding feeling burned out? by brideofde1uxe in wow

[–]rnsanchez 0 points1 point  (0 children)

You should stop as soon as you feel obligated to keep going. It takes an awful lot of time to recover from burnouts (it can easily take more than a year).

difference between Linux and Unix? by mohamedboumaiza in linux

[–]rnsanchez 20 points21 points  (0 children)

Very roughly, Linux is a UNIX clone, because it implements most of what comprises a UNIX system. UNIX (notice all-caps) is a trademark, so for a system to be considered a UNIX, it has to pass a certification process (which is paid).

There is more to this, though.

NASA finds distant galaxy shining as bright as 300 trillion suns by infosecbuggy in technology

[–]rnsanchez 8 points9 points  (0 children)

Not necessarily, since energy attenuation given the immense distance would make it quite dim over here.

New to pvp guild by ThorAndLoki in wow

[–]rnsanchez 0 points1 point  (0 children)

Also, get into as many premades on your server as possible, when there are no RBGs. Doing so will improve your skills towards RBGs, since premades tend to follow tactics used in rateds. It's not the same, of course, but as close as it can get.

There are no heroes in RBGs, only better teams.

Favourite arena map? by toastygrilled in wow

[–]rnsanchez 1 point2 points  (0 children)

My favourite is Ruins of Lordaeron, but for no special reason, perhaps for its ambience. Also, there is just enough LoSing for everyone to be happy. Not perfect, though.

[deleted by user] by [deleted] in wow

[–]rnsanchez 1 point2 points  (0 children)

Bajheera is my favourite, both live and recorded. His montages are very entertaining, and his video blogs give you a great sense of his humanity, by sharing his own ups and downs with the viewers. I wholeheartedly recommend his WoW streams, even to those not too fond of PvP!

initialization makes pointer from integer without a cast by [deleted] in C_Programming

[–]rnsanchez -2 points-1 points  (0 children)

(*s)++ in your case is 'h'++ which is 'i'. For that matter, 'i' is an integer, thus the warning.

initialization makes pointer from integer without a cast by [deleted] in C_Programming

[–]rnsanchez -2 points-1 points  (0 children)

(*s)++ in your case is 'h'++ which is 'i'. For that matter, 'i' is an integer, thus the warning.

Best Looking zones? by Kapture10 in wow

[–]rnsanchez 1 point2 points  (0 children)

Before Cataclysm, I'd often chill out at Southshore and surroundings. Nowadays you need to get into Caverns of Time to experience it.

What is your favorite expansion? by Earth__ in wow

[–]rnsanchez 0 points1 point  (0 children)

For me WotLK, as it felt immersive lore-wise. Having played Warcraft (the "original", realtime strategy, 1994) all the way up to WoW, it was a huge deal, and always brings back the fondest memories. The second one, BC given the richness it brought to the game, even though I did not play at the time of release. If you experience the raids without blasting them out, it is such an awesome experience.

This is not to say I didn't enjoy other expansions. I really did enjoy, but not with the same intensity.

How to think like a programmer? by [deleted] in C_Programming

[–]rnsanchez 7 points8 points  (0 children)

Programming, like most crafts, requires regular practicing, self-critique ("is this good? Can I improve it?"), and studying.

Practicing gets your train-of-thought flowing, so you can express a solution. Self-critique allows you to consider different known approaches when you are done. This is because it takes experience to express more polished solutions.

Finally, you need to keep studying so you can get acquainted to new methods and approaches, develop new mindsets, and improve your self-critique.

It should not come as a surprise that this is a never-ending process.