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

/dpt/ - Daily Programming Thread

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

Thread replies: 316
Thread images: 30

File: scheme.png (384KB, 1024x768px) Image search: [Google]
scheme.png
384KB, 1024x768px
What are you working on, /g/?
Previous thread: >>61393119
>>
File: 1324690418001.jpg (35KB, 388x380px) Image search: [Google]
1324690418001.jpg
35KB, 388x380px
Why should I learn haskell if my job is mostly C++/Python/Matlab?
>>
File: unit testing framework.jpg (52KB, 600x373px) Image search: [Google]
unit testing framework.jpg
52KB, 600x373px
>>
>>61398050
>What are you working on, /g/?
Trying to get my way arounf CSFML.
>>
OP can this be a no pajeets edition?
They ruined the last thread by trying to convince people their country wasn't shit
>>
File: annotated_monads.1.jpg (86KB, 711x1024px) Image search: [Google]
annotated_monads.1.jpg
86KB, 711x1024px
>>61398062
dumb frogposter
please DON'T learn Haskell, you're a fag and we don't want you

thanks
well no

no thanks
fag
>>
>>61398067
How does it compare to SDL, GLFW, Freeglut, etc?
>>
>>61398062
it gives you a new perspective on how to program
>>
>>61398050
Should I not use md5 for my database?
>>
>>61398062
Like in almost everything, constraints are great for inspiration.
>>
>>61398100
But is it efficient though?
>>
File: 1499902918655.jpg (39KB, 411x381px) Image search: [Google]
1499902918655.jpg
39KB, 411x381px
Why do you have to post anime in every /dpt/?
>>
>>61398111
As long as you're not hashing passwords with it, I think it's okay.
>>
>>61398133
>As long as you're not hashing passwords with it
Nothing wrong with doing that.
>>
>>61398127
Anime imageboard
>>
>>61398141
MD5 is cryptographically insecure though. It's only slightly better than storing the passwords unhashed in your database.
>>
>>61398090
Can't say desu, haven't really mucked about with any of the rest of those other than GLEW.
Though I can say with absolute certainty that I would take CSFML over GLEW any day of the week.
>>
>>61398145
there's a special place in hell for people like you, it's called /a/
>>
>>61398074
But is it efficient though?
>>
>>61398111
this: >>61398133

If you are using passwords, use sha256.
>>
>>61398074
I don't get the depiction of list here.
>>
>>61398141
Shit's been broken, never use it for sensitive data
>>
>>61398152
>MD5 is cryptographically insecure though
This is absolutely wrong.

>>61398178
Don't talk about shit you have no idea about please.

>>61398173
Why?
>>
>>61398167
There's an entire special dedicated hell for all of us
it's called 4chan
and there's anime there
deal with it, good people who deserve the kind of content they want to read don't get sent here
>>
>>61398177
branching computations
the end result is concatenated
>>
Hi guys, Newbie/Retard here. I have a simple question regarding this merge sort algorithm.
/* C program for Merge Sort */
#include<stdlib.h>
#include<stdio.h>

// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
int i, j, k;
int n1 = m - l + 1;
int n2 = r - m;

/* create temp arrays */
int L[n1], R[n2];

/* Copy data to temp arrays L[] and R[] */
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
for (j = 0; j < n2; j++)
R[j] = arr[m + 1+ j];

/* Merge the temp arrays back into arr[l..r]*/
i = 0; // Initial index of first subarray
j = 0; // Initial index of second subarray
k = l; // Initial index of merged subarray
while (i < n1 && j < n2)
{
if (L[i] <= R[j])
{
arr[k] = L[i];
i++;
}
else
{
arr[k] = R[j];
j++;
}
k++;
}

/* Copy the remaining elements of L[], if there
are any */
while (i < n1)
{
arr[k] = L[i];
i++;
k++;
}

/* Copy the remaining elements of R[], if there
are any */
while (j < n2)
{
arr[k] = R[j];
j++;
k++;
}
}

/* l is for left index and r is right index of the
sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
if (l < r)
{
// Same as (l+r)/2, but avoids overflow for
// large l and h
int m = l+(r-l)/2;

// Sort first and second halves
mergeSort(arr, l, m);
mergeSort(arr, m+1, r);

merge(arr, l, m, r);
}
}

My question lies on this part of the code
 /* Copy the remaining elements of L[], if there are any */ 
and
   /* Copy the remaining elements of R[], if there are any */ 
. What do they do? i don't understand their purpose. Thanks in advance.
>>
>>61398193
>Don't talk about shit you have no idea about please.
Right back at you fag, you would know this if you had even the slightest idea about security
>>
>>61398223
But is it efficient though?
("It" being Haskell)
>>
>>61398223
Show me a (second) preimage attack on md5.
Protip: you can't
Thus, MD5 hasn't been broken.
>>
>>61398050
A higher level LLVM assembly metalanguage with Common Lisp macros and JIT compilation.
>>
>>61398193
https://duckduckgo.com/?q=md5+scheme&t=ffsb&ia=answer
Take this result

And plug it into this website:
https://crackstation.net/

It's like magic.
>>
>>61398247
>rainbow table
Thanks for nothing, rainbow tables exist for every hash function.
>>
>>61398265
But is it efficient though?
>>
>>61398117
I don't think it's that much more efficient, it's probably the same as imperative languages, but it does lead to better and easier testing and less bugs, especially in concurrent workflows
>>
>>61398230
Wow, you sure showed me, guess I'll go use md5 for all my security needs.
>>
>>61398286
Not an argument.
>>
Honest dumb question. Can i buy a shit used laptop to learn programming? I'm doing cs50 on eDX right now and I'm using a IDE to make the programs. I guess 4gb ram is the minimum required in 2017 r-right?
>>
>>61398303
nothing less than an i9 32GB of ram if you want to program
>>
>>61398303
4gb is overkill for most programming you'd do anon, depending on what tools you use.

You don't need a very good computer to program, and to be honest programming on a shit one will force you to write code that isn't absolute dogshit.
>>
>>61398298
It's not exactly a controversial idea that it's insecure.
http://www.kb.cert.org/vuls/id/836068
>>
>>61398303
you can learn programming with a computer from the 80s
>>
>>61398199
After a merge operation, one of the sorted sub-arrays will run out of data to put back into the initial array.
Those bits of code are there to make sure that all of the data is copied over from both sub-arrays when this happens.
>>
>>61398303
yes but only if you know linux
windows is the only good os, linux is shit, but the good thing about linux being shit is that it works with computers that are also shit, whereas windows is a spoiled brat and runs slower than molasses if you don't feed it right
>>
>>61398330
>collision attacks
Literally nobody cares about collision attacks, as long as they are not second preimage attacks it's fine.
>>
>>61398199
let's say the loop before terminated after having put all the elements of L into arr, R would still have elements in it that needed to be put into arr. The additional two loops just put the remaining pieces of the sub array into arr
>>
>>61398303
when I started college I went for /g/'s advice and bought a 10" shittop with 2gb that was $200 and had an atom. It ran really hot and made me wait while compiling a lot. Then I got to my higher level classes and they required visual studio for ASP, which wouldn't run and SQL developer to connect to a database, so yeah, there might be a minimum when you go buy one.
HOWEVER, one of my classmates' laptop recently got trashed, and he bought a Dell Latitude with a second gen i5 (non-ULV) on craigslist and that ran all the software perfectly and it was nice to develop on.
I'm not telling you to buy a thinkpad but try to go for a core-i5+ machine, (>64gb) SSDs, and 8gb of RAM in that order of priority, you should be able to get something like that for $400-600
>>
>>61398353
Yes, trust the random anon on the Internet, ignore the fact that literally everyone else says it's insecure
>>
>>61398397
Literally everyone, sure lol
https://crypto.stackexchange.com/questions/41860/
https://crypto.stackexchange.com/questions/13303/
https://en.wikipedia.org/wiki/MD5#Preimage_vulnerability
https://news.ycombinator.com/item?id=13180513
>>
>>61398127
Touhou is not an anime
>>
>>61398141
MD5 is a shitty way to hash passwords in 2017 https://github.com/juuso/BozoCrack
bcrypt (or possibly scrypt) is what you want, because bcrypt will slow down some farm of GPUs working to crack your password dump.


