Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Maintenance is complete! We got more disk space.
Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 97 KB, 736x703, 1508083630301.jpg [View same] [iqdb] [saucenao] [google] [report]
62923737 No.62923737 [Reply] [Original] [archived.moe] [rbt]

Old thread: >>62915957

What are you working on, nyaa?

>> No.62923762 [DELETED] 

I wish I had friends

>> No.62923770

>>62923742
And?

>> No.62923777

nth for opengl brainlets

>> No.62923789

>>62923737
im trying to get a girlfriend at the moment

>> No.62923791

>>62923737
nothing
bingewatching cppcon

https://www.youtube.com/watch?v=JYG5LFHkUuE

>> No.62923818

>stuck on OpenGL 2.1
>mesa drivers support random extensions that exist in OpenGL core 4.0+
>I can write a shitty mix of glBegin and shader code if I want

What should I target?

>> No.62924030
File: 33 KB, 664x724, 2017-10-15-194329_664x724_scrot.png [View same] [iqdb] [saucenao] [google] [report]
62924030

Working on a tiling algorithm/system for a window manager I've written in C. Lots of fun. Also starting to learn kernel basics, my copy of the MINIX book is on the way and I'm reading a few babby's first kernel resources. Also touching up the code for my 4chan bulk image downloader, also in C

>> No.62924102
File: 19 KB, 600x340, CbHCbDUWEAA3WFm.jpg [View same] [iqdb] [saucenao] [google] [report]
62924102

>working on an old project of mine and it's so bad an inconsistent I just want to resign and cry myself to sleep
I wish I were a good programmer

>> No.62924151

>opengl lacking behind dx for decades
>only good quality is it is cross platform
>vulkan happens
opengl fags on suicide watch

>> No.62924253

>>62923818
OpenGL 2.1 has vertex buffers.

>> No.62924369

>>62924151
Except plenty of developers (including Valve) have said OGL implementations outperform DX.

>> No.62924389

khronos hurry the fuck up and give us multi gpu

>> No.62924570

>>62924030
>ywn be this good
Why even bother
Just end me

>> No.62924730
File: 99 KB, 448x537, 1477875882841.jpg [View same] [iqdb] [saucenao] [google] [report]
62924730

https://hexus.net/tech/news/software/105895-vulkan-opencl-will-merge-single-api/

>> No.62924808

Reviewing the source of a wayland compatible window manager written in 100.0% Rust.

https://github.com/Drakulix/fireplace

>> No.62924815
File: 28 KB, 600x800, 123812738172983.jpg [View same] [iqdb] [saucenao] [google] [report]
62924815

>>62924730

>> No.62924892

>>62924808
Do you program in rust or are you just interested in learning? I've actually been looking at that wm as well, kind of as a jumping off point to get into more serious/larger scale rust code once I'm comfortable with the basic stuff

>> No.62924943

Does anyone know if c# has a method somewhere that basicly does the following:
//if (expr1) return -1;
//if (expr2) return 1;
//return 0;
int SomeFunction(bool expr1, bool expr2) => expr1 ? -1 : expr2 ? 1 : 0;


This is what I am currently using. But I was hoping there would be a build in method for this.

>> No.62924949

>>62924892
Yeah, I'm in the middle of the rust book myself, just wanted to see how people do low level things. It's pretty nice actually.

>> No.62925128

On codefights.com you can go head to head with a random person in a codewriting competition. You can also go against a bot. How can there be a code writing bot? Theres no way they are fuzzing a correct solution right?

>> No.62925144

>>62925128
they probably just arbitrarily slow down type-writer text

>> No.62925178

>>62925144
They are talking about "engineers working on them" and its all in a serious tone. Like it really sounds like marketing bullshit, but their audience is actual programmers, I dont get it.

>> No.62925193

>>62925144
I guess its supposed to be taken as a joke.

>> No.62925241

/dpt/, I'm a beginner in assembly and I'm terribly confused about how to do loops

I'm trying a simple division program, trying to divide 2 numbers, 7 and 3 as a test

mov r3,#0 @loop counter
.loop:
cmp r0,r1 @loop while r0-r1 > 0
sub r0,r0,r1 @store in r0 the subtraction of r0 and r1
add r3,r3,#1 @add 1 to loop
ble .loop @loop while cmp is less equal?


IDK how the loop conditions work or how it's checked, I'm doing this trying to figure it out but fuck.

>> No.62925334

Can you write a function with variadic generics in Rust? Or emulate it with macros or something

>> No.62925352

How do I write multithreaded applications with OpenGL?
The state machine design pretty much limits drawing to a single thread only.

>> No.62925415

>>62925352
Only draw from one thread.

>> No.62925449

>>62925241
you should cmp before ble

>> No.62925477

>>62923789
What steps are you taking to achieve this?

>> No.62925544

>>62925449
For some reason that only loops once...
E.G if I run 7 R0, and 2 R1 I get 5 (7-2=5).
It should keep looping until R0 is less than R1, IDK why it's not though.

>> No.62925570

Does anyone have the answer key for the PSM1, or at least know where I can get it? This is serious, I don't have money to waste if I fuck up on it

>> No.62925662

>>62925352
you can't
just prepare all your resources as much as possible on different threads before handing them over to the rendering thread

>> No.62925801

https://www.youtube.com/watch?v=RwdQA0pGWa4&list=PLGvfHSgImk4acseLJnjc6_QUPvxVmjm7o

>> No.62925888

>>62925801
UMA

>> No.62926053

>>62924730
who even uses opencl anyway

>> No.62926062

>>62924151
>vulkan is cross-platform
lmfao

>> No.62926079

>>62926062
Which GPU API is more portable than Vulkan?

>> No.62926087

>>62926079
opengl es

and vulkan is only marginally better (<40%) for performance at 10x the development cost of opengl

>> No.62926282
File: 35 KB, 1024x576, 56e15f04dd0e4c75a2c3e577e942210c8c9a392d_hq.jpg [View same] [iqdb] [saucenao] [google] [report]
62926282

I'm trying to generate a natural-seeming 2D tile-based map with no less than 250 000 (500 x 500) tiles.

How do I go about this?

>> No.62926303

>>62926282
for each tile, randomly decide if the title is in land or in water.

>> No.62926304
File: 146 KB, 1200x1138, CnMNL9tXEAAojDE.jpg [View same] [iqdb] [saucenao] [google] [report]
62926304

>>62926282
by not posting chinese cartoons you dumb dweeb

>> No.62926356
File: 111 KB, 500x500, 1350594293765.jpg [View same] [iqdb] [saucenao] [google] [report]
62926356

>>62926303
But just randomly deciding will not make the map natural.

>> No.62926361

>>62926356
if the map is not natural, reject it and try again

>> No.62926401

Why segfault?
#include <stdio.h>

int * read_data() {
int three[3];
scanf("%d", three + 0);
scanf("%d", three + 1);
scanf("%d", three + 2);
return three;
}

void print_data(int * data) {
for(int i = 0; i < 3; i++)
printf("%d ", data[i]);
puts("");
}

void print_data_reverse(int * data) {
for(int i = 2; i >= 0; i--)
printf("%d ", data[i]);
puts("");
}

int main() {
int * data = read_data();
print_data(data);
print_data_reverse(data);
}

>> No.62926464
File: 11 KB, 286x307, Untitled.png [View same] [iqdb] [saucenao] [google] [report]
62926464

Can someone please explain this to me? Why does preallocating my array take MORE time than not doing so?

>> No.62926493

What conferences do you guys attend/watch?
I recently found myself listening to shit like defcon and black hat
Only programming one i know is cppcon, but that's hardly useful since I dev with php backend

>> No.62926514

>>62926464
>push
what do you think this function does when you have an array of length 5?

>> No.62926515

>>62926464
I am 85% sure that you're still appending to the array on the second one

