I love C where types are basically a suggestion rather than a rule
-
den2k88 wrote:
C++ is ... hard to read and often very hard to write
Am I using it wrong, because I've never had these problems?
“If we get $100,000, we will go to Potato blockchain.” Enable the dream!
Funny, I was thinking the same things. But then again, I've encountered code like the OP described. Usually written by electrical engineers.
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
Funny, I was thinking the same things. But then again, I've encountered code like the OP described. Usually written by electrical engineers.
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
:laugh: You mean C++ that is no more than C or, even worse, FORTRAN?
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
den2k88 wrote:
C++ is ... hard to read and often very hard to write
Am I using it wrong, because I've never had these problems?
“If we get $100,000, we will go to Potato blockchain.” Enable the dream!
Well, some of the template stuff out there... :wtf:
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
yeah, that'll work so long as you don't stash your structs pointers this way. :)
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
No problem. Placement
new
to the rescue! Sorry, wrong language. :laugh:Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
The cast operator is why I can cast my struct directly to an "array" of bytes and stash it in a file. It makes me happy. It's so elegant. So concise. And so dangerous.
Real programmers use butterflies
the file is also not compatible between architecture to the next! :( i.e. endianess for sure.. but probably computer struct paddings too! :/ though haven't used C in decades, so I am not so sure about that one...
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
the file is also not compatible between architecture to the next! :( i.e. endianess for sure.. but probably computer struct paddings too! :/ though haven't used C in decades, so I am not so sure about that one...
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
Sometimes that doesn't matter. Sometimes you're writing software dedicated to a particular microcontroller and it expects the thing to be wired a certain way in order to run anyway.
Real programmers use butterflies
-
Sometimes that doesn't matter. Sometimes you're writing software dedicated to a particular microcontroller and it expects the thing to be wired a certain way in order to run anyway.
Real programmers use butterflies
oh well.. yes if consumer and producer is the same one, I guess it's all good! :)
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
Well, some of the template stuff out there... :wtf:
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.When that becomes easy to read, you know you are a real programmer!
“If we get $100,000, we will go to Potato blockchain.” Enable the dream!
-
:laugh: You mean C++ that is no more than C or, even worse, FORTRAN?
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.Yeah, that too. But yes, c++ that was like trying to interpret sanskrit.
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
No problem. Placement
new
to the rescue! Sorry, wrong language. :laugh:Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.Yeah, but that processing the struct after-the-fact. Her technique is great for 'simple' structs.
#SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
-
The cast operator is why I can cast my struct directly to an "array" of bytes and stash it in a file. It makes me happy. It's so elegant. So concise. And so dangerous.
Real programmers use butterflies
I've read this subject line several times now, wanting to point out what's so wrong with it. Anyway, I think you will love Javascript.
Wrong is evil and must be defeated. - Jeff Ello Never stop dreaming - Freddie Kruger
-
I've read this subject line several times now, wanting to point out what's so wrong with it. Anyway, I think you will love Javascript.
Wrong is evil and must be defeated. - Jeff Ello Never stop dreaming - Freddie Kruger
There's a special place in programmer hell for whoever came up with duck typing.
Real programmers use butterflies
-
[Program: Shoot in foot](http://www.personal.psu.edu/sxt104/program1.html)
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
The cast operator is why I can cast my struct directly to an "array" of bytes and stash it in a file. It makes me happy. It's so elegant. So concise. And so dangerous.
Real programmers use butterflies
-
den2k88 wrote:
C++ is ... hard to read and often very hard to write
Am I using it wrong, because I've never had these problems?
“If we get $100,000, we will go to Potato blockchain.” Enable the dream!
Neither did I, until I discovered I "was using it wrong" and had some "true C++ programmer" abusing templates lambda functions like there was no tomorrow.
GCS d--(d+) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++* Weapons extension: ma- k++ F+2 X
-
[Program: Shoot in foot](http://www.personal.psu.edu/sxt104/program1.html)
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
The C++ one is even more accurate when pointers are involved !
-
The cast operator is why I can cast my struct directly to an "array" of bytes and stash it in a file. It makes me happy. It's so elegant. So concise. And so dangerous.
Real programmers use butterflies
You could always use a union, no need to even cast then (: I wouldn't want to program in C targeting a PC these days; but it is good for 8 & 16 bit embedded work, where you need to get at hardware registers and only have maybe 2K RAM and 16K or 32K ROM.
-
The cast operator is why I can cast my struct directly to an "array" of bytes and stash it in a file. It makes me happy. It's so elegant. So concise. And so dangerous.
Real programmers use butterflies
If you were using [fwrite](https://en.cppreference.com/w/c/io/fwrite), you wouldn't even need a cast...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
It's good for you - puts hair on your chest.** ** I don't know what to tell if you aren't looking for that. :~
Real programmers use butterflies
Dang! I chased FAR too many pointers! :laugh:
-
I use unions sometimes, but i only needed the cast in two places in the code that inspired this post, and it was all it was ever going to need. :)
Real programmers use butterflies
I really liked being able to cast nearly anything to anything. For a cheap and easy (and not too secure) 'encryption' I'd just do something like:
union {
char * readable;
ulong * notSoMuch;
}and then you can trivially make a string unreadable by storing the int array in a text file (lots of options there, too, spaced or other-delimiters? left-zero-filled? Decryption is obvious - and really no overhead as all - I always though of it as the string and its encrypted version coexisting in different planes of their little universe.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010