>>61398199
Weird way to write mergesort
Some pseudocode:

void sort (int[] A,int lo, int hi);
{
if (hi-lo <= 1) return;
int mid = lo + (hi-lo)/2;

sort(A, lo, mid);
sort(A, mid, hi);
merge(A, lo, mid, hi);
return;
}


You would have to write merge function, but the simple and efficient way to merge two sorted array segments (so
that the result is again sorted) is to create a temporary array, scan each of the segments from left to right, copying the smaller of the two into the temporary array. This is a linear time (O(n)) operation, but it also requires a linear amount of temporary space.
>>
>>61398336
>>61398368
Thank you so much for your answers. I can finally see their purpose, for some reason I thought that the
 while (i < n1 && j < n2) 
was enough to copy every element from both arrays, into the original array. Obviously not, but I did say I was a newbie/retard lol.
>>
>>61398457
Everyone starts somewhere, anon.
Don't worry about it!
>>
>>61398449
>bcrypt (or possibly scrypt) is what you want, because bcrypt will slow down some farm of GPUs working to crack your password dump.
bcrypt nor scrypt will save you. scrypt is what litecoin for example uses. See how many asics for it exist.

The real solution would be to simply use many iterations of the hash function or have passwords with good enough entropy.
>>
>>61398467
Thanks for the support anon. I will keep at it.
>>
Is there a term for a datum's ratio of size of the datum to size of the smallest expression that evaluates to that datum, for some objective and language agnostic definition of expression size?
>>
>>61398449
Thanks for the answer anon. I will screenshot all the answers I have gotten today, so i can revisit them another day. I liked the time analysis you made of the algorith. I should probably spend some time getting the "math" down on every algorithm, to "truly" understand them.
>>
>>61398474
It is also possible with Scrypt to set the memory space needed to compute the result thus making a brute-force attacker pay penalties.

Litecoin has set both the memory difficulty and parallel difficulty to 1, the basic value https://litecoin.info/Scrypt

Somebody who is encrypting their password database, is not going to set it to 1.
>>
>>61398514
>language agnostic definition of expression size
>>
>>61398523
Merge sort is slower than that, just the actual merging is only (O(n)). If you're interested then read these pdf lecture notes http://www.cs.cmu.edu/~15122/schedule.shtml
>>
Learning front-end so I'm employable when really all I want is to code back-end and not have to worry about the latest trendy frameworks.
>>
>>61398435
Jesus Christ, we're dancing around the original point. Find me one person (other than you) who thinks using md5 in a security context is okay. There are none, because everyone knows it's easy to get around.
Also respond to
http://www.kb.cert.org/vuls/id/836068
properly and tell me why they're wrong in telling people not to use it in any capacity.
>>
>>61398457
I think the final while might be redundant since everything in R comes from the latter half of arr
>>
>>61398542
>because everyone knows it's easy to get around
Still waiting for you to show me any practical preimage attack on md5.

>http://www.kb.cert.org/vuls/id/836068
This is a collision attack, not a second preimage attack thus it is irrelevant in the real world.
>>
>>61398531
Thank you man. I will definitely check it out.
>>
>>61398559
>thus it is irrelevant in the real world
Oh, I guess they were just kidding when they said never to use it then.
>>
>>61398193
>absolutely wrong
You really should be using md6 now. Finding collisions for md5 is trivial.
>>
So, I'm trying to write a bot for this site but I can't figure out images yet.
When I POST and look at it in the network monitor window, I get this for the image:
Content-Disposition: form-data; name="upfile"; filename="1180680378089.jpg"
Content-Type: image/jpeg

(actual image dataa)

How would I format this for requests?
I've tried all sorts of combinations of:
file = {'filename':    'png.png',
'upfile': open('Untitled.png','rb')}
the_post = requests.post('https://the_website/'.format(board),
data=Form,
files=file)

I'm not sure what I'm doing wrong. Posting text only works fine.
>>
>>61398514
So if I understand you, 1's measure would at least 1.0, because in lisp 1 is an expression that evaluates to 1, so 1 byte for 1, and 1 byte for 1.

And the list (1 2) would be at least 5.3 because (1 2) is represented with 2 128 bit words in Chicken and you can construct (1 2) with
'(1 2)
. So 32 bytes over 5 bytes.

What's the point of this?
>>
>>61398544
Would mind showing me how you would write it? I would always like to see improvements. Also, is it bad to be redundant on programming? Or should I see it as a "sanity check"? Serious questions, I am not being a snarky/sarcastic asshole. Thanks in advance.
>>
>>61398570
Are you planing to use an actual argument or are you planing to continue mindlessly repeating what others said without any actual understanding of the topic?

>>61398575
MD6 is actually really cool, it is the only hash function that I know of that uses merkle trees instead of a MD-like construction.

>Finding collisions for md5 is trivial.
Finding second preimages for md5 is not however. Nobody cares about random collisions.
>>
File: 1376505409276.jpg (48KB, 524x480px) Image search: [Google]
1376505409276.jpg
48KB, 524x480px
>This fucking retard advocating MD5
It's fucking shit because it's so easy to compute them.
Any kind of brute-force/dictionary attack is going to fly though that shit no problem. People of your retardation shouldn't be allowed to program, let alone touch a computer.
>>
>>61398604
Yes, I understand it's preimage resistant.
Do you plan on continuously telling me it's perfectly fine to use in the real world anyways even though nobody else would say this? Tell me why they're wrong in saying "Software developers, Certification Authorities, website owners, and users should avoid using the MD5 algorithm in any capacity". Clearly collisions have relevance in practical situations if that's what they've concluded. Or are you going to tell me you know more than them?
>>
>>61398622
>literally the same holds true for every single cryptographic hash function

>>61398636
Still waiting for a proper argument instead of an appeal to authority.
>>
>>61398524
Actually Litecoin has even turned off the mixing step, so no shuffling of the blocks occurs.

The couple of libraries I just checked that would be responsible in most languages for hashing passwords with scrypt set this to The default parameters for scrypt are N=16384, r=8, p=1 (16 MB memory), you could boost r=16 to a more paranoid level and none of those ASICs are doing shit anytime today in terms of efficiently cracking those hashes without running out of memory.
>>
>>61398655
except bcrypt/scrypt which incur a memory penalty with each iteration trying to brute force/guess attack a hash.

