Kernel hacking edition
Old:
>>54555253
No languages higher than C allowed. C++ is neither allowed see: http://harmful.cat-v.org/software/c++/linus
Overly bloated and abstracted OOP is terrible. If you want to go higher level than C, use Haskell or Lisp.
Embrace the goto and don't be an anti-goto cargo-cultist: http://koblents.com/Ches/Links/Month-Mar-2013/20-Using-Goto-in-Linux-Kernel-Code/
Place your opening bracket on the same line: https://www.kernel.org/doc/Documentation/CodingStyle
Finally, if you're a Windows user, you will be laughed at in this edition. It simply is a defective OS and its filesystem is a fucking joke that continues the tradition started with FAT. See pic.
Please upgrade: https://www.gentoo.org/downloads/
>>54562244
hot opinions sperg
==4907== 72,704 bytes in 1 blocks are still reachable in loss record 1 of 1
==4907== at 0x4C2ABD0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4907== by 0x4EC193F: pool (eh_alloc.cc:123)
==4907== by 0x4EC193F: __static_initialization_and_destruction_0 (eh_alloc.cc:250)
==4907== by 0x4EC193F: _GLOBAL__sub_I_eh_alloc.cc (eh_alloc.cc:326)
==4907== by 0x400F499: call_init.part.0 (in /usr/lib/ld-2.23.so)
==4907== by 0x400F5AA: _dl_init (in /usr/lib/ld-2.23.so)
==4907== by 0x4000DC9: ??? (in /usr/lib/ld-2.23.so)
>Valgrind
2nd for reasonable adults
>>54562244
>No languages higher than C allowed.
>>54562244
Why is ext2 so god damn fast?
>>54562422
Simplicity, no journaling for example.
Is there something like numpy for C++?
>>54562244
>It simply is a defective OS and its filesystem is a fucking joke
I know this feel. I decided that I wanted to play some GTA V last night / morning, and rebooted into Win7 from Debian. Updates disabled etc, started Steam and let all the 20 game updates run (only boot Windows a handful of times a year). I gave up and went to bed after TF2 took 50 minutes to install it's updates, and CS:GO was 30 minutes into it's update (with no end in sight, game would run like shit with slow disk read).
The updates would download at 8MiB/s, but the disk usage was just going nuts.
Oh well, at least it's better than the last time I booted into Windows in December last year for Fallout 4; Windows update took an hour and a half to run, 20 minutes to "finish" updating on reboot, only to tell me that it had installed incompatible updates and needed to revert, which took another 15 minutes, then another 15 to take another step back. Finally I was on the home stretch another set of reboots and updates after disabling to problem update and installing the ones that were supposed to come after it failed.
All in all it took over 3 hours for me to give the game developer/publisher my money. Why do they choose Wangblows again?
>>54562612
>Why do they choose Wangblows again?
Because, in the beginning, there were no other options. DirectX was king.
I'm having a pretty good time learning java so I can take the AP computer science test
I'm basically to make a version of this https://www.youtube.com/watch?v=HQYsFshbkYw in a javaFX jframe
am I wasting my time? is javaFX just some meme GUI software or can I do some reasonable graphics calculations?
>>54562612
My updates complete almost instantly after they finish downloading. They always have, on both mechanical drives and SSDs.
Moreover, you have the ability prioritize updates on steam. You didn't have to update any game other than the one you wanted to play.
You, sir, are an idiot.
>>54562388
Lisp is allowed, as is Haskell, so we're good
>>54562841
Haskell is trash and Lisp is good, but that still misses most of the languages that people actually use.
>>54562841
Please ignore that trip.
>>54562819
>I don't know how to argue a simple fucking solution and my computer is a pile of shit.
>>>/out/
>>54562819
>if you're not having problems with windows you must be a /v/ermin teehee xddddDDD
get blown scrub
guess you just suck at computing
quick, write a virtual machine for a superset of the basic opcodes (mov, add, etc) of the x86 architecture in your language of choice in under 10 minutes to prove you're not a cancer on this general
>>54562950
pajeet detected
>>54562244
real thread
>>54562664
>>54562934
>superset of the basic opcodes
kid, can you even into avg2int?
>>54562976
sure i can, my professor taught me#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define JAVACODE "public class Average {\n
public static void main(String[] args) {\n
int a = Integer.parseInt(args[0]);\n
int b = Integer.parseInt(args[1]);\n
int c = (a + b)/2;\n
System.exit(c);\n
}\n
}"
#define JAVA_CMDLINE "java Average %d %d"
int main(void) {
FILE *fp = fopen("Average.java", "w+");
if(NULL == fp) {
return -1;
}
size_t javacode_len = strlen(JAVACODE);
fwrite(JAVACODE, javacode_len, 1, fp);
if(ferror(fp)) {
return -1;
}
fclose(fp);
system("javac Average.java");
puts("Please provide two integers to average, separated by a newline:");
int a, b;
scanf("%d", &a);
scanf("%d", &b);
size_t buf_size = strlen(JAVA_CMDLINE) + 1 - 2;
char buf[buf_size];
sprintf(buf, JAVA_CMDLINE, a, b);
char const *aux = buf;
int c = system(aux);
printf("Result of averaging %d and %d: %d\n", a, b, c);
return 0;
}
>>54562612
IoT axe when
>>54563002
kid, we already rekt you, so...
>>54562728
>am I wasting my time?
yes
>is javaFX just some meme GUI software
yes
>>54563002
it's not even correct
>>54563019
what an innovative solution
>>54563031
>>54563053
as i said when i posted it originally, it's the idea that matters, not the actual implementation
>>54563065
it misses the entire point if it doesn't even work, the joke is ruined, you should cast to long or something in the java code
>>54563033
Ok, what can I use that is better
I'm not trying to make >muh games, I just want to do some thinking
>>54563079
or use BigInteger, might be funnier
>>54563079
it's not a joke, but fine, i'll get around to fixing it and asking my professor to review the fix and post it here (sometime)
anyway, no one has done the challenge yet
Which is the comfiest kernel to hack on? Linux? FreeBSD?
>>54563106
freebsd is not a kernel
dat boi absolutely BTFO
>>54563135
FreeBSD has a kernel
>>54563141
of course
>>54563136
kys
>>54563136
kys
>>54563136
kys
>>54563173
kys
are java servlets/jsp's still being used in web development?
>>54563187
kys
>>54563187
kys
>>54563192
replaced by jsf
Can't comment on how it differs to jsp because I never did anything with it
NEW THREAD
>>54543664
>>54543664
>>54543664
>>54562244
>http://harmful.cat-v.org
the search continues
>>54563226
kys
What is the best way to learn ASP.NET if I already know programing in other languages? Any good tutorials?
>>54562808
>Moreover, you have the ability prioritize updates on steam. You didn't have to update any game other than the one you wanted to play.
I know, but it just shouldn't have been an issue in the first place.
>>54562819 is not me
vec3 operator+(vec3 &rhs)
{
vec3 v;
v.vec[0] = vec[0] + rhs.vec[0];
v.vec[1] = vec[1] + rhs.vec[1];
v.vec[2] = vec[2] + rhs.vec[2];
return v;
}
I'm new to C++, how can this be optimized?
>>54563002void read_number(int *ptr)
{
int result = scanf("%d", ptr);
if (result == EOF)
exit(-1);
if (result == 0) {
while (fgetc(stdin) != '\n')
;
}
}
int main(void)
{
int a = 0;
int b = 0;
read_number(&a);
read_number(&b);
char buffer[1024] = {0};
snprintf(buffer, 1024, "python -c \"import sys; print(int(sys.argv[1]) + int(sys.argv[2]))\" %d %d", a, b);
system(buffer);
return 0;
}
>>54563430
With the += operator, and a for loop
>>54563463
>for loop
>optimization
uhhh
int average(int a, int b)
{
int sum;
sum += (a & b);
sum += (a ^ b) / 2;
return sum;
}
>>54563430
By using C instead of C++.
>>54563463
Retard alert
>>54563475
>I don't know anything about compilers
>>54563475
There's nothing wrong with a single for loop.
Also, your compiler will unroll it anyway
>>54563235
>Linus is a retard now
I guess you're more intelligent than him. What have you done in your life that is has relevant as the linux kernel ?
There's pros and cons, but one must admit that most high level languages are fucking garbage. Few of them might solve and make coding faster, but you realize fast enough that it is just trash.
>>54563463
(manually) unrolling loops is faster because no comparison instructions
i dont know how branching works so i might be wrong on taht though
+= is really the same as example posted
>>54562612
>took hours to download several gigs worth of game updates
>must be because of windows
>>54563430
use mmx
but it's possible that compiler already did that for you
>>54563430
Fucking hell... oh my stars... the constructor and destructor calls in this shit. Pajeet, kill yourself immediately.
Guys I wrote a function to average 2 ints!void swap(int *x, int *y)
{
int tmp = *x;
*x = *y;
*y = tmp;
}
int average(int x, int y)
{
if (x > y) {
swap(&x, &y);
}
while (x < y) {
x++;
y--;
}
if (x == y) {
return x;
} else {
return y;
}
}
>>54563085
Then it shouldn't matter whether something is a meme or not.
You can always apply the mental routine to other memes.
>>54563530
>Linus is a retard now
>sizeof really is a function
seems so
>>54563498
Thanks for making your presence known.
>>54563430
by addingv.vec[3] = vec[3] + rhs.vec[3];
>>54563475
>>54563498
>>54563535
Did me mean optimization like run time efficiency, or not looking like shit to read? I assumed the latter because the former is impossible to take any further.
>>54563636
hehe xd
>>54562728
>I'm having a pretty good time learning java so I can take the AP computer science test
m8 wasn't that like a few weeks ago?
>>54563647
It's a vec3, not a vec4. Retard.
And how the fuck would that optimize it?
>>54563663
I meant the former.
>>54563692
>not a vec4
use a vec4 then
>how
seems like you're the retard
>>54563530
>but one must admit that most high level languages are fucking garbage
okay dude enjoy jerking off to those buffer overflows :^)
ill just be over here suffering from the lack of bugs
>>54563716
I don't want to use a vec4, I don't need to.
Now explain to me how adding an extra element and doing useless operations on it would somehow improve performance. Go on.
>>54563713
In that case ignore my advice, I think you've already taken it as far as you can go (then again, I don't speak CPP).
someone give me a problem that involves lots of pointer shit
im not good at it
>>54563744
Well, I was mostly interested in the C++ side of things.
Example, I noticed how every operation will create a new object and copy it out of the function, so I was wondering if there's a way to optimize that, because that could possibly destroy performance.
>>54563770
swap 2 ints
>>54563739
>I don't want
you don't want it to be faster?
>I don't need
ok, if you don't need performance
>explain
seems like I'd be wasting my time since you don't seems receptive to knowledge
>>54563770
Implement double linked list without bugs.
>>54563799
>Adding more useless shit to stuff makes it go faster
Ok.
>>54563818
>makes it go faster
yes
>useless
it's not useless if it improves performance
>>54563782,>,<[>>+<<-]>[<+>-]>[<+>-]<.>.
>>54563818
>Performance is useless.
Webkids should just leave /g/.
>>54563770void swap_ints(int *a, int *b)
{
int temp = *a;
*a = *b;
*b = temp;
}
>>54563800
shieeet that one will take a long itme
>>54563852
bf meme is no more funny
>>54563844
Ok, now explain how it improves performance.
I'm listening, if you explain it I'll understand.
Otherwise you're obviously full of shit.
>>54563430
a for loop is not really appropriate in this situation, the code is too small.
>>54563716
>>54563799
fucking retard, a vec4 takes more memory, and memory access is the main performance concern for today's machines
>>54563844
Wait, let me guess.
Is it because of SSE? I could see how adding a fourth element might make the compiler generate SSE instructions.
Is that correct?
>>54563935
yes
>>54563931
you don't actually know how computers work
>>54563891
see >>54563935
>>54563530
Linux only gained popularity because the BSDs were wrapped up in legal trouble when Linux appeared. It has nothing to do with skill or technical superiority. Linux is utter shit compared to BSD but Linux happened to appear at the right time. Linus got lucky.
>>54563951
Ok, I understand now.
Sorry for doubting you before.
>>54563951
kill yourself arrogant idiot
you have NO relevant benchmark to show for it
What's a good java reference manual/book?
>putting the * next to the identifier not next to the type
Fucking why, it makes no sense? I don't give a shit if great coders prefer that, I need a good explanation of why would you put * next to the name of a variable, and next to a type.
>>54563975
https://docs.oracle.com/javase/tutorial/
>>54563975
Core Java for the Impatient. It's perfect
>>54563996
Because writing
int * x
doesn't mean that "x" is a "int *"
it means that "* x" is an "int".
That's why you must put * near the name and not the type
int* x is incorrect
int *x is correct
>>54563996int *a, b, *c;
>>54564016
Dammit, I meant to say: next to the name of a variable, and not next to a type.
>>54563996
There's no good reason.
>>54564016 is retarded because it's all valid
>>54564019 shows a use case of the syntax that also doesn't make much sense
Why can't I declare three int pointers like so:int* a,b,c;
The real answer is that it's just the way it is and you're free to not do it, but don't expect any open source projects to accept code in that style.
>>54564055
If you want int * to be a type you can dotypedef int *intptr;
void stupidfunction (void) {
intptr a, b, c;
}
>>54564038
You also mean the brackets for arrays I guess? Because in that case you don't even get to choose... think about it
>>54564078
>if I want more consistent behavior I have to do some shady shit
>>54563952
>wrapped up in legal trouble
please stop with this bullshit excuse; the lawsuit only lasted for 2 fucking years, it ended in '94; '94 linux market share was shit; why don't you also mention linux's legal truble with sco? why didn't that boost bsd above linux?
>has nothing to do with skill or technical superiority
no argument there
>utter shit compared to BSD
yes, the code is not as nice as bsd's because it's written by joe random with no centralized design; it's stupid easy to contribute to linux while bsd is cathedral style; sure, this doesn't guarantee high quality code, but on the other hand, maybe this has something to do with everyone contributing to linux instead of bsd?
>Linus got lucky
yes, with the development model and with the license
>>54563973
no need to get angry for losing an argument on an anonymous image board
What's a good resource to learn as quick as possible to use threads in c ? I'm mainly interested in implemeting the quicksort algorithm using a thread pool.
>>54564055
>There's no good reason.
Yes there is: Keningham and Ritchie decided that the syntax for the type should resemble the syntax for what you can do with this type. Do you thinkVAR x: PTR INTEGERis more elegant and intuitive than int *x; ? No you don't, so that's why.
>>54563800#include <stdio.h>
#include <stdlib.h>
#define ITER 10
typedef struct node {
int data;
struct node *prev;
struct node *next;
} NODE;
NODE *init_node(NODE *prev, NODE *next)
{
NODE *node = malloc(sizeof(NODE)); //God says it won't fail.
node->prev = prev;
node->next = next;
return node;
}
void free_node(NODE *node)
{
if (!node) return;
if (node->prev)
node->prev->next = NULL;
free(node);
}
void iterate_from_top(NODE *node)
{
while((node = node->next) != NULL)
printf("%d\n", node->data);
}
void iterate_from_bottom(NODE *node)
{
while((node = node->prev) != NULL)
printf("%d\n", node->data);
}
int main(void)
{
NODE *top = init_node(NULL, NULL);
NODE *cur = init_node(top, NULL);
top->next = cur;
int i;
for(i=0; i<ITER; i++)
{
NODE *tmp = init_node(cur, NULL);
tmp->data = i;
cur->next = tmp;
cur = tmp;
}
iterate_from_top(top);
iterate_from_bottom(cur);
//iterate and free all nodes
while((top = top->next)) free(top);
return 0;
}
pls be gentle
>>54564172
https://computing.llnl.gov/tutorials/pthreads/
>>54564016
>int * x
>doesn't mean that "x" is a "int *"
m8...
>>54564158
you're fucking delusional
>>54564200
He's right though.
SSE would speed it up.
>>54564186
Please code insert and remove
>>54564200
>still mad
ok
>>54564207
>>54564210
you have no proof, in any reasonable application it would just take up more memory
What engine would you suggest for a side scroller 2d game? Also would you suggest java or c++? I'm not interested in python.
Tutorials would be nice as well. I'm guessing a lot of you have been into this kind of thing so I'm asking here.
I'm a backend webdev but wanted to this for fun this summer with a couple mates.
>>54563730
>I'll just be over here waiting for gc
ftfy
>>54564221
>in any reasonable application
I doubt a person with your lack of experience knows what a "reasonable application" is
>>54564221
post code for vec3 so we can play around
>>54564263
The person you are responding to is not the person who posted the vec3 snippet.
>>54564262
kill yourself delusional retard
>>54564232
Just use gamemaker desu. That's what all the profitable 2d indie games use (Risk of Rain, Hyper Light Drifter, etc).
It depends though. If you're more interested in learning about programming than making something playable, you could use slick2D or whatever game libraries people use nowadays.
Ask your much beloved programming literate anything (IAMA).
>>54563996
because in C, the declaration mimics the evaluation.
>>54563573
Nice (∩_∩ )
>>54563430
By using the compiler builtin vector types and builtin operators ?
>>54562244
NTOS concurrency is much better than linux. (Cutler > Torvalds ?)
>>54564186
>not using a double pointer
http://wordaligned.org/articles/two-star-programming
http://grisha.org/blog/2013/04/02/linus-on-understanding-pointers/
>>54564186
Make a separate insert function, init_node does a pretty poor job of that
number of benchmarks showing that vec4 is faster than vec3 when you just need vec3: 0
>>54564194
he's right though, it means that x is an int * and *x is an int
>>54564309
>he's right though, it means that x is an int*
>>54564016
>doesn't mean that "x" is a "int *"
nestedcode block
>>54564182
If I may interrupt you two, I think int* x is more logical than int *x because it kind of corresponds to the way people think about stuff.
In the first case the thing on the left completely describes the thing on the right
>its a pointer to a number called x
The second case kind of breaks the flow, even though the visual difference is pretty small.
>>54564281
>>54564297
at this point you're just embarrassing yourself
I want to read last modified date using either my own code or the C standard library (no C++ standard library).
I don't have to go to the Windows API for this I hope.
>>54564208//from = base ptr
//where = how far to go
//data = data to insert
void insert_node(NODE *from, int where, int data)
{
int i;
for(i=0; i<where; i++) from = from->next;
NODE *new_node = init_node(from, from->next);
from->next = new_node;
new_node->data = data;
}
//from = base ptr
//where = how far to go to remove node
void remove_node(NODE *from, int where)
{
int i;
for(i=0; i<where; i++) from = from->next;
NODE *tmp = from->prev->next;
NODE *tmp2 = from->next;
free_node(from);
tmp->next = tmp2;
tmp2->prev = tmp;
}
maybe my code wouldnt be so pajeet if i hadnt skimmed k&r
>>54564361
you're a fucking joke dude get a grip
take a hypothetical example of adding 30 GB worth of vec3s vs adding 40 GB vec4s... which do you think will be faster... idiots
>>54564381
>my ass hurts so bad right now
if you're so salty maybe you shouldn't get into internet arguments when your knowledge is lacking
>>54564373
Have you test it? Check for every memory leak? Etc?
>>54564407
the second one
>>54564408
>>54564426
stay delusional retard
>>54564415
no i dont know how to use debuggers
>>54563187
jys
Just because Java is an OO language doesn't mean you have to write OO code.
Ignore the side-effect meme. Use only pure functions
>>54564443
You don't need a debugger to debug a program. Who taught you programming?
>>54564407
If you write code properly vec3's is faster. If not and you just write the simplest thing in simd/have it happen on the GPU, and assuming it's float/double stored in the vectors then vec4 is potentially the same speed.
>>54564476
youtube and lurking dpt/prog
>>54562244
what if i'm generating C code from lisp?
>>54564492
Try to debug without a debugger. You need that skill before complex things
>>54564474
If you're gonna go with functional why even write Java?
>>54564186
Your goal: if it's done right, the user of the library, main in this case, shouldn't have to manually adjust the next and prev pointers, the node function should do it correctly automatically. We're far from that tho. Here it's scattered around, with e. g. free_node removing itself from its prev but not from its next. Also why didn't you use it in "iterate and free all nodes" ? You have two nodes more than there are data also, and if init_node inits a node, it should update the next and prev pointers of its prev and next, respectively: it's just easier that way. Finally, your model is strange because of what >>54564295 pointed out.
>>54564373
What if where is too big? Why are you updating from->next but not the next node's prev in insert? What is withtmp = from->prev->next? It's no different fromtmp = from;here. In short: absolutely haram.
>Understanding pointers
Why is this so hard for people?
I really don't get it. They're the simplest thing imaginable, have an intuitive name and almost every explanation I can find is dead simple.
Is it the star for deference syntax that fucks with people?
>>54563530
>Linus linked to cat-v
>Linus in charge of PL design
>C not garbage
the search continues
>>54564511
>that skill
Not sure what you're on about but there's no real reason not to use a debugger unless you're moving to a platform where you won't be able to use one.
Anon catching logic errors can't be accelerated in any way. Relying on debuggers doesn't hamper that progress at all. More information is always good when learning to deal with issues.
Why would a debugger somehow not learn him the same things? If he steps through his code using the tool or steps through the code in his head does it matter? Why not just let the computer do the math? That's really the only difference.
>>54564534
people are retarded
the majority of people have an IQ below 110
I made a Qt Widgets application on windows but i want it to look appealing, is it possible? how should i go about this?
Did i fuck up?
>>54564570
>no real reason not to use a debugger
I totally agree, but it's not the same thing as not knowing how to debug without a debugger.
>>54564534
They say it's the basic test for abstraction: if you don't get it, you won't be a programmer.
Can't find the source again tho. Also to broaden the topic:
Why is recursion so hard for people?
I really don't get it. It's the simplest thing imaginable, has an intuitive name and almost every explanation I can find is dead simple to me.
>>54564580
>but i want it to look appealing
Leave that for artists.
>>54564580
Hope this helps: http://de.slideshare.net/qtbynokia/how-to-make-your-qt-app-look-native
>>54564571
>the majority of people have an IQ below 110
Uhh... IQ is normalized. That means the majority have an IQ <= 100, by definition. We could all be geniuses and the median IQ would be 100.
>>54564293
Jesus christ you fag, can you stop writing question marks like this ?
Hi /dpt/, I seek your enlightment
I know the basics of python (all the data types and shit), and I can write simple programs and complex mathematical things with it.
The thing is, I don't know how to build a project at all. I can't use libraries for shit, I have no clue how to interact properly with the user, how to build a GUI, in fact I can't do anything useful.
The other day I wanted to do a simple labyrinth game for training, where a labyrinth (#) is displayed in a terminal, and you have to move your character (@) from one end to the other.
I had no idea how to make the character move, how to make sure that he couldn't go through a wall, etc.
So I was wondering : are there any books on how to build a project, how to perform well with libraries, etc ? Cause I know all the notions individually, but I can't seem to interlace them into something consistent.
>>54564615
lrn2read
>remainder: not all people are as intelligent as you are, that's why you personally are high on the relative scale that IQ is
>>54564615
anything below 110 is pretty stupid, above 110 you could be a decent programmer
>>54564534
This.
>>54564607
>recursion
I think maybe people are stuck thinking of their program in a sequential way. Since they always return to their calling site after the function is done I imagine the confusion that you could enter a function twice or more times might be confusing.
I agree it's weird that people don't get it but there's some mindsets you could be in that would make it confusing. Imagine calling functions without a call stack. Then you just picture the function as having its own locations for variables (local variable X is shared between all 'instances' of foo()) it'd make recursion a very confusing concept if you think about it like that.
>>54564615
It's a very dumb statement for sure. But the point is clear. He's saying I'm overestimating normal people.
I legit have 89 IQ
>>54564703
are you a nigger
>http://harmful.cat-v.org
That site thinks Go is a good language. Into the trash.
>>54564703
I sometimes find it hard to believe I've met people like you but you and below are like 25% of the population.
I'd really like to know where you notice it playing a role and how. I have trouble understanding stupid people (no offense).
>>54564703
If this is true, I want to let you know that IQ is pretty much completely bullshit created by insecure fucks that want to feel better about themselves.
>>54564723
no i was in a car accident at the age of 3 and i hit my head in the car door window pretty hard
I've made a relatively simple program, but I don have 6 or 7-fold nests in there somewhere, and other similar crap that looks simply awful, even to me.
Since it's about 800 lines of code, should I fix it, or write a better version from the ground up?
>>54564745
damn
>cat-v
I hope you guys know this is satire, right?
>>54564745
That really sucks dude. So how are you doing now?
>>54564752
Nah rewriting from the ground up is evil. Just rewrite the bit with the 7 layer deep code if it's actually a problem.
>>54564772
They have the entire manpage base of Plan9, that has been useful to me at a time. To what extent is it satire you think? Or are you just trying to smear them?
>>54564736
>>54564781
i am physically healthy but i am having a hard time learning logic and math, it makes no sense to me but after a few weeks it suddenly makes sense out of nowhere and it feels good man, very very good
i am doing this because i normally struggle to pay for things (like rain main, except that i am bad at math)
if i have $20 and i buy something for eg. $7.32
it takes me like 30 seconds to calculate in my head what my change will be
i have a person to aid me but i want to be independent
>>54564822
sorry, I was talking about the harmful section of the website
>>54564752
>but I don have 6 or 7-fold nests in there somewhere
Why would this be important?
>>54564648
>111
>decent programmer
please
Why does frequently syncing reduce I/O performance?
>>54564833
>if i have $20 and i buy something for eg. $7.32
>it takes me like 30 seconds to calculate in my head what my change will be
Mental math is a matter of practice for most, are you sure this isn't the case for you too? In fact I'm sure it's the case. Just practice a lot of this shit and you'll be fine at it.
Why would anyone ever use linked list when dynamic arrays are much faster?
>>54564839
why not?
>>54564839
140+ IQ is pretty rare, you have to balance quality/quantity, 111+ can be code monkeys at least
>>54564834
I see.
Anyone has unbiased info on how 9front is doing? Just asking, I don't expect anything big from it anyway. Their coc: http://9front.org/coc
>>54562244
Dubs decides what I program for 4 hours
>>54564534
Lots of people get into CS for shitty reasons like wanting to make games
>>54564858
As soon as your elements reach a certain size, they aren't.
Fucking CS students and their number games.
>>54564607
>Why is recursion so hard for people?
>I really don't get it. It's the simplest thing imaginable, has an intuitive name and almost every explanation I can find is dead simple to me.
most recursion explanations are shit and use terrible examples that shouldn't even be solved by recursion, like fibonacci
>>54564846
i hope so anon
>>54564740
well i am really stupid and my brother who says he has 130 iq runs his own business and makes a lot of money
>>54564837
But I do* I made a typo, sorry.
>>54564870
Video player for TempleOS
>>54564870
A C interpreter
>>54564534
>Is it the star for deference syntax that fucks with people?
The C syntax for pointers has nothing to do with the concept of pointers at all.
It's like saying block scope is hard because "var" in JavaScript does it wrong, requiring them to add a new keyword in ECMAScript 6.
This is why schools should use good languages to teach programming concepts.
>>54564870
implement a mouse driver for linux
>>54564903
Never in my life have I seen more bullshit. Please leave and >>>/sci/
>>54564933
I can't, I only have windows
>>54564870
Also a HolyC interpreter (show to terry after and capture his reaction)
>>54564833
I'm also bad at mental math. I just don't care for it though. Like I can figure out that it's 12.68 in maybe 5 seconds or so but I don't get certain of it until maybe 10 seconds.
>>54564858
No reason ever.
Even this guy who knows practically nothing about writing programs (no joke, Sturstrop is retarded)
https://www.youtube.com/watch?v=YQs6IC-vgmo
Says they're bad. You learn them just because people demand it of you at college. They want arbitrary examples for shit.
They do have a favorable deletion pattern I suppose (leaves no holes). Unless whatever you're storing is pretty huge and makes the pointers a negligible storage concern. And you really don't want holes in your vector it could be a good idea.
>>54564879
Doesn't seem like a shitty reason. Tons of money there.
https://www.patreon.com/combin_ation?ty=h (2k+USD for this shit)
Seems like a good side-gig.
>>54564903
/pol/ nobody cares. We judge people on an induvidual level.
>>54564928
Well there's no doubt pointers are associated with C/C++ for most newbies and it's certainly a bit of a confusing syntax.
R8 my 2048, /g/
http://pastebin.com/hRi0v0Wf
>>54564928
What's a good alternative to C?
>inb4 go
>>54564953
a CS degree doesn't teach you how to make/design/program games
>>54564942
Well, you're installing gentoo now
>>54564961
Variable names and comments leave a lot to be desired
>>54564939
https://en.wikipedia.org/wiki/Mainstream_Science_on_Intelligence#Conclusions
>>54564961
what the fuck is u.h?
>>54564840
I/O is more efficient in batches. One large write is much faster than several smaller ones.
>>54564963
Maybe a meme language, but Rust has a lot of potential as a low-level systems language. No GC (unlike go) and it enforces memory safety (no segfaults, no race conditions, etc)
I've done a fair bit of scripting w/ python and javascript, I know java and c# as well
I want something very specific: a 3d plane you can view from any point, and input instructions with your mouse
I assume this is found in C++, right? Does anyone have any tutorials for this sort of thing? I would rather not have a prebuilt engine, this is for more for learning/fun. This isn't really for a game of any complexity, more of a simulation.
>>54565000
Yes, that's from 1994. Good one.
>>54565023
Well, nothing has really changed
>>54565023
>1994
>too old
Anon not that guy but that's a terrible argument. It's not like 1994 was the height of american slavery or anything either.
>>54565016
GLFW+GLEW
>>54565016
This is OpenGL 101, unless you want to do the projection math yourself.
You can easily do it in e.g. Python with pygame, if you don't really want to use c++
>>54564928
>This is why schools should use good languages to teach programming concepts.
Yes, like pascal.
>>54565055
http://antongerdelan.net/opengl/hellotriangle.html
Forgot the tutorial..
>>54564928
What's a better example for pointer syntax?
>>54565007
I find it difficult to understand why this is. Shouldn't the numerous small writes max out the disk anyway? Or are they unable to be sent fast enough because of OS operations?
>>54565059
>>54565055
and C++ has backwards compatability with C, right?
>>54565108
There's a startup and wind down cost to every IO operation. Thus it's most efficient to only flush or msync when you need to.
>>54565141
Thanks
>>54565133
I'm pretty certain this generates an error in C++, and this is everywhere in C code:int * i = malloc(sizeof(int) * 8);
From my understanding you *have* to cast void * types: there's no automatic type conversion.
>>54565133
C code can be compiled in C++ compilers (generally).
So basically write your code according to your knowledge. There's no reason to use C++ features unless they help you.
And moving from Java to C++ isn't hard.
>>54565078
http://www.kednos.com/pli/docs/reference_manual/6291pro_014.html
>>54564607
>Why is recursion so hard for people?
Non-tail recursion just doesn't appear come naturally to humans[1].
I suspect it didn't come naturally to you either, but after years of programming it feels like second-nature.
[1] https://web.stanford.edu/~roypea/RoyPDF%20folder/A27_Kurland_Pea_85.pdf
>>54565078
>What's a better example for pointer syntax?
bumping this question, hence the weird pic related. I'm curious but pretty sure there isn't tho.
>>54565192
Ouch that shit is f*cking awful
>>54565209
>CHILDREN'S MENTAL MODELS OF RECURSIVE LOGO PROGRAMS*
That's pretty cool.
>Children who had a year of Logo programming experience were asked to thinkaloud about what brief Logo recursive programs will do
Really cool.
>>54565223
Just using another symbol for deference is better syntax than C.
>>54565192
>BASED (BUF_PTR)
Absolutely based.
What is google ion and why should I program my next mobile app with it?
https://github.com/google/ion
>>54562244
why did no one tell me scheme was comfy? i feel decieved
>>54565209
Good source.
>I think maybe people are stuck thinking of their program in a sequential way. Since they always return to their calling site after the function is done I imagine the confusion that you could enter a function twice or more times might be confusing.
>
>I agree it's weird that people don't get it but there's some mindsets you could be in that would make it confusing. Imagine calling functions without a call stack. Then you just picture the function as having its own locations for variables (local variable X is shared between all 'instances' of foo()) it'd make recursion a very confusing concept if you think about it like that.
I guess my "should be a black box" model protected me from that. Gotta check my oldest code to see how I did things though.
>>54565294
What? One of the main tools of the schemer is that Scheme be comfy:
One of the authors of Scheme uses this quote on the first page of his book:
>I think that it's extraordinarily important that we in computer science keep fun in computing. When it started out, it was an awful lot of fun. Of course, the paying customers got shafted every now and then, and after a while we began to take their complaints seriously. We began to feel as if we really were responsible for the successful, error-free perfect use of these machines. I don't think we are. I think we're responsible for stretching them, setting them off in new directions, and keeping fun in the house. I hope the field of computer science never loses its sense of fun. Above all, I hope we don't become missionaries. Don't feel as if you're Bible salesmen. The world has too many of those already. What you know about computing other people will learn. Don't feel as if the key to successful computing is only in your hands. What's in your hands, I think and hope, is intelligence: the ability to see the machine as more than when you were first led up to it, that you can make it more
>>54563876
>Not using xor swap
out of curiosity, is there any language that lets you define new operators like swift, has a default regex type like js and ruby, and has complex numbers like python?
>>54565361
>tfw you interview a candidate and they try to show off by using xor swap
Shig diggi doogie, da dig dop heyy
>>54565403
perl
Any idea why strncpy segfaults here?int loop(int sfd)
{
int k = 0;
char buf[513], **message = malloc(513 * 513); /* feed me mem */
char pong[64] = "PONG :";
const char *pass = "PASS finninbin\r\n";
const char *nick = "NICK kek\r\n";
const char *user = "USER kek 0 0 :kek\r\n";
memset(message, '\0', 512 * 512);
send(sfd, pass, strlen(pass), 0);
send(sfd, nick, strlen(nick), 0);
send(sfd, user, strlen(user), 0);
int len = recv(, buf, 512, 0);
for (int i = 0; len != 0; ++i)
{
strncpy(data, buf, 512);
for (int j = 0; j < 512; ++j)
if (buf[j] == '\r' && buf[j + 1] == '\n')
{
buf[j + 2] = '\0';
strncpy(message[0], buf, 0);
puts(message[k]);
for (int l = 0; l < k; ++l)
if (strncmp("PING :", message[l], 6) == 0)
printf(strcat(pong, message[l] + 6));
++k;
if (k >= 512)
message = realloc(message, sizeof(message) + 512);
}
len = recv(sfd, buf, 512, 0);
}
return 0;
}
>>54562244
>Overly bloated and abstracted OOP is terrible.
You don't have to use all of the high level features if you don't want to.
>>54565403
>operator overloading
>default regex type
>complex number standard library
Never heard of it.
>>54565445
That strncpy call was supposed to be:strncpy(message[k], buf, 512);
>>54563770
Find the total number of nodes in a tree where each node has a variable number of child nodes.
>>54565403
Racket. No seriously: no special syntax for operators is better than overloadable operators because it just lets you focus on what's important, and the other two things are present. Check it out.
>>54565499
forgot pic
>>54563770
Make a system for giving some sort of data closure for an update loop.
>>54562244
>Kernel hacking edition
>C++ is neither allowed
I made a kernel in C++, fite me.
>>54565403
Haskell
>>54562244
If this is "kernel hacking edition", how do I get into kernel hacking? I want to be able to write modules, fix bugs, etc.
>>54565223
>>54565078
Crystal where Pointer is a generic type.foo = Pointer(Int32).malloc
foo.value = 1337
>>54565534
eudyptula-challenge.org
>>54565538
Yeah, nice enough.
what's a jesus aproved language?
Hey guys, I found this image on /pol/, how accurate is this?
>>54565538#define pointer *
char pointer c;
>>54565578
HolyC
>>54565529
I honestly can't tell because haskell is unreadable meme garbage
>>54565499
huh, cool
>>54565442
sweet jesus perl is cool. If only people still used it
>>54565534
Do you know C? If not, learn that.
Do you know computer architecture? If not, learn that.
Do you know OS fundamentals? If not, learn those.
Then get a book on the Linux kernel and try to apply that. I recommend this book.
Probably a good idea to get Algorithms and Data Structures under control too.
>>54565583char pointer c, d, e, f; /* only c is a pointer, the others are chars */
>>54565578
java
>>54565579
It's missing the shadowy figure who uses common lisp
>>54565578
C++
>>54564870
Copy of C++ string type in C.
>>54563478
Good job.
>>54563975
Introduction to Java Programming, Tenth Edition
>>54564703
>>54564736
>>54564867
>>54564903
IQ is a bullshit psychology scam. Work hard and you will get the results you seek.
>>54565587
Catholics fuck off
>>54565611
You serious?
>>54565611
Never much liked that "feature" of C anyway.
>>54565578
Scheme
Is 22 too old to start a programming career?
>>54564870
Fizzbuzz in 16bit assembly.
Then write it to a USB stick and make it boot your computer.
>>54565611
>using /* */ for single line comments
>>54565658
Depends how motivated you are. If programming is FUN for you, it's never too late. Even if some of us started a decade ago.
>>54565579
not very accurage, lua/something/groovy should be a hipster fag, java should be an office drone, rub/C#/F# are garbage, C would suit the language lawyer poindexter with the book, python should be a baby
>>54565638
>catholic pope
>nigger that practices their shitty indigenous african religion
>he doesn't know holy church is the biggest charity fund in the world
lel
nice try fedora.
>>54565636
>IQ is a bullshit psychology scam. Work hard and you will get the results you seek.
you're not fooling anyone, shlomo
>>54565673
// isn't C89
>>54565693
They have a lot of money, but only a very small part of it goes to charity. Because they have a lot of money, that puts them up at the top, despite definitely not "sell[ing] all they own"
>>54565684
That pic is funny, but not very realistic. Most people I know who can actually write in assembly, are really good at it.
That shelf would be a bizantine horror from the depth of Hell, but it would be the most solid, most effective, mind bending shelf you have ever laid eyes on.
>>54565693
Ofc one of richest organizations in the world that gives to charity will be one of biggest charity organizations in the world.
Am I bad at this, /g/?#include <stdlib.h>
#include <string.h>
#include "../include/log.h"
typedef struct Entry Entry;
struct Entry {
Entry *prev;
Entry *next;
char *text;
};
struct _Log_ {
Entry *first;
Entry *last;
char *name;
};
Log *log_init(const char *name) {
Log *self = malloc(sizeof(Log));
self->first = malloc(sizeof(Entry));
self->first->prev = NULL;
self->first->next = NULL;
self->first->text = NULL;
self->last = self->first;
self->name = malloc(strlen(name) + 1);
strcpy(self->name, name);
return self;
}
void log_push(Log *self, const char *text) {
Entry *entry;
if (!self->first->text) {
entry = self->first;
} else {
entry = malloc(sizeof(Entry));
entry->prev = self->last;
entry->prev->next = entry;
entry->prev->prev = self->last->prev;
}
self->last = entry;
entry->next = NULL;
entry->text = malloc(strlen(text) + 1);
strcpy(entry->text, text);
}
char *log_name(const Log *self) {
return self->name;
}
char *log_list(const Log *self, const int newln) {
Entry *tmp = self->first;
char *ret = malloc(strlen(tmp->text) + (newln ? 1 : 2));
strcat(strcpy(ret, tmp->text), (newln ? "\n" : ""));
while (tmp->next) {
tmp = tmp->next;
ret = realloc(ret, strlen(ret) + (strlen(tmp->text) + (newln ? 1 : 2)));
strcat(strcat(ret, tmp->text), (newln ? "\n" : ""));
}
return ret;
}
void log_free(Log *self) {
while (self->last->prev) {
self->last = self->last->prev;
free(self->last->next->text);
free(self->last->next);
}
free(self->last->text);
free(self->last);
free(self->name);
free(self);
}
>>54565718
you'd put something in the shelf and the shelf would change shape to accomodate it in the most space-efficient manner
the shelf would also suck your dick if you asked it to
>>54565606
>If only people still used it
https://metacpan.org/recent?size=200
>>54565738
>struct _Log_ {
>_Log_
Identifiers starting with an underscore followed by a capital letter are reserved for the implementation, therefore your program exposes undefined behavior under some theoritical implementations of C.
Gotta love the language.
>>54565738
Why are people so obsessed with lists? They suck period. Its a data structure so it makes you feel smart?
>>54565614
Here I fixed it.
>>54565804
New thread
>>54565821
This thread hasn't reached bump limit fag. Do you see italics on the post count?
>>54565773
Lists are dynamic. Arrays are fixed.
>>54565840
I use Clover
>>54565852
You can grow array. realloc
>>54565852
check c++ vector.
>>54565870
I don't know the name of what you'd call a cunk of memory with a pointer at the end pointing to the next chunk of memory?
Is it just called a linked list still?
Reallocs at the wrong time is a bother.
>>54565895
It's still at linked list.
And it's a popular way to implement the world's slowest malloc.
>>54565895
thats why you prealloc more memory than needed and grow it for eg. using powers of 2, so as more data you have fewer reallocs you do
>>54565935
This.
Few things are slower than a linked list, and few things are faster than a vector.
>>54565935
Yeah well duh. Still a bother though.
I mainly stick to pools for this reason.
Very little reason not to use them where you're allocating memory usually. Since you probably don't have a memory allocation plan that actually grows your allocated memory in a permanent fashion.
>>54565935
>vector of 1gb totally full
>add one more element
>>54565981
In such situation you have studied your program and did preallocation.
>>54565981
well you obviously have to realloc if you use my example
>>54565996
has a point
>>54565996
Or study your program and use linked lists like someone who isn't a cargo cult faggot.
>>54566047
1gig, it's big data, and it means preallocation
>>54566047
but linked list is slower why would you use it?Lookup is O(n), access is O(n)....
>>54566068
Yep cargo cult faggot. The big data might have a lot of variance. In that situation good trade off is a linked lists of arrays of a few mb.
If you can preallocate then you should never ever use vectors.
>>54566128
>If you can preallocate then you should never ever use vectors.
We're talking about arrays, not vectors.
>>54566128
Shouldnt you use hashmaps or trees for big data?
>>54566153
It really depends on the situation.
>tress for big data
>arrays for small data
Is excessively simplistic.
>>54566208
>tress
What's that?
>>54566208
Well ofc but in any case you wouldn't use linked list.
Is there any reason to use linked list at all? I used them only as an entry into data structures, since then i only used arrays or maps.
>>54566273
Yes. Head and tail insertion speed destroys everything else. Sequential removal obliterates everything else. To do removal in an array you have to shift the remaining bits.
>>54566347
t. data structures class
Does the C++ standard library use malloc under the hood?
If not, what does it use and how can I access it?
And I'm not talking about new, new isn't the allocator itself, it calls an allocator, and I want to know what that is.
>>54566414
you learn about circular arrays in most data structures classes
>>54566347
Okay insertion is fast but you arent only inserting you probably mostly do stuff with data, you dont shuffle it around much after you store it. I guess it depends, I could see it being useful if you have large amount of insertions. But with growable Also arrays are O(1) with insertions
>>54565870
>You can grow array. realloc
What if you want to insert an object into a specific position?
>>54564474
You cannot write a function in Java that is not inside of a class.
Java is forced OO, deal with it.
>>54563421
>good luck making a non-trival actual program and not just babby's first little script
have you ever looked at your typical linux distro? many programs, even some critical system programs, are made in python.
>>54566475
you'd have to reshuffle and maybe realloc + copy.
>>54566452
Growable arrays have the problem of having to be realloc'd. So they're fine most of the time then suddenly there's a big fucking spike. And that spike might be big enough real a real fucking problem to happen, or the realloc could fail.
>>54566415
malloc itself is implemented using whatever function you need to use for your platform.
Which is VirtualAlloc on Windows iirc. I assume that the STL on windows would use VirtualAlloc.
>>54566526
Scratch that. It actually uses HeapAlloc on windows.
>>54562612
>The updates would download at 8MiB/s, but the disk usage was just going nuts.
dumbass, steam is to blame for that. even on linux, steam uses a shitload of disk space, even more than what it's supposed to use.
>>54564607
Recursion is easy to understand.
It's just a huge meme.
>>54566525
Im convinced. Now why wouldnt you use btree or avl tree instead? log(n) for pretty much everything and no spikes.
>>54566563
>huge meme
Why? Please develop I want to laugh.
>>54566601
Iteration is superior 100% of the time.
You never ever need recursion.
>>54566574
For btrees sequential access on large data sets becomes more expensive as you have to travel back up a lot.
>>54566617
>Iteration is superior 100% of the time.
No. And there are some cases where recursion with tail call is superior to iteration (except if you use goto and label).
>>54566638
yes you are right, could use avl tree but its a pain to implement.
isnt cache missing a problem with linked lists since they are sparse in memory?
>>54566653
Recursion with tail call can only ever be the same as iteration, not superior.
Iteration is way more clear about what's going on, and it is better performing than recursion 100% of the time, and doesn't tip fedoras in your code.
>>54566574
judy array
>>54566709
Cache missing is a problem with trees too. Trees are essentially just nested linked lists anyway.
>>54566735
Yes i know i was thinking about array vs list case... My writing skills suck today.
>>54566713
No. With tail call recursion, you can switch between two iteration loops. The equivalent in iteration would be the sue of goto and label. Sorry, but anything iteration can do recursion can do. But iteration needs goto and label to catch up with recursion.
STFU, you're ignorant. You shoudl already know that, but you're ignorant and don't event understand what you should already know.
>>54566483
do you even know what object oriented programming is? classes with only static methods have nothing to do with OOP. the class acts just as a namespace then
>>54566765
Just remember, when writing performance needed code, always profile my anon.
>>54566916
Ah yes, imagine a world where you could just look at big O table and see which data structure to use? Why cant it be easy?
>>54564249
>what is Rust
>>54564534
>Is it the star for deference syntax that fucks with people?
yes, the syntax is fucking retarded as shit and it was what made it not an immediately understandable concept for me (at the very least). the actual concepts of pointing to an address in memory is not that difficult
>>54564607
>Why is recursion so hard for people?
it's not, it's like easiest thing ever
>>54564887
why do you need an explanation to understand the concept of a function calling itself? how is it any harder than a function calling to another function?
>>54565209
not really, it came natural to me as soon as i tried it the first time. and ever since then it's seemed a lot simpler to me than iteration 90% of the time
>>54567021
I think out of the 3 tripfags I regularly in /dpt/ see you're the most retarded.
>hurr its ez for me its ez for everybudy
l2theoryofmind
>>54566047
lol, fucking idiot, a 1 GB linked list would be ridiculously slow
>>54567021
>why do you need an explanation to understand the concept of a function calling itself? how is it any harder than a function calling to another function?
There are 2 or 3 implications, mainly base case, but the biggest problem is the mental model, see >>54564689
>>54566491
>have you ever looked at your typical linux distro?
kek'd irl
linux is a fucking joke
>>54567167
i guess i can see that being the case
kinda like how when people try making a game the first time they dont plan it out well to be able to reset all the state at first, i guess people would just have it set up a bunch of mutable state in the function the first time thinking it's not gonna execute during the next call
i think the base case is objectively easier than the condition for iteration (at least if the syntax doesn't make it retarded). like with for loop syntax in languages like C, you have to actively think about whether each value is going to be used (i.e. is this loop inclusive?) and that's the cause of so many off-by-one errors (which i'd argue cease to exist once one understands recursion)
>>54567098
the paper someone linked about it being difficult to grasp was about children, i think anyone who's had decent exposure to math should be able to understand the idea behind recursion
btw thanks for the compliment :^3
>>54566769
>goto and label
fuck off, kid
>>54567157
What if each node is 100MB and it's a linked list of 10 items?
>>54567260
>decent exposure to math
And that's why you're an idiot. Most people have had horrible exposure to math.
>>54567306
Here we are. The ignorant think his advice if relevant.
Im bored so:
c++ vector vs java vector and why?
>>54567319
then a size 10 array of pointers would still be much faster, fucking idiot
>>54567260
Good points OSGTP. Once you get past the recursion bump -- and there will be bumps no matter what -- you won't run into off-by-ones. And mathematical thinking is good anyway, "Everyone should learn to program a computer because it teaches you how to think", Steve Jobs before he joined the dark side. SICP and LYAHFGG both introduce recursion well enough (IMHO, thoughts?), and they're the best books there is so...
>>54567440
>java vector
it hasn't been used by anyone in the last decade
>>54567484
>Good points OSGTP.
That's not me, my dude.
>>54567488
Hey its obviously used by java today!
>>54567521
it's basically deprecated
>>54567507
Kill me. No, rather you tripfags kill yourselves.
Love y'all
t. Hime
>>54567543
Bad question i guess since answer is obvious. Seriously tho who thought that java vector would be good idea?
>>54567546
Absolutely rude and uncalled for.
>>54567440
>c++ vector vs java vector
One is in a language I use one isn't.
>>54565445
Please respond.
>>54565484 this was me btw, not the reason for the segfault.
>>54566347
>To do removal in an array you have to shift the remaining bits.
If you don't care about sequence in the array, you don't have to.
If you do care, you wouldn't be removing elements anyway.
>>54567975
If you don't shift the shit it's no longer an array and no longer has O(1) lookup time. Hell you could say the concept of lookup becomes incoherent. And that only works if your array has a NULL value. An array of integers has a NULL value only if you're working with nonzero integers.
>>54568168
>it's no longer an array
wtf are you talking about? just take the last element and overwrite the "removed" element