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: 384 KB, 1024x768, scheme.png [View same] [iqdb] [saucenao] [google] [report]
61398050 No.61398050 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/?
Previous thread: >>61393119

>> No.61398062
File: 35 KB, 388x380, 1324690418001.jpg [View same] [iqdb] [saucenao] [google] [report]
61398062

Why should I learn haskell if my job is mostly C++/Python/Matlab?

>> No.61398065
File: 52 KB, 600x373, unit testing framework.jpg [View same] [iqdb] [saucenao] [google] [report]
61398065

>> No.61398067

>>61398050
>What are you working on, /g/?
Trying to get my way arounf CSFML.

>> No.61398069

OP can this be a no pajeets edition?
They ruined the last thread by trying to convince people their country wasn't shit

>> No.61398074
File: 86 KB, 711x1024, annotated_monads.1.jpg [View same] [iqdb] [saucenao] [google] [report]
61398074

>>61398062
dumb frogposter
please DON'T learn Haskell, you're a fag and we don't want you

thanks
well no

no thanks
fag

>> No.61398090

>>61398067
How does it compare to SDL, GLFW, Freeglut, etc?

>> No.61398100

>>61398062
it gives you a new perspective on how to program

>> No.61398111

>>61398050
Should I not use md5 for my database?

>> No.61398112

>>61398062
Like in almost everything, constraints are great for inspiration.

>> No.61398117

>>61398100
But is it efficient though?

>> No.61398127
File: 39 KB, 411x381, 1499902918655.jpg [View same] [iqdb] [saucenao] [google] [report]
61398127

Why do you have to post anime in every /dpt/?

>> No.61398133

>>61398111
As long as you're not hashing passwords with it, I think it's okay.

>> No.61398141

>>61398133
>As long as you're not hashing passwords with it
Nothing wrong with doing that.

>> No.61398145

>>61398127
Anime imageboard

>> No.61398152

>>61398141
MD5 is cryptographically insecure though. It's only slightly better than storing the passwords unhashed in your database.

>> No.61398157

>>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.

>> No.61398167

>>61398145
there's a special place in hell for people like you, it's called /a/

>> No.61398170

>>61398074
But is it efficient though?

>> No.61398173

>>61398111
this: >>61398133

If you are using passwords, use sha256.

>> No.61398177

>>61398074
I don't get the depiction of list here.

>> No.61398178

>>61398141
Shit's been broken, never use it for sensitive data

>> No.61398193

>>61398152
>MD5 is cryptographically insecure though
This is absolutely wrong.

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

>>61398173
Why?

>> No.61398194

>>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

>> No.61398198

>>61398177
branching computations
the end result is concatenated

>> No.61398199

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.

>> No.61398223

>>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

>> No.61398227

>>61398223
But is it efficient though?
("It" being Haskell)

>> No.61398230

>>61398223
Show me a (second) preimage attack on md5.
Protip: you can't
Thus, MD5 hasn't been broken.

>> No.61398236

>>61398050
A higher level LLVM assembly metalanguage with Common Lisp macros and JIT compilation.

>> No.61398247

>>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.

>> No.61398265

>>61398247
>rainbow table
Thanks for nothing, rainbow tables exist for every hash function.

>> No.61398270

>>61398265
But is it efficient though?

>> No.61398272

>>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

>> No.61398286

>>61398230
Wow, you sure showed me, guess I'll go use md5 for all my security needs.

>> No.61398298

>>61398286
Not an argument.

>> No.61398303

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?

>> No.61398322

>>61398303
nothing less than an i9 32GB of ram if you want to program

>> No.61398326

>>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.

>> No.61398330

>>61398298
It's not exactly a controversial idea that it's insecure.
http://www.kb.cert.org/vuls/id/836068

>> No.61398334

>>61398303
you can learn programming with a computer from the 80s

>> No.61398336

>>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.

>> No.61398343

>>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

>> No.61398353