of course there is custom hardware for this now, like Moxie Marlinspike's cloud cracking service or owning a miner that is running Hashcat which can effectively run gagillions of guesses per second against MD5 or any other hashes except bcrypt/scrypt.
>>
>>61398655
>>literally the same holds true for every single cryptographic hash function
No, it really fucking doesn't.
>>
File: YYYY-07-DD 21_07_SS.png (12KB, 752x132px) Image search: [Google]
YYYY-07-DD 21_07_SS.png
12KB, 752x132px
>ode45
>>
>>61398713
Sure thing m8

>>61398694
Nowadays one would go for argon2i.
>>
>>61398723
>matlab
>2GB/s
>>
>>61398655
Still waiting for someone who'd be okay with using md5 in a security context (besides you).
>meanwhile tons of resources saying not to use it
>>
File: bscap0042.jpg (35KB, 640x336px) Image search: [Google]
bscap0042.jpg
35KB, 640x336px
Is it possible to read from certain processes in computer memory? I don't know much about how computer memory works on the low level, but I figure that all strings and information that every process is using should be avaliable in the memory. So, if I wanted to write a script in a language to read off of a particular thing in that process (for example, say if I wanted to read the number on an open Calculator application) would it be possible to do? What would I need to read to go about doing this? And why hasn't anyone sat down to make libraries for this kind of stuff?

Thanks in advance, my ignorance is probably showing. pic unrelated
>>
>>61398755
Still waiting for a proper argument, shitposter.
>>
File: YYYY-07-DD 21_07_SS.png (29KB, 903x609px) Image search: [Google]
YYYY-07-DD 21_07_SS.png
29KB, 903x609px
>>61398737
time step too big lul
>>
>>61398759
Yes, it is possible, but dodgy as fuck.
That's how programs like cheatengine and various debuggers work.
>>
>>61398759
Yes it is possible and yes, it already exists. (see cheatengine for example)
>>
>>61398768
>matlab
>8GB/s
>>
>>61398761
>many resources saying not to use it vs. one faggot on 4chan
Wow, who should I trust.
>>
>>61398759
Open up gdb, set program breakpoint you want to analyze, read what's in the registers.

Otherwise you can just grab memory though the operating system (depending on what it is) often makes this difficult but not impossible.

This book will show you how to do it
https://www.nostarch.com/gamehacking
>>
>>61398598
You'd just remove the while (j < n2) loop.

Basically if anything remains in R and L has been exhausted of all elements then every element of R corresponds with arr.

Basically for every i R[i] == arr[i+m]
>>
File: name.jpg (53KB, 640x480px) Image search: [Google]
name.jpg
53KB, 640x480px
>>61398590
nvm I figured it out
>>
>>61398769
>>61398770

Got it, so if you were in my position, would it be a good idea to mess around with Cheat Engine and maybe view the source? Also, looking to roll something out on Ubuntu as well, so I may need an alternative, but I'll do my research from then on out - quick searching shows scanmem?

>>61398796

Wow, thank you so much for your post! I will look into gdb, and also the book you provided, since it seems very useful. Do you happen to have any other book recommendations, by any chance? I can code a few applications together, but I lack a lot of background on the low-level portions like this, I feel like there's some reading I should do, and I'd love to connect this to my programming. I could always do my research, again, but a slight nudge in the right direction/advice would help tremendously
>>
How do you teach someone good design?

I'm friends with a guy who's been doing C++ for upwards of five years and he's never heard of or even tried to apply basic design principles like SOLID. All his code is in one file, most of the methods that do anything are in one or two classes, and he thinks that this is the way people are supposed to write C++.

Is all hope lost for him?
>>
>>61398900
>SOLID
I have literally never heard of this acronym

>OOP
It simply isn't good design.
>>
>>61398839
Sure take this course
https://www.cs.cmu.edu/~213/schedule.html

Click on 'old video' it's public lecture vids from 2015. Get the book that comes with the course, you want the 3rd (64bit) edition: https://www.amazon.com/gp/offer-listing/9332573905/ref=dp_olp_used?ie=UTF8&condition=used

Try some of the labs, you'll use gdb to analyze program memory, and an attack lab to inject code into stack frames by using return oriented programming. You don't need to know C or anything it will teach you basically as you go.

Also here's that gamehacking book
http://libgen.io/book/index.php?md5=53AAE2AE81BB7E2E0BE8E0A63C4948E7

And here's an entire curriculum of CS to keep you busy for the next 3-4 years if you do it p/t
https://functionalcs.github.io/curriculum/
>>
File: home.png (128KB, 880x739px) Image search: [Google]
home.png
128KB, 880x739px
>>61398167
I mean not like the home posts anime
>>
>>61398914
I don't like OOP myself, but I can write it in provided I stick to SOLID (which is basically the universal principles of good design, no matter what paradigm you use).
>>
>>61398957
These aren't really principles at all
>SRP
I disagree with this but in OOP it's probably necessary
>OCP
Things don't really need to be extended or modified if they're sufficiently parametrised
>liskov substitution
This is just subtyping. It doesn't need a special name and a principle.
>many interfaces
Until you have to import all of those interfaces.
It depends, convenience isn't worthless.
>dependency inversion
parametrisation solves this, FP in general and intricate type systems
>>
>>61398936
Bro, I am not the anon you replied to, but holy molly is this gold. Thanks for posting it.
>>
>>61398826
Thanks for the reply, anon. I see what you are saying, but don't you still need to copy the contents of R[i] back into the array? Because, if I remember correctly, the contents of arr[i + m] are inside R[i], so we need to put it back into arr[ ]. I am aware this question may make me sound retarded, but I prefer to sound retarded, than to have doubts in my mind. Anyway, thanks for helping me out.
>>
>>61398759
You can hook to the window process of the calculator (on Windows this is easy), and listen for the value, set a value, inject key presses, etc.
https://msdn.microsoft.com/en-us/library/dd460756.aspx

https://stackoverflow.com/questions/352236/reading-from-a-text-field-in-another-applications-window
>>
>>61398936
>>61398936

Thank you so much anon, I will be forever grateful
>>
Looking for inspiration /g/:

For a school assignment, I have to essentially write a web scraper and it has to use the python random module. It has to be a coherent program and justify why i'm using random.

I can't think of any reason to use random for webscraping tho.
>>
>>61399354
make it get all the links from a page, then follow a random link and repeat it a bunch of times. maybe you'll end up somewhere interesting but probably not.
>>
>>61399506

Not bad, thanks anon
>>
>>61398781
Many resources say that Java is awesome vs one faggot on 4chan.
Fuck off pajeet.
>>
>>61398050
>What are you working on, /g/?

>programming trading algorithms
>they work decently, considering I haven't even started reading my quant books
>notice I'm using 1 million dollars for backtesting
>set my budget to something more realistic I can afford, let's see if commissions fuck me over
>suddenly the algorithm hemorrhages money

You can't even have fun losing money with programming when you're a poorfag.
>>
Anyone knows if it's possible to mount a FUSE filesystem inside of another unrelated FUSE filesystem?
>>
>>61399354
make something that browses random twitter accounts for sentiment analysis data collection. random is important to prevent any form of bias.
>>
>>61399354
>>61399506

you could do this with wikipedia, and following only wikipedia links. It would be really fun to see where the fuck it ends up by going in random directions in the human-knowledge-space. Please post your results, anyway, if you do something cool
>>
>>61400000
Gotta check those quints
>>
>>61399506
>>61400000
>>61400025

