[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: 334
Thread images: 33

File: 1491122907332.jpg (534KB, 1428x1428px) Image search: [Google]
1491122907332.jpg
534KB, 1428x1428px
What are you working on, /g/?

Old thread: >>59804801
>>
>>59809632
1st
>>
h a s k e l l
>>
is unsound shit
>>
>>59809632
>expected cute anime image?
>too bad is me, Chaika.
>>
Learning Clojure.
>>
>>59809718
NOT LISP and barely even programming language.
>>
File: 1420843599096.png (220KB, 518x644px) Image search: [Google]
1420843599096.png
220KB, 518x644px
>"don't use async in C# unless you absolutely need it, it starts spreading like a virus once you use it anywhere"
>that sounds silly, let's just use it
>it really starts spreading like a virus
>end up using a blocking wait to stop the outbreak
>>
Assembler such as GAS is definitely an abstraction, and "1 to 1 mapping" is even a stretch.

mov <X>, <Y>
The output varies greatly based on what X and Y are.

foo: add $1, %eax
cmp $10, %eax
jle foo
The label has to be compiled and linked, which is quite an abstraction. Especially considering labels can appear before or after the jump instruction.

There are also a LOT of assembler directives:
https://sourceware.org/binutils/docs/as/Pseudo-Ops.html
You can't possibly be saying that ".fill" or ".set" or ".if" are any more "just 1 to 1 mappings to machine code" than C is
>>
>>59809746
>NOT LISP
It's a dialect of Lisp.
>barely even programming language
It actually is a programming language.
>>
>>59809760
The discussion was in the other thread.
sageru!
>>
>>59809757
Did I just skim this correctly? Do you honestly have to create some top-level methods to declare whatever is supposed to handle asynchronously? Really?
>>
>>59809757
T H R E A D P O O L
>>
>>59809757
Who are you quoting?
>>
File: class.jpg (44KB, 488x499px) Image search: [Google]
class.jpg
44KB, 488x499px
can anyone tell me why the highlighted class has that little diamond on the icon and what that means. Im new to android studio
>>
File: 13A.jpg (83KB, 720x960px) Image search: [Google]
13A.jpg
83KB, 720x960px
Is using quaternion calculations in your program makes you autistic or math genius?
>>
My game proceeds apace, I'm finally adding enemy AI and sheeit but boy is it a bore sometimes.
>>
>>59809880
It means that your code is of enterprise quality.
>>
>>59809880
Class is final
>>
>>59809887
It makes em wet that's what it does
>>
>>59809700
SSE2 doesn't completely supersede MMX, does it?
In any case try compiling some vectorizable code (eg. using 32-bit rgba pixel structures) with -march=pentium-mmx. I haven't seen gcc emit a single mmx instruction so far.
>>
>>59809887
>quaternion
>math genius
>>
>>59809887
>autistic or math genius
Is there a non-autistic math genius?
>>
>>59809887

If you are programming the space shuttle (which used quarternions) you are a math genius

If you are mayking a gayme then you are autistic
>>
>>59809940
>tfw mathlet ;_;
>>
What language to you use for small/simple projects?
>>
>>59809887
last time i tried using them i watched youtube videos on them for like 2-3 hours then gave up.

i am obviously neither
>>
>>59810053
Common Lisp
>>
>>59810053
D
>>
>>59809887
This needs a name. I'm sure it's a dude but I don't give a shit.
>>
>>59810055
>i am obviously neither
You most likely have low-functioning autism
>>
>>59809935
>SSE2 doesn't completely supersede MMX, does it?
It does.
>In any case try compiling some vectorizable code (eg. using 32-bit rgba pixel structures) with -march=pentium-mmx. I haven't seen gcc emit a single mmx instruction so far.
Auto vectorizng is still pretty garbage in all compilers, you need to adhere pretty strictly to very simple patterns for it to work, and even then it's often not close to optimal.
You can forget about hoping to get things like rgba blending vectorized. Use intrinsics.
>>
>>59810202
>You can forget about hoping to get things like rgba blending vectorized.
My compiler can easily do that. Just don't use a shit compiler.
>>
>>59810220
>My compiler can easily do that.
No it can't.
>>
File: 1483074731582.png (3KB, 200x200px) Image search: [Google]
1483074731582.png
3KB, 200x200px
What math topics should i learn before learning 2D-3D graphics.
>>
>>59810253
Linear algebra
>>
>>59810253
Proof theory.
>>
>>59810251
It can, quite trivially even.
>>
>>59810294
Nope.
>>
>>59810220
>>59810251
>>59810294
>>59810314
lets solve this now lads, cocks out.
>>
Why has /g/ such a hateboner for everything popular, like Java or Python and shills for hipster languages that almost doesn't exist in real world?
>>
>>59810314
It can. Didn't expect you to understand such simple concepts anyway.
>>
Playing around with retraining of depth neural networks
>>
>>59810329
What is the real world? How can a language exist outside of it? How can something "almost" exist when existence is a binary state?
>>
>>59810345
>>59810329
>>
>>59809632
What is the best programming language in the world?
>>
>>59810356
Visual Basic.
>>
>>59810356
Lisp
>>
>>59810356
C++
>>
>>59810363
Trash.
>>59810370
Trash.
>>59810374
Trash.
>>
>>59810356
Python
>>
>>59810356
>>59810363
>>59810370
>>59810374
>>59810383
Ook.
>>
>>59810374
return *this;
>>
>>59810387
Absolute trash.
>>59810389
Almost good but still trash.
>>
>>59810397
Malbolge
>>
>>59810401
Even closer to being good but unfortunately it's still trash.
>>
>>59810397
https://esolangs.org/wiki/Parenthesis_Hell
>>
>>59810331
>It can.
It can't.
>>
So looks like there is no perfect programming language. And to programmers should know at least 4-5 languages.
Let me guess them
>R for statistics
>C for embedded and SoC
>C++ for windows, linux and eveything general purpose, mostly video games.
>Javascript for web
>Objective C for mac.
Did I miss something.
Also imo if C++ can do the job then there is no need for java.
>>
>>59810450
Just use C for everything.
>>
>>59810450
Who are you quoting?
>>
>>59810450
>>59810467

> balls for smashing
> anus for smashing
> dick for smashing
> anus back again for smashing
just reading off my notes here.
>>
>>59810450
>javascript for web
>java for desktop
>c for hardware
>haskell for memes
>>
>>59810463
Name one modern website made in your utter disgusting C language?
>inb4 javascript v8 engine is written in C++ which is an spritual successors to C. SO every website is written in C.
>>
>>59810482
Oh, I see. Continue on then.

>>59810483
>>59810485
Who are you quoting though?
>>
>>59810501
imma quote w/e i wanna quote
>>
>>59810450
Python for Data science/ML
>>
>>59810485
Why would I want to name a 'modern website' written in C? I hope there aren't any, because they're all shit.
>>
>>59810501
>Green texting is made for quoting and nothing else.
>>
>>59810450
>>59810482
>>59810483
> C for websites
> R for config management
> Javascript for server-side applications
> VB for data science
prove me wrong faggots
>>
>>59810510
But who were you quoting?
>>59810529
Nobody said this, why are you quoting it?
>>
>>59810253
Trig , linear , and calc preferably.
The more the better really.
>>
>>59810537
You mum is calling you.
>>
>>59810537
>Nobody said this, why are you quoting it?
>>
File: alpha_float.png (202KB, 648x546px) Image search: [Google]
alpha_float.png
202KB, 648x546px
rate my vectorized alpha blending, /g/
>>
>>59810535
Why are you plebbit-spacing your quotation operator? And who are you quoting?
>>
>>59810485
C guys are too busy to do webdev codemonkey job.
>>
>>59810517
Data Science?
>Data science, also known as data-driven science, is an interdisciplinary field about scientific methods, processes and systems to extract knowledge or insights from data in various forms, either structured or unstructured,[1][2] similar to Knowledge Discovery in Databases (KDD)
From Wikipedia
Didn't know this. Thanks I will look up more .
>>
File: alpha-16.png (26KB, 648x546px) Image search: [Google]
alpha-16.png
26KB, 648x546px
>>59810565
this is 16-bit with a 1-bit alpha channel
much darker for some reason, I'm probably mis-shifting a bit somewhere
>>
>>59810550
She isn't though.
>>
>>59810565
OpenGL or DirectX?
I will give you 8/10
>>
>>59810601
no api, writing straight to video ram.
>>
>>59810573
> Does that trigger you faggot?
>>
>>59810608
Got any tutorial on that?
>>
>>59810613
Whomst was the original source of this phrase?
>>
>>59810565
How many cycles/pixel?
>>
>>59810624
look up VBE (VESA BIOS Extensions). that's what I'm using to find the framebuffer address.
>>
>>59810624
Not Him but it looks like an x86 DOS emulator , so video ram is somewhere from 0xA0000 to 0xB0000 (cant remember now). I think you can read that up in OsDev.net

You cant really do that in protected mode on modern day systems in case you did not know that.
>>
>>59810573
>>59810613
> I'm quoting the bible nigger.
>>
>>59810613
>>59810705
Whom quotest thou?
>>
>>59810565
You must be very proud
>>
File: vector_alpha.png (115KB, 778x1710px) Image search: [Google]
vector_alpha.png
115KB, 778x1710px
>>59810644
too many probably
(the whole loop doesn't fit on my screen)
>>
>>59810715
I think you mean whomst'd
>>
>>59810692
you can use vbe to access the frame buffer directly from protected mode. A000 is the vga segment and is limited to a 64k window.

>>59810721
oh yes I am.
>>
>>59810722
What disassembler is that?
>>
>>59810824
objdump
>>
File: 1437497521042.jpg (60KB, 1280x720px) Image search: [Google]
1437497521042.jpg
60KB, 1280x720px
Employed Haskell programmer reporting in
>>
>>59810844
Can I get fries with that?
>>
File: 1490963506037.jpg (95KB, 1280x720px) Image search: [Google]
1490963506037.jpg
95KB, 1280x720px
>>59810844
Unemployed Haskell programmer reporting in
>>
>>59810835
Oh, so it's just a colored objdump output? Thanks, m8, appreciate it.
>>
File: 1469182488691.png (444KB, 457x457px) Image search: [Google]
1469182488691.png
444KB, 457x457px
Employed Coq programmer reporting in
>>
>>59810856
>>
>>59810485
>javascript v8 engine is written in C++
>SO every website is written in C
I like the subtle implication that every backend is written in JS, I give your shitposting 7 out of 10
>>
File: 796fc629e4297bf4debfa5cf41abca67.jpg (146KB, 914x1467px) Image search: [Google]
796fc629e4297bf4debfa5cf41abca67.jpg
146KB, 914x1467px
Employed Java programmer reporting in
>>
@59810933
>Java
>>>/r/abbit
>>
>>59810722
Either a debug build or too much abstraction around your pixel data structure, because that's a lot of stack juggling and massaging to access the data.
The sse code looks reasonble for an interleaved format, but if you want maximum throughput consider a framebuffer format of consecetive reds, then blues, then greens, etc instead if rgbargbargba... Do the final interleaving (and integer conversion) only at display time.
>>
if (optionA) {
doA();
return;
}
if (optionB) {
doB();
return;
}
if (optionC) {
doC();
return;
}


vs

if (optionA) {
doA();
}
else if (optionB) {
doB();
}
else if (optionC) {
doC();
}
>>
Currently working on what to work with. I am interested and started to learn C language. I read a book on Visual Basic. What is my next step, do I read a book on C? What should I learn? I still haven't got any preferences but this things like low level stuff is in my interest, like coloring a pixel on screen but knowing where is that address physically, is it in the gpu or in the ram. That is interesting....very much!
>>
>>59810985
The latter....
>>
>>59810953
>@59810933
>>Java
>>>>/r/abbit
>>>/auschwitz/
>>
>/dpt/ thinks they're superior to Indian software engineers who have studied 12 hours a day, 5 days a week for 4 years with state-of-the-art equipment at top universities
>/dpt/ doesn't realize (or is willfully ignorant of the fact that) an Indian computer science freshman will have to write a bootloader and a compiler IN THEIR FIRST SEMESTER or fail their degree
>/dpt/ considers themselves better than such engineers... and it's all because the engineers have brown skin
Inferiority-superiority complex much?
>>
@59811024
>>>/belzec/
>>
>>59811076
I wrote a bootloader before university
>>
>>59811076
Okay pajeet
>>
>>59811076
Who said this?
>>
What's the simplest most basic picture file format in use today? Is it .bmp?
>>
>>59811110
pmi or w/e
>>
>>59811110
PPM
>>
Are hash tables only for mapping strings to values? If they're not just used for mapping strings to values, is it uncommon to use a hash table to match other data types to values?
>>
>>59811144
Not just strings.
>>
>>59811154
Also, no to your latter question.
>>
>>59811144
Normally, keys and values can be of any type.
>>
File: blend.png (62KB, 932x1057px) Image search: [Google]
blend.png
62KB, 932x1057px
>>59810960
That's -O3 -ffast-math... not a debug build :(
You're right though, I might have gone a bit overboard with the abstractions. The whole thing is a big template clusterfuck so it can blend any possible pixel structures (currently does rgba floating-point, 8888, 8880, 6668, 5650 and 5551 bit types).
>>
>>59810985
optionA && doA();
optionB && doB();
optionC && doC();


Yes, this does work.
>>
>>59811185
Sadly doX() consists of more than one line.

Also fuck that readability.
>>
do you think quantum computing is going to void everything we've been working so hard getting good at and it's going to be completely different, or do you think there's going to be some carry over? they already have used quantum computers to factorize prime numbers
>>
>>59811165
>>59811171
Thanks for the help.

I'm attempting to implement a hash table in JavaScript, but it doesn't have a native hashing function that I can work off and improve upon like Java does. Any idea about what I should do for hashing non-integer numbers in JS?
>>
>>59811198
>they already have used quantum computers to factorize prime numbers
they've already used humans to do that
>>
>>59811185
optionA_t& operator&&(auto rhs) {}

oops
>>
>>59810396
Nothing wrong with this.
>>
>>59811194
It's much more readable though.
>>
>>59811212
optionA was a wrong name. Condition would be better.
>>
>>59810450
>Python/Bash for scripting
>C++ for programs that need to run efficiently
>Javascript for web
>>
>>59811076
they look like poo and most of them have hilariously annoying accents, how can you not feel superior? i know it's not right but you can't really help it
>>
>>59811226
JavaScript for embedded systems
C for web
C++ for small scripts
>>
>>59811225
And? Just wrap the condition / function call.
>>
>>59811226
Who are you quoting?
>>
>>59811210
new(this) decltype(*this) { *this };
>>
>>59811205
if i said they've used floating hoverboards to travel a city block would you say the same
>>
Is learning CMake the first step to getting away from an IDE and coding using sublime or VScode?
>>
>>59811252
>globa 6 - quality of posts

fuck off back to /s4s/
>>
>>59811255
yes
>>
File: 1491151487585.png (916KB, 580x923px) Image search: [Google]
1491151487585.png
916KB, 580x923px
>>59811252
this god amongst men
>>
File: 1424066452627.png (39KB, 429x410px) Image search: [Google]
1424066452627.png
39KB, 429x410px
>>59811258
> coding using sublime or VScode?

make files are easy my man, cmake just makes it so other people can build your shit with whatever they use.
>>
>>59811253
new(this) decltype(*this) { static_cast<decltype(*this)&&>(*this) };
>>
>>59811283
I don't know why but I seem to be retarded when it comes to writing makefiles. I try to write some automated one so I don't have to list all the dependencies but all the online examples seem complicated
>>
>>59811248
For 3 or so lines? nah m8
>>
>>59811253
>>59811284

Nothing wrong with these.
>>
>>59811258
yes, use vim as well now

speaking of vim, how do i make it so when i hit tab, type some stuff, and then enter, the next line starts at the same indentation level by default until i backspace?
>>
>>59811300
just build off: http://nuclear.mutantstargoat.com/articles/make/ and https://randu.org/tutorials/c/make.php
>>
>Coding in mousepad
When did it all go so wrong.
>>
>>59811258
do not forget vim or emacs
>>
>>59811317
nm found it on reddit, they call it autoindent
>>
>>59811327
use geany you bwaka
>>
>>59811327
Who said that?
>>
What will happen to C when Rust becomes the standard for microcontrollers?
Will it be then only used for low level libraries, drivers and legacy kernels?

Would, in say a distant future, Rust be feasible (memes aside) as a language to build drivers in? How about libraries? Can you use C linkage/ABI with Rust?
>>
Thinking of picking up a new language mostly just for fun. What's /dpt/s opinion on Rust and Elixir. Any better suggestions?
>>
>>59811378
>when Rust becomes the standard for microcontrollers
Presumably it then gets replaced by Javascript
>>
>>59811378
Rust only runs properly on x86. By the time it gets support for other architectures, it'll be dead.
>>
>>59811363
Neat, it's fast and light.
Thanks senpai
>>
red pill me about programming languages /dpt/
>im too white for java
>im too young for php/c
>im too straight for javascript
>im not masochist, so no c++
>>
>>59811378
we've had c++ for ages and you've seen what happens. c-tards keep sticking to their dusty macros and void pointers.
>>
>>59811431
C++ is a pile of shit with no direction
>>
>>59811430
Who wrote this?
>>
>>59811430
C isint that fucking hard as people make it out to be. Hell it's less complicated than python, the problem with C vs python usually is boilerplate code.
But in general C is just manipulating arrays with logical operators. Python abstracts that heavily behind 30 thousand things.

Here's your red pill.
>>
>>59811451
me, serbian anon
>>
>>59811430
Common Lisp
>>
File: rust.png (54KB, 704x548px) Image search: [Google]
rust.png
54KB, 704x548px
>>59811407
??
>>
>>59811479
when i said im too young
it meant that i wasnt born in 1950
>>
>>59811086
This.
>>
>>59811488
https://forge.rust-lang.org/platform-support.html
>>
>>59811490
>Needing a bleeding egde language when shit from 1900 does stuff in exactly the same way with less bullshit.
>>
File: 1404311335478.jpg (33KB, 416x403px) Image search: [Google]
1404311335478.jpg
33KB, 416x403px
Do you leave your assertions enabled in production code?
No matter where I look there are always people arguing that production assertions are the devil's spawn and people arguing that they're actually a perfectly reasonable solution
>>
>>59811508
So it's not unlikely that it will support those proper anytime soon, or at least I can see them pushing stability for the more common architectures since they already have some support for them.
>>
Has anyone ever made a thorough write-up of developing imageboard software? They aren't particularly complex applications, but given they have been around for decades now you'd think there'd be more information out there about what needs to be taken into consideration when writing one. I'm sure the developers of 4chan have hit countless snags and gotchas over the years - it would be nice to know about them in advance so I don't make the same mistakes.

My list of considerations as it stands is:

File size cap
User input sanitization (inc image/filename)
Anti-spam (captcha?)
Request throttling
Secure DB authentication
>>
>>59811520
That really depends on the context tho.
>>
>>59811521
>the more common architectures
So why isn't ARM tier 1? It's the most common architecture currently.
>>
>>59811513
Who are you quoting though?
>>
>>59811555
What I was implying is that it wouldn't be unlikely that architectures such as ARM would receive Tier 1 support soon.
>>
>>59811558
Who is doing that though ?
>>
>>59811565
[citation neede]
>>
>>59809632
My first hello world program in C++, wish me luck anons
>>
File: java-vs-haskell.png (102KB, 2435x913px) Image search: [Google]
java-vs-haskell.png
102KB, 2435x913px
>>59811430
>>
>>59811594
What's that site you got there?
>>
>>59811581
Don't use iostreams.
>>
>>59811603
Don't use C++.
>>
>>59811594
I'm disappointed with my countrymate being top 1 in Java.
>>
>>59811623
Why would you be disappointed in your fellow countrymate being in the top?

I mean yeah it's Java but he still managed to bet everyone else.
>>
>>59811594
>>59811623
it's hackerrank. being #1 doesn't matter at all, it's literally everyone who completes a problem who becomes #1. really kind of a stupid website with loads of indians but i had an interview that made me use it
>>
>>59811623
I wouldn't call him my countrymate if I were you.
>>
if i wanted to dick around with making an app that works on both ios and android, would i need anything other than a java IDE?

i have absolutely no idea how mobile development works
>>
any good resources on machine learning as in neural networks and tensor flow and that kind of stuff? i'm taking a machine learning class with an indian professor and we're just fitting linear models and doing KNN, while the guy who i'm doing a research internship wants me to know about the stuff i mentioned previously
>>
>>59811602
HAckerank
>>
>>59811716
http://stevenmiller888.github.io/mind-how-to-build-a-neural-network/

http://welmish.blogspot.pt/search/label/neural%20network
>>
>>59811520
Yes, even if you do lots of testing your user will likely always find some edge case you didn't expect.
>>
File: 123ertgh.jpg (22KB, 413x777px) Image search: [Google]
123ertgh.jpg
22KB, 413x777px
where are you, /g/?
>>
>>59811775
Expert.
>>
>>59811775
skill is a social construct
>>
>>59811763
anything written by a really old white guy?
>>
>>59811775
Competent tbqh
>>
>>59809757
What did you expect? Asynchronous programming is fundamentally different than what you're used to. Trying to bridge the gap will just lead to bullshit.
>>
>>59811806
the fuck?
>>
#include <stdio.h>

int isPrime(long num)
{
for (long i = 2; i * i <= num; i++)
if (!(num % i))
return 0;
return 1;
}

int main()
{
unsigned long long sum = 2;
for (long i = 3; i < 2000000; i += 2)
if (isPrime(i))
sum += i;
printf("%lli\n", sum);
return 0;
}
>>
>>59811880
The year is 2017, use stdbool and stdint already.
>>
>>59811904
stdint is bad because it's way too portable. Can't secure your employment that way.
>>
in Firefox, if you go to the URL
about:memory

and click in
Minimize memory usage


it lowers the memory used by Firefox.

is it possible to write a script that clicks that button automatically for me?
>>
How do I use Linux system calls directly without faggotry like glibc
>>
>>59812069
http://man7.org/linux/man-pages/man2/syscall.2.html
>>
File: android18.jpg (95KB, 800x1111px) Image search: [Google]
android18.jpg
95KB, 800x1111px
Rate my string reversal C program pls
#include<stdio.h>
#include<string.h>
int main(int argc,char** argv){
if(argc != 2)
return;
++argv;
int i=0;
char p;
while(i<strlen(*argv) && **argv){
p = *(*(argv)+strlen(*argv)+i+1) = *(*(argv) + i++);
}
i = 0;
while(i < strlen(*argv))
*(*(argv)+i) = *(*(argv) + 2*strlen(*argv) -i++);
*(*(argv)+strlen(*argv)) = '\0';
printf("%s\n",*argv,__TIME__);
return 0;
}
>>
>>59812081
Those fucking manpages just tell you how to use glibc functions as if they were the kernel interface

Many of those functions behave differently than the actual syscall
>>
>>59812117
Are you retarded?
>>
>>59812111
Needs more strlen calls.
>>
>>59812111
char *strrev(char *str)
{
char *p1, *p2;

if (! str || ! *str) {
return str;
}
for (p1=str,p2=str+strlen(str)-1;p2>p1;++p1,--p2) {
*p1 ^= *p2;
*p2 ^= *p1;
*p1 ^= *p2;
}

return str;
}
>>
>>59812142
I didn't use extra varibles.
>>
>>59811520
Assertions (I'm assuming C/C++ assertions here) should be avoided in production because assertions cause the app to crash. And you don't want your customers pissed off, do you? But if you can manage to have a two control groups to test for bugs I suggest having two (or more, depends on what you're debugging) versions of the same app in production. One in optimized mode and the other in debug mode.

Having a rich and up-to-date test suite also helps. It's really up to you and how you measure your costs, etc.
>>
>>59812142
>XOR swap, ever
>>
>>59812111
>calling strlen every interation

>>59812142
>relying on xor swaps
>>
>>59812199
Would you rather the program crash in a controlled manner because of an assertion or do something undefined?
>>
if i have two persons, A and B, whereas A is called John Kennedy and B Claire Kennedy, but from completely different families, does that mean they came from the same ancestor?
>>
>>59812207
I can save strlen value in some variable.
I just made it in one go and posted.
>>59812207
>>59812142
>>59812141
But did you guys understand how am I doing thatt?
>>
>>59812199
>Assertions (I'm assuming C/C++ assertions here) should be avoided in production because assertions cause the app to crash.

You'd rather ignore the error and let data become corrupted and segfault eventually anyway?
>>
File: 1470955843833.png (389KB, 756x678px) Image search: [Google]
1470955843833.png
389KB, 756x678px
>>59812216
>>
>>59812246
?
>>
>>59812200
>>XOR swap, ever
>>relying on xor swaps

not an argument.
>>
>>59812216
no, they share the same last name dumbass
>>
>>59812210
>>59812244
Personally, I'd rather test as much as possible. There are a lot of tools out there to help you with this. I'm aware that in certain scenarios is difficult to test all avenues (like timing related code), but the more you test the better. Having good coding practises also helps.
>>
>>59812268
Swapping with a temporary is more efficient and can even be optimized to instructions like xchg in some cases.
>>
>>59812277
Tests aren't really a replacement for assertions.
>>
>>59811880
>you had one job
>>
>>59812277
What you are describing is a rookie mistake in software development.

I suggest you take a glance over at The Pragmatic Programmer.

"Leave Assertions Turned On
There is a common misunderstanding about assertions, promulgated by the people who write compilers and language
environments. It goes something like this:
Assertions odd some overhead to code. Because they check for things that should never happen, they'll get
triggered only by a bug in the code. Once the code has been tested and shipped, they are no longer needed,
and should be turned off to make the code run faster. Assertions are a debugging facility.
There are two patently wrong assumptions here. First, they assume that testing finds all the bugs. In reality, for any
complex program you are unlikely to test even a miniscule percentage of the permutations your code will be put
through (see Ruthless Testing). Second, the optimists are forgetting that your program runs in a dangerous world.
During testing, rats probably won't gnaw through a communications cable, someone playing a game won't exhaust
memory, and log files won't fill the hard drive. These things might happen when your program runs in a production
environment. Your first line of defense is checking for any possible error, and your second is using assertions to try to
detect those you've missed.
Turning off assertions when you deliver a program to production is like crossing a high wire without a net because
you once made it across in practice. There's dramatic value, but it's hard to get life insurance.
Even if you do have performance issues, turn off only those assertions that really hit you. The sort example above
may be a critical part of"
>>
>>59812307
what job?
>>
>>59812216
i was going to shitpost and say that if you go back far enough everybody has the same common ancestors. Then i considered that maybe back when humans were bacteria they independently asexually reproduced and that may not be the case

programming, am i right fellas?
>>
>>59811594
POO
>>
>>59812319
I thought the meme was to sum first 2e6 primes, not primes under 2e6
>>
>>59812294
Tests and assertions aren't really a replacement for types.
>>
self = Self(self)
self.self(self, self, self)
self self
>>
>>59812294
I didn't mean that they were. I'm just saying that at the end of the day good testing (with or without assertions) helps.

>>59812316
Okay.
>>
File: 1451772954721.png (220KB, 640x412px) Image search: [Google]
1451772954721.png
220KB, 640x412px
Hi /dpt/, I work in the corporate office for a major financial institution in "data analytics". I put this in quotes because my team is comprised entirely of people who were hired straight out of college with no programming or analytics background, myself included. Yes, this is the data meme. We code exclusively using SAS and nothing else. I have a very tenuous grasp on coding in general and have been doing this job for a year.

This role is kind of nice because I am able to learn and implement a lot of different things since none of my superiors know the first thing about any of this stuff. That said the job is a dead end. I don't really see myself going anywhere just using SAS alone and would like to learn other languages in my spare time. With SAS being my background, what languages would be the easiest to pick up first. Is there some sort of progression you guys would recommend? I was thinking I'd start with python since it will open me up to more of a development environment instead of just plain analytics all the time.

Of course I am retarded and have no idea wtf I'm doing.
>>
Don't assertions have negligible runtime cost anyway since they can be predicted to always pass?

>>59812341
I agree, but they're still useful for prototyping. If I'm not sure that a theorem is even correct, I'll test it before attempting to prove it.
>>
>>59812368
Yeah an assert will likely be optimized to be a pass so the cost of it is very very low assuming your code is bug-free and if it's not you avoid UB.
>>
>>59812364
Pajeet?
>>
How do I improve this?
 #include <stdio.h>

#define FIZZ 3
#define BUZZ 5

int is_div(int divisor, int dividend);

int main() {
for (int i = 1; i <= 20; i++) {

if ( (fizz(i)) | (buzz(i)) ) {}
else {
printf( "%d", i);
}

printf( "\n" );

}
return 0;
}

int is_div(int dividend, int divisor) {
if (dividend % divisor == 0) {
return 1;
}
else return 0;
}

int fizz(int dividend) {
if (is_div(dividend, FIZZ)) {
printf( "Fizz" );
}
}

int buzz(int dividend) {
if (is_div(dividend, BUZZ)) {
printf( "Buzz" );
}
}
>>
>>59812417
Yes, Sir?
>>
Leave assertions in production Java and you automatically become a pariah
I still maintain that stuff like Google's Truth library works well even for input validation, but apparently if your code ever raises an AssertionError outside of testing people will grab their pitchforks
>>
>>59812434
MuSigma?
>>
I'm writing a server which streams audio.

I'm trying to get timing right. I want it to send 1s of data every second. Should I:

1. Read file in its entirety, and insert into audio buffer

2. Begin a loop to broadcast 1s of data every second

---

or should I:

1.) read 1s of data every second and insert into audio buffer

2.) in a separate thread send 1s of data every second

---

I feel if I do the second one, then it may be slower and it may accidentally send old data
>>
>>59812432
#include <stdio.h>

#define FIZZ 3
#define BUZZ 5

int is_div(int dividend, int divisor)
{
return !(dividend % divisor);
}

int fizz(int dividend)
{
if (is_div(dividend, FIZZ)) {
printf("Fizz");
}
}

int buzz(int dividend)
{
if (is_div(dividend, BUZZ)) {
printf("Buzz");
}
}

int main()
{
int i;
for (i = 1; i <= 20; i++) {
if ((fizz(i)) | (buzz(i)));
else
printf( "%d", i);
puts("");
}
return 0;
}
>>
>>59812417
Guy you're responding to here, my name is not Pajeet and I'm not Indian/Pakistani/Bangladeshi if that's what you're implying. I don't know what this guy is getting at >>59812434.
>>
>>59812465
Use a realtime OS u dum
>>
>>59812449
Please email me the answer, Sir

[email protected]

thank you, Sir
>>
>>59812497
what is a realtime os
>>
>>59812465
Try send()ing the whole file and hope for the best.
>>
>>59812492
Then I suggest you to do Python.
...But it is interpreted language.

Learn basic C++/JAVA/C# which are compiled language.
Java will be easier to grasp.
>>
>>59812528
what is google
>>
>>59812465
Configurable buffer size, keep reading samples and sending them, when the last chunk is sent, just read into the buffer again and start sending over the next chunk of samples.
>>
>>59811880
run this and tell me what happens
me@debian:~/c$ time ./sumOfPrimes 123456789
420604415154383

real 0m4.078s
user 0m3.948s
sys 0m0.128s
me@debian:~/c$
>>
File: HackerRank-1940x827.jpg (38KB, 960x408px) Image search: [Google]
HackerRank-1940x827.jpg
38KB, 960x408px
>>59812521
>>
>>59812528
what is autism
>>
>>59811880
>>59812558
because i suspect your computer will just whirr endlessly instead of getting an answer like my elegant and safe code does j/s
>>
>>59812548
>>59812564
K well I need to run this on Ubuntu
>>
>>59812558
i think you got the out wrong.

its the sum of primes under 2 mil
[~] >>> time ./a.out 123456789
142913828922

real 0m3.574s
user 0m3.552s
sys 0m0.012s

>>
File: 1454311771979.gif (148KB, 340x340px) Image search: [Google]
1454311771979.gif
148KB, 340x340px
>>59812490
Thanks
>>
>>59811623
kurwa
>>
File: hr.png (88KB, 900x663px) Image search: [Google]
hr.png
88KB, 900x663px
Does IIT really produce the best programmers?
>>
>>59812582
i'm saying run it on 123456789. your code isn't efficient. for 2 million it should do that in a fraction of a second. mine does that in .066 seconds
>>
>>59812603
Why is grill autistic
>>
>>59812610
it produces the best cheaters
>>
>>59812142
can u do this using str pointer only?
>>
How would I go about making LMGTFY but instead of google you post a thread on 4chan?
>>
>>59812610
i'm just glad trump removed computer programmer from the h1b list. a bunch of pajeets on reddit were up in arms. i don't care if he does nothing else, he's already improved my lot just by that
>>
>>59812641
Wait, he did that? Link pls
>>
>>59812610
Indians are the worst people to work with
>>
>>59812575
Mine takes ~20 seconds but is not nice, written in python and lists first 2e6 primes instead of primes under 2e6.
Did I get the meme memo wrong again?
>>
>>59812619
more than 1 minute. i stoped it after
using
gcc (Ubuntu/Linaro 4.7.3-2ubuntu1~12.04) 4.7.3
[/code
>>
File: rad.jpg (34KB, 412x441px) Image search: [Google]
rad.jpg
34KB, 412x441px
>>59812628

>log into friend's hacker rank account
>do all the interview questions for him
>get them all correctly
>friend lands position
>pays me $500
>mfw
>>
>>59812639
void strrev(char *p)
{
char *q = p;
while(q && *q) ++q;
for(--q; p < q; ++p, --q)
*p = *p ^ *q,
*q = *p ^ *q,
*p = *p ^ *q;
}
>>
>>59812639
void strrev(char *s)
{
for (char *end = s + (strlen(s) - 1); (end > s) ; --end, ++s) {
char tmpChar = (*s);
(*s) = (*end);
(*end) = tmpChar;
}
}
>>
>>59812653
https://www.axios.com/computer-programmers-may-no-longer-be-eligible-for-h-1b-visas-2342531251.html?utm_source=twitter&utm_medium=social&utm_campaign=organic&utm_term=technology&utm_content=textlong
>>59812657
>>59812672
when you're at 1,999,999 you look back at 2 - 1,999,998, and when you're at 1,999,998 you look back at 2 - 1,999,997 etc. instead of checking primes by using modulus, iteratively mark numbers that are composite from between 1 and your goal number. you're checking if 3 is prime 1,999,999 times
>>
GCC 7 OUT!

https://gcc.gnu.org/gcc-7/changes.html
>>
>>59812737
>when you're at 1,999,999 you look back at 2 - 1,999,998, and when you're at 1,999,998 you look back at 2 - 1,999,997 etc. instead of checking primes by using modulus, iteratively mark numbers that are composite from between 1 and your goal number. you're checking if 3 is prime 1,999,999 times
post your solution
>>
>>59812752
Come back when GNU code isn't trash

Use Clang instead of GNU garbagio
>>
File: aw-shit-nigga.png (190KB, 580x435px) Image search: [Google]
aw-shit-nigga.png
190KB, 580x435px
>>59812752
>>
>>59812786
not an argument.
>>
>>59812697
you are still using q pointer.
>>
>>59812765
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
if(argc != 2) return 1;

int bound;
int* primes;

if ((bound = atoi(argv[1])) <= 0) return 1;
if ((primes = calloc(bound, sizeof(int))) == NULL) return 1;
primes[0] = 1;
primes[1] = 1;
int count = 2;
while(count < bound)
{
for(int multiples = 2*count; multiples < bound; multiples += count)
{
if(multiples < bound) primes[multiples] = 1;
}
for(int newCount = (count+1); newCount <= bound; newCount++)
{
if(newCount == bound) count = bound;
if(primes[newCount] == 0)
{
count = newCount;
newCount = bound;
}
}
}
unsigned long long sum = 0;
for(int sumCount = 0; sumCount < bound; sumCount++)
{
if(primes[sumCount] == 0)
{
sum += sumCount;
}
}
printf("%llu\n", sum);
return 0;
}
>>
>>59812804
Ok here's an argument

https://github.com/lattera/glibc/blob/master/stdlib/getenv.c#L32
>>
>>59812786
>>59812804
How can a normal person ever encounter the first difference in practice between using clang and gnu?
>>
>>59812737
Thanks for the link.
>>
>>59812817
so?

it just works. and its fast.

https://geoff.greer.fm/vim/#realwaitforchar
>>
>>59812815
is this a branch and bound solution?
>>
>>59812837
Isn't the point of GNU to share readable code? RMS bitches about minifying Javascript code because it's unreadable but still GNU publishes this trash
>>
>>59812815
nice
[~] >>> time ./a.out 2000000
142913828922

real 0m0.156s
user 0m0.144s
sys 0m0.008s
[~] >>> time ./a.out 123456789
420604415154383

real 0m12.043s
user 0m11.677s
sys 0m0.340s

>>
File: saccs.png (171KB, 1427x965px) Image search: [Google]
saccs.png
171KB, 1427x965px
stupid questions general is reaching limit atm so pls dont mind me asking here
Im trying to install packages for Visual Studio and this happens

it's just like a few packages out of so much I installed cause I wanted to have everything but this happened 3 times in a row
what do
>>
>>59812860
The GPL requires that it be the preferred version for editing.
If you normally write in obfuscated code, and make changes directly in it, then that's the source for GPL. If you work on a readable version, and then run it through any sort of obfuscator, the readable version is what the GPL considers the source.

"Readability" is subjective and not defined.
It is legal to release really bad, hard to understand, code under the GPL.
It is not legal to take the version that you make changes in, remove the whitespace or otherwise make it less readable, and call that the source under the GPL.
>>
>>59812921
>Visual Studio

you almost had me
>>
Quick question here about SICP for same reason as >>59812921

Is there no way to do loops? I understand that you can accomplish the same with linear recursion but am just curious
>>
>>59812921
i don't think you should get the w10 sdk when you're not using win10
>>
>>59812979
If you want loops, implement them yourself.
>>
What do you guys think of TensorFlow?
>>
>>59813028
More like MemeFlow
>>
>>59812926
Regardless of the legality, GNU Code is just terrible. It's loaded with inline pre-processors and uses K&R formatting (the worst possible formatting).

GPLv3 is also terrible. Someone needs to get together and rewrite all GNU code legibly and in MIT license so that unwashed old hippy can die in obscurity
>>
>self-taught no-degree programmer comes for an interview
>gets upset when asked theory questions
>>
>>59813043
So you just want code that you can sell for free?
>>
>>59813059
If you know (s)he's self-taught and has no degree then it's kind of a dick move to waste everyone's time.
>>
>>59812894
is your computer a toaster??
>>
>>59813123
self taught koder detected. nothing stopped her from reading introduction to algorithms
>>
>>59813043
So your grievances aren't technical, just political.
>>
>>59813123
How do you know a programmer is self-taught? Don't worry, they'll tell you.

I don't even look at people's resumes before interviewing them, to avoid bias.
>>
>>59812752
>Disclaimer: GCC 7 has not been released yet, so this document is a work-in-progress.
>>
>>59813200
>I don't even look at people's resumes before interviewing them, to avoid bias.


So you're wasting both of your time if he didn't have what you wanted to begin with?
>>
>>59813181
Yes, reading all volumes of The Art of Computer Programming before an interview is really practical. Makes sense.

What's the point of interviewing someone that doesn't have the requirements you're looking for?

>>59813200
What's the point of interviewing someone that doesn't have the requirements you're looking for?
>>
>>59813254
I trust HR to do that sort of filtering before candidates even get near me.
>>
>>59813262
>What's the point of interviewing someone that doesn't have the requirements you're looking for?
It's HR's job to filter out candidates who don't meet the requirements.
>>
>>59812752
>caring about GCC when clang exists and is stable.
>>
>>59813289
>using nonfree software
>>
>>59813283
>>59813268
HR is not a programmer, they are a monkey. You can teach a monkey to filter by simple stuff but they will fail to know how to filter people who just fake it on their resume.
>>
>>59813304
>they will fail to know how to filter people who just fake it on their resume.
And then it's his job as the interviewer to confirm that the resume is truthful.
>>
>>59813304
Not all HR departments are like that.
>>
>>59813319
but you could have done it by scanning the resume and looking for bullshit. Avoiding wasting anyone's time further.
>>
>>59813344
And then if it wasn't bullshit he would have biased the process.
>>
>>59813283
What academic qualifications do you think HR people have? They come from a social sciences background.
>>
>>59813352
What's your point? You should be biased against everyone that wants to work for you. They need to PROVE that they are worth the cost and time.
>>
>>59813360
Not all of them do, and besides, there's a lot of very smart people who didn't study STEM.
>>
new thread
>>59813382
>>
>>59813370
The bias should be applied evenly. Knowing a candidate went to the same university as I did might make me favor them.
>>
>>59813397
Then you are a bad person who has no self control and your bias would have affected you no matter what whether you knew before or if you found out during.
>>
>>59813435
You sound upset, are you self-taught?
>>
>>59813262
introduction to algorithms != the art of computer programming. it's a thousand pages, read 3 a day and you're done in under a year
>>
>>59813456
No, I did my time. You are a bad interviewer and shouldn't be interviewing if you can't control your biases.
>>
>>59813165
yes

old HP laptop
>>
File: 1486424161788.jpg (92KB, 1280x720px) Image search: [Google]
1486424161788.jpg
92KB, 1280x720px
>>59809887
>pepsi
>>
>>59810253

try it and find out
>>
File: diamond.png (566B, 19x17px) Image search: [Google]
diamond.png
566B, 19x17px
>>59809905
>>59809919
no I meant this one
>>
>>59813059
>>59813289
>>59813296
Who said that?
Thread posts: 334
Thread images: 33


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