>>61398330
>collision attacks
Literally nobody cares about collision attacks, as long as they are not second preimage attacks it's fine.

>> No.61398368

>>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

>> No.61398395

>>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

>> No.61398397

>>61398353
Yes, trust the random anon on the Internet, ignore the fact that literally everyone else says it's insecure

>> No.61398435

>>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

>> No.61398439

>>61398127
Touhou is not an anime

>> No.61398449

>>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.

>> No.61398457

>>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.

>> No.61398467

>>61398457
Everyone starts somewhere, anon.
Don't worry about it!

>> No.61398474

>>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.

>> No.61398495

>>61398467
Thanks for the support anon. I will keep at it.

>> No.61398514

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?

>> No.61398523

>>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.

>> No.61398524

>>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.

>> No.61398527

>>61398514
>language agnostic definition of expression size

>> No.61398531

>>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

>> No.61398538

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.

>> No.61398542

>>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.

>> No.61398544

>>61398457
I think the final while might be redundant since everything in R comes from the latter half of arr

>> No.61398559

>>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.

>> No.61398564

>>61398531
Thank you man. I will definitely check it out.

>> No.61398570

>>61398559
>thus it is irrelevant in the real world
Oh, I guess they were just kidding when they said never to use it then.

>> No.61398575

>>61398193
>absolutely wrong
You really should be using md6 now. Finding collisions for md5 is trivial.

>> No.61398590

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.

>> No.61398596

>>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?

>> No.61398598

>>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.

>> No.61398604

>>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.

>> No.61398622
File: 48 KB, 524x480, 1376505409276.jpg [View same] [iqdb] [saucenao] [google] [report]
61398622

>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.

>> No.61398636

>>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?

>> No.61398655

>>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.

>> No.61398662

>>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.

>> No.61398694

>>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.

>> No.61398713

>>61398655
>>literally the same holds true for every single cryptographic hash function
No, it really fucking doesn't.

>> No.61398723
File: 12 KB, 752x132, YYYY-07-DD 21_07_SS.png [View same] [iqdb] [saucenao] [google] [report]
61398723

>ode45

>> No.61398730

>>61398713
Sure thing m8

>>61398694
Nowadays one would go for argon2i.

>> No.61398737

>>61398723
>matlab
>2GB/s

>> No.61398755

>>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

>> No.61398759
File: 35 KB, 640x336, bscap0042.jpg [View same] [iqdb] [saucenao] [google] [report]
61398759

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

>> No.61398761

>>61398755
Still waiting for a proper argument, shitposter.

>> No.61398768
File: 29 KB, 903x609, YYYY-07-DD 21_07_SS.png [View same] [iqdb] [saucenao] [google] [report]
61398768

>>61398737
time step too big lul

>> No.61398769

>>61398759
Yes, it is possible, but dodgy as fuck.
That's how programs like cheatengine and various debuggers work.

>> No.61398770

>>61398759
Yes it is possible and yes, it already exists. (see cheatengine for example)

>> No.61398774

>>61398768
>matlab
>8GB/s

>> No.61398781

>>61398761
>many resources saying not to use it vs. one faggot on 4chan
Wow, who should I trust.

>> No.61398796

>>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

>> No.61398826

>>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 == arr[i+m]

>> No.61398830
File: 53 KB, 640x480, name.jpg [View same] [iqdb] [saucenao] [google] [report]
61398830

>>61398590
nvm I figured it out

>> No.61398839

>>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

>> No.61398900

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?

>> No.61398914

>>61398900
>SOLID
I have literally never heard of this acronym

>OOP
It simply isn't good design.

>> No.61398936

>>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/

>> No.61398939
File: 128 KB, 880x739, home.png [View same] [iqdb] [saucenao] [google] [report]
61398939

>>61398167
I mean not like the home posts anime

>> No.61398957

>>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).

>> No.61398988

>>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

>> No.61398992

>>61398936
Bro, I am not the anon you replied to, but holy molly is this gold. Thanks for posting it.

>> No.61399102