Thanks gents, you're amazing
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
111st for CCC
>>
Why don't garbage-collected languages just have a refcount on their objects and free them/add them to a list of objects that need to be freed when the refcount drops to zero?
It's simple and you can just let the developpers deal with circular references.
>>
>2017
>Defining your behavior
C masterrace here.
>>
badly drawn thinking emoji jpg
>>
File: 1482612226073.jpg (35KB, 500x471px) Image search: [Google]
1482612226073.jpg
35KB, 500x471px
>>61398050
>ywn create beauty through drawing,painting,sculpting
>ywn compose music enjoyed by people all around the world
>you will always be a soulless code monkey
>>
File: images.jpg (7KB, 256x197px) Image search: [Google]
images.jpg
7KB, 256x197px
>>61400444
Checked
>>
>>61400737
Learn FP
>>
>>61400744
>FP
https://en.wikipedia.org/wiki/FP

???
>>
>>61400712
If you develop your algos always(!) create a test and training set. Otherwise you are likely to overoptimize
>>
>>61400768
functional programming
>>
File: 1467655190399.jpg (14KB, 358x358px) Image search: [Google]
1467655190399.jpg
14KB, 358x358px
>>61400776
>wouldnt make me better at any of those listed above
>inefficent
>rarely used
>a /g/ meme
>probably a gateway to being a neet crossdresser

ill pass
>>
>>61400737
Programming is relatively ugly, but the underlying mechanical logic it translates to is quite beautiful. Trivial if any difference between it and neuroscience, molecular biology, physics, etc. It is the same basic rules and demands at work, any task that is to occur requires a means.
>>
>>61400823
>nah i dont need a soul
>>
File: d6454745400283.582f27c13dfb3.jpg (589KB, 1024x1347px) Image search: [Google]
d6454745400283.582f27c13dfb3.jpg
589KB, 1024x1347px
>>61400826
thank you anon
kind words

>>61398167
rude
>>
#define BIT_64 9223372036854775808

typedef struct ndec_s {
uint64_t z, *r, n;
uint8_t p;
} ndec_t;

int PrintND(ndec_t *nd){
unsigned int i;
if (!nd->p) printf("-");
printf("%" PRIu64 ".", nd->z);
i = 0;
while (!(nd->r[i]>>63))
printf("%"PRIu64, nd->r[i++]);
printf("%"PRIu64, nd->r[i] - BIT_64);
return 1;

}

int main(){
ndec_t n;
n.z = 12512; /* integer component */
n.r = (uint64_t *) malloc(sizeof(uint64_t) * 2); /*rational compnent */
n.r[0] = 123456789012345678;
n.r[1] = 90123456 + BIT_64;
n.p = 1; /* parity */
n.n = 25; /* precision */

PrintND(&n);

free(n.r);
}
>>
File: 1470047710352.jpg (103KB, 334x338px) Image search: [Google]
1470047710352.jpg
103KB, 334x338px
>doesn't use Terminus font
>calls herself a programmer
ISHYGDDT
>>
>>61401084
Each uint64 can hold 10^19 - 1 making the 64th bit usless since it would just fuck with carrying
But the 64th bit can be indicator of the end of the array. I don't think really that this is worth it, maybe it is. Not like storing an extra 7 bits would be that big of a deal. Unfortunately I don't think there's a way to store parity or precision in the extra bits.
>>
File: 1499659753162.png (446KB, 808x805px) Image search: [Google]
1499659753162.png
446KB, 808x805px
Oh wait no I'm an idiot
10^19 - 1 > 2^63
I was thinking of 10^18
>>
Could someone help out a C novice? Got sent here from /sqt/.

I'm learning memory management with an int array. Am I using sizeof() correctly? My realloc() works (even though it looks stupid right now) but the print statements aren't changing.

/* Takes a pointer to a list struct, which has *sortedList, which is a pointer to an array of ints.
Increases the memory allocation for sortedList. For some reason I have to use DOUBLE_NUMBER (equal to 2) twice for it to work.*/
void foo(list *ls)
{
printf("sizeof sortedList is: %lu\n", sizeof(ls->sortedList));
ls->sortedList = realloc(ls->sortedList, DOUBLE_NUMBER * DOUBLE_NUMBER * sizeof(ls->sortedList));
printf("sizeof sortedList is: %lu\n", sizeof(ls->sortedList));
}


When I run this I get the allocation I need but both the print statements say "sizeof sortedList is: 8". Any tips?
>>
>>61401259
You're taking the size of a pointer, not the size of what it is pointing to.
>>
>>61401259
try sizeof(&ls->sortedList)
>>
>>61401271
>>61401276

Ah, makes sense. Thanks, maybe now I can make realloc better too.
>>
>>61400826
I wouldn't say it is ugly, but programming is full of compromises.
When you have a very short piece of code, you can make it very pretty.
But any real programming project will have compromises that can be improved.
>>
>>61401259
printf("memory is: %lu\n", ls->maxSize * sizeof(int));
ls->sortedList = realloc(ls->sortedList, DOUBLE_NUMBER * ls->maxSize, sizeof(int));
printf("now memory is: %lu\n", ls->maxSize * sizeof(int));


memory is: 20
now memory is: 40

Got it.
>>
>>61401406
oh, typo
* instead of , of course
>>
Hey /dpt/, I need some advice.

I'm using HackerRank to brush up on my coding. I took a few classes in math undergrad/grad and completed some coding assignments in both, but I'm largely self taught (aside from the fundamentals learned from two intro classes and data structures).

Some questions I have:

I'm starting to look for positions in the tech field and I'm practicing my coding. I've forgotten a bit of it (aside from the stuff I learned in my recent MS), but I've become fond of HackerRank. Found out about it three days ago and I've been spending hours on solving problems in many of their sections.

Questions:

1. Is this a good way to refine/learn coding? I'm also learning from a book by doing some self studying, but HackerRank is really awesome and I find myself enjoying coding a lot more.

2. For some of the problems, is it bad to use Google for parts of it? For example, for one problem, I was able to develop an algorithm to solve it, but forgot how to find the min/max of an array (which was necessary for my algorithm to work). I looked up how to implement the min/max of an array, understood/learned the logic of it and then implemented it into my own code. The algorithm worked, I was happy. Is this bad or considered cheating? I didn't look up the question itself.

3. The algorithms and code I develop seem to be a bit more ... plentiful? I see other people solve coding challenges with like 10 lines of code while mine has 15 or more lines. Or, they have two for loops, but I have three or four. I'd imagine this is bad, but how bad is it?

Tried to start a stand alone thread, but it died. Thanks for any replies, if any.
>>
>>61401424
have you ever made anything useful? you aren't going to get hired by bragging about your hackerrank score.
>>
>>61401463
Not true actually,.
>>
File: scr.png (49KB, 1680x1050px) Image search: [Google]
scr.png
49KB, 1680x1050px
>>61398050
>What are you working on, /g/?

Exploring the deepest, darkest corners of Racket.
>>
>>61401463
I'm not intending to put that on my resume, but thanks for assuming that!

And yes, I have. I guess so. I used to teach math classes as a TA and I made a program for my prof to input the names/uncurved grades to his classes and then generate the curved grades for each student, depending on the class average. Also, as a mathematics tutor at a community college, I gave the tutoring center a program that allowed students to find slopes/y-intercepts/x-intercepts/distance and some other things, as long as they put in the numbers. Also, percents. A lot of students found it useful and the tutoring lab used it for the summer; I don't know if they kept using it later on. I was never contacted about it, ever again.

