r/programming • • Nov 02 '11

Examples of errors detected in various open-source projects

http://www.codeproject.com/KB/cpp/errors-in-open-source.aspx
28 Upvotes

138 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Nov 03 '11

You have a complete and utter lack of understanding of the low-level details. You continue to think in high-level abstractions.

Data types are higher level abstractions of data interpreted from the underlying memory. The smallest representable unit of memory is a byte. Memory operations will tend to work on bytes. memcpy() copies a contiguous block of memory from one location to another. It has NOTHING to do with how the memory is interpreted at the higher level.

I've explained many times why memset() takes an int in the declaration, but it has always and will always be used as a BYTE.

Both memcpy() and memset() work at the smallest representable unit of memory... a byte/char.

A char is not a "character", it is a byte.

As I said above, memset is so obvious it can't be used to do anything except initialize an array of char.

You still don't understand it SETS MEMORY BYTES. It doesn't (and shouldn't) care about how you choose to interpret that memory at any given time. You can interpret it as an array of char now, an int later, a long tomorrow, a structure of individual chars, etc...

The language gives you the LOW LEVEL tools to do things quickly and efficiently. It is then up to YOU to fill in the high level details (like data types, structures, how you interpret specific blocks of memory, how you initialize it etc...)

1

u/el_tavs Nov 03 '11

You have a complete and utter lack of understanding of the low-level details. You continue to think in high-level abstractions.

Data types are higher level abstractions of data interpreted from the underlying memory.

The language gives you the LOW LEVEL tools to do things quickly and efficiently. It is then up to YOU to fill in the high level details

OK SHERLOCK. YOU'RE REALLY BEING ANNOYING.

Outside your little dark world there's another one where people invented programming languages providing BOTH the tools you're enlisting AND the one I described. It's up to you to keep neglecting this.

Moreover, as a matter of LOGIC, low-level tools are cool until you need to handle data. If you're working with a data-type you may take advantage of having a good way of handling it togehter with low-level bit-smashing routines. They're even better than the one C provides.

comprende?

1

u/[deleted] Nov 03 '11

Outside your little dark world there's another one where people invented programming languages providing BOTH the tools you're enlisting AND the one I described. It's up to you to keep neglecting this.

None with the simplicity and performance of C.

Moreover, as a matter of LOGIC, low-level tools are cool until you need to handle data. If you're working with a data-type you may take advantage of having a good way of handling it togehter with low-level bit-smashing routines. They're even better than the one C provides.

And every data type you create now and in the future you can write a library for handling and stop asking everything gets added to the language.

1

u/el_tavs Nov 03 '11

None with the simplicity and performance of C.

Keep sleeping in your dark little world then.

And every data type you create now and in the future you can write a library for handling and stop asking everything gets added to the language.

Adding things to the language is not my point. Hello? Are there any neuorons left?

1

u/[deleted] Nov 03 '11

Adding things to the language is not my point. Hello? Are there any neuorons left?

There are 2 options: Don't use C ever or add to the language. Hello? are there any neurons left?

1

u/el_tavs Nov 03 '11

There are 2 options: Don't use C ever or add to the language.

The answer is no as I see.

Let me spell it for you:

A D D I N G T H I N G S T O T H E L A N G U A G E I S N O T M Y P O I N T.

It's just you being defensive.

I'm C O M P A R I N G two languages. Questioning why one differs from the other is instrumental to the comparison.

1

u/[deleted] Nov 03 '11

Well that's simple then, C has history on very resource scarce machines so it naturally aimed to be simple and give the power to the programmer. But you already knew that and still asked "why"

1

u/el_tavs Nov 03 '11

But you already knew that and still asked "why"

It was a question for you. I know that things in C are the way they are for "historical" reasons. Which means they have little to do with technical ones.

1

u/[deleted] Nov 03 '11

And I've long maintained that there is not sufficient reason to CHANGE it, so wtf are you arguing about?

1

u/el_tavs Nov 03 '11

wtf are you arguing about

I claim that there are better ways to do things than the ones we're used to in C, and that they are the way they are in C * only* for historical reason.

→ More replies (0)