>>61398826
Thanks for the reply, anon. I see what you are saying, but don't you still need to copy the contents of R back into the array? Because, if I remember correctly, the contents of arr[i + m] are inside R, 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.

>> No.61399228

>>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

>> No.61399353

>>61398936
>>61398936

Thank you so much anon, I will be forever grateful

>> No.61399354

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.

>> No.61399506

>>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.

>> No.61399531

>>61399506

Not bad, thanks anon

>> No.61399534

>>61398781
Many resources say that Java is awesome vs one faggot on 4chan.
Fuck off pajeet.

>> No.61399928

>>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.

>> No.61399948

Anyone knows if it's possible to mount a FUSE filesystem inside of another unrelated FUSE filesystem?

>> No.61400000

>>61399354
make something that browses random twitter accounts for sentiment analysis data collection. random is important to prevent any form of bias.

>> No.61400025

>>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

>> No.61400136

>>61400000
Gotta check those quints

>> No.61400391

>>61399506
>>61400000
>>61400025

Thanks gents, you're amazing

>> No.61400444
File: 173 KB, 600x355, old_hag_langs.png [View same] [iqdb] [saucenao] [google] [report]
61400444

111st for CCC

>> No.61400692

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.

>> No.61400708

>2017
>Defining your behavior
C masterrace here.

>> No.61400712
File: 111 KB, 2546x756, Screenshot from 2017-07-16 10-34-44.png [View same] [iqdb] [saucenao] [google] [report]
61400712

badly drawn thinking emoji jpg

>> No.61400737
File: 35 KB, 500x471, 1482612226073.jpg [View same] [iqdb] [saucenao] [google] [report]
61400737

>>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

>> No.61400740
File: 7 KB, 256x197, images.jpg [View same] [iqdb] [saucenao] [google] [report]
61400740

>>61400444
Checked

>> No.61400744

>>61400737
Learn FP

>> No.61400768

>>61400744
>FP
https://en.wikipedia.org/wiki/FP

???

>> No.61400770

>>61400712
If you develop your algos always(!) create a test and training set. Otherwise you are likely to overoptimize

>> No.61400776

>>61400768
functional programming

>> No.61400823
File: 14 KB, 358x358, 1467655190399.jpg [View same] [iqdb] [saucenao] [google] [report]
61400823

>>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

>> No.61400826

>>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.

>> No.61400840

>>61400823
>nah i dont need a soul

>> No.61400938
File: 589 KB, 1024x1347, d6454745400283.582f27c13dfb3.jpg [View same] [iqdb] [saucenao] [google] [report]
61400938

>>61400826
thank you anon
kind words

>>61398167
rude

>> No.61401084

#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);
}

>> No.61401090
File: 103 KB, 334x338, 1470047710352.jpg [View same] [iqdb] [saucenao] [google] [report]
61401090

>doesn't use Terminus font
>calls herself a programmer
ISHYGDDT

>> No.61401238

>>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.

>> No.61401257
File: 446 KB, 808x805, 1499659753162.png [View same] [iqdb] [saucenao] [google] [report]
61401257

Oh wait no I'm an idiot
10^19 - 1 > 2^63
I was thinking of 10^18

>> No.61401259

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?

>> No.61401271

>>61401259
You're taking the size of a pointer, not the size of what it is pointing to.

>> No.61401276

>>61401259
try sizeof(&ls->sortedList)

>> No.61401285

>>61401271
>>61401276

Ah, makes sense. Thanks, maybe now I can make realloc better too.

>> No.61401391

>>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.

>> No.61401406

>>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.

>> No.61401412

>>61401406
oh, typo
* instead of , of course

>> No.61401424

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.

>> No.61401463

>>61401424
have you ever made anything useful? you aren't going to get hired by bragging about your hackerrank score.

>> No.61401485

>>61401463
Not true actually,.

>> No.61401486
File: 49 KB, 1680x1050, scr.png [View same] [iqdb] [saucenao] [google] [report]
61401486