I also took some engineering classes and used MATLAB for some projects, but that's about it. Like using Simulink/SimScape to develop controllers for a dynamical system.
>>
>>61401506
but do you have a github that shows software you developed or contributed to?
>>
>>61400692
Isn't that what Apple's "GC" langs did?
>>
>>61401616
Yes, I put those two projects on my GitHub and some other small things (e.g., for an all-girls HS coding class I was teaching, I had them create some programs and I put the template code for all assignments on GH).

Signed up for GH two weeks ago, btw.
>>
>>61401642
in that case you have done more than literally everyone on /g/
>>
What's the best IDE for C on GNU/Linux?
>>
>>61401806
*sh.
>>
>>61401806
no IDE, only an editor and independent command line tools (gcc, gdb, valgrind, cmake, objdump..), and some sort of clang completion daemon in the editor, such as irony.
>>
>>61401817
>>61401894
Look, can you just recommend me an IDE already?
>>
>>61401909
*sh.
Your shell is an Integrated Development Environment. It enables you to access a text editor, a compiler and a debugger all in the same place.
>>
>>61401934
I'm going to be experimenting with multithreaded programming, and I want something that has built-in, GUI tools for debugging.
If I was just doing hello world I'd use vim, but I'm a novice and just want some debugger that doesn't require a decade to learn how to use and what it's saying.
>>
>>61401909
you asked for the best GNU/Linux IDE so I answered your question exactly. There's also qtcreator, it's alright, my colleagues use it with good success.
>>
I'm rewriting my resume to hopefully get out of shitty webdev hell and start programming in C. I can't think of what to title this section though. Any ideas?
C Projects
Extensive work using the C programming language to create fast, efficient and small programs that encompass numerous areas of Information Technology and Computer Science.
Implemented minimum heap, priority queue and uniform search algorithm able to process 30 nodes per millisecond
Mandelbrot set visualiser for use on a super computer to create thousands of frames at high resolution
Simple cross platform TCP/IP library designed to interact with a virtual stock exchange in real-time
Basic Stack Machine that parses and interprets a custom instruction set
>>
>>61401946
GDB is quite straightforward. Start it with the name of the program you want to debug as argument. Place breakpoints with "break filename.c:linenumber". Start the program with "start argument1 argument2 argument3". When you hit a breakpoint, type "continue" to continue executing the program. When you want to step to the next line, type "step". And so on.
If you have a hard time figuring how to do something there are a tons of stackoverflow questions about using gdb, just ask your search engine.
>>
I'm brainstorming on a new project. It'll be a tool to help me learn Japanese with flashcards using the Leitner system. It's basically my homegrown Anki clone.
My idea is to use Haskell and SQLite. I initially wanted to use Rust, but Haskell is a more interesting creature.
What library would you recommend for SQLite? Preferrably one with an ORM. Should I use Cabal or Stack? I feel like Cabal is easier and thus more suited for this project.
>>
>>61398622
That this person is likely touching security somewhere is most concerning.
>>
How to learn multi threading and good memory management in C for ARM? Are there any good video tutorials?
>>
>>61402151
what those have to do with arm? it's more of an os matter.
>>
>>61402151
Posix threads, synchronization primitives and OpenMP are some subjects you may want to look up. It's hard to say because ARM programming per se doesn't really mean much.
Good memory management in C is to free() what's been malloc()'d in symmetric ways, not much else to say about the subject.
>>
>>61402151
>good threading
The entirely on the domain issue. There's no good general solution. I don't know if it exists but find a tool to check just what state you're using. The way virtually nothing is thread local in C is a problem usually.
But once you're past that how to make your mult-threading efficient is not very easy.
>good memory management
Depends on what you're managing. Write your own allocators.
Region based memory arenas are my favorite because their efficiency and how they're easy to manage.
I advise writing your own allocators also because it makes debugging a lot easier. Not for bugs that appear in long running programs though. Those are the most difficult.
It's not as hard as people make it out to be though. Generally what happens in GCd systems for instance is that they hide your issues. You allocate things that shouldn't be and the GC can clean it up without issue. But the allocation is still an issue.
>>
>>61402275
>Good memory management in C is to free() what's been malloc()'d in symmetric ways, not much else to say about the subject.
kek. cs101 student here, guys.
>>
Is there a better way to do this?

#include <glm\glm.hpp>

// Object containing minimum and maximum bounds of a static model.
class StaticBounds
{
public:
// Minimum bounds (in object space).
glm::vec3 min;
// Maximum bounds (in object space).
glm::vec3 max;

// Constructor.
StaticBounds() { first = true; };
// Destructor.
~StaticBounds() {};

// Alters the minimum and maximum values depending on the components of the passed vertex.
// If unset, the first vertex passed will determine the minimum and maximum bounds.
void addVertex(const glm::vec3& vert)
{
if (first)
setFirst(vert);
else
allChecks(vert);
};

private:
// Boolean indicating whether or not the first vertex has been set yet.
bool first;

// Sets the minimum and maximum values to the passed vertex, then sets first to false.
void setFirst(const glm::vec3& vert)
{
min = max = vert;
first = false;
};

// Performs checks on all components of the passed vertex.
// Alters minimum and maximum values accordingly.
void allChecks(const glm::vec3& vert)
{
xCheck(vert);
yCheck(vert);
zCheck(vert);
};

// Performs checks on the x-component of the passed vertex.
void xCheck(const glm::vec3& vert)
{
if (vert.x < min.x)
min.x = vert.x;
else if (vert.x > max.x)
max.x = vert.x;
};

// Performs checks on the y-component of the passed vertex.
void yCheck(const glm::vec3& vert)
{
if (vert.y < min.y)
min.y = vert.y;
else if (vert.y > max.y)
max.y = vert.y;
};

// Performs checks on the z-component of the passed vertex.
void zCheck(const glm::vec3& vert)
{
if (vert.z < min.z)
min.z = vert.z;
else if (vert.z > max.z)
max.z = vert.z;
};
};
>>
I just figured out that you can put anything into a Java array - similar to how you can put anything into a Python list - if you declare the array as an Object[] array
>>
>>61402495
This is very bad practice because the object insides of the array become pretty much unusable. You can only do things with them that Objects can do.
>>
>>61402495
It gets worse.
Object[] arr = new Integer[1];
arr[0] = "kek";

Compiles but gives you a runtime error
>>
>>61402510
What if you increase the Integer array size to match the length of the string?
>>
>>61402519
That's not how it works.
>>
Ive taken to learning python since ive got no friends or life after work and think i can use it to automate some stuff at my job. Im doing a udemy course which i got for $10, its going fairly well but i feel like i should be supplementing the lectures with other sources. Can you guys recommend any sites or material i should be looking at? Also the course teacher recommended i use atom, which runs like shit on my pc. What would you guus use?
>>
>>61402533
Just saying, it might be interpreting the string as an array of characters, and then casting those characters to integers.
>>
Share your insight in software testing with me.
>>
>>61402545
Java does not do that. Integer and String inherit from Object. Integer is not an int and String is not a char[].
>>
>>61402534
Python 2 or 3?
>>61402545
No, it compiles because it expects an Object, and doesn't check that it actually needs an Integer
>>
>>61402491
I wouldn't break it up in such a convoluted way but in principle it's fine.