>> No.62926532
File: 63 KB, 600x600, 903812389123.jpg [View same] [iqdb] [saucenao] [google] [report]
62926532

>>62926493
webshit pls go

>> No.62926556

>>62926401
Look up RAII and you'll find out why

>>62926532
unemployed pls go

>> No.62926560
File: 5 KB, 243x119, Untitled.png [View same] [iqdb] [saucenao] [google] [report]
62926560

>>62926514
>>62926515
Thanks. This really made me think.

>> No.62926601

>>62926556
But I'm using C.
Srs, what went wrong?

>> No.62926618

>>62926601
Here's a better hint
Look up RAII and scope and you'll find out why

>> No.62926657

>>62926401
three is stored on the stack, and you returned a pointer to it. When you called printf you overwrote the memory location previously occupied by three with printf's stack data. You then attempted to dereference it, and ended up dereferencing an address that wasn't in the process' virtual address space. This triggered a segmentation fault.

>>62926556
This has nothing to do with RAII. In fact, that code could just be C, which doesn't have it.

>> No.62926705

>>62926657
>Resource Acquisition Is Initialization
>resource allocation(or acquisition) is done during object creation (specifically initialization), by theconstructor, while resource deallocation (release) is done during object destruction (specifically finalization), by thedestructor.

Replace object with array and you get why. The array was destructed as soon as it hit end of scope and it only passed a pointer

>> No.62926727
File: 18 KB, 735x713, Untitled.png [View same] [iqdb] [saucenao] [google] [report]
62926727

Pictured is a 4x4 array of arrays. Where is element [0][0]? What are the indices of the blue, green and red elements? How would (you) order this grid?

>> No.62926728

Assuming someone has a fast CPU, is it always faster (in terms of IO, specifically reads) to use compressed data?

Data would be compressed on writes(slower than raw writing probably), and thus smaller, so when loading it should be faster to go from disk->memory, as long as the CPU can handle the decompression algo quickly, right?

>> No.62926741

>>62926728
this makes sense to me

>> No.62926754

>>62926727
origin is top-left

>> No.62926760

>>62926705

I'm pretty sure you can't rightly call the automatic deallocation of stack memory "RAII."

>> No.62926768

>>62926556
no RAII in C lol

>> No.62926795

>>62926760
>>62926768
uses the same principles brah
And besides, nobody should be coding in a deprecated language anyway

>>62926728
Loading into ram would be quicker and that's pretty much it. Nothing reading and writing would be slower because of how segmented things get in lz compression. And it'll definitely be a headache in multi threaded applications

>> No.62926805

>>62926705
No destruction going on. The stack pointer is just being set to the frame pointer.

>> No.62926809

Trying to learn OpenGL.

Which library does /g/ recomends? SFML? GLFW? SDL?

Also, tutorials or something would be helpful. No "read the documentation" please, already tried, it's unbearable.

>> No.62926812

>>62925544
https://community.arm.com/processors/b/blog/posts/condition-codes-1-condition-flags-and-codes

>> No.62926813

>>62926809
I use SDL. It's good enough. No experience with the others.

>> No.62926817

Python3, Kafka, Spark. Doing some distributed computing and message queue work.

>> No.62926818

>>62926809
To add onto this, which linear algebra library is good? glm is c++ and I want to work in c.

>> No.62926844

>>62925334
Macros are the only place where Rust has variadic arguments of any kind, but you can use them to build recursive types and then use the trait system, which is Turing-complete, to introspect them.

Example: https://github.com/cristicbz/rust-doom/blob/master/engine/src/type_list.rs

>> No.62926845
File: 60 KB, 960x720, slide_60.jpg [View same] [iqdb] [saucenao] [google] [report]
62926845

>>62926727
like pic related

transpose of this:
http://reference.wolfram.com/language/howto/CreateAMatrix.html

>> No.62926846

>>62926809
They won't teach you opengl lad, theyre wrappers.
If you want to learn it, you should write one yourself.

>> No.62926855

>>62926809
try this as a babby-tier introduction but you're going to have to read the documentation and the actual spec

https://open.gl/

>> No.62926864

>>62926809
Don't bother. Skeletal animation is virtually impossible to implement.

>> No.62926910
File: 669 KB, 900x506, 093128391283.png [View same] [iqdb] [saucenao] [google] [report]
62926910

>>62926809
None.
Just grab glLoadGen for your loaders, pull in winapi, and go to town

>> No.62926925

>>62926910
I got really excited when I saw your post because I like doing things as completely from scratch as I can but then I remembered I can't be bothers to program at all right now. Why is doing things so hard and not worth it?

>> No.62926956
File: 299 KB, 700x700, 903128938123921.jpg [View same] [iqdb] [saucenao] [google] [report]
62926956

>>62926925
Because you're a lazy piece of shit. Now get to work and impress me. Remember your programmer gear

>> No.62926967
File: 356 KB, 1200x1200, 1423520938212.jpg [View same] [iqdb] [saucenao] [google] [report]
62926967

>>62926956
What should I make?

>> No.62926986

>>62925477
Wearing programming socks

>> No.62926993
File: 50 KB, 600x800, 839182391283.jpg [View same] [iqdb] [saucenao] [google] [report]
62926993

>>62926967
Implement atmospheric scattering

>> No.62927008
File: 342 KB, 1204x960, sccg10_3.png [View same] [iqdb] [saucenao] [google] [report]
62927008

>>62926993
>>62926967
Also it has to look at least as good as this

>> No.62927009
File: 32 KB, 256x256, 1419669638912.png [View same] [iqdb] [saucenao] [google] [report]
62927009

>>62926993
That's too vague. I can't be bothered.

>> No.62927029
File: 33 KB, 1403x639, 432948239.jpg [View same] [iqdb] [saucenao] [google] [report]
62927029

>>62927009
See >>62927008

>> No.62927047
File: 327 KB, 4000x2250, 1425359149791.png [View same] [iqdb] [saucenao] [google] [report]
62927047

>>62927029
Anon, I just said I'm fucking lazy. You expect me to do this bullshit right off the bat? At least build up to it or something.

>> No.62927059

>>62927047
build me a sun renderer where i can play with time of day and lighting and intensity.

>> No.62927071
File: 106 KB, 1200x858, CoPgYxVXgAQ800T.jpg [View same] [iqdb] [saucenao] [google] [report]
62927071

>>62927047
Did I say it was easy you scrawny little shit? You set up a big goal and work towards it. It's the carrot on a stick. Now scram.

>> No.62927073

>>62927059
Yeah do this one

>> No.62927084
File: 188 KB, 700x709, 1422500682786.png [View same] [iqdb] [saucenao] [google] [report]
62927084

>>62927071
Carrots only work when you can see them dangling in front of you.

>> No.62927108
File: 209 KB, 798x598, templeos.png [View same] [iqdb] [saucenao] [google] [report]
62927108

Why do the 3d objects in TempleOS have such a grainy appearance instead of having just flat colors?
Does he apply a sort of noise effect on purpose?

>> No.62927112

/*
* wc.c
*
* Created on: Sep 8, 2017
* Author:
*/


#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
#include <string.h>
//node struct
typedef struct node {
char * word;
int count;
struct node * next;
} Node;

