[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

CS undergrads will understand

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 65
Thread images: 9

File: Untitled.png (115KB, 600x315px) Image search: [Google]
Untitled.png
115KB, 600x315px
>>
>>60291476
Because either constantly reallocating your array or scattering the contents all over memory is such a good idea. Much efficienct wow.
>>
>>60291476
>what is malloc
You fucking scrub
>>
>Pascal
>dynamically sized array

Yeah, no. Several Object Pascal dialects have something that looks like a dynamic array, but is actually just a pointer in disguise that's reallocated as needed and freed at the end of a procedure. Also all the modern 8-bit and unicode string types are heap-based with automatical reference counting.
http://wiki.freepascal.org/Dynamic_array
http://wiki.freepascal.org/Character_and_string_types#AnsiString

The pure Pascal way uses either arrays with fixed size baked into their type signature or pointers (including pointer arithmetic) just like C.
>>
>>60291498
>*autistic screeching*
>>
>>60291856
muh cache misses
>>
You can easily implement a dynamic array in C with about 10 minutes if you're not retarded. And at least that way you know the cost of it.
>>
File: autistic screeching.png (399KB, 3555x2198px) Image search: [Google]
autistic screeching.png
399KB, 3555x2198px
>>60291476
>>
>>60291476
If you aren't working with fixed size data structures, you might have to think about what data structures you actually need to use to get a decent representation and decent performance.
>>
File: meem.gif (297KB, 300x168px) Image search: [Google]
meem.gif
297KB, 300x168px
>>60291872
Don't be such a baby.

All applications run on 60 megs of xeon L2
>>
What the fuck? People still use Pascal?

I learned that shit back in high school 15 years ago.
>>
>>60291985
What the fuck? People still use C?

I learned that shit back in high school 40 years ago.
>>
>>60291996
I don't recall Pascal being used industry-wide...
>>
>>60291476
>Catering to undergrads
And that's how we get code monkeys
>>
>>60291806
Came here to point this exact thing out, fuck you OP.
>>
File: 1494276716858.jpg (592KB, 3702x2198px) Image search: [Google]
1494276716858.jpg
592KB, 3702x2198px
>>
>>60291476
>what is malloc
>what is realloc
>>
File: untitled.png (489KB, 3555x2198px) Image search: [Google]
untitled.png
489KB, 3555x2198px
>>
>>60292094
That's why you use superior C++ instead of C
>>
#include <stdio.h>

int five_star_add(int *****a, int *****b)
{
return *****a + *****b;
}

int main(void) {
int a = 5;
int b = 2;

int *ap = &a;
int **app = &ap;
int ***appp = &app;
int ****apppp = &appp;

int *bp = &b;
int **bpp = &bp;
int ***bppp = &bpp;
int ****bpppp = &bppp;

printf("%d\n", five_star_add(&apppp, &bpppp));
return 0;
}
>>
>>60292190
>*autistic screeching*
>>
>>60292190
Post a function pointer one.
>>
>>60291875
>10 minutes
wew
>>
>>60292190
This is literally autistic screeching
>>
What operating system are you posting this thread on OP?
>>
>>60292508
BlackPantherOS
>>
>>60292508
Windows
>>
>>60291498
>>60291511

C makes assumptions that my OS follows a memory model from the 1960s
>>
var foo = 'reee';
console.log(foo + (foo.slice(1).repeat(50));
>>
>>60292587
>repeat
D has this too
>>
>>60292585
memory layout hasn't changed since then
>>
>>60292595
>repeat
E has this too
>>
>>60292606

>he uses a commodity architecture
>>
>>60292094
>What is an ADT
>>
>>60292649
something that doesn't solve the problem
>>
>>60292681

if ADT's aren't a solution C is the problem

ain't even the best choice for embedded systems anymore (VHDL/ASICs)
>>
File: 1494165781078.jpg (272KB, 1378x919px) Image search: [Google]
1494165781078.jpg
272KB, 1378x919px
they even give you a valid license.
>>
File: 1494297278708.jpg (83KB, 716x898px) Image search: [Google]
1494297278708.jpg
83KB, 716x898px
>>
>tfw I can't program my PIC with rust

I would use Rust if they were serious about it being a systems language
>>
>>60292771
Because nobody uses it. They can't even give it away lol XD XD
>>
>>60292508
macOS Sierra <3
>>
File: lazarus.png (98KB, 450x300px) Image search: [Google]
lazarus.png
98KB, 450x300px
>>60292784
>using modern delphi
>>
File: index.jpg (10KB, 180x280px) Image search: [Google]
index.jpg
10KB, 180x280px
>>60291875
*with almost 100% chance of exposing buffer overflow or dangling pointer vulnerabilities

Man, C is truly shit
>>
>>60291476
I'd like to see how nicely your dynamic array resizing holds up in a kernel, especially an interrupt handler. Faggot.
>>
>>60292585
And it'd still be correct today, because your OS still follows that same model.
>>
>>60293452
Doesn't happen in my code.
Maybe you just suck at programming?
>>
>>60293532
>>60292606
Not the quoted, but I think the meant that memory capacity at the 60s was generally so low that you absolutely HAD to micromanage so you could get max performance.

Pascal didn't allow this.
>>
>>60291806

The entire dynamic array thing falls apart as soon as you try to copy it, since it's just a pointer.

Also C has realloc, isn't that what OP wants?
>>
>>60293594
>>>/pajeet/
>>
>>60293594

Memory capacity might not be an issue any more but efficient memory usage is absolutely important. As processors get faster and memory stays slow, efficient cache usage and memory locality are increasingly important for performant computing.
>>
>>60291476
pascal has real array, real string.
C just has pointers

And pascal was invented before C.

WTF?
>>
>>60293715
no, OP doesn't want anything other than shitposting
>>
>>60295258
>implying strings aren't backed by more pointers
>>
>>60291875
But apparently, nobody does it the right way, judging from 99.99999999% of all C repositories.
>>
>>60293557
That's a lie. You write bugs.
You just deluded yourself into ignorance.
>>
>>60292712
>ain't even the best choice for embedded systems anymore (VHDL/ASICs)
It is truly incredible how close to the peak of mount stupid you are.
>>
>>60291476
you do realize that when you dynamically size an array in python/whatever, it's doing the same thing you do in C under the hood?
>>
ITT bad programmers blame a language because they failed their data structures course
>>
>>60291476
there is no such thing as a dynamically sized array
>>
>>60295258
You should go back to Logic class
>>
>>60295345
>implying strings aren't backed by more pointers
in discussions of C vs other languages people often confuse types and implementation. you can obviously implement anything in C, and for the most part "modern languages" aren't doing anything else different in implementation.

C types, however, are very inexpressive, and in professional C you end up writing a lot of text macros to overcome this; i'm sure everyone has seen something like
#DEFINE_DYNAMIC_ARRAY_TYPE(int)


the main difference between that and std::vector<int> is that the language and compiler isn't cognizant of the macro, so it can't e.g. check whether the int type actually satisfies the requirements of vector (e.g. movable/copyable for resize). so you turn a compile-time error into a runtime error, which is a concrete problem
>>
>>60291476
if an array is dynamically sized can it even be called an array?
>>
>>60291476
> what is malloc
>>
>>60295865

>in professional C you end up writing a lot of text macros to overcome this; i'm sure everyone has seen something like
>#DEFINE_DYNAMIC_ARRAY_TYPE(int)
What exactly does this mean?
>>
>>60295738
thuis
Thread posts: 65
Thread images: 9


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.