I'd add a function that lets you pass an array of verts too.
>>
anons is there a website that can convert java to c++

im trying to learn the syntax
>>
File: 1499404611227.png (96KB, 400x400px) Image search: [Google]
1499404611227.png
96KB, 400x400px
>>61402552
In theory, it's pretty nifty. For stuff like NASA and banks, it's absolutely mandatory.

Outside of these businesses, however, things get hairy. When new hires get made to do test driven development without ever having done it before, shit absolutely hits the fan.

One company I was with hired a woman to do test driven development. She was given a simple task, to transform an input XML-document into an output-array, which would be returned and sent to a program I had written as input.

The only test she ever wrote was one which took the entire example file she had been given (formatted as a single-line string of course) and expected the example output that had been provided.

Needless to say, every input but the example broke everything about her code. And naturally, it fell to me to fix her garbage to meet the deadline.

She was not fired for this. In fact, I think she still works there, botching project after project.
>>
>>61402622
no
>>
>>61402491
By not using Sepples.
>>
File: 1498855111293.png (207KB, 403x433px) Image search: [Google]
1498855111293.png
207KB, 403x433px
>>61402635

t-thanks for the quick respond
>>
>>61398050
How do I run a python script all the time if I don't want to keep my computer switched on all the time?
>>
>>61402616
Good idea. Thank you!

>>61402644
What is Sepples?
>>
>>61402563
Python 3
>>
>>61402659
Get a VPS or use heroku or friends
>>
>>61402670
sepples is the meme name for C++
>>
File: anime-girl-questionmark.jpg (176KB, 1280x1024px) Image search: [Google]
anime-girl-questionmark.jpg
176KB, 1280x1024px
>>61402685
Is there a better language to use for writing rendering engines?
>>
>>61402682
Cheers
>>
>>61402676
Have you checked out this site
https://docs.python.org/3/
It has anything you might want to know, but it's not too accessible to complete beginners.
>>
>>61402695
C++ is fine. Don't listen to those faggots.
>>
Is anyone here into webgl ? I'm trying to create a small 3d engine. How do you structure your code ? Any tips,creations are welcome.
>>
>>61402765
I've actually been creating a game engine for mostly 2d stuff and literally every thing I've found has just pointed to helper libraries. It's been really useless and I've just winged it which has caused it to be pretty bad because I'm horrible at structuring code.
>>
>>61402682
Why heroku? What makes it better?
>>
>>61402790

What helper libraries do you use ? Might pick some for my project.
>>
>>61402659
If it's not overly performance critical you could also get a Raspberry for this

I got one solely for running my Python stuff (webscraping) 24/7 and improving on my nonexistent Gahnoo Kleenux skills
>>
>>61402695
rust
>>
>>61398062
>my job is mostly C++/Python/Matlab?
lucky basterd
>>
>>61402921
I didn't use one. I think people use stuff like threejs or something.
>>
>>61400823
>Inefficient
Not if you are lazy
>>
>>61402930
Tell me about your webscraping. What do you scrape the web for?

I've been wanting to automate my instagram stalking activities, but haven't really gotten around to it
>>
>>61403000

Oh you were just referring to the fact that everyone uses these libraries and no one uses raw webgl so you can't learn from someone on that matter.
>>
>>61402695
C or (((Rust)))
>>
>>61402860
If you don't want to spend time administrating your VPS it's a lot less hassle
>>
>>61403010
Yeah pretty much. Most tutorials or references touch on it for a single paragraph then immediately abstract it away.
>>
>>61403006
My latest project was crawling lewds from aliexpress
>>
>>61403028

I thought I was the only one tha noticed this. It drives me crazy man. For now I read/watch regular opengl books/videos and try to implement the structure of the code. The thing is I try so hard to emulate the classes and as a JavaScript amateur I obviously don't know things about the language and I probably hinder my progress, but I guess progress is still progress. I think that optimizations and code base structure won't affect the end product so much.
>>
>>61403108
Try looking at other js 3d engines. They will probably implement the helper libraries themselves instead of using them separately.
>>
>>61403108
Optimizations mean EVERYTHING when working with OpenGL. Something as simple as checking whether or not you need to update an object before actually updating it can mean the difference between 20 and 60 FPS.
>>
File: upset meme.jpg (41KB, 450x450px) Image search: [Google]
upset meme.jpg
41KB, 450x450px
How do unions work?
>>
>>61403262
In which language?
>>
>>61403286
C/C++
>>
>>61403294
A union stores several variables in the same memory location. The variables are overlapping each other in memory, so you can only use one at a time. The size of the union is the size of the biggest member.
>>
>>61403262
like pyramid schemes
>>
>PartialOrd
How can people tolerate this much pain in the ass?

use std::cmp::PartialOrd;

fn largest<T: PartialOrd + Copy>(list: &[T]) -> T {
let mut largest = list[0];

for &item in list.iter() {
if item > largest {
largest = item;
}
}

largest
}

fn main() {
let numbers = vec![34, 50, 25, 100, 65];

let result = largest(&numbers);
println!("The largest number is {}", result);

let chars = vec!['y', 'm', 'a', 'q'];

let result = largest(&chars);
println!("The largest char is {}", result);
}
>>
Any language slower than C++ needs to die.
>inb4 "muh vidya"
Irrelevant. A faster language is inherently desirable in and of itself. It conserves computational resources for simple tasks and makes hypothetical more computationally challenging tasks more feasible, regardless of whether the latter yet has any important real world use, because we never know when it might. Also, faster languages mean less demand on end user patience.