static Node * makeNode(char * newWord, Node * next){
char * nWord = newWord;
Node * newNode = (Node*) malloc(sizeof(Node));
newNode->word = nWord;
newNode->count = 0;
newNode->next = next;
next = newNode;
return newNode;
}
static Node * findNodeForWord(char * findWord, Node * findNode){
Node * current = findNode;
if (current->next == NULL ||(strcmp(current->next->word,findWord) > 0) ){
current->next = makeNode(findWord,current->next);
return current->next;
}
else if(strcmp(current->word,findWord) != 0) {
findNodeForWord(findWord, current->next);
}

return current;
}
static void printList(Node * head){
if(head == NULL){
printf("end");
}
else{
printf("%-10s, %1d", head->word, head->count);
printf("\n");
printList(head->next);
}
}
int main(void){
Node * head = makeNode("", NULL);
FILE *fp = fopen("Syllabus.txt", "r");
setbuf(fp,0);
char line[100];
char *lp = line;
char c = getc(fp);
char * word;
while (c != EOF){
if(isalpha(c)){
*lp = c;
lp++;
c = getc(fp);
}
else{
*lp = '\0';
word = malloc(strlen(line)+1);
strcpy(word,line);
Node * node;
node = findNodeForWord(word, head);
node->count++;
lp=line;
c = getc(fp);
}
}
printList(head);
}


This is creating a duplicate node for words. Say there are 5 of the same word, it keeps making nodes and it is not supposed to. It is supposed to go through the link list and find the node and not do anything.

>> No.62927130
File: 68 KB, 640x360, 04cfe2f9b720ff04dbfb5db57d190ade1468357575_full.jpg [View same] [iqdb] [saucenao] [google] [report]
62927130

>>62927108
The noise comes from his connection with God

>>62927084
You're disappointing me faggot

>> No.62927137
File: 146 KB, 850x850, 1460001220748.jpg [View same] [iqdb] [saucenao] [google] [report]
62927137

>>62927130
Give me something easier! Also I do better with positive reinforcement!

>> No.62927152
File: 46 KB, 778x438, 90218390128312.jpg [View same] [iqdb] [saucenao] [google] [report]
62927152

>>62927137
Some other anon suggested >>62927059
Good build up for the proper thing
Also positive reinforcement is for homos and women

>> No.62927155

>>62926813
>>62926818
>>62926846
>>62926855
>>62926864
>>62926910
Thanks god. I actually hated the idea of using them, but normies be like "that's too difficult, use this shit instead". I'd rather make things from scratch

>> No.62927163
File: 191 KB, 500x500, 1420553077823.jpg [View same] [iqdb] [saucenao] [google] [report]
62927163

>>62927152
That's too hard though. Give me something easier. It doesn't even need to be opengl related.

>> No.62927171

>>62923737
Trying to come up with an art style that is interesting and that will allow me to use widely different art assets without the player noticing. Low light, black unlit models. The idea for the game is a combination of Fallout Shelter with twitchy mind-upload missions from Worldwide Communist Gangster Computer God where you can permanently lose your precious dudes.

>> No.62927189
File: 432 KB, 1557x718, fhhfhhfhfg.png [View same] [iqdb] [saucenao] [google] [report]
62927189

>>62927171
forgot pic

>> No.62927204
File: 47 KB, 637x579, 1505648216378.jpg [View same] [iqdb] [saucenao] [google] [report]
62927204

>>62927163
If you're not willing to challenge yourself you're never gonna make it, and you'll be stuck in brainletdom. You might as well download unity right now

>> No.62927219
File: 264 KB, 850x850, 1417957325721.jpg [View same] [iqdb] [saucenao] [google] [report]
62927219

>>62927204
I don't think I'm dumb I can't can't be bothered to do anything. I want to do stuff though it's just too much work. Maybe I should just give up and do some shitty webdev job.

>> No.62927232

>>62927163
Write a crawler that lurks /dpt/, and recognizes and downloads images of cirno using neural networks

>> No.62927233
File: 96 KB, 400x400, 1499404611227.png [View same] [iqdb] [saucenao] [google] [report]
62927233

>>62927219
Please do not post that dog while sad.

>> No.62927251

>>62923818
Vulkan

>> No.62927262
File: 668 KB, 1000x1000, momiji2.png [View same] [iqdb] [saucenao] [google] [report]
62927262

>>62927233
I wanna fucking kill myself every day. Life is a bother and there's no reward or worth to it.

>> No.62927446