>>61398050
>What are you working on, /g/?

Exploring the deepest, darkest corners of Racket.

>> No.61401506

>>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.

>> No.61401616

>>61401506
but do you have a github that shows software you developed or contributed to?

>> No.61401632

>>61400692
Isn't that what Apple's "GC" langs did?

>> No.61401642

>>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.

>> No.61401671

>>61401642
in that case you have done more than literally everyone on /g/

>> No.61401806

What's the best IDE for C on GNU/Linux?

>> No.61401817

>>61401806
*sh.

>> No.61401894

>>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.

>> No.61401909

>>61401817
>>61401894
Look, can you just recommend me an IDE already?

>> No.61401934

>>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.

>> No.61401946

>>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.

>> No.61401961

>>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.

>> No.61401979

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

>> No.61402011

>>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.

>> No.61402105

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.

>> No.61402139

>>61398622
That this person is likely touching security somewhere is most concerning.

>> No.61402151

How to learn multi threading and good memory management in C for ARM? Are there any good video tutorials?

>> No.61402203

>>61402151
what those have to do with arm? it's more of an os matter.

>> No.61402275

>>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.

>> No.61402403

>>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.

>> No.61402428

>>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.

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

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;
};
};

>> No.61402495

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

>> No.61402499

>>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.

>> No.61402510

>>61402495
It gets worse.
Object[] arr = new Integer[1];
arr[0] = "kek";

Compiles but gives you a runtime error

>> No.61402519

>>61402510
What if you increase the Integer array size to match the length of the string?

>> No.61402533

>>61402519
That's not how it works.

>> No.61402534

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?

>> No.61402545

>>61402533
Just saying, it might be interpreting the string as an array of characters, and then casting those characters to integers.

>> No.61402552

Share your insight in software testing with me.

>> No.61402555

>>61402545
Java does not do that. Integer and String inherit from Object. Integer is not an int and String is not a char[].

>> No.61402563

>>61402534
Python 2 or 3?
>>61402545
No, it compiles because it expects an Object, and doesn't check that it actually needs an Integer

>> No.61402616

>>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.

>> No.61402622

anons is there a website that can convert java to c++

im trying to learn the syntax

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

>>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.

>> No.61402635

>>61402622
no

>> No.61402644

>>61402491
By not using Sepples.

>> No.61402654
File: 207 KB, 403x433, 1498855111293.png [View same] [iqdb] [saucenao] [google] [report]
61402654

>>61402635

t-thanks for the quick respond

>> No.61402659

>>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?

>> No.61402670

>>61402616
Good idea. Thank you!

>>61402644
What is Sepples?

>> No.61402676

>>61402563
Python 3

>> No.61402682

>>61402659
Get a VPS or use heroku or friends

>> No.61402685

>>61402670
sepples is the meme name for C++

>> No.61402695
File: 176 KB, 1280x1024, anime-girl-questionmark.jpg [View same] [iqdb] [saucenao] [google] [report]
61402695

>>61402685
Is there a better language to use for writing rendering engines?

>> No.61402717

>>61402682
Cheers

>> No.61402726

>>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.

>> No.61402747

>>61402695
C++ is fine. Don't listen to those faggots.

>> No.61402765

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.

>> No.61402790

>>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.

>> No.61402860

>>61402682
Why heroku? What makes it better?

>> No.61402921

>>61402790

What helper libraries do you use ? Might pick some for my project.

>> No.61402930

>>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

>> No.61402939

>>61402695
rust

>> No.61402990

>>61398062
>my job is mostly C++/Python/Matlab?
lucky basterd

>> No.61403000

>>61402921
I didn't use one. I think people use stuff like threejs or something.

>> No.61403002

>>61400823
>Inefficient
Not if you are lazy

>> No.61403006

>>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

>> No.61403010

>>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.

>> No.61403014

>>61402695
C or (((Rust)))

>> No.61403024

>>61402860
If you don't want to spend time administrating your VPS it's a lot less hassle

