Ok, so this one goes out to C...
-
So y'all know... I'm getting my Zig on. And I come across videos about how slices are sooooooooo powerful, like Zig invented it. Basically, a slice just takes a subsection of an array with a pointer and a length. So you can focus on one part of it, in memory. Now... all you C coders know exactly what I'm about to say here... :laugh:
int main() {
int data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};int \*slice = &data\[4\]; \*slice = 42; // we had this since the 70s printf("Bruh %d", data\[4\]); return 0;
}
Don't get me wrong. Zig does have one nice abstraction in the fact it tracks the length for you for bounds checking. But still... come on. Gotta give props to C when talking about stuff when making it seem like this is something new. :laugh:
Jeremy Falcon
-
So y'all know... I'm getting my Zig on. And I come across videos about how slices are sooooooooo powerful, like Zig invented it. Basically, a slice just takes a subsection of an array with a pointer and a length. So you can focus on one part of it, in memory. Now... all you C coders know exactly what I'm about to say here... :laugh:
int main() {
int data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};int \*slice = &data\[4\]; \*slice = 42; // we had this since the 70s printf("Bruh %d", data\[4\]); return 0;
}
Don't get me wrong. Zig does have one nice abstraction in the fact it tracks the length for you for bounds checking. But still... come on. Gotta give props to C when talking about stuff when making it seem like this is something new. :laugh:
Jeremy Falcon
My favorite optimization is Java substring which returns “slices” which reuse the source string’s char[]. If you have a big string in memory you can pull as many substrings as needed without ever copying a char. Each substring has the storage overhead of a char* to the shared buff, offset, and length.
-
My favorite optimization is Java substring which returns “slices” which reuse the source string’s char[]. If you have a big string in memory you can pull as many substrings as needed without ever copying a char. Each substring has the storage overhead of a char* to the shared buff, offset, and length.
That's pretty cool.
Jeremy Falcon
-
So y'all know... I'm getting my Zig on. And I come across videos about how slices are sooooooooo powerful, like Zig invented it. Basically, a slice just takes a subsection of an array with a pointer and a length. So you can focus on one part of it, in memory. Now... all you C coders know exactly what I'm about to say here... :laugh:
int main() {
int data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};int \*slice = &data\[4\]; \*slice = 42; // we had this since the 70s printf("Bruh %d", data\[4\]); return 0;
}
Don't get me wrong. Zig does have one nice abstraction in the fact it tracks the length for you for bounds checking. But still... come on. Gotta give props to C when talking about stuff when making it seem like this is something new. :laugh:
Jeremy Falcon
Unrelated to that... After the recent discussions of C/C++, I began a bit of C refreshing today. I had forgotten so much over the past twenty years of using C#.
-
Unrelated to that... After the recent discussions of C/C++, I began a bit of C refreshing today. I had forgotten so much over the past twenty years of using C#.
Yeah man, it's fun to dust off the cobwebs every now and again. Not gonna lie, I still love C and can't swear I'll never use it again. It is fun trying new stuff though. Or, in your case old new stuff. :laugh:
Jeremy Falcon
-
Unrelated to that... After the recent discussions of C/C++, I began a bit of C refreshing today. I had forgotten so much over the past twenty years of using C#.
In case you're wondering why my sudden interest in systems coding again, for the application I'm working on I need extreme performance. So, time to get raaaaawwwwww. Muwahahahah
Jeremy Falcon
-
My favorite optimization is Java substring which returns “slices” which reuse the source string’s char[]. If you have a big string in memory you can pull as many substrings as needed without ever copying a char. Each substring has the storage overhead of a char* to the shared buff, offset, and length.
We had this in the proprietary language I started using in 1981. They were known as descriptors: each one contained a pointer and the number of elements, with the size of the elements determined at compile time. They could be created at run-time by specifying the first and last offset into an array.
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
In case you're wondering why my sudden interest in systems coding again, for the application I'm working on I need extreme performance. So, time to get raaaaawwwwww. Muwahahahah
Jeremy Falcon
Jeremy Falcon wrote:
for the application I'm working on I need extreme performance
Usual PCs or RT one? if interaction with the physical / electric world needed, current PLCs might get cycles around 100 us with a noticiable load of code (if that's fast enough for you)
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
-
Jeremy Falcon wrote:
for the application I'm working on I need extreme performance
Usual PCs or RT one? if interaction with the physical / electric world needed, current PLCs might get cycles around 100 us with a noticiable load of code (if that's fast enough for you)
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
Nelek wrote:
Usual PCs or RT one?
Usual PC.
Nelek wrote:
if interaction with the physical / electric world needed, current PLCs might get cycles around 100 us with a noticiable load of code (if that's fast enough for you)
Nothing like that, nor embedded. It's a financial app. I just want it running faster than my JavaScript version... because I can. :laugh:
Jeremy Falcon
-
Nelek wrote:
Usual PCs or RT one?
Usual PC.
Nelek wrote:
if interaction with the physical / electric world needed, current PLCs might get cycles around 100 us with a noticiable load of code (if that's fast enough for you)
Nothing like that, nor embedded. It's a financial app. I just want it running faster than my JavaScript version... because I can. :laugh:
Jeremy Falcon
Jeremy Falcon wrote:
I just want it ... because I can.
That's the root of all crappy IoT devices and many other depicable actions... vade retro ;P :laugh:
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
-
Jeremy Falcon wrote:
I just want it ... because I can.
That's the root of all crappy IoT devices and many other depicable actions... vade retro ;P :laugh:
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
I dunno what vade retro means, but don't take my toys away Nelek. I need my toys. :((
Jeremy Falcon
-
Unrelated to that... After the recent discussions of C/C++, I began a bit of C refreshing today. I had forgotten so much over the past twenty years of using C#.
Iwas converting a AVR C++ to ARM C and found I was trying to make it C++.
A home without books is a body without soul. Marcus Tullius Cicero PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com Latest Article: EventAggregator
-
I dunno what vade retro means, but don't take my toys away Nelek. I need my toys. :((
Jeremy Falcon
The quotation is from a film: "vade retro satanas" (I think is latin). "Vade retro" is like "step back", "walk away"
Jeremy Falcon wrote:
I need my toys. :((
mmmm not sure if you were a good boy this year... I'll need to ask Santa for a report :laugh: :laugh:
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
-
The quotation is from a film: "vade retro satanas" (I think is latin). "Vade retro" is like "step back", "walk away"
Jeremy Falcon wrote:
I need my toys. :((
mmmm not sure if you were a good boy this year... I'll need to ask Santa for a report :laugh: :laugh:
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
Nelek wrote:
"step back", "walk away"
:omg:
Nelek wrote:
I'll need to ask Santa for a report
Good luck, I paid Santa off so he could make his sleigh electric. :suss:
Jeremy Falcon