Don't mistake me for saying C, C++, and Rust are any good. They're shit. In fact I'm very disappointed in them. There's no reason they can't be much higher level and still just as fast to run: just make them slower to compile. And that's not actually a problem really. Programmers are already overstressed. (I don't want to say "overworked" because their job literally consists of sitting around, and although I don't doubt their work ethic, willpower, ability to tolerate stress, and ability and willingness to genuinely work hard if the need ever presented itself, you have to admit that as it stands, they're physically [Not Mentally] very lazy, further attested to by the associated occupational risk of obesity.) So giving them longer brief moments of respite would actually be a good thing.

So yeah. We need a lightning fast very high level language that achieves its abstraction by taking ages to compile and at no other cost. That would be awesome.
>>
>>61403547
>I want C++ to take longer to compile
What the fuck is wrong with you?
>>
>>61403557
It would give the compiler time to make the language it understands more elegant without compromising runtime speed.
Language elegance and runtime speed are both important. Compilation time basically isn't. My point is I don't see why it's always framed as a debate between the prior two (e.g. Haskell vs C++) when we could just be beating the shit out of the latter and boosting the prior two way the fuck up together.
>>
>>61403611
Compilers struggle to even to optimize away trivial cases where garbage collection is unnecessary. How do you expect them to know what the best data structure to use is without profiling and recompiling like a JIT compiler?
>>
>>61403547
There are things that you can't just compile. You can't make a garbage collector disappear just by compiling (no, Rust's lifetimes aren't equivalent to a garbage collector, you have to help the fuck out of it in order for it to work). You can't "just compile" Erlang's processes either (no, replacing them with posix threads isn't a good idea).
>>
>>61403611
Most programs are currently developed under the open world assumption, which means compilers cannot reliably infer hypotheses that stand for whole programs in their entire lifetime. (If you can prove static properties leading to optimization, these can be destroyed by introduction of new code by dynamic loading).
Under just-in-time compilation you can adapt to changing hypotheses, but you are consuming CPU resource during execution in order to improve compilation, which is a somewhat schizophrenic goal (slowing down to accelerate better).
>>
>>61403730
>without profiling and recompiling like a JIT compiler
Why should it not do this though?
I would gladly wait as much as half a day for a very high level source file to compile if the end result would be just as fast as C.
>>
>>61403547
>There's no reason they can't be much higher level and still just as fast to run: just make them slower to compile.
Anon there's no reason we can't have both. C++ is just a shit language. That's why it's so slow to compile. Look at JAIs compile times. It's also aiming to be high level and it compiles many magnitudes faster than C and has the full benefit of LLVMs optimizer.

High level languages tend to suffer in that their schematics require them to work. Which seems kinda obvious and necessary but if you compare an optimized routine written in C to a high level language "equivalent" you can't give the detail you would in C to that high level construct because it'd completely cripple the point of the high level construct. And the compiler can't decide to make the C versions result because it's a highly specific and interdependent system usually (things like how you store the data and access it can't be determined locally to be optimal for the entire program).

What you could do if you absolutely don't give a shit about compile time is that you could create a build system that profiles your code and chooses different sets of underlying representations for your high level structure by some intelligent bruteforcing algorithm.
But that's still problematic because you'd have a very large set of representations to go through and figuring out which (and how) is difficult for programmers to do manually. To automate this is an even more difficult task.

To me it sounds like you want Java honestly. It's similar in speed to C++ when the JVM is tuned right (not trivial to do) and it's largely removing the low level concerns.
I don't know what kind of facilities the JVM has to export its previous JIT conclusions about the code but it could probably make your code fully compiled if you can.

I find it difficult to take a C++ programmer who wants to run away from the low-level nature of it seriously. It's why you use C++ really.
>>
>>61403766
Like >>61403757 described, dynamic linkage completely destroys any assumptions you can make.
Even C's linkage model sucks for full-program optimization. LTO is awfully tricky.
>>
>>61403794
>Even C's linkage model sucks for full-program optimization.
That's because it's a very poor model for that.
>>
>>61403792
>compiles many magnitudes faster than C
I meant to say C++. Since i use C throughout the rest of the post it's confusing so I'm correcting myself. Normally I'd have you figure this shit out..
>>
>>61398090
It's a more complete, natively object oriented framework for multimedia applications. SFML would be to OOP what SDL is to imperative programming, so CSFML basically pulls it into the same realm. A clear advantage it has over SDL is built-in support for shaders if you want control over your graphics pipeline. Otherwise there really isn't a big difference, both are fine if you need to have a well-furnished multimedia API, although (C)SFML is a bit higher level.

t. GLFW + GLEW + OGL shill
>>
Is a properly coded C program with statically linked musl-libc as fast as a properly coded asm program?
>>
>>61403909
Define properly coded.
>>
File: test.gif (489KB, 205x142px) Image search: [Google]
test.gif
489KB, 205x142px
>>61403547
>"hur a dhur just take all the overhead and move it over there"
>he assumes you can just do this
>he assumes resolving complicated runtime shit at compile time is in the general case a task computers are actually capable of
>he is this much of a brainlet
>>
>>61403909
It depends on the program but
>properly coded
Meaning optimal for the target machine? An asm representation is more granular so it will win out.

As for style you'll probably find that C programmers do make concessions for clarity all over. If you program in asm you do the same.
>>
>>61403794
Can't you statically link it, or straight up #include the .c files instead of the header files so it compiles all the libraries again too?
>>
>>61403935
Properly coded meaning optimized for speed.
>>
what's a good first real language to learn for a normie with basic computer, html and a bit of sql knowledge? is python a good first choice?
>>
>>61403938
>Can't you statically link it
Static linking means you have compiled code which you may insert. Context is lost when you compile units as seperate.
>can't you just #include everything into one translation unit?
You could usually. It's just not how things are done usually.
>>
>>61403938
Even basic shit like inlining functions is difficult with C's static linkage.
>>
Dumb question but what is general rule of using switch instead of if-statement or vice versa?
>>
>>61403909
a modern optimising compiler shits all over 99% of code an experienced assembly developer can put out
>>
>>61403958
What would the performance be like? If I run sed 's/\.h>$/\.c>/g' on all my source files and subarch compile them, what will happen?
>>
I need to master oop. I already know the basics, but my boss demand me to study more. I would like to know any good resource to master this. And yeah, java is a must.
>>
>>61403996
No idea. Depends entirely on your library use and what could actually be done now that couldn't be done before. It's impossible to tell.
>>
>>61403979
Think of a case where multiple if-elses would add horrendous noise to your program.
>>
>>61403979
Traditionally (although many modern languages have changed this) switch statements' case expressions must be compile time constants. To this day, it's best practice not to use a switch statement if your case expressions would have to do things like call functions.
>>
I wish to learn about https://gitlab.com/xonotic
It's a very impressive game in some ways and it's completely open source, so that's nice.

But I don't see where I should start learning about this project. How do you approach something like this? I don't have any specific goals aside from figuring out how the warpzones (https://www.youtube.com/watch?v=ORh6NfQRDxg) work so smoothly (this video isn't a good representation since it's recorded from a demo perspective, ingame it's completely free of artefacts). But I'd also like to get a general gist of the engine.

Should I run some graphing tools on it? What do I do?
>>
>>61403396
proc largest[T](values: seq[T]): T=
result = values[0]
for value in values:
if value > result:
result = value

proc main()=
@[12,22,13,-3].largest.echo
@['e', '0', 'A'].largest.echo

main()
>>
>>61404009
Writing code utilizing OOP concepts is probably the best way to learn.
>>
>>61403953
I'd say yeah. Python has nice syntax and is easy to get to a point of creating something quickly to reinforce your motivations.

However you should eventually learn C since all the good parts of Python are written in C/C++
>>
what does this function does,/g/?

i was asked this question and couldn't answer?
int foo(int t1, int t2)
{
int t7;
int *t6;
int t3 = 0;
int t4 = 0;
while (t2 > t4) {
t7 = t6[t4];
t3 = t3 + t7;
if (t3 <= 0)
break;
t4++;
}
return t4;
}
>>
>>61404048

int *t6;
...
t6[t4]

How are you dereferencing an uninitialized pointer?
>>
>>61404048
Undefined behavior, I believe.
>>
>>61403979
>switch instead of if-statement or vice versa?
It's generally about the number of conditions and the nature of them.
If you have a lot of complex logic (i.e. many different conditions to be fulfilled for each branch) you're kinda stuck with if else. In that case using a switch case outside the if else to remove some of the conditional work would be advised for clarity, the compiler shouldn't struggle with simplifying your logic though.

Using switch cases shouldn't be forced. When it's not forced it's usually good. It can be tircky to tell when you should morph your input data to give you something to switch on. That's really difficult.

But dont' worry too much about it.
>>
>>61404048
It crashes, most likely.
Unless you're running in a freestanding environment, you can't just declare a pointer and start using it to write to memory. The address that pointer refers to could be anywhere, and is almost certainly invalid.
>>
>>61404037
What am I looking at?
>>
Which gives faster code? GCC or Clang?
>>
>>61404100
finding the largest value in a generic range
>>
>>61404093
>>61404070
>>61404065
the question was this

"given the 3-address code below, explain what the following function does" (3 marks)
( 1) t1 := param[0]
( 2) t2 := param[1]
( 3) t3 := 0
( 4) t4 := t3
( 5) if t2 <= t4 goto (13)
( 6) t5 := t4 * 4
( 7) t6 := t1 + t5
( 8) t7 := *t6
( 9) t3 := t3 + t7
(10) if t3 <= 0 goto (13)
(11) t4 := t4 + 1
(12) goto (5)
(13) return t4
>>
man, playing around with ESP8266 is the most fun I ever had since I played with toy and legos years ago.
>>
>>61404119
GCC
>>
>>61404119
There's tons of benchmarks anon.
I suggest you look at the ones with more realistic situations.
>>
>>61404119
Depends on the code being compiled. GCC used to be and might still be slightly faster.
>>
>>61404119
gcc is absolutely disgusting and needs to die though.
>>
>>61404123
No shit, what language?
>>
>>61404119
In my experience I find GCC slightly faster except when it comes to vectorization where Clang wins hands down. Clang produces cleaner assembly outputs.
>>
>>61404126
This doesn't look like C. Define the semantics of the language.
>>
>>61404126
I'm glad I'll find this kind of code at my future job!
>>
>>61404155
>vectorization
I'm a clang fan but you shouldn't use this unless you're just lazy.
>>
>>61404157
its a intermediate representation (IR) of C code

these are the rules the 3-address code was written
x := y op z
x := uop y
x := y
goto L
if x relop y goto L
param x
call p, n
return
x := call p, n
return x
x := param[i]
x := y[i]
x[i] := y
x := &y
x := *y
*x := y
>>
>>61404151
nim
>>
>>61404194
Looks comfo desu senpai.
>>
>>61404126
>>61404191
Looks like an infinite loop if the first element of the array is 0.
Don't want to bother with the rest desu.
>>
>>61404048
int foo(int t1, int t2)
{
int t7;
int *t6;
int sum = 0;
int i=0;
for( i=0; t2 > i;i++) {
t7 = t6[i];
sum = sum + t7;
if (sum <= 0)
break;
}
return i;
}

It's obviously undefined behavior but it sums every 4 bytes interpreted as signed integers until the result is <=0 at which point it returns the number of ints it summed.

I don't know what the answer to the question should be though.
>>
>>61404126
It seems to compute the length of a negative-terminated int array whose address is t1, where that length can be at most t2. It's basically strnlen, but for nonnegative ints instead of nonzero chars.
>>
Idris > Haskell > *
>>
>>61404393
Get a job.
>>
>>61404401
BTFO
>>
>>61404393
I want fries with that!
>>
>>61404126
(cont from >>61404362)
Wait, no, I was wrong. This calculates how many ints from t1 you can add up (but at most t2) before the result is negative or 0.
>>
>>61404037
Someone told me people replace Lua with nim.
How do i sandbox in nim?
>>
>>61404401
Nah

>>61404413
You should lay off the fries, they seem to be doing funny things to your brain
>>
>>61404437
You don't even exist.
>>
>>61404453
>You don't even exist.
Cogito ergo sum!
>>
>>61404437
>Nah
what are you? a NEET?

did you trick the government to give you money'?
>>
>>61404464
This statement assumes that causality exists. You can't prove that causality exists.
>>
>>61404484
>You can't prove that causality exists.
Causality is order by definition; we therefore know it exists because we know that not all observations are the same
>>
File: haskellprogrammer.jpg (10KB, 300x300px) Image search: [Google]
haskellprogrammer.jpg
10KB, 300x300px
>In fact I'm very disappointed in C++
>>
>>61404506
This statement relies on causality and therefore doesn't prove that causality exists.
>>
>>61404512
>having expectations for C++
>>
>>61404470
>trick
Disability checks for programming in haskell. He's not tricking anyone
>>
>>61404538
lawl
>>
>"Hey doc, I like programming in Haskell"
>"Say no mo faam, here is your check"
>>
>>61404484
Telling someone their proof is not persuasive because it assumes the existence of causality assumes the existence of causality due to the implicit "because." There is therefore self inconsistency inherent to that counterargument, and therefore you shouldn't use it.
>>
how to uncurry my life?
>>
>>61404598
Your statement doesn't prove that my statement is wrong. It only proves that my statement might not be true, much like every other possible statements, including "cogito ergo sum".
>>
File: 113449.png (50KB, 700x700px) Image search: [Google]
113449.png
50KB, 700x700px
Was he right?
>>
>>61404603
\f (x,y) -> f x y
>>
>>61404629
But telling someone their proof is not persuasive because it assumes the existence of causality assumes the existence of causality due to the implicit "because." There is therefore self inconsistency inherent to that counterargument, and therefore you shouldn't use it.
>>
File: 1500171841066.png (234KB, 1732x2076px) Image search: [Google]
1500171841066.png
234KB, 1732x2076px
>>61404603
Stop using functional languages.
>fpfags accuse oopfags of being curryniggers
>fpfags literally make use of a technique called currying
>mfw it's actually very useful
>mfw they were indian enough to name something that's actually very useful after curryniggers
>mfw
>>
>>61404646
Curry is an English surname and has been for hundreds of years you illiterate peasant
>>
>>61404393
How's library support on Idris?
>>
>>61404656
Wrong. It is street shitter food.
>>
>>61404643
But your statement doesn't prove that my statement is wrong. It only proves that my statement might not be true, much like every other possible statements, including "cogito ergo sum".
>>
>>61404674
never reproduce you fucking idiot
>>
>>61404670
Idris doesn't have libraries
>>
>>61404629
The aim wasn't to prove you're wrong, the aim was to prove you're being unreasonable in your standard of skepticism.
>>
>>61404674
Do you have to constantly wear a helmet to avoid walking into things?
>>
>>61404686
Why should I when you are the one who is wrong?
Curry has been a thing eaten by disgusting low lives who poo in street far longer than it's been a name.
>>
It's happening...

>>61404703
>>61404703
>>61404703
>>
>>61404702
see: >>61404710
>>
>>61404689
Great, all the more reason to keep being a Hasklet.
>>
>>61404712
>posted before bump limit
leave
>>
>>61404710
>>61404728
Wow anon, you're so funny !! xD!!! keep telling jokes xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD xD
>>
>>61404757
>x*
>>>/r/ibbit
kys reddit cancer
>>
>>61404693
What does being reasonnable mean? Doesn't being reasonnable mean studying every possibility in order to find the one that is the most factually correct?

Not trolling or arguing in bad faith btw, I've been haunted by this question for more ten years.
>>
>>61404743
okie doke
>>
>>61404781
xD curry xD curri curry curryie xD india xD pajeet xd
>>
New thread:

>>61404703
>>61404703
>>61404703
>>
>>61404794
reasonable*
I think the ideal you're aiming for is logic rather than reason, anon. And sure, if you believe your human mind is capable of studying each and every possibility, do so. I personally don't believe we are capable of doing such things, and that one should only ask questions and search for logic that can then be transformed into practise in life. Logic which exists for its own sake without any real practicality is useless.
>>
"""functional"", more like malfunction
>>
>>61404035
You start reading, any where.

Then you keep reading and when you eventually find main() you probably understand half the code.
>>
>>61398914
>I have literally never heard of this acronym
lmao plen
Thread posts: 316
Thread images: 30


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

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


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