>>62927112
else if(strcmp(current->word,findWord) != 0) {

findNodeForWord(findWord, current->next);


I believe the error is in here but reading this back it should work.

Also sorry I didn't state this before but this is a word count program.

>> No.62927453

>>62923791
You should watch the Ansel Sermersheim talk on multithreading. It'

>> No.62927496

>>62927262

You have to find what is "worth it" in life just like everyone else before you. What gives you the audacity to think you have a right to end your life when countless generations before you managed to weather it out to the end?

>> No.62927506

>C++'s modules spec is headed by an african nignog cowboy who works at MS
ripip

>> No.62927664

>>62927506
C++ is entirely microgarbage.

>> No.62927679
File: 74 KB, 512x512, 1434113251014.jpg [View same] [iqdb] [saucenao] [google] [report]
62927679

>>62927496
Because the problems they faced were easier to solve. "I'm hungry" "eat", "I'm thirsty" "drink", "life is empty and everything I do lacks any worth to me outside of escapism to a better existence" "...".

I wish I had real problems but instead of I'm just a lazy faggot.

>> No.62927776
File: 66 KB, 250x273, 1501231103584.png [View same] [iqdb] [saucenao] [google] [report]
62927776

How do I program computers?

>> No.62927785

>>62927776
just pick a language lad

>> No.62927940
File: 510 KB, 756x720, g.png [View same] [iqdb] [saucenao] [google] [report]
62927940

>>62927506
whaddya say boi

>> No.62928058
File: 3 KB, 210x25, 2017-10-15--1508136287_210x25_scrot.png [View same] [iqdb] [saucenao] [google] [report]
62928058

how do i write the circle with a line through it or whatever that is

>> No.62928063

>>62927776
here you go lad

>> No.62928065
File: 58 KB, 600x400, 1500576257114.gif [View same] [iqdb] [saucenao] [google] [report]
62928065

In JavaScript, I have a one-dimensional array of length x * y.

var myArray = new Array(x * y);
populate(myArray);


How do I split this array into a 2-dimensional array?

myArray2D = pure2DArrayFu(myArray);
console.log(myArray2D.length); // Output: x

>> No.62928069

>>62928063
*https://automatetheboringstuff.com/chapter0/

>> No.62928094

>>62928065
myarray = [];
for (i = 0; i < x; i++) {
myarray[i] = [];
for (j = 0; j < y; j++) {
// if you want to initialise them
myarray[i][j] = 0;
}
}

>> No.62928116
File: 36 KB, 809x390, C5S95ikWIAAS_zg.jpg [View same] [iqdb] [saucenao] [google] [report]
62928116

>>62928094
Thanks! I want to marry my arrays now!

>> No.62928123

>>62928058
It's @, you mong

>> No.62928139

>>62928123
its obviously not an @

>> No.62928169

>>62928058
radius?

>> No.62928190

okay it might have been an '@'
still want to use cool unicode characters though

>> No.62928191

>>62928139
looks like a squished @ to me

>> No.62928198

>>62927679

If you have no real problems, you have no reason to kill yourself. Eat, shit, work, play, sleep, repeat. Is that so hard?

>> No.62928213

>read one side of coding tutoral

good enough. im ready to go shitpost on /g/ now.

>> No.62928217

>>62928198
You're right that not having a reason to live isn't a reason to die but that doesn't make it worth doing.

>> No.62928277
File: 84 KB, 807x1429, 1507901771954.jpg [View same] [iqdb] [saucenao] [google] [report]
62928277

What are your code style pet peeves?
>using 'we' in documentation excessively
>copying mathematical symbols like "theta", "delta", dx, xs
>function calls split across multiple lines
>macros that pretend to be functions and copy paste expressions hundreds of times and bloats up the binary

>> No.62928390

Man, the C++ team sure get flustered when somebody brings up how language X already solved Y problem.

>> No.62928418

char buf[50] = {0};
scanf("%s", buf);

How come this works? Isn't buf[] stack allocated and local to the function? How can scanf() write to it?

>> No.62928425

>>62926282
Perlin noise heightmap, then add water to all tiles <50% height

>> No.62928451

this spaces instead of tabs and column matching the ghci tries to enforce is disgusting desu

>> No.62928459

>>62928418
because buf is still in memory, it hasn't been deallocated yet because the function hasn't exited its scope yet.

>> No.62928497

>>62928277
Unneeded localization. Writing really retarded code that leaks memory and hoping the compiler fixes it. while/if/for without {}. rand() fuckups (srand(rand()) is a classic). Excessively large comments. Excessively large variable/function names, especially local. "f(type arg) {". "f\n(type arg)". "while/if/for\n(expr)"

>> No.62928546

>>62928418

Because you passed a pointer to its first element.

>> No.62928636

>>62928546
Yes, but isn't accessing stack allocated memory via pointer outside of its scope UB?

>> No.62928645

>>62928418
Because pointers.
Also, don't use an unrestricted %s in scanf. It's vulnerable to buffer overflows.
Use fgets or use it like scanf("%49", buf);

>> No.62928649

>>62928645
>%49s
I mean

>> No.62928658

>>62928636
I don't think you understand what lexical scoping is; or the stack for that matter.

>> No.62928666

>>62928636
It's not out of scope in the example you posted

>> No.62928675

Im looking for a way not to use #defines anymore in my C++ programs (except for the headers declaration), Ive looked around for a solution to my issue, but no luck so far:
How would you translate
#define REP(i,a,b) for(auto (i) = (a); (i) < (b); ++(i))
in pure C++?

>> No.62928678

>>62928645
I wouldn't use scanf anyway, this was just a quick example.
>>62928658
>>62928666
Does it go out of scope when the function returns, not just when we're no longer inside the function?

>> No.62928694

>>62928678
It goes out of scope when the function that the stack variable was defined in ends.

>> No.62928698

how useful are programming books ?
I am a decent programmer, but I could use some more practice/studying
I do C mostly, what book should i try ? SICP ?

>> No.62928706

>>62928678
In the example you posted there is no returning or ends of functions.

I get the feeling you're talking about your code as if we have it, but you only posted a two-line snippet that doesn't show us anything about scope.

If the lines in the example you gave are actually consecutive in your real code, then of course they're in the same scope because no block has ended between them.

>> No.62928711 [DELETED] 

>>62928694
>>62928678
Actually, scope can be misleading. It is only in scope inside the function it was defined in, you just passed the pointer to it, which is in the stack. That value hasn't been popped off the stack yet because the function it was defined in hasn't exited yet.

>> No.62928727

>>62928675
There isn't really a direct answer to your question but C++ iterators and for each loops are a nice abstraction over basic for loops.

>> No.62928730

>>62928675
don't do that, all you're doing is ghetto syntactic sugar for a for loop which harms readability, and it's perfect for #defines
>>62928706
int main()
{
char buf[50] = {0};
scanf("%s", buf);
return 0;
}

Like that.
>>62928711
So scope only closes on the way out/up?

>> No.62928733
File: 19 KB, 586x203, contours.png [View same] [iqdb] [saucenao] [google] [report]
62928733

>>62928678
pic related

>>62928698
For lisp do SICP -> On Lisp -> Let Over Lambda ->(and bonus) Lisp in Small Pieces

>> No.62928735
File: 37 KB, 278x278, 1502344586073.jpg [View same] [iqdb] [saucenao] [google] [report]
62928735

How does this work?

seed = (seed * 9301 + 49297) % 233280;
rng = seed / 233280;

>> No.62928749

>>62928730
Do you know how a stack works? It is First In, First Out. When you call a function, variables get put in the stack, and only get deallocated when they're at the top of the stack and the function ends. The variable buf is still in scope and can still be referenced by other functions further up the stack. But once the function buf was defined in ends, it will get deallocated.

>>62928735
It uses linear randomization. Learn basic group theory.

>> No.62928754

>>62928749
>>62928735
I mean:
https://en.wikipedia.org/wiki/Linear_congruential_generator

>> No.62928757

>>62928730
In that example, what would possibly make you think that buf goes out of scope before the scanf?

>> No.62928788

>>62928277
>function calls split across multiple lines
Yeah much rather have to scroll horizontaly, that's so much better

>> No.62928789

>>62928735
rng is float, right?
0 <= seed < 233280 (seed is 0-233280), guaranteed by modulus, so rng is guaranteed to be 0 <= seed < 1.
9301/233280 = 25.08, so if seed > 25 the output is "basically" randomly distributed. The +49297 part ensures that.
It's not a very good rng, but good enough.
>>62928757
I understand now, scope only exits on the way up/out? I thought it was only in scope while in main(), and that scope exited both after return and function call.

>> No.62928803

>>62923737
>otome shit

Somehow I doubt OP intended to make a thread with cat trap boys, but I doubt OP would dislike this revelation.

>> No.62928806
File: 34 KB, 540x390, 1499765932226.jpg [View same] [iqdb] [saucenao] [google] [report]
62928806

Has anyone ever programmed in SETL? Do you think it could be useful for implementing parallel algorithms?

>> No.62928813

>>62926809
>No "read the documentation" please, already tried, it's unbearable.

you are the example of people who only like tutorials and in the end when they write a project, write a shit filled with aids documentation.

fuck off.

>> No.62928826
File: 231 KB, 391x311, 1449787969871.png [View same] [iqdb] [saucenao] [google] [report]
62928826

>>62927776

>> No.62928838

>>62928788
It's only acceptable when you have something which 1) naturally can be organized in a n x m grid 2) have long names
for example (horrible example, seriously hope you guys don't do this)
bool collision = areColliding
(playerArray[i]->x, playerArray[i]->y, playerArray[i]->z,
playerArray[j]->x, playerArray[j]->y, playerArray[j]->z);

>> No.62928843

How do I write a good API? I'm writing a simple linear algebra library in c and it's getting shit fast.

>> No.62928903

>>62928843
Think about usage code first, then write your API.

>> No.62928939

>>62928903
Even better, write some usage code.

>> No.62928944

>>62928903
>>62928939
What if I don't know how to use it?

>> No.62928965

>>62928944
Why would you bother writing it?

>> No.62928970

>>62928965
Because I need to use it?

>> No.62928983

>>62928970
Are you autistic?

>> No.62928985

>>62928983
I'm just not as good at maths as I should be.

>> No.62929007

>>62927108
It's probably dithering

>> No.62929018

>>62927108
yes he applies random noise when he draws them
where's the footage of the racing game?

>> No.62929027

https://git.musl-libc.org/cgit/musl/tree/src/prng/rand.c
https://git.musl-libc.org/cgit/musl/tree/src/prng/rand_r.c
What the fuck is going on here? Why aren't they just using xorshiro or xorshift proper which are both both faster and better?

>> No.62929077

>>62929027
>c will never just have
import std.random : uniform;
auto r = uniform(0,11);

>> No.62929092

>>62929077
It abolutely will: http://en.cppreference.com/w/cpp/experimental/randint

>> No.62929099

>>62929092
tfw doesnt work on my machine

>> No.62929102

>>62929092
>experimental
Now we wait for it to be moved into the std

>> No.62929123

>>62924943
what exactly is the usecase of this function that you would justify it being a builtin

>> No.62929126

>>62929077
#define RANGE_RAND(a, b) (a+(b-a)*rand())
Someone should make a "psuedo-standard" library for C, like a common and heavily optimized util.c.

>> No.62929132

>>62929126
>macros
absolutely gross

>> No.62929138

>>62929126
fuck
#define RANGE_RAND(a, b) (a+(((b-a)*rand())/RAND_MAX))

there we go
>>62929132
It should be inlined though.

>> No.62929139

>>62929126
RANGE_RAND(i++, j)

>> No.62929151

>>62929138
Then make it an inlined function.

>> No.62929161

>>62929092
>C++
>>62929126
Yeah now hand me a macro defining Gauss distribution.

>> No.62929168 [DELETED] 

I trying to write a program in python that would take a string, reverse it, then rearrange it such that the character at [0] and [length-1] would be the first and second letters, then [1] and [length-2] would the third and fourth letter and so on. I keep getting an index out of range error for the line
s1 = s[0]+s[len(s)-1]

within the while loop. however, if i print this line before the loop there is no error. can anyone guide me in the right direction?

def encrypt(s):
'''(str)->str
Encrypts a string by returning a string with the characters inverted and rearranged
'''
s = s[::-1]
n = math.floor(len(s)/2)-1
i = 0
s1 = ''
s2 = ''
while i<1:
if len(s) == 1:
return s
s1 = s[0]+s[len(s)-1]
s2 += s1
while i<=n:
s = s[i:len(s)-1]
s1 = s[0]+s[len(s)-1]
s2 += s1
i += 1
i += 1
return s2

>> No.62929173

>>62929139
dont do that
>>62929151
why? it's common to write it that way in the caller
>>62929161
use a function then, that's more complicated

>> No.62929198

>>62929173
Even worse
RANGE_RAND(i & 0xff, j)

>> No.62929226

>>62929077
>>62929092
pretty disgusting, in production software you should take RNG seriously and choose an appropriate algorithm etc

>> No.62929228

How do you like your C functions? Also naming things is hard.
// modifies out and returns it
llaVec3* llaVec3Add(llaVec3* out, llaVec3* v1, llaVec3* v2);
// modifies v1 and returns it
llaVec3* llaVec3Add(llaVec3* v1, llaVec3* v2);
// returns result
llaVec3* llaVec3Add(llaVec3* v1, llaVec3* v2);

>> No.62929246

>>62929226
You can still do that.

>> No.62929248

How do I do an UPDATE SQL Query where the row with the earliest date is updated?

>> No.62929272

>>62929228

The third is optimal. The first would be okay if it were returning an error code instead of the Vec3 itself.

>> No.62929281

>>62929228
llaVec3* llaVec3Add(llaVec3* v1, llaVec3* v2); // Sets errc in case of a failure. :^)

>> No.62929284

>>62929272
The problem with the third is it would require malloc/free where it would probably not be necessary.

>> No.62929298

>>62929226
literally does not matter for non-science applications. uniform is perfectly acceptable.

>> No.62929299

>>62929284

If you want the user to provide the memory, then use #1 and return an error code, or make it void.

Returning dest is some strcat shit.

>> No.62929313

>>62929299
It allows for chaining operations though. I honestly can't decide.

>> No.62929333

>>62929313
>It allows for chaining operations though

I actually didn't think of that. If that's the intent, then go for it.

>> No.62929397

>>62929198
that's a valid point
#define RANGE_RAND(a, b) ((a)+((((b)-(a))*(rand()))/RAND_MAX))

there, now it looks like a proper /pol/ rant like a macro should

>> No.62929403

>>62929284
Can't you just stack allocate it?

>> No.62929430

>>62929397
#define RANGE_RAND(a, b) ((a)+((((b)-(a))*(rand()))/RAND_MAX)))

there, fixed it further

>> No.62929446

>>62929403
You'd have to pass something in to do that.

>> No.62929449

Is C99 modern C or the standard used after 1999?

>> No.62929455

>>62929449
C11 is "modern" C

>> No.62929459

>>62929449
C99 is the standard defined in 1999 (the one people use)
C11 is the standard defined in 2011 (the latest)

>> No.62929491

>>62929430
>RANGE_RAND(1, 2)
>always returns 1
please

>> No.62929509

C was a mistake.

>> No.62929518

>>62929459
>the one people use
GCC and Clang both default to C11 (GNU11 technically), so probably a lot more people are using C11 than people realise.
The differences between C11 and C99 are pretty minor, though.

>>62929449
It doesn't change change anybody else's answer, but there is a new C standard in the works, likely to be C21 or C22.

>> No.62929519

>>62929509
You are a mistake.

>> No.62929521

>>62929491
returns a random number where a <= x < b
1 <= 1 < 2
don't see the problem here, substitute b for b+1 and RAND_MAX for RAND_MAX+1 if you want

>> No.62929540

Why does this work?
typedef struct type_t {
float Elements[4][4];
} type_t;

inline type_t initType(void) {
type_t Result = {0};
return (Result);
}
Type_t t = initType();


I didn't think you could return arrays like this?

>> No.62929552

>>62929518
GCC defaults to c90 or c89, you can't do for (int i = 0; ...) by default

>> No.62929564

>>62929552
2014 called: they want their compiler back.

>> No.62929580

>compiles to native code
>easy syntax
>easy GUI building
>powerful enough
>compiled size isnt bloated
>close ties to win32 API
What else fits the bill as nicely as VB?
I am unhappy with my C# project not satisfying these, because .NET Native still forces me to include huge libraries with the exe
I feel like C++ would be the obvious answer but I have not yet began my long trek of learning that one

>> No.62929583

>>62929564
gcc --version
gcc (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

>> No.62929591

>>62929583
>4.9.2

>> No.62929595

>>62929580
C + Tcl + Tk
>compiles to native code
check, and does it well
>easy syntax
check, C is very easy
>easy GUI building
check, Tk is easy to use
>powerful enough
check, extremely powerful
>compiled size isnt bloated
check, used for embedded
>close ties to win32 API
check, win32 api was made in it

>> No.62929598

>>62929583
Jesus chirst, anon. Get with the times.
$ cat test.c
#include <stdio.h>

int main()
{
printf("%ld\n", __STDC_VERSION__);
}
$ gcc --version
gcc (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc test.c
$ ./a.out
201112

>> No.62929601

>>62929540
Well, you're returning a struct, not an array.
You can return structs. You can also put arrays in structs. Ergo you can do this.

>> No.62929613

>>62929583
Jesus christ anon I'm on 4.8.3 and even I think you're a dummy.

>> No.62929614

>>62929601
>>62929540
Yes, you can use structs to wrap arrays and treat them like normal first-class values.
It's pretty inefficient, though.

>> No.62929622

>>62929591
>>62929598
>>62929613
sudo apt-get install gcc
[sudo] password for ***:
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version.

>gcc is already the newest version.

>> No.62929628

>>62929622
>Debian
Not even once.

>> No.62929629

>>62929521
>returns a random number where a <= x < b
That's silly. Fix it.

>> No.62929639

>>62929622
>yes hello i have no idea how to update my sources

>https://gcc.gnu.org
GCC 7.2 (changes)
Status: 2017-08-14 (regression fixes & docs only).
Serious regressions. All regressions.
GCC 6.4 (changes)
Status: 2017-07-04 (regression fixes & docs only).
Serious regressions. All regressions.
Development: GCC 8.0 (release criteria, changes)
Status: 2017-04-20 (Stage 1, general development).
Serious regressions. All regressions.

>> No.62929670

>>62929628
>>62929639
I don't want to update every 10 minutes, debian stable is recent enough for all practical purposes and stable. Pulling in separate repos is a bad idea if it's in the regular ones.
>>62929629
I told you how to fix it
#define RANGE_RAND(a, b) ((a)+(((((b+1))-(a))*(rand()))/(RAND_MAX+1))))

now it's a <= x <= b

>> No.62929684

>>62929670
Actually, now that I think about, your previous version was broken - RANGE_RAND(1,2) sometimes could return 2.

>> No.62929696

>>62929670
Wait, Stretch still has 4.9.2 as the default?

>> No.62929716

>>62929696
I'm using Devuan Jessie (Stable / 1.0.0 LTS), no idea about what Debian is using.

>> No.62929719

>>62929716
>Devuan
oh no wonder.

>> No.62929730

>>62929719
>wanting systemd

>> No.62929738

>>62929730
no, devuan is fine.
But you should probably update gcc someday though.

>> No.62929749

>>62924030
What font n editor memes r u using my man

>> No.62929751

>>62929595
Interesting. What is the best way to get into C?
I am unsure that I will do well with it, since I started with JS, moved on to dabbling with C#. What makes me feel uneasy about C is all the manual memory management, high chance of segfaulting, etc.
Altho I approach languages with caution and try to understand the underlying mechanics, so I can say for example that I am confidetn with my JS, not so much my C# yet since this one project of mine was put together hastily out of need.

>> No.62929762

>>62929738
I will, when Devuan ascii becomes stable I'll get 6.3.0-18.
>>62929751
K&R, or start working on a project and apply stackoverflow liberally until you get the hang of it.
Manual memory management isn't that bad, and segfaults won't happen if you're careful. There are libraries that make things like that easier, there's one for strings called bstring for example.

>> No.62929764

>>62929749
I'm not 100% certain, but it looks like Terminus.

>> No.62929871

>>62929762
Right, right. However, what about the people who say that there are people who use C who should be using C++ and vice versa? What does one mean when they say that?

>> No.62929884

>>62929871
C++ is C with some useful features and a lot of bad features. Good C++ is very, very similar to C, but it's easy to write bad code. For example, inheritance is almost never used in good code, but it's a cornerstone of the language.

>> No.62929895

>>62929884
single inheritance is fine.
If C had struct inheritance, people would never shut up about it.

>> No.62929904

>>62929895
You can nest structs and use macros for even more advanced street shitting.

>> No.62929919

>>62929904
Sorry.
inheritance without hacks*

>> No.62929930

>>62929919
>nested struct
>a hack

>> No.62929943

I'm working on a program for my siblings, "who is going to sit in the middle when we ride the car" so atm trying to make Sql work with my wfa

>> No.62929951

>>62929930
getting any decent use out of it will result in hacky-things.

>> No.62929959

if (a == b) { doSomething();
doSomethingElse();
return 19; } else {doSomethingReallyElse();
return 20; }

Is this the perfect indent style? Saves space, forces you to keep code short, very clearly groups things together.

>> No.62929996
File: 17 KB, 500x508, 1492989609471.jpg [View same] [iqdb] [saucenao] [google] [report]
62929996

>It is important to remember that the arguments to node matchers are predicates on the same node, just with additional information about the type. This is often useful to make matcher expression more readable by inlining bind calls into redundant node matchers inside another node matcher

>> No.62930005

>>62929959
awful.
I'll never understand the autism with """"""wasted""""" lines.
if (a == b)
{
doSomething();
doSomethingElse();
return 19;
}

else
{
doSomethingReallyElse();
return 20;
}

>> No.62930009

>>62928838
be less autistic

use clangformat

>> No.62930018
File: 36 KB, 268x237, 1470792067398.png [View same] [iqdb] [saucenao] [google] [report]
62930018

Employed Haskell programmer here

>> No.62930026
File: 14 KB, 180x188, gnu-slash-joke.png [View same] [iqdb] [saucenao] [google] [report]
62930026

For the body of the function, our recommended style looks like this:
if (x < foo (y, z))
haha = bar[4] + 5;
else
{
while (z)
{
haha += foo (z, z);
z--;
}
return ++x + bar ();
}

>> No.62930028

>>62930018
>seems legit

>> No.62930048

>>62930026
imagine living in your own little world for your entire life, stubbornly refusing to admit that your coding style is garbage

>> No.62930089

>>62930005
I can't fit many lines on my screen, if I code like that then I'll have to scroll around all the time.
>>62930026
Disgusting, you can't tell what's going on for shit, who designed this?

>> No.62930105
File: 335 KB, 500x281, tumblr_mj7q7bJHlT1qgewyzo1_500.gif [View same] [iqdb] [saucenao] [google] [report]
62930105

Honestly, C++ is treat to use. Easy and smooth once you get a hold of most of its pitfalls. But C++ language tools are utterly horrible to use. Anyone who suggests that his build system is easy to use is either lying or pretending to be retarded. C++'s lack of package management is one of the reasons why new devs will eventually stop using it.

Rust, on the other hand is genuinely hard to work with. It makes C++ looks child's play (at least that was my experience). However its build system is so much user-friendly! Pick any crates, add them into Cargo.toml, re-build. Cargo will download and compile the library under your ~/.cargo/ (you can change the directory if you really want to).

So nice! In fact I'm thinking of adding some patches to cargo, make it work like apt. So it should be able to search repos from crates.io, list installed libraries, and install/remove libraries without users having to touch the cargo.toml

Rust can only get better, as I said many times before, If Rust gets a major design overhaul like C++11, I can safely suggest Rust to any group of users confidently.

Thanks for reading my blog.

>> No.62930109

>>62930089
Come join us in the 21st century anon, our screens actually have four digit resolution sets.

>> No.62930112

where is an array declared outside of main stored in C?

>> No.62930121

>>62930105
C is the perfect language, that Rust manages to outclass sepples is neither hard nor noteworthy.

>> No.62930145

>>62930089
>Disgusting, you can't tell what's going on for shit, who designed this?
All GNU software is written like this, including GCC.

>> No.62930201

I use size 24 font when programming so please don't waste vertical lines

>> No.62930210

>>62930145
One more reason to not use GCC or GNU software.

>> No.62930216
File: 180 KB, 1024x914, 57577jpeg.jpg [View same] [iqdb] [saucenao] [google] [report]
62930216

What's a stack and heap in C? Is a stack a more organized chucks of memory and a heap a chuck of unallocated memory garbage(heap of garbage)?

>> No.62930226

>>62930105

nice blog, Ruby.

>> No.62930272

>>62930201
I have a 1280x720 screen.

>> No.62930277

>>62924943
expr1 * (-1) + expr2

>> No.62930280

>>62930216
The stack is something the operating system already allocated for you to use. The heap is the rest of the RAM that you need to ask for to receive.

>> No.62930281

>>62930216
stack = local variable
heap = global variable

>> No.62930306

>>62930105
WIP
https://github.com/withoutboats/cargo-add
https://github.com/rust-lang/cargo/issues/4

>> No.62930311

>>62924943
lol the fuck are you doing

redesign your shit so you don't need the function in the first place or leave it like that

>> No.62930358

>>62930105
>>62930306
How old is this pasta?

See https://github.com/killercup/cargo-edit

>> No.62930372

>>62930112
Implementation-defined

>> No.62930384

>>62930277
>both true
>returns 0

>> No.62930393

>>62930384
expr1*-1 + expr2*!expr1

>> No.62930398

>>62930384
nice catch, thanks

>> No.62930403

https://clang.llvm.org/docs/LibASTMatchersReference.html
I want to match any identifier in the global namespace. What should I use? Expr and then filter?

>> No.62930423

>>62930216
The stack is where local variables live.
The heap is where malloc'd variables live.
Global and static variables don't reside in either.

>> No.62930440

>>62924030
Jesus fucking christ why is everyone putting the return type in function definitions on a separate line recently, it looks fucking ugly.

>> No.62930444

>>62929614
>his compiler lacks RVO

>> No.62930447

>>62929884
>C++ is C with some useful features and a lot of bad features
modern C++ has many useful features, and few that i would call straight-up "bad". and feature use is optional anyway. you're supposed to pick and choose based on your needs and priorities, and you only pay for what you use. what exactly are you referring to (besides inheritance, which i'll address)?

>For example, inheritance is almost never used in good code, but it's a cornerstone of the language
it's an entirely optional feature with multiple zero-cost uses. i agree (like many, many C++ users) that using it for virtualization of overabstracted class hierarchies is a generally bad and frequently abused idea, and multiple inheritance is just asking for trouble (except the very last case following), but what about static polymorphism, metaprogramming uses, or inheriting constructors? deriving different sets of interface functions from a base of data members to expose different interfaces conditionally based on template parameters? or, perhaps my favorite, a lambda overload set type using variadic multiple inheritance and inheriting constructors?

>Good C++ is very, very similar to C, but it's easy to write bad code
eh... sort of. this has become much less the case with the new standards. i mean, technically it's never that hard to write bad code, but it's gotten much easier to write good code, and good code is cleaner and more readable/concise than ever. i'm a costful-abstraction-avoiding, enterprise-OOP-hating, dissasembly-comparing type of sperg, but make no mistake, i can think of features from every C++ standard i would end up missing very much if i were to do a library in C (which i would do if ABI portability/language bindability were a priority). i'd live, but... it's not an exciting thought

>> No.62930449

>>62930216
>>62930112
Try running this program
#include <stdio.h>
#include <stdlib.h>

static unsigned globals[128] = { 0 };

int main(int argc, char **argv) {
static unsigned static_local = 0;
void *heap_allocation = malloc(128);

printf("Global is at %p\n", &globals[0]);
printf("Static local is at %p\n", &static_local);
printf("Argument is at %p\n", &argc);
printf("Heap allocation is at %p\n", heap_allocation);

free(heap_allocation);

return 0;
}


Try adding lots of local variables and see how the numbers change

>> No.62930459

>>62930216
https://www.youtube.com/watch?v=IX3fDYz0WyM

>> No.62930469

Plz help a noob out. How are libraries like SDL and such actually implemented? What's happening under the hood when I call those fancy functions? What actually causes pixels to turn a certain color?

>> No.62930491

>>62930447
>you're supposed to pick and choose based on your needs and priorities
Right, that's the point, it's easy to get tricked into using garbage like boost because someone on SO told you to. Some of them are okay, but there's too much garbage in there.

>what about <buzzwords>
All they do is make the code more complicated for no good reason, they're rarely useful and introduce new "exciting" modes of failure (template vomit anyone?)

>i can think of features from every C++ standard i would end up missing very much if i were to do a library in C
Sure, if you know how to deal with sepples' "features" and what to avoid, it's decent. But there are C libraries for most of the good stuff implemented in much saner ways than STL/boost does.

>>62930469
Look at terry davis' video where he talks about the flight simulator

>> No.62930497

>>62930469
https://github.com/spurious/SDL-mirror/tree/master/src

it's just a bunch of wrappers of open GL, winAPI, and custom alias types.

>> No.62930498

>>62924030
Why use C when you can use C++?

>> No.62930506

>>62930440
you look ugly
>>62924030
thank you for using bsd knf
what text editor is that?

>> No.62930515

>>62930469
>What actually causes pixels to turn a certain color?
That part happens when your GPU talks to your display. It just writes numbers to the correct offsets in video memory and the display changes the brightness of the red, green, and blue subpixels to whatever number the GPU put there.

>How are libraries like SDL and such actually implemented? What's happening under the hood when I call those fancy functions?
Should be obvious now, but they just upload data to the GPU and tell the GPU to send it to the display. The different pixel formats (RGBA8888, RGBA5551, YUV, etc.) are different possible formats that a GPU can understand. The library doesn't necessarily know which to use, but usually it can ask the GPU driver which ones will work.

>> No.62930536

>>62930449
This wont make a computer explode will it?

>> No.62930539

>>62930393
>integer multiplication by 1 instead of negation
>doing something algorithmically instead of with 2 cmps and 2 jmps
baka

>> No.62930569

>>62930539
>jmp
who's the baka here

I don't know if c# has the negation stuff
but
(-expr2)&expr1
there, happy? only valid on twos complement

>> No.62930583

>>62930569
>only valid everywhere
NO
MY MANA

>> No.62930598
File: 21 KB, 460x340, 17842522.jpg [View same] [iqdb] [saucenao] [google] [report]
62930598

>>62930491
>>62930497
>>62930515

Thanks for the answers bruhz, you've unironically helped me a lot.

>> No.62930633

>>62930598
By the way, don't make a video game.

>> No.62930644

>>62930469
it's using a graphics API like OpenGL or Direct3D, which interface with the GPU. basically, GPUs render images by taking in vertices (which contain information about the geometry to be rendered) and shaders (programs that tell the GPU how to process vertices and pixels, primarily), and other things like textures (images). it transforms the vertices as instucted by the vertex shader, then assembles the results into primitives (triangles, generally), then colors the visible pixels in the triangles as instructed by the pixel shader (which can sample from textures), and writes the color value to either the screen, or into a texture (which can then be supplied to other shaders on subsequent draw passes for more complex effects)

>> No.62930686
File: 126 KB, 1012x820, wallpaper-1964531 (1).jpg [View same] [iqdb] [saucenao] [google] [report]
62930686

I've just started to learn assembly and I can't exactly understand how does the calculation work? Anyone knows how to solve pic related using TASM?

>> No.62930707

>>62930686
>load the appropriate numbers into registers
>apply the appropriate instructions to the appropriate registers in the appropriate orders

>> No.62930720

We are learning databases with php.
What I really miss is some add on or plugin for a texteditor ir the sorts which explains to me what ANYthing means or what these functions do.
Something like a java or any other ide with something to show me what this function's purpose is and so on?

>> No.62930757

>>62930707
but how to make an error check?

>> No.62930768

>>62930757
put the error code in an unrelated register

>> No.62930863

What does the C committee even do? Do they just sit around doing absolutely nothing all day?

>> No.62930885

>>62930686
Assign your arguments to registers, break down the expression into subexpressions, and start evaluating left-to-right while reusing registers.

c *= -2;
d *= 82;
c += d;
a /= 4;
a -= 1;
c /= a;
return c;


Now convert that to whatever instructions. You didn't say whether you were working with floats or what, so I'll leave that part up to you.

>>62930757
That depends on what errors you're supposed to handle. Try providing more detail next time if you want useful help.

>> No.62930901

>>62930863
what committee

>> No.62930909

<?php
<html>
<body>

<form>
</form>

</body>
</html>

?>
why does this result in a syntax error?

>> No.62930918

>>62930491
>it's easy to get tricked into using garbage like boost because someone on SO told you to
>Some of them are okay, but there's too much garbage in there
well, sure. but that's not really a criticism of C++.

>what about <buzzwords>
so "buzzwords" just means "things i can't be bothered to understand", then?
>All they do is make the code more complicated for no good reason, they're rarely useful and introduce new "exciting" modes of failure
did you even read what i said? your point only even potentially applies to two of the examples, not to mention two of the others were just things i described the process of doing (the opposite of "buzzwords"). either way, my code making use of modern features has seen a drastic reduction of syntax (*especially* template syntax; constexpr eliminates the need for a lot of template metaprogramming code by replacing it with regular C++ code, and generic lambdas eliminate a lot of template syntax as well. oh and dear god, return type deduction), and a drastic increase in readability

>Sure, if you know how to deal with sepples' "features" and what to avoid, it's decent
yeah. so... know what you're doing. obviously. when you do, C++ is great. it's well worth the investment

>But there are C libraries for most of the good stuff implemented in much saner ways than STL/boost does
again, that's not really a language argument. most of the dependencies of my current project are C libraries, and they're great. but i'm sure as shit still doing my project in C++, because it has a bunch of useful-as-hell features i don't want to make do without

>> No.62930921

>>62930901
The ISO C committee.

>> No.62930969

>>62930863
They want to have nice and round numbers so nothing for the next 4.2 years

>> No.62931021

Anyone here familiar with Clang?

>> No.62931066
File: 62 KB, 850x1021, 1478815764741.jpg [View same] [iqdb] [saucenao] [google] [report]
62931066

Show me at least one situation where coroutines would be better or more efficient than threads and/or std::async.
Protip: You can't.

>> No.62931090

Haskell or Erland?

>> No.62931094

>>62931066
std::async was a mistake

>> No.62931098

>>62931090
erlang*
fuck

>> No.62931103

>>62931094
What's wrong with std::async?

>> No.62931107

>>62931066
It's much easier to avoid data races. There's more control over when the continuation changes.

>> No.62931123

>>62931103
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3780.pdf

>> No.62931125

>>62931090
Erlang actually has a practical application.

>> No.62931127

>>62931107
>It's much easier to avoid data races
As if that was difficult in the first place, with std::atomic and std::mutex etc.

>There's more control over when the continuation changes
You will never ever need control over this, and if you do, rethink your shit design.

>> No.62931154

>>62931127
>using mutexes and atomics like they're candy
Honestly don't bother with multithreaded code yet anon. You're not ready. Abusing those data structures ruins performance.

>> No.62931180

>>62931127
>he doesn't write non blocking code

>> No.62931247
File: 45 KB, 493x461, topmost-kek.jpg [View same] [iqdb] [saucenao] [google] [report]
62931247

>there are "people" in this thread right now who haven't mastered lisp

>> No.62931272
File: 29 KB, 600x600, consider.jpg [View same] [iqdb] [saucenao] [google] [report]
62931272

new thread, though
>>62931267

>> No.62931293

>>62931272
>page 3

>> No.62931302
File: 11 KB, 238x212, you.jpg [View same] [iqdb] [saucenao] [google] [report]
62931302

>>62931293
>being this mad on internet

>> No.62931319

>>62931302
>not waiting until page 10

>> No.62931326

>>62931127
Suppose you're designing a nuclear power plant:

A nuclear power plant needs to adjust cooling, adjust the control rods, and adjust the chemistry of the coolant.

The calculations for the chemistry take an incredibly long time. You have to check the cooling and control rods several times during the chemistry calculations.

You could, if you were a brainlet, implement calls to adjust cooling and control rods inside the chemistry calculations.

If you were slightly less of a brainlet, you'd use threads, but threads don't guarantee that certain parts execute. They're also pretty heavyweight, nondeterministic, require a kernel, and have a significant performance impact. One of those days everyone dies because the kernel didn't let the cooling procedure complete before switching to something else.

Coroutines are not only super lightweight, but let you decouple the cooling calculation from the other calculations, replacing those calls with yield() or whatever sepples does. And they don't potentially let everyone die in a nuclear holocaust like threads might.

>> No.62931342

>>62931326
>lecturing people about coroutines
>using a language that doesn't support delimited continuations

>> No.62931362

>>62930498
Why C++ when you can use Rust?
Just use C. =)

>> No.62931368

>>62931326
>because the kernel didn't let the cooling procedure complete before switching to something else.
Yeah and then it switches back in a very short amount of time, and no one dies.
Are you retarded?

>> No.62931384

>>62930921
They have big plans to ruin C forever so we have no choice but to use Rust.

>> No.62931387

>>62931342
Anon, coroutines are a light abstraction over continuations. They're about 20 lines of code.

>> No.62931396

>>62931368
All the world's a vax huh?

>> No.62931418

>>62931387
>coroutines are a light abstraction over continuations
But that's my point, you peasant. You can't even implement your own coroutines in your blub language.

>> No.62931448

>>62931418
Who the fuck actually uses C++ though anon? Clearly if I use the world continuation I use scheme.

>> No.62931466

>>62931448
>Who the fuck actually uses C++ though anon?
Literally nobody. C++ programmers aren't persons.

>Clearly if I use the world continuation I use scheme.
I said "delimited continuations", Scheme peasant.

>> No.62931474

So I taught myself context-free grammars and Backus-Naur forms, and it makes it a lot easier to learn new programming languages because it matches the way my brain autistically tries to parse expressions anyway while reading code. Instead of reading a 1000+ page manual on a new programming language, just give me the EBNF and the cliff notes and I can parse even the most complicated expressions.

http://my.safaribooksonline.com/book/operating-systems-and-server-administration/unix/1565923472/syntax/lbs.appd.div.3

I guess this is what you miss out on by not having a formal CS education.

>> No.62931498
File: 393 KB, 640x360, oh shit nigger what are you doing.gif [View same] [iqdb] [saucenao] [google] [report]
62931498

>>62931474
>reading a 1000+ page manual

>> No.62931504
File: 67 KB, 404x404, wtf-am-i-reading.png [View same] [iqdb] [saucenao] [google] [report]
62931504

>>62931474
>he thinks syntax is the hard part of understanding a new programming language
>he thinks that thousand page long manual (Sepples?) explains the syntax

>> No.62931519
File: 22 KB, 432x445, apu.jpg [View same] [iqdb] [saucenao] [google] [report]
62931519

is it proper way of writing factorial?

private static int fact(int i)
{
if (i < 1)
return 1;
else
return i * fact(i - 1);
}


or do I have to use
if (i == 0) {return 1}

or
if (i==0 || i == 1) {return 1}


?
is mine code wrong or is it just matter of efficiency/aesthetic?

>> No.62931524

>>62931519
dumb frogposter

>> No.62931533

New thread:

>>62931530
>>62931530
>>62931530

>> No.62931543

>>62931519
unsigned int fact(unsigned int i) {
return i == 0 ? 1 : i * fact(i - 1);
}

It's undefined for i < 0.

>> No.62931551

>>62931504
When you ask a question on StackOverflow and some genius turbo autist chimes in with the answer to some obscure quirk or gotcha of the language and gets thousands of upboats... it always raises the question to me, "Where did THEY get that information from?" It kind of bothers me to rely on 2nd-hand information. That StackOverflow guy got the information from somebody who got the information from somebody [...], eventually there had to be a primary source, a contract if you will. I have an addiction to reading manuals, standards, and RFCs because they're the OFFICIAL legal contract of a language or protocol. If there is any disagreement on StackOverflow or wherever, consult the document and it should settle all arguments. I don't want to be caught off guard by some gotcha at work because I didn't read Chapter 23 Section 8 Subsection 3 Paragraph ii of the ISO Standard.

>> No.62931558

>>62931551
now THIS is what I call autism

>> No.62931588

>>62931474
that's cool. how did you learned? like, can you recommend some resources?

>> No.62931648

test

>> No.62931669

test

>> No.62931699
File: 26 KB, 656x470, code.png [View same] [iqdb] [saucenao] [google] [report]
62931699

Hello, SQL pro.
I'm super beginner and I can't make an atomic counter in PHP with SQLite. Please help. I wrote,
See pic. It caused connection error.

I expected that I could get value of (A) at (B), but I couldn't. Atomic counter itself works, but I can't get the value. How should I do?

>> No.62931728

>>62931551
That's all very nice, but the BNF isn't going to teach you any of that because it doesn't tell you anything about the semantics of the language, and any non-trivial language is going to be far more complicated on the semantics end than on the syntax end, not to mention that the BNF specification you will find for most real languages accepts a superset of the actual language, including loads of nonsensical programs that won't even compile.

>> No.62931777

>>62931588
https://www.youtube.com/watch?v=224plb3bCog
https://www.youtube.com/watch?v=vhiiia1_hC4
https://www.youtube.com/watch?v=RjOCRYdg8BY

https://en.wikipedia.org/wiki/Context-free_grammar
https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form
https://en.wikipedia.org/wiki/Recursive_descent_parser

>> No.62931963

>>62929749
>>62930506
Good old Terminus (Terminusmodx for the bold) and vim my guys

>>62930498
because I'm not a brainlet who needs my higher level structures written for me. If sepples was neccesary for the project I would have used it, but it wasn't, and usually isn't.

>> No.62931978

>>62931699
OK, I'll ask this in new thread. Thanks.

>> No.62932687

What is the advantage/disadvantage/difference between using:

>sed
>awk
>bash native regex

>> No.62933152

>>62930226

Not my post. I generally see no problem with C++ build tools. C++ doesn't need a package manager, since it uses the system package manager.

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
reCAPTCHA
Action