>> No.61403028

>>61403010
Yeah pretty much. Most tutorials or references touch on it for a single paragraph then immediately abstract it away.

>> No.61403045

>>61403006
My latest project was crawling lewds from aliexpress

>> No.61403108

>>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.

>> No.61403198

>>61403108
Try looking at other js 3d engines. They will probably implement the helper libraries themselves instead of using them separately.

>> No.61403210

>>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.

>> No.61403262
File: 41 KB, 450x450, upset meme.jpg [View same] [iqdb] [saucenao] [google] [report]
61403262

How do unions work?

>> No.61403286

>>61403262
In which language?

>> No.61403294

>>61403286
C/C++

>> No.61403330

>>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.

>> No.61403360

>>61403262
like pyramid schemes

>> No.61403396

>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);
}

>> No.61403547
File: 4 KB, 188x164, 4ed1d74cfaf1de8f553a833d3384351f.jpg [View same] [iqdb] [saucenao] [google] [report]
61403547

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.

>> No.61403557

>>61403547
>I want C++ to take longer to compile
What the fuck is wrong with you?

>> No.61403611

>>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.

>> No.61403730

>>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?

>> No.61403748

>>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).

>> No.61403757

>>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).

>> No.61403766

>>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.

>> No.61403792

>>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.

>> No.61403794

>>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.

>> No.61403807

>>61403794
>Even C's linkage model sucks for full-program optimization.
That's because it's a very poor model for that.

>> No.61403824

>>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..

>> No.61403837

>>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

>> No.61403909

Is a properly coded C program with statically linked musl-libc as fast as a properly coded asm program?

>> No.61403917

>>61403909
Define properly coded.

>> No.61403932
File: 489 KB, 205x142, test.gif [View same] [iqdb] [saucenao] [google] [report]
61403932

>>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

>> No.61403935

>>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.

>> No.61403938

>>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?

>> No.61403951

>>61403935
Properly coded meaning optimized for speed.

>> No.61403953

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?

>> No.61403958

>>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.

>> No.61403961

>>61403938
Even basic shit like inlining functions is difficult with C's static linkage.

>> No.61403979

Dumb question but what is general rule of using switch instead of if-statement or vice versa?

>> No.61403984

>>61403909
a modern optimising compiler shits all over 99% of code an experienced assembly developer can put out

>> No.61403996

>>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?

>> No.61404009

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.

>> No.61404013

>>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.

>> No.61404014

>>61403979
Think of a case where multiple if-elses would add horrendous noise to your program.

>> No.61404025

>>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.

>> No.61404035

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?

>> No.61404037

>>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()

>> No.61404039

>>61404009
Writing code utilizing OOP concepts is probably the best way to learn.

>> No.61404044

>>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++

>> No.61404048

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;
}

>> No.61404065

>>61404048

int *t6;
...
t6[t4]

How are you dereferencing an uninitialized pointer?

>> No.61404070

>>61404048
Undefined behavior, I believe.

>> No.61404081

>>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.

>> No.61404093

>>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.

>> No.61404100

>>61404037
What am I looking at?

>> No.61404119

Which gives faster code? GCC or Clang?

>> No.61404123

>>61404100
finding the largest value in a generic range

>> No.61404126

>>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

>> No.61404129

man, playing around with ESP8266 is the most fun I ever had since I played with toy and legos years ago.

>> No.61404133

>>61404119
GCC

>> No.61404134

>>61404119
There's tons of benchmarks anon.
I suggest you look at the ones with more realistic situations.

>> No.61404138

>>61404119
Depends on the code being compiled. GCC used to be and might still be slightly faster.

>> No.61404149

>>61404119
gcc is absolutely disgusting and needs to die though.

>> No.61404151

>>61404123
No shit, what language?

>> No.61404155

>>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.

>> No.61404157

>>61404126
This doesn't look like C. Define the semantics of the language.

>> No.61404158

>>61404126
I'm glad I'll find this kind of code at my future job!

