[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 24
File: eggplant.jpg (51 KB, 480x640) Image search: [Google]
eggplant.jpg
51 KB, 480x640
previous thread
>>52553087

what are you working on, anon?
:3
>>
>>52560989
How should I study for a facebook frontend interview?
>>
File: KnDuVkD.webm (2 MB, 640x640) Image search: [Google]
KnDuVkD.webm
2 MB, 640x640
Ask your favorite programming literate anything.
>>
>>52560989

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM8S_IT_H
#define __STM8S_IT_H

/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"
#include "globs.h"
#include "control.h"

/* Exported functions ------------------------------------------------------- */
INTERRUPT void EXTI_PORTB_IRQHandler(void); /* EXTI PORTB */
INTERRUPT void EXTI_PORTC_IRQHandler(void); /* EXTI PORTC */
INTERRUPT void TIM2_UPD_OVF_BRK_IRQHandler(void); /* TIM2 Interrupt */
INTERRUPT void ADC1_IRQHandler(void); /* ADC1 End of Scan Interrupt */

#endif /* __STM8S_IT_H */
>>
https://www.reddit.com/r/IAmA/comments/4226aq/hello_reddit_we_are_hitomi_tanaka_julia_and_anri/

reddit don't FUCKING deserve this
>>
>>52561024
Why do you keep on doing this when you never answer anything actually programming relevant, only irrelevant shit?
>>
Reminder that people in /dpt/ who advocate C have no clue how to program in C and have no issue leaking memory because "it still runs in O(n)".
>>
>>52561064
This
>>
>>52561040
/* You don't need to explain what any of this shit does, it's been in every C source file for the last 30 years ----------------------------------------------------- */
>>
Reposting, desperately looking for feedback:
>>52559454
https://github.com/rzumer/Webbum/ (see website for screens)
I did fix the dependency problem, so now it should launch fine.
>>
>>52561048
have a (You)
>>
>>52561078
>>52561064
Reminder that autistic people repeats their shitposts and samefags whenever people make mistakes
>>
>>52561082
I didn't, copied a ready header and modified in this case
>>
>>52561084
I'll look at it in a few days because I'm genuinely interested however lacking time (sorry anon).
>>
>tfw i installed linux a few hours ago and i'm already missing the botnet
>>
>>52561106
sure faggot
>>
>>52561106
Stay strong anon. Almost all the convenient convenience can be easily emulated.
>>
Why aren't you using a Java framework, /g/?
>>
>>52561100

> lacking time
> on 4chan
>>
File: 34647574532.jpg (64 KB, 510x487) Image search: [Google]
34647574532.jpg
64 KB, 510x487
>>52561151
>>
>>52560989
Who is this semen demon?
>>
>>52561151
>plaintext
>>
>>52561151
> Why aren't you using a Java framework, /g/?
> C++ is higher than Java
...and that is why I use C++.
>>
>>52561106
start learning the command line
>>
>>52561151
Wtf??? I thought Java was supposed to be slow??
>>
>>52561084
>Known restrictions:
>64kbps audio only (Opus/Vorbis codec restricted by the WebM format)
What? WebM has not such restriction, you are doing it wrong.
>>
>>52561151
>nothing about the memory consumption

#REKT
>>
>>52561151
>nothing about faggotry level
>>
>>52561197
>Implying that matters in enterprise systems with terabytes of shared RAM
>>
Which IDE you guys use for Java?
Can't decide between Eclipse or Netbeans.
>>
>>52561181
It's not slow at all, it's even faster than C++ in some instances because of JIT magic.

>>52561197
RAM is cheap
>>
>>52561216
vim and makefiles
>>
>>52561216
>Which IDE you guys use for Java?
Netbeans is bretty gud, but I use Eclipse because I also use it for C++ and CUDA
>>
>>52561166
me :3
>>
>>52561247
Post eggplant in anus or gtfo
>>
>>52561220
>even faster than C++ in some instances because of JIT magic.
repeated ad infinitum on the internet without anyone ever showing a source
>>
>>52561192
Yeah, I meant WebM supports only opus+vorbis while the 64kbps restriction is something I set as default and haven't gotten around to fixing yet.
>>
>>52560989
>absolutely no gf
>>
>Javafags talking about things in C they clearly have no idea about
Enjoy your gimped, sorry, "streamlined" language
>>
Since the other thread is dying, I post my reply here:

#include <stdio.h>

int undefined_behaviour()
{
int a; // affects memory
return ++a;
}

int initialise_memory()
{
int a = 0; // affects memory
return a;
}

int corrupt_memory()
{
int a = 0xdeadbeee; // affects memory
return a;
}

int well_defined_behaviour()
{
static int a = 0; // this memory will not be affected
return ++a;
}

int main()
{
initialise_memory(); // maybe sets memory to 0
undefined_behaviour(); // maybe sets memory to 1
undefined_behaviour(); // maybe sets memory to 2
undefined_behaviour(); // maybe sets memory to 3
int a = undefined_behaviour(); // maybe sets a to 4
printf("undefined (4?): %x\n", a); // will (maybe) print 4 or result in a demon flying out your nose

corrupt_memory(); // this messes with the same memory area
a = undefined_behaviour();
printf("undefined ( ?): %x\n", a); // will maybe print deadbeef

a = well_defined_behaviour(); // sets a to 1 because not affected
printf(" defined ( 1): %x\n", a);
a = well_defined_behaviour(); // sets a to 2 because not affected
printf(" defined ( 2): %x\n", a);

a = undefined_behaviour(); // sets a to some random value (most likely 1)
printf("undefined (1?): %x\n", a);
initialise_memory(); // maybe sets memory to 0?
a = undefined_behaviour(); // maybe sets a to 1?
printf("undefined (1?): %x\n", a);

a = well_defined_behaviour(); // sets a to 3 because not affected
printf(" defined ( 3): %x\n", a); // prints 3

return 0;
}
>>
>>52561268
>http://blog.carlesmateo.com/2014/10/13/performance-of-several-languages/
>https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=java&lang2=gpp

oh and that frameworks source

>https://www.techempower.com/benchmarks/#section=data-r11&hw=peak&test=plaintext
>>
So I was looking to reduce the garbage my C# code was generating, and noticed a lot was coming from subscribing to events. Specifically, at one point I have an object subscribe to 80 other object's events like this:

void SubscribeToStuff() {
for (int i = 0; i < Objects.Length; i++) {
Objects[i].OnSomething += HandleSomething;
}
}


The above is generating about 10kb of garbage. However, if I cache the Action delegate and use that to subscribe, there is no garbage at all:

    Action _handleAction; 
void SubscribeToStuff() {
_handleAction = HandleSomething;
for (int i = 0; i < Objects.Length; i++) {
Objects[i].OnSomething += _handleAction;
}
}


This doesn't generate any garbage. I'm confused why this happens? Should I just make the delegate prior to subscribing for every event or shouldn't I do this? There doesn't seem to be a downside.
>>
>>52561181
you fell for an ancient epic meme stupid tard

>>52561268
k tard
>>
>>52561216
eclipse
>>
http://blog.rust-lang.org/2016/01/21/Rust-1.6.html

It's here boys
>>
>>52561375
>Rust, a SJW language
>No female contributors
kek
>>
>>52561425
So it's for faggots? I guess you'll fit right in.
>>
>>52561442
What's wrong? Did I trigger you?
>>
>>52560989
Insertion pics,when?
>>
>>52561040
>#ifndef __STM8S_IT_H
>#define __STM8S_IT_H
The mark of code monkeys.
>>
File: 6489.jpg (497 KB, 2560x1440) Image search: [Google]
6489.jpg
497 KB, 2560x1440
>>52561268

Java OpenJDK:                   1.189619693 seconds time elapsed
Scala: 1.484613540 seconds time elapsed
C++ clang++: 5.518077517 seconds time elapsed
C++ G++: 4.659448453 seconds time elapsed
>>
>>52561279
Please not include a copy of ffmpeg, the download is slow as fuck, make it optional.
Also, ignore *.pro.user and all other irrelevant files.

https://github.com/github/gitignore/blob/master/Qt.gitignore
>>
>>52561493
Java OpenJDK:                   118.9619693 seconds time elapsed
Scala: 1484.613540 seconds time elapsed
C++ clang++: 0.05518077517 seconds time elapsed
C++ G++: 0.0004659448453 seconds time elapsed

FTFY
>>
>>52561473
This
>>
>>52561362
nobody answers to a legit question because everybody is a programmer wannabe sysadmin faggot,here.
>>
CONDUCTOR WE HAVE A PROBLEM
>>
>>52561483
Do you have a better way, autist?
>>
>>52561564
Nobody answers the garbage questions because nobody cares about you pajeets and rajeets. Go cry a river off in your dedicated crying street.
>>
>>52561579
#pragma once
>>
>>52561362
fucking Cshart lmfao

http://codeblog.jonskeet.uk/2014/07/16/micro-optimization-the-surprising-inefficiency-of-readonly-fields/
>>
>>52561581
only if you answer to a question! are you a sysadmin?
>>
>>52561611
Go easy on the memes lad
>>
>>52561494
Do you mean in the repo or in the release?
If the repo, I will ignore the bin directory, it should cut the size down.
If the release, I guess I can make archives without it. It just seems like an annoyance if someone wants the whole package (although I can't include MSVC++ redist I think). If you want to use an ffmpeg in your PATH I'd like to see if it works, by the way, I haven't tried it.
I do have *.pro.user in .gitignore, so I don't know why it is still there, I will delete it from the web interface and hope it doesn't bug me to sync it back home.
>>
>>52561247
no you're not
fuck off sissy
>>
>>52561564
>>52561581
>>52561362
I don't answer because I don't know C# and therefore don't know the first thing about how the CLR stores objects or how events are handled.
>>
>>52561639
this

just use java or C++
>>
>>52561621
Your delicious butttear nourish me!
>>
https://github.com/7Y3RPXK3ETDCNRDD/dungeon_generator

made it 6 months ago. r8.
>>
File: error.jpg (345 KB, 1302x768) Image search: [Google]
error.jpg
345 KB, 1302x768
I have a compiling problem, realized now that it probably fits here rather than SQT. I am compiling Heimdall from github, when I get to the last step on the wiki, I get [pic related]. Any general ideas on how to fix an error like that?

All the way down here is what I am doing (Windows): https://wiki.cyanogenmod.org/w/Install_and_compile_Heimdall
>>
>>52561673
Pretty cool, I will use it to make maps to test my path finding algos.
>>
>>52561351
ur just mad u have to work twice as hard to get comparably performant code
>>
>>52561425
top kek SJWs are the worst fucking beta whiteknight fagets. nice "gender equality" on that list lmfao hypocrites
>>
File: 1419276460727.jpg (61 KB, 500x539) Image search: [Google]
1419276460727.jpg
61 KB, 500x539
>>52561732
>mfw I realise I share threads with literal 14 year olds

Is there anywhere on the internet to talk about programming with adults?
>>
>>52561755
If you actually want to talk about programming /r/programming is legit better than here.
>>
>>52561639
>avoiding question

sysadmin cuck,detected.
>>
>>52561755
the only reason you're triggered is because you don't agree with us.

>mfw software engineering is filled with betafag white knights
>>
>>52560989
Skiddie facilitation bots in IRC.
>>
>>52561773
This

In almost every popular thread on there there are insights etc from really experienced devs
>>
>>52561790
Or maybe I'm just not so delusional that I think I can answer about stuff I have no clue about. The Donning-Kreuger is strong with you.

Also, C# is pretty much the sysadmin entry level programming.
>>
>>52561821
>>52561773
This. Let's just go to r/programming and leave this shithole behind for good.
>>
>>52561799
>we

?
>>
>>52561837
still not answering to the question sysadmin or not?just simply write YES or NO.
which is at this point unneded because already everybody knows that you are a fag sysadmin.
>>
best recursive function to do factorial in c?
>>
>>52561839
>r/programming
>hai guys dae think python is the best programming lang of all time???
>>
>>52560989
I-Is this a racism thing?
>>
>>52561755
literally reddit
>>
>>52561874
unsigned factorial(unsigned n)
{
if (n <= 1)
return 1;
return factorial(n - 1) * n; // allow compiler to do some TCO magic here
}
>>
How long does it take you to burn out after staring at computer code for most of the day?
11 hours for me.
>>
File: 1450844080429.gif (696 KB, 242x191) Image search: [Google]
1450844080429.gif
696 KB, 242x191
Anyone here ever written a program on a graphing calculator? I'm trying to write a simple guess-the-number game on my TI-84, but it isn't working. It picks a random number, then prompts the user for a guess, but for some reason it skips the while loop and just ends the program there. This is my code:
X→randInt(0,100)
prompt Y
while Y≠X
if Y<X
then display "LOW"
if Y>X
then display "HIGH"
if Y=X
then display "WIN"
prompt Y
end
>>
>>52561952
About 30 minutes here
>>
>>52561938
Which compiler does that?
>>
>>52561875
Fucking retard, you blew my cover! Now they know I'm trying to get them to fuck off back to reddit where they belong!
>>
File: castle-brit-1.jpg (452 KB, 1920x1178) Image search: [Google]
castle-brit-1.jpg
452 KB, 1920x1178
>>52561732>>52561425
They did the CoC not because women, fags, or anything like this, but because one hysterical Russian contributor.
https://www.reddit.com/r/rust/comments/3sjrvr/lrs_an_experimental_linuxonly_standard_library/cwy0f9x
>>
>>52561938
Wouldn't this be better?
unsigned int factorial(unsigned int n, unsigned int product){
if(n == 1){
return product;
}else{
return factorial(n-1, n * product);
}
}
factorial(10, 1);


Because of tail recursion?
>>
>>52561987
gcc, clang, icc
>>
>>52562083
gcc doesn't do tail call optimization. Is there a flag for that?
>>
>>52561361
>link to a shitty microbenchmark that increments a number used to conclude Java is faster than modern C++ implementations in general, which doesn't even know to use logarithmic scaled graphs
>link to a benchmarksgame comparison where Kava loses in most tests and wins by a narrow margin in just a couple

Oh boy, I believe you
Java wins hands down
>>
>>52562072
Yes anon, the other one can't even be optimized by most compilers
>>
>>52562090
It does starting with -O2 (not sure with -O1 but it might even).
>>
>>52561987

GCC with -O2 or higher optimizations. Clang does it as well, I think, with -O3. MSVC does it with /O2. I'm not sure whether Intel does it but it is likely.
>>
File: Contempt.jpg (56 KB, 640x425) Image search: [Google]
Contempt.jpg
56 KB, 640x425
>>52562072
>}else{
>>
>>52562071
>dat whole thread
Rust devs BTFO
So they added the CoC because they were mad that someone was poking holes left and right in their piss-poor implementation.
>>
what's the name of a queue-like data structure where the output order is not guaranteed to be sequential to the input?

i.e, a non-linearizable queue
I thought this would have a simple name but I can't find it on wikipedia
>>
>>52562172
What's wrong with that? Do you prefer the brackets out like
if(cat)
{
...
}
else
{
..
}

I don't usually use C anyways, I haven't really touched that in a while.
>>
>>52562071
is this strcat(AKA thestinger) or someone else?
Rust lost a fuckton of devs that built the language from the ground up from their stupid political bullshit.
>>
Php server, Android client.
>>
File: 1425324303858.png (96 KB, 748x710) Image search: [Google]
1425324303858.png
96 KB, 748x710
>>52562072
return (n == 1) ? product : factorial(n-1, n * product);

no enterprise coding pls
>>
>>52562284
I was actually writing that first, but again, I haven't used C in a while and wasn't sure if I could use return in a ternary statement.

I could faintly remember that once I got an error for doing that, so whatever.
>>
>>52561725
No, I just use D
>>
>>52562252
Yes.
>>
>>52561725
No, I just use D
>>
>>52562330
>>52562337
*suck
>>
>>52562346
:^)
>>
>>52561725
write a function that swaps the values of parameters int x and int y
>>
>>52560989
tfw git's version control is git
(someone pliz mindblown.gif)
>>
>>52562252
This is how I write C/++, makes it easier for me to read.
>>
>>52562262
strcat left them.
>>
>>52562072
>Wouldn't this be better?
If you're not sure your compiler can work TCO magic, then yes. However, most can.

Also, there's the issue about mathematical "correctness". Some people will argue that factorial should only take one argument.

I would prefer to do something like
static unsigned _factorial(unsigned n, unsigned p)
{
// ...
}

unsigned factorial(unsigned n)
{
return _factorial(n, 1);
}

but then you could probably argue that one should just do it in a loop.
>>
>>52562090
>gcc doesn't do tail call optimization. Is there a flag for that?
It does, but you need optimization flags.

>>52562164
Clang does with O2 as well.

>>52562083
MSVC does too.
>>
Wondering why almost all BPF programs check and reject fragmented packets with ldh [20]/jset #0x1fff. I mean, fragmentation isn't nice, but you don't have to outright reject them all. Yet the check is there almost every time (if you go above layer 2, then it's guaranteed to be there).

Then there's this monster you get if you use "protochain 50" filter:

(000) ldh      [12]
(001) jeq #0x800 jt 2 jf 22
(002) ldb [23]
(003) ldxb 4*([14]&0xf)
(004) jeq #0x32 jt 20 jf 5
(005) jeq #0x3b jt 20 jf 6
(006) add #0
(007) jeq #0x33 jt 8 jf 20
(008) txa
(009) ldb [x + 14]
(010) st M[1]
(011) txa
(012) add #1
(013) tax
(014) ldb [x + 14]
(015) add #2
(016) mul #4
(017) tax
(018) ld M[1]
(019) ja 4
(020) add #0
(021) jeq #0x32 jt 56 jf 22
(022) ldh [12]
(023) jeq #0x86dd jt 24 jf 57
(024) ldb [20]
(025) ldx #0x28
(026) jeq #0x32 jt 54 jf 27
(027) jeq #0x3b jt 54 jf 28
(028) jeq #0x0 jt 32 jf 29
(029) jeq #0x3c jt 32 jf 30
(030) jeq #0x2b jt 32 jf 31
(031) jeq #0x2c jt 32 jf 41
(032) ldb [x + 14]
(033) st M[1]
(034) ldb [x + 15]
(035) add #1
(036) mul #8
(037) add x
(038) tax
(039) ld M[1]
(040) ja 26
(041) jeq #0x33 jt 42 jf 54
(042) txa
(043) ldb [x + 14]
(044) st M[1]
(045) txa
(046) add #1
(047) tax
(048) ldb [x + 14]
(049) add #2
(050) mul #4
(051) tax
(052) ld M[1]
(053) ja 26
(054) add #0
(055) jeq #0x32 jt 56 jf 57
(056) ret #262144
(057) ret #0


I haven't been able to decipher it entirely.

Well, I guess I've reached the end of my week-long BPF incursion. There's not much left to do.
>>
>>52562377
>using the smiley with a carat nose
>>
>>52562498
>not using it
>>
>want to learn C++
>remember ->
>>
>>52562109
Yeah... You should learn to read. I said Java beats C++ in some instances, not all. Also if everything is so wrong except what you think, why don't you make your own benchmark? Because so far you haven't proved jackshit.
>>
>>52562517
C++ gives you stds
>>
>>52562484
I don't understand, why is the assembly relevant to the question?
>>
>>52561773
>600k users
>one post per day that is le upvoated xDD 1000 times
>all others are below 100
Now that is what I would call cancer.
>>
>>52562284
>factorial
>product
Get your fucking verbose code off my lawn.
>>
/dpt/, what's a simple practice or technique that you use to make the development process more efficient?
>>
File: bench.png (183 KB, 1050x750) Image search: [Google]
bench.png
183 KB, 1050x750
>>52562640
tdd
>>
>>52562640
Don't post on 4chan.
>>
>>52562065
It would never have worked anon. They would've just came back to shitpost like they always do.
>>
>>52562544
You mean the longer listing? It isn't relevant, it's just a big and complicated filter program I discovered. I've been trying to figure out how exactly it works, but it's too complex for my little mind. I understand parts of it, but not the big picture.
>>
>>52561179
And more legible. C++ is love. C++ is life.
>>
>>52562640
tdd
>>
>>52562668
No thanks, I like programming languages that don't limit me
>>
>>52562640
Know exactly what I want to write before I write it
>>
>>52562769
tdd?
>>
>>52562936
yeah, mate
>>
Mapped memory is accessible from child processes if they are created after the memory was mapped, right?
>>
>>52562668
this is b8

using clang on a virtual machine for god sakes
>>
>>52562951
what is that i meant
>>
>>52562640
Don't use C or assembly
>>
>>52562991
this is c++ btw
>>
File: Screenshot_2016-01-22_11-53-14.png (9 KB, 447x134) Image search: [Google]
Screenshot_2016-01-22_11-53-14.png
9 KB, 447x134
>>52562991
This is what I got with gcc for C
>>
>>52561024
Where do you get your webm's/gifs
>>
File: nSH3.webm (1 MB, 1072x600) Image search: [Google]
nSH3.webm
1 MB, 1072x600
>>52563042
>>
>>52563076
ouch

did he died?
>>
>>52563076
what did he jump off?
>>
>>52563076
That's what he gets for rolling forward
>>
>>52561048
>MIRD-150 Being the best of 2015

Nigger what? That definitely goes to KAWD-380, by a fucking mile.
>>
>>52563098
no he didn't
>>52563099
an old crane
>>
>>52563033
>1 off
>>
>>52560989
>eggplant
THIS IS A WORKSAFE BOARD, ANON!!!
>>
>>52563159
you're a loser proclaiming their porn of the year in a programming thread
>>
>>52562668
$ time ./test
133333333

real 0m1.380s
>>
>>52563174
What? That's exactly what was in the picture
>>
>>52563211
meant for >>52562991
>>
>>52563184
>>52561886
Can someone please explain this meme to a newfag?
>>
>>52563207
>I'm using a significantly better CPU than the one used for the comparison therefore I can safely say that java on a pentium 2 v.s. C on a i7-9999 blacked.com edition is a fair and even comparison and it says c is faster
>>
What's the difference between != and !== in JavaScript? I understand the difference between == and ===, but in this case is the first just a short hand of the second?
>>
>>52563207
jesus christ, but run all three on the same cpu
>>
>>52563244
>>>/reddit/
inb4 spoonfeeders
>>
>>52563246
>unironically using js
No stop
>>
Okay, so I declared and defined a function that takes two doubles as arguments and then performs an operation with said doubles and returns the result.

The function also increments a static variable timesCalled to keep track of how many times the function has been called.

In my main(), I want to output the value of timesCalled, but it's undefined because it is local to the function. How do I fix this shit without making timesCalled a global variable?
>>
>>52563265
I'm debugging someone else's code anon.
>>
>>52563244
>>
>>52563244
it's a benis
>>
memes = do  
gen <- newStdGen
print $ isInfixOf "object-oriented programing" $ randomRs ('a','z') gen

I'm mining for memes in random strings. Work's hard, but honest.
>>
>>52563267
This was already answered like 5 times. Fuck off, it's nobody's issue that you're retarded.
>>
>>52563267
Make timesCalled local to main and pass-by-reference?
>>
>>52563281
>banning someone for posting an aubergine

>github

I don't even programme but even I've heard of how cuntish github are
>>
>>52563246
>I understand the difference between == and ==
Then you should understand the difference between != and !== too

>==
Equality operator
>===
Identity operator

This means that

>a != b
a is not equal to b
>a !== b
a is not identical to b
>>
>>52563312
>github
This has nothing to do with github and everything to do with the people in charge of said project.
>>
>>52563267
make a new parameter for your function and pass it an int by reference. assign that variable the value of timesCalled before returning from your function.
>>
>>52563327
Wait, so !== actually means "!===", then?

Gah, that's confusing. It should've just been !== and !=== then.
>>
>>52563245
>>52563248
fucking fine

$ time ./testc
133333333

real 0m1.376s
user 0m1.376s
sys 0m0.000s
$ time ./testcpp
133333333

real 0m1.394s
user 0m1.393s
sys 0m0.000s
$ time java Test
133333333

real 0m2.257s
user 0m2.251s
sys 0m0.012s
>>
>>52563267
I already replied in the previous thread, anon.

See >>52561356
and >>52561055
>>
>>52563345
No, github pretty much endorses this behavior 100%.
Look at their code of conduct.
It explicitly has a clause that encourages sexism against white people and that the management will turn a blind eye to this because we don't like MRA's.
>>
>>52563267
http://www.codingunit.com/c-tutorial-call-by-value-or-call-by-reference
>>
>>52563374
cool
>>
>>52563366
>Wait, so !== actually means "!===", then?
Well, put in other terms.

(a != b) == !(a == b)
(x !== y) == !(x === y)
>>
>>52563327
>>52563366
I don't understand why these things exist.

One is equal-ish and the other is equal, and you just kind of have to memorize the various nuances of each.

Which is fucking dumb.

But this is my opinion as a programmer that's only been in the industry for 2 years.
>>
all of these threads are retarded

no one on /g/ knows shit
>>
>>52563422
in javascript, == compares 2 variables and coerces both types to be the same before the comparsion
it's like an implicit cast
if you want to explicitly prevent this, use ===
>>
>>52563387
>No, github pretty much endorses this behavior 100%.
Stop repeating this meme

>Look at their code of conduct.
REEEEEEEEEEE


THEIR COC APPLIES TO GITHUB PROJECTS, NOT TO PROJECTS ON GITHUB

WHY IS THIS SO HARD FOR YOU ANAL AUTISTS TO UNDERSTAND

GitHub's OWN fucking projects use GitHub's Code of Conduct. They recommend that other projects use it too, but they in no fucking way enforce THEIR code of conduct on other people.
>>
>>52563300
I wasn't satisfied with the answers.
>>
>>52563443
>>>/asylum/
>>
>>52563389
Thank you mein freund.
>>
>>52563439
Is that why webmconverter was banned? It was a github project? I didn't know!
>>
>>52563443
Static variables internal to functions are basically globals anyways so stop fucking around and just use a global
>>
>>52563478
But I heard that was sinful.
>>
>>52563484
It isn't unless you're a retarded cppfag.
>>
>>52563422
Equality is not the same thing as identity.

In Java, for example, == returns true if the reference is the same. This means that if you compare two strings, you need to implement equalTo or compareTo or shit like that.

Obviously, it would be nice to just do == instead but then how do you differentiate between equality of references (are the two variables pointing to the same object) or equality of the value (are the two [different] objects "equal")?

This is why PHP and JS have == and ===.

Java dropped this altogether and just force people to implement the interface Comparable<T> instead.

In Python, == checks equality and you need to do special magic to check object identity instead (comparing the output of doing id() on an object).

In C# and C++ this is solved with the fact that references and pointers are different variable types.
>>
>>52563473
>webmconverter was banned
What? Why would a webm converter be banned?
>>
>>52563473
Either a github project or another project where they used a similar or the same COC. The person that made the image was clever enough to crop that info out of the image.
>>
>>52563506
Because it was a fork of "webm for r*t*rds" which contains the R word!
No, fucking seriously!
And fuck off back to tumblr for trying to justify this bullshit!
>>
>>52563496
>and just force people to implement the interface Comparable<T> instead
Why does Java keep forcing shit?
>>
>>52563473
it was banned because the program was titled "WebM for Retards".
Someone found it offensive and a beta orbiter cuck on github promptly deleted it after drinking his 3rd vacuum brewed mocha fellapuchino for the day.
>>
>>52563473
>webmconverter
That's the name of the project, not the user.
>>
>>52563514
>the guy banned himself from his own 1-man project goys, there was no communication with github and they didn't literally require the guy to remove the r word
The tumblr is strong in this one.
>>
>>52563496
I won't lie, I really think that operator redefinition is really missing from java
>>
>>52563521
>Why does Java keep forcing shit?
You (or other anon) just said that the alternative (having different operators) was stupid...
>>
>>52563526
No. It was titled webmconverter. It was a fork of "webm for retards'.
>>
>>52563532
Amazing! Did you figure this out on your own or did your mum give you a hand?
>>
>>52563549
You lie. Forks retain the name of the forked project.

>>52563535
>hurr durr my arbitrary make belief story with no background information what so ever
The FUD is strong with this shilling jew
>>
>>52563549
when the original is banned, so are all the forks
>>
>>52563496
>In Python, == checks equality and you need to do special magic to check object identity instead (comparing the output of doing id() on an object).
pretty sure that's wrong. in python 3 == always compares compares object identity unless you specifically override "__eq__" in which the 'is' operator still compares object identity.

what you're referring to is immutable objects being stored using as flyweights so they compare as equal because they are the same anyway.

it's pretty bloody transparent imo
>>
>>52563548
The other anon lad. Different operators does sound stupid though, you should be able to specify whether what you're comparing is a pointer or the pointed, or even longer counts of pointers to pointers. That seems like the simplest way imo
>>
>>52563518
Well, that seems insensitive to people like yourself.

It deserved a ban.
>>
>>52563496
>and you need to do special magic to check object identity instead
literally the "is" keyword
>>
>>52563496
>In Java, for example, == returns true if the reference is the same. This means that if you compare two strings, you need to implement equalTo or compareTo or shit like that.
God damn, yet another reason why many prefer C# to Java.
>>
What are your opinions on data science?

Is it a good field to go into or are they just statisticians who live in San Fransisco?
>>
function EntityAdd ( objtype, ID, x, y ) 
if _G[objtype] then
if entity[ID] == nil then
entity[ID] = entityMT:import( objtype )

entity[ID].ID = ID

entity[ID].offset.x = x
entity[ID].offset.y = y

if entity[ID].new then
entity[ID]:new()
end

print( "ENT: added entity at ", ID )
else
print( "ENT: unable to add entity ", ID )
end
else
print( "ENT: unable to find objtype: ", objtype )
end
end

function EntityDel ( ID )
if entity[ID] ~=nil and entity[ID].ID == ID then
entity[ID] = nil
print( "ENT: removed entity ", ID )
else
print( "ENT: unable to remove entity ", ID )
end
end

function EntityUpdate ( ID, dt )
if entity[ID] ~=nil and entity[ID].ID == ID then
if entity[ID].update then
entity[ID]:update( dt )
end
else
print( "ENT: unable to update entity ", ID )
end
end

function EntityDraw ( ID )
if entity[ID] ~=nil and entity[ID].ID == ID then
if entity[ID].draw then
entity[ID]:draw()
end
else
print( "ENT: unable to draw entity ", ID )
end
end


I think I got it optimized some more, it doesn't crash now!
>>
>>52563608
it's statistics rebranded
>>
>>52563576
>in python 3 == always compares compares object identity unless you specifically override "__eq__" in which the 'is' operator still compares object identity.
While you are correct that is checks identity, I'm fairly sure that == is the equality operator.

It might default to the same method for objects, but they are not the same operator. "is" calls __id__ under the hood.

Pic related
>>
Doing a program that calculates the determinant of any matrix in C. Can't figure out what's wrong with it though...
>>
File: ruh_roh[1].jpg (67 KB, 499x349) Image search: [Google]
ruh_roh[1].jpg
67 KB, 499x349
>>52563495
>unless you're a retarded cppfag.
>>
>>52563602
Yes, see >>52563622

My brain simply forgot the "is" operator for a second.
>>
>>52563575
The fork was banned manually, not just the original.
>>
I typed in
register tmp
and it compiled.

Is this implicitly an int or something?
>>
>>52563569
>>>/tumblr/
>>
>>52563625
int determinant(int n, int *matrix)
{
int sum = 0 ;
int i = 0 ;
int j = 0;
int k = 0;
int A[(n-1)*(n-1)] ;

if (n == 1) {

return *(matrix) ;
}

else {


for (i = 0 ; i < n ; i ++){


for (j = 0 ; j < n ; j ++ ) {


for (k = 0 ; k < n ; k ++ ) {


if (k >= j) {

*(A + i * n + k ) = *(matrix + i * n + k + 1) ;
}
else {

*(A + i * n + k) = *(matrix + i * n + k) ;
}
}


sum += ( pow(-1,j + 2) * *(matrix + j) * determinant((n-1), A) ) ;

}
}
}


return sum ;

}
>>
>>52563652
yes
>>
>>52563652
shit anon, you might break your computer creating virtual registers willy nilly
>>
>>52563648
the beta orbiter cuck who banned the first one was still salty
>>
>>52563607
Do you really have a big use case for writing your own string class? I can't think of any other reason you would have to implement equalTo.
>>
>>52563625
Just use blas faggot.
>>
Hopefully someone here can tell me how retarded I am. I wrote a program in java that finds the sum of all prime numbers under a certain value, but I fucked up, and don't know how.

It works for small values, like 8, but not larger ones, like 2 million. I'm using long as the variable type, and the numbers shouldn't come even close to the limit. Is there something basic I don't understand about variables? I just can't figure this out
>>
>>52563684
>I wrote a program in java
Very retarded
>>
>>52560989
can /dpt/ name a function you can calculate with WHILE but not with GOTO?
>>
>>52563662
You are wrong, as simple as that.

>>52563669
>I can't think of any other reason you would have to implement equalTo.
Hello Sanjeet.

Just because you don't use PriorityQueues and SortedArrayLists and the similar, doesn't mean others don't.
>>
File: ideas.png (305 KB, 1920x1080) Image search: [Google]
ideas.png
305 KB, 1920x1080
rolling
>>
>>52563706
Thanks for your help, man. Glad you figured it out
>>
>>52563684
off by one error
>>
>>52563718
>You are wrong, as simple as that.
Tumblr in a nutshell
>>>/tumblr/
>>
>>52563717
while, for, do-while, do-until, if-then, if-then-elses-, switches, selects etc are all just syntactic sugar for goto's
>>
>>52563723
What do you mean? Shouldn't it always be off by one, then?
>>
>>52563741
that's wrong, you can't implement if else with the semantics of goto, you need new semantics and thus if can't be syntax sugar.
>>
>>52563717
control flow structure is implemented entirely using goto
>>
>>52563732
>facts are not facts because of how I feel
Sounds like you belong on Tumblr, anon
>>
>>52563741
GOTO is syntactic sugar for JMP.
>>
>>52563684
post your code
>>
>>52563684
>It works for small values, like 8, but not larger ones, like 2 million. I'm using long as the variable type, and the numbers shouldn't come even close to the limit. Is there something basic I don't understand about variables? I just can't figure this out
Your prime finding algorithm is probably too expensive.
>>
>>52563756
>Shitlord! MRA! This is tumblr territory, get out silly man!
>>
>>52563622

here is an example showing they do the same thing:
>>> class ex:
def __init__(self):
self.var = 1


>>> a = ex()
>>> b = ex()
>>> a == b
False
>>> a is b
False


these objects have equal values but because we haven't overridden __eq__ it returns false because the pointers are different. if it were truly the equality operator it would have return true.

your example is worthless for precisely this reason: list()s have implemented the __eq__ method so that you can actually compare them by value easily.

it is the equality operator only by name. it is the same as by definition 'is' except it allows you to override it. there is no identity check functionality built into == like you suggest.
>>
Rate my bubblesort.

Rate my bubblesort.
void bubblesort(unsigned *arr, unsigned size)
{
while (!is_sorted(arr, size))
{
unsigned i;
for (i = 0; i < size - 1; i++)
{
int state = compare(arr[i], arr[i+1]);
if (state > 0)
swap(arr+i, arr+i+1);
else
continue;
}
}
}
>>
>>52563754
If else you can though. There is no need for the "else" keyword

IF NOT condition GOTO else
do stuff
GOTO endif

else:
IF NOT other_condition GOTO endif
do other stuff

endif:
blablabla
>>
>>52563755
>>52563741
k thanks
guess I can stop trying really hard to come up with such a function then
>>
>>52563609
seems like you have too many steps involved, but I don't know lua very well

at least you aren't using ; anymore
>>
>>52563757
No. It's the same thing.
>>
>>52562668
see>>52563374

btfo
>>
>>52563788
>if it were truly the equality operator it would have return true.
No, because you've created 2 different instances, off course they don't point to the same thing
>>
Oi, /dpt/ care to help a newbie?

started to learn C week ago using a book and now am on arrays, I don't understand how to work with them, any of you have some kind of explanation?
>>
can someone bring me up to speed on this eggplant maymay
>>
>>52563826
arrays are just pointers
Thread replies: 255
Thread images: 24

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.