>> No.61404167

>>61404155
>vectorization
I'm a clang fan but you shouldn't use this unless you're just lazy.

>> No.61404191

>>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

>> No.61404194

>>61404151
nim

>> No.61404212

>>61404194
Looks comfo desu senpai.

>> No.61404314

>>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.

>> No.61404355

>>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.

>> No.61404362

>>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.

>> No.61404393

Idris > Haskell > *

>> No.61404401

>>61404393
Get a job.

>> No.61404411

>>61404401
BTFO

>> No.61404413

>>61404393
I want fries with that!

>> No.61404416

>>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.

>> No.61404418

>>61404037
Someone told me people replace Lua with nim.
How do i sandbox in nim?

>> No.61404437

>>61404401
Nah

>>61404413
You should lay off the fries, they seem to be doing funny things to your brain

>> No.61404453

>>61404437
You don't even exist.

>> No.61404464

>>61404453
>You don't even exist.
Cogito ergo sum!

>> No.61404470

>>61404437
>Nah
what are you? a NEET?

did you trick the government to give you money'?

>> No.61404484

>>61404464
This statement assumes that causality exists. You can't prove that causality exists.

>> No.61404506

>>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

>> No.61404512
File: 10 KB, 300x300, haskellprogrammer.jpg [View same] [iqdb] [saucenao] [google] [report]
61404512

>In fact I'm very disappointed in C++

>> No.61404522

>>61404506
This statement relies on causality and therefore doesn't prove that causality exists.

>> No.61404527

>>61404512
>having expectations for C++

>> No.61404538

>>61404470
>trick
Disability checks for programming in haskell. He's not tricking anyone

>> No.61404576

>>61404538
lawl

>> No.61404578

>"Hey doc, I like programming in Haskell"
>"Say no mo faam, here is your check"

>> No.61404598

>>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.

>> No.61404603

how to uncurry my life?

>> No.61404629

>>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".

>> No.61404639
File: 50 KB, 700x700, 113449.png [View same] [iqdb] [saucenao] [google] [report]
61404639

Was he right?

>> No.61404640

>>61404603
\f (x,y) -> f x y

>> No.61404643

>>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.

>> No.61404646
File: 234 KB, 1732x2076, 1500171841066.png [View same] [iqdb] [saucenao] [google] [report]
61404646

>>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

>> No.61404656

>>61404646
Curry is an English surname and has been for hundreds of years you illiterate peasant

>> No.61404670

>>61404393
How's library support on Idris?

>> No.61404674

>>61404656
Wrong. It is street shitter food.

>> No.61404675

>>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".

>> No.61404686

>>61404674
never reproduce you fucking idiot

>> No.61404689

>>61404670
Idris doesn't have libraries

>> No.61404693

>>61404629
The aim wasn't to prove you're wrong, the aim was to prove you're being unreasonable in your standard of skepticism.

>> No.61404702

>>61404674
Do you have to constantly wear a helmet to avoid walking into things?

>> No.61404710

>>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.

>> No.61404712

It's happening...

>>61404703
>>61404703
>>61404703

>> No.61404728

>>61404702
see: >>61404710

>> No.61404730

>>61404689
Great, all the more reason to keep being a Hasklet.

>> No.61404743

>>61404712
>posted before bump limit
leave

>> No.61404757

>>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

>> No.61404781

>>61404757
>x*
>>>/r/ibbit
kys reddit cancer

>> No.61404794

>>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.

>> No.61404799

>>61404743
okie doke

>> No.61404806

>>61404781
xD curry xD curri curry curryie xD india xD pajeet xd

>> No.61404851

New thread:

>>61404703
>>61404703
>>61404703

>> No.61404871

>>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.

>> No.61404877

"""functional"", more like malfunction

>> No.61405301

>>61404035
You start reading, any where.

Then you keep reading and when you eventually find main() you probably understand half the code.

>> No.61406303

>>61398914
>I have literally never heard of this acronym
lmao plen

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