[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: 314
Thread images: 57

File: 1492832377473.png (769KB, 1052x1342px) Image search: [Google]
1492832377473.png
769KB, 1052x1342px
old thread: >>60250799

Friendly reminder not to reply to the D language shitposter, they are the same person who spams that illya mac desktop all day.
They will also reply to you the same way, do not talk to him.
>>
nth for lets all get along and share what were working on
>>
First for anime.
>>
>>60254560
If you have freedom of speech you are free to reply to anyone.
>>
I need to learn python to get A on reprogramming class

I'm just a dumb engineer
>>
>>60254560
D shitposting is mild and actually rather fun. Unlike "muh buffer overflows" and "whom art thou quoting" shitposting, which have really become stale.

>>>60254557
>that would imply
Only if you're a brainlet.
>>
File: 1434127516224.png (52KB, 700x419px) Image search: [Google]
1434127516224.png
52KB, 700x419px
Free speech is a spook.
>>
https://www.rust-lang.org/en-US/faq.html

>Does Rust do tail-call optimization?

>Not generally, no. Tail-call optimization may be done in limited circumstances, but is not guaranteed. As the feature has always been desired, Rust has a keyword (become) reserved, though it is not clear yet whether it is technically possible, nor whether it will be implemented.

>What are higher-kinded types, why would I want them, and why doesn't Rust have them?

>[T]here’s no inherent reason for the current lack of support.

Why is there so much hype about Rust?
>>
>>60254597
wtf is a reprogramming class
>>
>>60254560
>Friendly reminder not to reply to the D language shitposter
Wow, sorry for responding to faggots sperging out over a language
>>
>>60254609
Sorry
Programming class
I'm learning shit like octave, but now I need to git gud on python
>>
>>60254602
Because it does something different.
People dont care whether its good or bad.
Personally i see rust becoming as bloated and clusterfucky as c++
>>
>>60254602
>Why is there so much hype about Rust?
People use it, they like it, they recommend it to the others. That's how. Every languages have their shortages and from what I see, you really are nitpicking
>>
File: dpt kaguya.jpg (579KB, 1280x1115px) Image search: [Google]
dpt kaguya.jpg
579KB, 1280x1115px
Have you read your SICP today?
>>
>>60254650
I don't think wanting to be able to guarantee TCO in a language in 2017 is really nitpicking. Scheme has had it for *decades*.
>>
>>60254663
Well, they have a keyword reserved for it, they may implement it later down the road
>>
>>60254656
Yes.
>>
File: dlang_chan.jpg (139KB, 470x545px) Image search: [Google]
dlang_chan.jpg
139KB, 470x545px
Threadly reminder that dlang-chan is not dead, and she's super duper cute and holy fuck you guys are absolutely retarded: stop shitposting over language usage and start a decent discussion or at least shitpost over something else. FUCK
Oh, and she's fast! Say something nice about her, you mongs!
>>
>>60254656
Bought it years ago, never read it.

fite me
>>
>>60254675
D is easy to prototype. This is why I like D
>>
>>60254671
>they may implement it later down the road
Just like D will get rid of its garbage collector soon! You just have to wait a little longer, honest!

I'm being harsh, but the promise of something this basic maybe, possibly being implemented at some point in the future doesn't exactly fill me with confidence.
>>
>>60254675
Please just stop, I'd really rather not see more shitflinging
>>
>>60254704
>Just like D will get rid of its garbage collector soon!
When did I say that?
Also, you can strip D out of it's runtime and GC
>>
>Can I overload operators? Which ones and how?

>The following operators can be overloaded:

Why can't I just define my own symbolic operators/functions, like >=> and >>> and =<<?
>>
File: ayy_lmao.jpg (59KB, 339x339px) Image search: [Google]
ayy_lmao.jpg
59KB, 339x339px
>>60254696
Yes it is! Thank you for not shitposting.

>>60254710
Those faggots will just shitpost about something else then. That's how they work.
>>
File: ran's_DMRG.png (1MB, 900x1440px) Image search: [Google]
ran's_DMRG.png
1MB, 900x1440px
>>60254656
Read about some different implementations of DMRG and QMC today.
>>
>>60254720
operator overloading is bad and you should feel bad if you do it
>>
>>60254712
I never said you said that, I'm just comparing you saying Rust may implement a way to guarantee TCO at some point to people saying D will get rid of its garbage collector at some point.

Having to fuck about with the language/runtime doesn't count, you could implement TCO in Rust by editing the source and changing the language, it wouldn't mean Rust today has TCO.
>>
>>60254724
Although I am thinking of ditching D since I am getting used to Rust by the days. Writing D programs without GC is tedious
>>
>>60254734
t. java programmer

I'm not really inclined to take design advice from a language in which this compiles:

String[] strings = new String[10];
Object[] objects = strings;
objects[0] = new Integer(3);
>>
>>60254763
one day they'll bite you in the ass, have fun while you want to though
>>
>>60254734
Operator overloading is bad in most cases, but in some it can be useful; with that said, those cases still don't justify its inclusion in a language.

>>60254754
And I can't blame you for it. I'll probably be dead before dlang-chan gets her GC tumor removed. And yet, I still love working with her. She and C are my langfus.
>>
>>60254675
When is she going to get rid of that garbage collector?
>>
>>60254773
Been programming for years and never been bitten by overloading operators.

It must be so frustrating, needing the language to straitjacket you in order to stop you hitting yourself in the face. Most people just don't hit themselves in the face.
>>
>>60254786
There are many language without GC as well.
D is in the middle ground really.

I'd suggest an alternative stdlib with no GC instead of removing GC altogether, GC is quite handy at times.
>>
>>60254786
When her parents can afford chemo.
>>
>>60254796
you're the first person i've ever heard be up on a high horse about operator overloading. it's not elegant or impressive, genuinely don't know why you seem proud of it
>>
>>60254746
Making @nogc exceptions will actually be a big step in making Phobos completely GC-free (though I haven't heard where Walter is with this, he might have talked about it at DConf). Until then, it doesn't bother me too much.
>>
File: dlang chan.png (319KB, 470x545px) Image search: [Google]
dlang chan.png
319KB, 470x545px
>>60254675
>>
>>60254826
Would you rather have

a . b . c


or

compose(compose(a, b), c)


?
>>
>>60254602
>Why is there so much hype about Rust?
No such thing, only propaganda from SJW because their plan's taking IT sector hostage now

That's also the same reason why suddenly everyone is "hyping" inclusion in tech for no good reason at all
>>
>>60254734
Why?
>>
>>60254949
a ∘ b ∘ c
>>
>>60254968
Operator overloading, then.
>>
>>60254949
compose(a, b, c)
>>
>>60254949
i'd rather use the syntax supported by the language, rather than building my own composition operator with operator overloading
>>
>>60254979
Disgusting.
>>
>>60254976
Not an operator. My language doesn't have those.
>>
>>60254991
But everyone knows that symbolic names means you're overloading operators. Function and method names cannot be symbolic.
>>
>>60254991
It's an operator
>>
>>60255001
My language doesn't have "methods". Only functions.
And why would I be overloading them? There is only one type in my language.
>>60255008
Nope.
>>
>>60255001
>Function and method names cannot be symbolic
According to whom?
>>
https://github.com/commit-sudoku/firefox-css

this is firefox after some css, is there a way I can make or get this theme on google chrome? does google chrome allow u to customize the tabs like that, so far ive just seen themes for it webpages and the only thing that I think has come close to me achieve what I want is a webpage from google from 3 years ago telling me ill have to code it in c sharp or some sht
>>
>>60255015
According to C++, Java, and C#. Y'know, real languages.
>>
>>60255011
>There is only one type in my language.
And that type is trash.
>>
>>60255026
What is a "real" language? The things you listed are shit languages only an idiot would use, there is nothing "real" about them.
>>
>>60255041
What do you have against real numbers?
>>
>>60255011
it's got nothing to do with types and everything to do with infixitivity
>>
>>60254763
Upcasting?
>>
>>60255011
>>60255079
or mixfixitivity
>>
>>60255054
They're mostly uncomputable.

>>60255082
Java arrays are covariant.
>>
>>60255094
So? That doesn't stop me from using them as my main type.
>>
>>60255099
You wouldn't use a space of 2^32 values to represent three possible results from a function...

Oh wait, Java already did.
>>
>>60255054
They're not supported on the 8086.
>>
>>60255114
No computer truly supports real numbers.
>>
>>60255110
My language is certainly better than Java though.
>>
https://www.youtube.com/watch?v=u_hDHm9MD0I
>>
I feel like I """learned""" a decent bit but I still feel like I cant do shit
i know for/while loops, if/else conditionals, functions, lists/dicts/tuples.
I tried making a "sum of all primes below 2 million" script but it takes too long to return anything.
>>
>>60255132
That's not much of a claim, anon.
>>
>>60255122
Why not?
>>
>>60255141
>I tried making a "sum of all primes below 2 million" script but it takes too long to return anything.

What if you could avoid some of the computations somehow?
>>
>>60254633
Then fucking do it? Don't know what you want us to tell you. Practice makes perfect.
>>
>>60255043
Don't bother. They don't get it. They're drunk with the feeling of superiority that having to care about low level details gives them.

And while they're still writing mutexes and struggling with dead locks, FPists have had concurrency solved for decades now.
>>
>>60255143
Because you can construct a bijection between the set of valid programs in any Turing-complete language and the natural numbers.
>>
>>60255141
Tips to speed up checking if a number is prime:
Don't check even numbers. Aside from 2, they will NEVER be prime.
Don't check above the square root of the number you're testing: they will never be a factor.
>>
>>60255141
>script
In what language, Python?
>>
>>60255155
FP itself isn't enough. It has to be non-garbage FP. That being said, any FP will be by definition better than the garbage presented in that post.
>>60255142
That makes me wonder, what "part" of real numbers can a computer truly support?
>>
>>60255256
last part meant for >>60255157
>>
>>60255256
https://en.wikipedia.org/wiki/Computable_number
>>
File: 1493486600168.png (122KB, 364x385px) Image search: [Google]
1493486600168.png
122KB, 364x385px
>>60255183
yes
I want to be a good programmer one day but I feel like I never will.
especially if I miss obvious stuff like >>60255162
>>
File: eat_shit.jpg (110KB, 532x525px) Image search: [Google]
eat_shit.jpg
110KB, 532x525px
>>60255272
Fuck off faggot
>>
>>60255288
no bully
also girls cant be faggots dumbo
>>
>>60255278
Don't worry about that kind of shit. Realistically, you don't check for that kind of stuff first.

You get your shit working, then you run it. While it's running, you look at what's eating up computation time. You find out that over half the numbers you're testing are not prime. Why the fuck is that? I'm wasting so much time, how can I filter these out? What do they have in common? Holy shit even numbers aren't prime. So you code that in. Same thing for square roots, "well, shit, every time this code runs, we find a lot of smaller factors, but larger factors are just wasting resources. wat do?
>>
>>60255272

how did you make your topbar look like that on os x?
>>
File: Yakumo.Ran.full.1170117.jpg (761KB, 664x1000px) Image search: [Google]
Yakumo.Ran.full.1170117.jpg
761KB, 664x1000px
>>60255278
https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
>>
>>60255288
sauce?
>>
>>60255302
you shouldn't spoil it. let him/her learn criticla thinking
>>
File: genki_tomboy.jpg (75KB, 383x491px) Image search: [Google]
genki_tomboy.jpg
75KB, 383x491px
>>60255278
>especially if I miss obvious stuff like
Get a discrete math textbook and you'll get a decent foundation on that kind of crap.

>>60255305
Tsuki ga Kirei
This girl will most likely not win, and the feMC is insufferable. So be prepared for that.
>>
File: yukari_toilet.png (277KB, 921x557px) Image search: [Google]
yukari_toilet.png
277KB, 921x557px
>>60255324
I don't give a fuck dude lfmao
>>
>>60255302
>>60255324
I know about that, I just couldn't think of a way to implement it correctly.
>>
>>60255363
It's literally given in pseudocode on the wiki page. You just copy it, you don't even need to know programming. I was able to implement a sieve not even a week into Python, with no programming experience beyond crude bash scripts
>>
File: 1471216526275.jpg (50KB, 433x469px) Image search: [Google]
1471216526275.jpg
50KB, 433x469px
>>60255388
you underestimate how stupid I am.
I didn't go down that far because I saw the logic of it and tried to write it myself.
>>
Rate my meme-program written in the meme-lang:
fn main() {
let mut primes = vec![2];

// Shitty meme-lang doesn't support custom steps yet
for i in (1..1_000_000).map(|x| x * 2 + 1) {
if primes.iter().take_while(|&x| x * x <= i).all(|x| i % x != 0) {
primes.push(i);
}
}
println!("{}", primes.iter().sum::<u64>());
}
>>
>>60255442
>meme
>>>/v/
>>
>>60255442
rust was a mistake
>>
>>60255442
>
custom steps
>>
>>60255427
Stupid boys are cute. Stay stupid and daddy will keep you safe.
>>
What do you do when your function declaration doesn't fit on one line?
>>
>>60255495
It always fits.
>>
>>60255442
If you're checking only odd numbers, you should only divide by odd numbers also. Also, there's no reason to not make a sieve, since it's trivial (you mark off multiples of primes, i.e. composites).
>>
File: confused_undines.jpg (77KB, 704x524px) Image search: [Google]
confused_undines.jpg
77KB, 704x524px
>>60255495
function(blah,blah, ... 
blah, blah)
>>
>>60255502
Mine don't. It's especially common when using Java-style naming.
>>
>>60255495
Buy a wider monitor
>>
File: 1458626540237.png (24KB, 240x240px) Image search: [Google]
1458626540237.png
24KB, 240x240px
>>60255488
Don't worry, even after reading it I still don't understand.
Makes me want to give up and kill myself desu.
>>
>>60255542
That doesn't help if you want to limit lines to 72 characters.
>>
Most Pajeet Languages List:
1.) C++
2.) Java
3.) C#
4.) C
5.) PHP
>>
>>60255519
>(blah
Bad practice. If you have open parentheses, the starting bracket should be whitespace as in
function(
blah blah)
>>
>>60255562
Go beyond your limits
>>
>>60255545
You're really cute anon but I want to help you out.
int sieve(int x)
{
int y = ((int) sqrt(x)) + 1;
if(y<2)
{
return 1;
}
for(int k=2;k<y;k++)
{
if(x%k == 0)
{
return 0;
}
else
{
return 1;
}
}
}

int primesumeme(int n)
{
int sum = 0;
for(int x=2;x<n;x++)
{
if(sieve(x) == 1)
{
sum += x;
}
}
}

primesumeme(2000000);
>>
>>60255576
Why?
>>
>>60255659
Don't forget to put
return sum;

at the end.
>>
>>60255659
That isn't a sieve, you spewing imbecile.
>>
>>60255849
True, the return 1 should be outside of the for loop
>>
>>60255571
I don't get how C++ is a pajeet language.

I mean, I get that it is, but fuck, C++ is probably the worst language to let people fuck around with your code with.

No reasonable company would outsource that shit or let h1bs touch their C++ code. It's really fucking obvious.

If anything proves capitalism wrong, it's that those dumbasses let it keep happening.
>>
>>60255933
No, it should be in the trash, where trail division belongs.
>modulo anything
>sieve
>>
File: doubt.png (1MB, 1366x768px) Image search: [Google]
doubt.png
1MB, 1366x768px
>>60255982
Oh so you're just autistic. Thought you actually knew that there was a mistake or something. Thank god.
>>
>>60256006
Trial division is not a prime sieve. You better be baiting.
>>
File: Waifu.jpg (23KB, 720x480px) Image search: [Google]
Waifu.jpg
23KB, 720x480px
What language is that? C++?
regardless, I cant read it because I'm a babby that can only read python.
I'll have a Mcjob for the rest of my life.
Thanks for trying.
>>
>>60256050
>>60255659
>>
File: Sieve_of_Eratosthenes_animation.gif (154KB, 445x369px) Image search: [Google]
Sieve_of_Eratosthenes_animation.gif
154KB, 445x369px
>>60256049
Forgot gif
>>
>>60256078
Yeah it's C++
>>
>tfw sieve is slower than brute force
What is wrong with you people?
>>
>>60255962
I don't either.

I deal with pajeets at work and they are 100% Java developers. They want to force fucking everything into a Java framework, even when it doesn't make any sense. If it's not Java, they suddenly can't understand it.
>>
>>60255141
You are supposed to put printf statements in your code yo know it is doing what you intended it to do.
>>
File: really_implores_you_to_ponder.png (147KB, 231x361px) Image search: [Google]
really_implores_you_to_ponder.png
147KB, 231x361px
>>60256079
std::vector<int> primes;
for(int n=1;n<=N;n++)
{
primes.push_back(n);
}

for(int l=2;l<((int) sqrt(n))+1;l++)
{
for(int k=2;k<((int) sqrt(n)) + 1;k++)
{
for(int m=0;m<primes.size();m++)
{
if(primes[m] == k*l)
{
primes.delete(m);
}
}
}
}

int sum = 0;
for(int m=0;m<primes.size();m++)
{
sum += primes[m];
}

return sum;

This better?
>>
>>60256107
A basic sieve, sieving from 2:
def sieve(limit):
primes = [1]*limit
for i in range(2, limit):
if primes[i]:
yield i
for j in range(i*i, limit, i):
primes[j] = 0

print(sum(sieve(2000000)))

And trail division implementing trivial optimizations, basically best-case:
def trial_division(limit):
if limit >= 2:
yield 2
for i in range(3, limit + 1, 2):
if not any(i % j == 0 for j in range(3, int(i**0.5) + 1, 2)):
yield i

print(sum(trial_division(2000000)))

Results in:
$ time python3 sieve.py 
142913828922

real 0m0.527s
user 0m0.512s
sys 0m0.016s

$ time python3 trial_division.py
142913828922

real 0m13.025s
user 0m13.008s
sys 0m0.012s

>>60256206
>primes.delete(m)
Terrible.
>>
got double x = 2,3;
How can i get them separated, make a and b from x.
a = 2, b =3
>java
>>
File: 1444459649810.jpg (162KB, 1920x1080px) Image search: [Google]
1444459649810.jpg
162KB, 1920x1080px
>>60256123
What did you say about java you son of a bastard bich?
>>
>>60256364
basterd*
>>
>>60256286
>What is the sqrt(n)
>>
>>60256286
>shrinking the array each time
>terrible
t. pajeet
>>
is there anything more redpilled than programming with one hand and eating a burger in the other?
>>
>>60256396
Programming in nothing but panties and a skirt with one hand and a burger in the other
>>
>>60256286
>Python
Literally laughing at that run time
>>
File: 1488270102588.png (257KB, 591x716px) Image search: [Google]
1488270102588.png
257KB, 591x716px
If I go back and actually learn basic algebra will I stop being this shit at programming?
>>
>>60256449
it's not the algebra itself that'll help you, but if you can't learn algebra then you can't learn programming.
>>
>>60256449
Why can't you learn basic algebra now?
>>
>>60256489
>>60256469
>>60256449

When you say algebra, what specifically do you mean by that?
Can you name some area?
>>
>>60255328
>Discrete maths textbook
Spoon-feed please?
>>
>>60256379
For retards who don't understand exponentiation. x**0.5 is faster, too, and no need to import an entire module.
>>60256387
Reassignment is O(1) in most languages, while deletion of dynamic array elements is O(n), aka learn how to program and stop spewing. Furthermore, the memory costs of sieving a non-segmented sieve are of the initial array size, and as such deleting is moot. Your sieve probably doesn't even work granted how incompetent you've been throughout this discourse.
>>60256409
It gets the work done, unlike the tenfold other meme languages.
>>
>>60254784
Why is D's GC bad?
>>
>>60256507
He said basic algebra in /dpt/ so I'm guessing the kind of algebra that deals with computer algorithms.
>>
>>60256532
Wastes cycles trying to collect the language
>>
>>60256507
I never passed algebra 1.
Actually, technically a highschool drop out.
>>60256489
I can, I just mean if I start trying to get better at algebra will I be less shit.
>>60256469
I guess my problem is that I'm shit at understanding programming logic
>>
>>60256537
I'm pretty sure he means basic equations with variables.

They're actually not important for programming, but for understanding mathematical equations, it's a severe handicap and it makes me wonder if he's also missing other fundamental knowledge, like fractions, exponentiation, logarithms and long division with remainders, which are all useful in programming.
>>
>>60256537
is linear algebra what you call just algebra?
I got like 5 different maths on my faculty per year, but only one algebra, linear. That is why im asking, to determine what specifically is he talking about.
Like is he talking about matrix, integrals or linear mapping etc
>>
>>60256286
>integers autocasting to boolean
absolutely disgusting
>>
>>60256526
>It gets the work done
Very slowly, the only way that's acceptable is if you have a CPU from 1980
>>
File: 1492580064907.png (365KB, 860x585px) Image search: [Google]
1492580064907.png
365KB, 860x585px
>>60256554
Well anon, I'm going to say something discouraging: you should stick to spending your time watching anime, reading mango and VNs, etc. Because I doubt you'll be able to discipline yourself such that you'll be able to finish learning algebra or even understand the fundamentals of programming. It's best that you spend your time on things you already enjoy instead of doing stuff that will never bring you joy because you'll never be good enough to produce anything decent.
And yes, I'm projecting because I'm in the almost exact same situation as you.
>>
>>60256592
Why are you even in this thread?
>>
File: 1454558746817.jpg (70KB, 400x400px) Image search: [Google]
1454558746817.jpg
70KB, 400x400px
>>60256537
>the kind of algebra that deals with computer algorithms
>>
>>60256554
I'm not sure if this will help you get better at algebra but it has made me a better programmer.

1.Follow your loop invariants. Read out loud if you have to.
2.Know your syntax
3.If you don't know what is wrong with your program, read your code first then look for answers.

>>60256622
>
I can explain... I'm not wearing a skirt.
>>
>>60256555
oh
everybody can learn all of that in max one day desu
there is not anything hard about that, i was thinking he is talking about something advanced math
>>
>>60256584
>>> True == 1
True
>>> False == 0
True
>>> sum((True, False, True))
2

:^)
>>60256590
You're wrong. A supercomputer gets magnitudes more down than anything consumer. So by your logic, consumer computers are unacceptable in terms of performance.
>>
>>60256554
Perhaps it would help to take a historical approach to understanding الجبر.
>>
>>60256614
Because I'm still chasing my dream of programming something that'll make me happy. Sadly, it's been 7 years; I'm still nowhere close to my goal.
I don't want that anon to experience what insurmountable failure tastes like.
>>
>>60256682
This is what anime does to people.
>>
>>60256658
Did you run that Python on a super computer? If so, holy shit.
>>
>>60256689
Anime is but a symptom, anon. It was only the last 4 years where I started to drown myself in it. It's a substitute for drinking myself into a coma.
>>
File: 1490514438016.jpg (93KB, 777x777px) Image search: [Google]
1490514438016.jpg
93KB, 777x777px
Is there always a single inferable type if the AST looks something like this?
Lambda Var Type Term
Pi Var Type Type
>>
>>60256712
yes
>>
you got x and y
x->bottom left position in coordinate system
y->right top position in coordinate system
x and y are double
You need to calculate area of a rectangle, how would you do it?
I dont know how to treat x/y as 2 separate numbers and use them to calculate dimensions of rectangle.

x and y examples are:
double x=2,2;
double y=4,4;

Any suggestions?
>>
>>60256871
How on earth are you using a single double to represent a point in 2D space?
>>
since my first semester I try to understand the need for private attributes and functions

I get that some methods deep down don't need to be seen by anyone using my code, like some custom sorting or whatever helper method for the real algorithm
but other than that every explanation is utter bullshit to me
as if I needed to protect anything

if the user is too stupid to not fuck around with something he shouldn't then he deserves all the bugs that come with it
I could just declare in the comments that he shouldn't touch this
otherwise it would offer intelligent programmers more opportunities
>>
>>60256903
you are stupid
>>
>>60256885
>double x=2,2;
>double y=4,4;
it's a true mistery
>>
>>60256926
Are these europeans meme commas, or do you just fucking have 2 doubles?
>>
>>60256938
if anything is a meme it's your decimal """"""points"""""" amerifart
>>
>>60256885
easy
double d = xpos * 1000;
d += ypos / 1000;
>>
>>60256903
>if the use is too stupid to not fuck around with something he shouldn't then he deserves all the bugs that come with it
>I could just declare in the comments that he shouldn't touch this

This seems reasonable when considering just your small university single-person projects, but I dare you to keep those thoughts after staring at a real project with tons of separate files.
>>
>>60254949
[a, b, c].compose()
>>
>>60256976
Awful
>>
>>60256987
No u
>>
File: 1467821966170.gif (662KB, 500x446px) Image search: [Google]
1467821966170.gif
662KB, 500x446px
>>60257020
damn
guess you win the argument
>>
>>60256950
You're on an English speaking website, eurocuck. Write with the English standards.
>>
>>60257036
Nah thanks, I'm good
>>
>>60256964
that only works for coords that are less than 1000 (or any set range).
What if you dont know how large coords will be?
>>
File: IMG_0310.jpg (123KB, 1280x720px) Image search: [Google]
IMG_0310.jpg
123KB, 1280x720px
>>60257028
>>
Okay simple thing here:

I have a python script.

I have a JSON file.

I want to add an entry into the file.

        with open (db_file, "w") as json_data:
data = json.load(json_data)
data['Images'][imgmd5] = {
"link" : imgurl,
}
json.dump(data, json_data)


This doesn't work.

io.UnsupportedOperation: not readable
>>
File: ss_010.png (15KB, 453x348px) Image search: [Google]
ss_010.png
15KB, 453x348px
>>60256885
how would you calculate this
>>
>>60257051
>>60256964
btw since it's a double you will miss a ton of coordinates

>>60257081
what the fuck dude
you're baiting, right?
>>
File: 1452471092796.png (372KB, 1280x720px) Image search: [Google]
1452471092796.png
372KB, 1280x720px
>>60257081
Did you miss primary school geometry or something?
>>
>>60257070
r+
>>
File: weird_goblin.png (35KB, 196x361px) Image search: [Google]
weird_goblin.png
35KB, 196x361px
>>60257081
lol
>>
>>60257107
da, i dont know how to calculate when input is 2,2 and 4,4 for x and y
i mean, i know what is answer but dont know how to program it :DDD
>>60257102
not baiting at all, question is same as that above about rectangle
>>
>>60257081
kek wth anon
you want to return a double without knowing type T?
dont use generics if youre stupid my man
>>
>>60257136
are you poojeet by any chance?
>>
File: 1456320308645.jpg (5KB, 205x246px) Image search: [Google]
1456320308645.jpg
5KB, 205x246px
>>60257081
>generics
>>
>>60257136
Why don't you stop being fucking retarded?
2 numbers is not enough to describe a rectangle in 2D, and trying to encode more than one number's worth of information into a single double is fucking stupid.
>>
>>60257116
Gives me this gigantic error.
    data = json.load(json_data)
File "/home/REDACTED/.pyenv/versions/3.5.3/lib/python3.5/json/__init__.py", line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/home/REDACTED/.pyenv/versions/3.5.3/lib/python3.5/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "/home/REDACTED/.pyenv/versions/3.5.3/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/REDACTED/.pyenv/versions/3.5.3/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
>>
>>60257170
anon hes trying to calculate an area and return that as a single number
still fucking retarded with generics tho
>>
>>60257202
Ok, since he's just got a single point, the correct result is
pooblic double getArea() {
return 0.0;
}
>>
>>60257157
What do "people" mean when they say this? It sounds retarded.
>>
>>60257225
see >>60257081
he has x and y
go to bed anon
>>
>>60257172
It means the first character is already not json.
Is file really json? Maybe check encoding.
>>
If I can do all of these challenges this summer, is that how I know I've broken the mold from a noob programmer?

https://github.com/karan/Projects
>>
>>60257286
x and y describe a single point. A point has no area.
>>
>>60257155
no, just learning java and got some problems to solve.
I may doing this wrong
Create interface IArea with method getArea which will return area, type double
Create generic class Rectangle, rectangle is defined with two points, x and y. X and Y are bottom left and top right points of rectangle. Area is area of a rectangle. Do not implement class Point.

In main function create linear collection of 5 rectangles, type int[(1,1),(2,2)][(2,2),(3,3)],[(2,2),(4,4)],[(3,3),(5,5)],[(3,3),(6,6)]
Check linear collection and add its members in unsorted collection where key is area and value rectangle. Iterate through that formatted collection and show its content and calculate area of a rectangle for all of them

i just saw that type is int :D:DD
Translating may be wrong at some parts but fuck it
>>
>>60257278
thats what its called. generics.
>>
>>60257294
>Fizz Buzz
Definitely.
>>
>>60257286
jesus anon its x and y in a rectangle class. x and y do NOT describe a single point but the width and height
>>
>>60257310
Did you not see the other challenges in there??
>>
>>60257302
Is there a non-retarded name for it? No sane person would call it that way.
>>
>>60257323
???
It's the only one that matters though.
>>
>>60257294
You can only move on from being a "noob programmer" once you're solved a millennium prize problem.
>>
>>60257296
>>60257319
my bad, who the hell writes this shit
>>60257299
>>
File: 1460527731158.png (117KB, 372x351px) Image search: [Google]
1460527731158.png
117KB, 372x351px
>>60257323
>Fizz Buzz
>challenges
>>
>>60257330
that the """oracle""" way to call it
don't know if there are languages where it is named some other way
>>
>>60256206

>people who use std::vector who don't know about the reserve() method and just use push_back a bunch of times, thus causing unnecessary re-allocations

Also, delete is not a method on vector. In fact, it's a reserved word and cannot be used as a method name for ANYTHING. Are you looking for erase()? If that's the case, you are doing this wrong on so many levels.
>>
>>60257338
I've almost solved one of them. Am I close to moving on?
>>
>>60257288
It was caused by the script deleting it earlier.

Or something.
I remade the template, and now it just creates the database twice.

So basically I have my template and then the desired input.

Any idea why?
>>
>>60257354
sometimes when he give as problem to solve, people cant figure out what is point of problem and what is required
nonsense all the time
>>
>>60257338
I have already done that, though.
>>
Hey guys, I'm learning Python and I've got a file as so:

123,4
456,8
684,9

I want to store them into a dictionary, should I read these lines into a list and then try and find a way to convert them into a dictionary or is there a way to read straight from the file and specify the comma delimiter is what seperates each value / key?
>>
>>60257417
with open (db_file, "r") as json_data:
data = json.load(json_data)
data['Images'][imgmd5] = {
"link" : imgurl,
}
with open(db_file, "w") as json_data:
json.dump(data, json_data)
>>
>>60257468
>Python
Stopped reading right there.
>>
>>60257361
Depends on how new to programming you are
>>
File: 1457486233712.jpg (83KB, 551x511px) Image search: [Google]
1457486233712.jpg
83KB, 551x511px
>>60254560
Any language with OOP is a disservice to intelligent programmers.
>>
>>60257469
Holy shit it works.

Thank you.
>>
>>60257468
Whichever one works best for you
>>
r8 my fizzpuzz
int[2] euclidean(int x,int y)
{
int q = 1;
loop:
int r = y - x*q;
if(r > x)
{
q = q + euclidean(x,r)[0];
goto loop;
}
else
{
return {q,r};
}
}


int truncate(int x)
{
int n = 1;
while(euclidean(x,n*10)[0] > n*10)
{
n++;
}
return x - euclidean(x,n*10)[1]
}

int coprime(int x, int y)
{
if(x < y)
{
int r = euclidean(y,x)[1];
coprime(x,r)
}
if(x == 1 || y == 1)
{
return 1;
}
}

void fizzbuzz(int x)
{
double pi = 4.0 * atan(1.0);
int n = truncate((int) (pi * 10)) / 10;
double sum = 0.0;
for(int s=1;s<10000;s++)
{
sum += 1/s^2;
}
int m = truncate(((int) sum ) * 4) - 1;
if(euclidean(x,n*m)[1] == 0)
{
print "phyzze-boughczy";
}
if(euclidean(x,m)[1] == 0 && not(euclidean(x,m*n)[1] == 0))
{
print "boughczy";
}
if(coprime(n,m) == 1)
{
if(euclidean(x,n)[1] == 0 && not(euclidean(x,m*n)[1] == 0))
{
print "phyzze";
}
}
else
{
if(euclidean(x,n)[1] == 0 && (not(euclidean(x,m*n)[1] == 0) && not(euclidean(x,m)[1] == 0)))
{
print "phyzze";
}
}
}
>>
>>60257468
dict(line.split(",") for line in f.readlines())

{int(i):int(j) for i,j in (line.split(",") for line in f.readlines())}
>>
>>60257538
0/100 for Python and it being non-compliant.
>>
>>60250106
>Blog post
The Op always asks what you're working on. Why do people dislike 'blog posts'?
>>
>>60257565
It isn't python lol
>>
Is masturbating 3-4 times a day normal?
I feel like it improves my programming.
>>
>>60257791
I jack it 7 to 8 times a day on average, and I don't get noticeably better from it. I think you need to wear some pantsu and thigh-highs to get an effect.
>>
>>60257294
Better to do project euler problems up to 100 or so.
>>
>>60257699
Huh? What is it then?
>>
>>60257791
Anally? Then yes.
>>
>>60257847
>shitting on python when you can't even recognize it
Pathetic.
>>
>>60257889
It is Python then, isn't it. Let's not lie.
And since when is it required to even have seen a language to know for a fact that it's complete garbage?
>>
>>60257918
It's not Python, you spewing retard. Regurgitating a meme doesn't make you fit in, especially when you get it wrong. Fuck off.
>>
>>60257918
Are you retarded? lmfao
>>
>>60257918
since always
python is a shitshow but you are actually just repeating memes you read on someones blog
>>
I want to shotgun approach my CG and system programming courses with one project. CG requires the project to be done in WebGL with some shitty JS frameworks I don't know shit about. How do I access Linux syscalls from JS?

I found this demo. https://s3.amazonaws.com/mozilla-games/ZenGarden/EpicZenGarden.html
Looks like it downloads and compiles something at the initialization. Idk if it's a part of the web app compiles on my machine and then runs while the controller/view stays in browser or what? If it's so then how much can I do with this? can I use my syscalls here, like open files, fork and maybe write a simple (local cause idk shit about networks) server that would communicate with multiple instances of my web app with POSIX/SystemV IPC?
>>
If Python is shit why do major tech companies use it?
>>
>>60257994
what other scripting language is there that isn't even bigger shit?
just because others are shitter doesn't mean it's "good"
>>
>>60257938
It is Python. I am sure of it. You won't fool me with your delusions.
>>60257946
Not that I'm aware of.
>>60257969
>since always
Nope. You can describe a language and I can always decide in a finite amount of steps whether it's trash or not.
>blog
What is a "blog"??
>>
File: 我開始方了.jpg (119KB, 392x495px) Image search: [Google]
我開始方了.jpg
119KB, 392x495px
>>60258034
>Not that I'm aware of.
Exactly what a retard would say.
>>
>>60258034
Shit bait.
>>
>>60258048
Proof?
>>60258058
Feel free to say something constructive anytime. Otherwise just fuck off.
>>
>>60258034
>Nope. You can describe a language and I can always decide in a finite amount of steps whether it's trash or not.
why don't you demonstrate your highly scientific method then?
>What is a "blog"??
XD

hope you got enough (You)'s now in this shitposting session so you feel valuable again
>>
>>60258048
>Exactly what a retard would say.
No retards either affirm or deny that.
>>
File: 1492859340696.jpg (99KB, 829x720px) Image search: [Google]
1492859340696.jpg
99KB, 829x720px
>>60258072
>highly scientific method
What is a "highly scientific method"? Just give me a language and I will run it through my machine which will produce the answer.
>XD
What the hell was that?
>>
>>60258113
>Just give me a language
Given that >>60257538 was very obviously C code (the only thing I would expect people to be confused about is the use of the 'not' keyword).
What does your machine say about C?
>>
Hi.
I am learnıng to code ın java and yesterday I was paır codıng wıth a more mature person.
The thıng ıs, he wrıtes a lot, then he checks hıs code, then debugs ıt.
I have always done ıt ıncrementally.
Say, codıng a small part, testıng ıt, do the next part.
And I always wrıte what I was tryıng to achıeve ın the comments.
I just wonder, when am I good enough to work through bıgger chunks of code?
Why do people wrıte so much, and then waste theır tıme correctıng the mess they've done?
>>
>>60258179
>C
My bad. C++
>>
>>60258179
>very obviously C code
It's not C.
>>
>>60258179
>the only thing I would expect people to be confused about is the use of the 'not' keyword
Which is what threw me off. But I still don't fully believe you. And sadly I don't have a C compiler right now to verify that what you're saying is correct.

>>60258205
Absolute garbage only a complete moron would willingly use.
>>
>>60258205
It's not Meme++ either.
>>
>>60258209
Yeah see >>60258205
It's valid C++ if we assume some declarations before the first line.
>>60258214
Is it simply invalid code then? Not actually a language?
>>
>>60258231
>It's valid C++
>Returning an array from a function
>print "phyzze-boughczy";
No.
>>
>>60258246
I know C++ is crazy but yes you can do all those things. But I'm sorry I won't bother showing you because writing correct C++ is just a mess.
>>
>>60258256
I'm not a filthy sepplesfag, but I'm pretty sure you can't do either of those things in C++.
That is returning arrays (as they're not first class types) and calling a function without ().
>>
>>60258256
I use C++ to write C with smart pointers
>>
Why doesn't there exists some kind of POSIX like standard for mobile operating systems?
>>
>>60258283
Because mobile is a trainwreck.
>>
>>60258277
That's almost good anon. I'm glad you're happy with that compromise though.
>>
File: 1492598161059.jpg (20KB, 377x331px) Image search: [Google]
1492598161059.jpg
20KB, 377x331px
How can I use undefined behavior to optimize my C codes? I don't care about portability.
>>
File: 1406803019377.jpg (103KB, 1280x720px) Image search: [Google]
1406803019377.jpg
103KB, 1280x720px
>>60258308
You've already asked this question before.
Stop being stupid and shut up.
>>
>>60258322
W I D E R
>>
File: 1435409632056.gif (905KB, 1000x1080px) Image search: [Google]
1435409632056.gif
905KB, 1000x1080px
>>60258322
>You've already asked this question before.
Yes, so?
>Stop being stupid and shut up.
But why is this stupid? I need more speed. I'm trying to build something truly powerful here...
>>
>>60258341
At least learn to wide properly.
>>
>>60258283
>Why doesn't there exists some kind of POSIX like standard for mobile operating systems?
Because monopolies.
>>
>>60258365
Ah fuck, I guess they filter full-width characters to normal width now.

>>60258364
>But why is this stupid?
It's not your job to exploit undefined behaviour; it's the compiler's. Putting UB into your program deliberately is beyond retarded.
>>
>>60258365
I tried to. How the fuck am I supposed to widepost now?
>>
File: dead_meiling.png (598KB, 906x739px) Image search: [Google]
dead_meiling.png
598KB, 906x739px
Now that the dust has settled what's the fastest language for number crunching and why is it Fortran?
>>
>>60258383
>It's not your job to exploit undefined behaviour
But why not? I can help the compiler.
>Putting UB into your program deliberately is beyond retarded.
I really need the extra speed and I'm willing to do almost anything at this point.
>>
>>60258410
>But why not? I can help the compiler.
You can help the compiler in other ways. Add 'restrict' to your pointers, make your program cache friendly, try and make your program multithreaded if it's appropriate (maybe using OpenMP), maybe use some compiler builtins (although this is non-portable as fuck).
Putting UB into your program literally makes it invalid.
>>
File: 1490336486113.png (318KB, 720x540px) Image search: [Google]
1490336486113.png
318KB, 720x540px
>>60256554
>I guess my problem is that I'm shit at understanding programming logic
you and me both

Somehow this problem solving part does not come naturally.

But I understand it as the result of years of suppression of critical thinking and creativity with the large amount of readily available information.and the overconsumption of media.

We have a lot to rewire in our brains, anon. I am a recovering English major myself, trying to get back all that lost time by studying simple math again and learning to program.
>>
>>60256871
>x->bottom left position in coordinate system
>y->right top position in coordinate system
wtf! (x,y) cannot be two different positions
>>
File: 1493805127613.png (166KB, 500x500px) Image search: [Google]
1493805127613.png
166KB, 500x500px
>>60258442
>the result of years of suppression of critical thinking and creativity with the large amount of readily available information.and the overconsumption of media.
This is so true my anus is perking.
>>
>>60258308
>>60258364
Did you read my 2000 character response? And watch the video?
>>
File: 1483612379132.png (128KB, 401x401px) Image search: [Google]
1483612379132.png
128KB, 401x401px
>>60258439
>Add 'restrict' to your pointers, make your program cache friendly
Where can I read more about this? I'm somewhat of a beginner.
>maybe use some compiler builtins
Like what? As I said, I don't care about portability.
>Putting UB into your program literally makes it invalid.
I'm writing a theorem prover which I'm using to prove properties about itself. I don't care if C thinks it's invalid. I just need the extra speed since I'm planning something big.

Also, how can I disable all runtime checks in C? I can switch to any compiler.

>>60258459
Sorry?
>>
File: 1492476070339.png (218KB, 500x500px) Image search: [Google]
1492476070339.png
218KB, 500x500px
>>60258479
>I can't read documentation or startpage anything
Leave anytime
>>
>>60258479
>Sorry?
It's fine someone else got some good info out of it (because someone replied positively).
But I won't bother helping you if you ignore what's being said.
>>
File: 1484862720362.jpg (30KB, 425x382px) Image search: [Google]
1484862720362.jpg
30KB, 425x382px
>>60258493
I'm not that good at reading documentation, sorry.
>>
>>60258479
>Where can I read more about this? I'm somewhat of a beginner.
Just google "restrict pointer".
>Like what? As I said, I don't care about portability.
Again, just google whatever the hell your compiler offers. Shit like __builtin_expect or whatever.
>I'm writing a theorem prover which I'm using to prove properties about itself.
Proving an invalid program with an invalid "prover" is completely pointless. You really don't seem to understand the implications of UB. The compiler is under NO OBLIGATIONS to do anything with your code. It can, and probably will, generate incorrect code.
>Also, how can I disable all runtime checks in C?
There were never any to begin with.
>>
File: 11171.png (164KB, 413x352px) Image search: [Google]
11171.png
164KB, 413x352px
>>60258507
Then you should call it quits, faggot.
>>
File: coq-logo.png (6KB, 66x100px) Image search: [Google]
coq-logo.png
6KB, 66x100px
>>60258479
Why not learn to use coq instead?
>>
File: 1484868878791.gif (881KB, 500x281px) Image search: [Google]
1484868878791.gif
881KB, 500x281px
>>60258506
>It's fine someone else got some good info out of it (because someone replied positively).
That was most likely me. I just don't remember your response being 2000 characters.
I did watch at least half of the video by the way, but he didn't explain how to use UB to optimize my code. And he was using C++, which I'm never touching.

>>60258517
>just google whatever the hell your compiler offers
Can you be more precise please?
>Proving an invalid program with an invalid "prover" is completely pointless.
It's not invalid, though, at least not for the purposes of theorem proving. I have my own precautions in place to verify that the type-checker works as intended. If UB suddenly changes this I will notice it immediately.
>It can, and probably will, generate incorrect code.
Even if it will, I will notice that and adjust my program accordingly.

>>60258546
Are you okay, anon?

>>60258549
That is what I was doing in the beginning, but it extracts to very slow languages (which I don't like) and I need maximum speed.
>>
>>60258401
C with restrict pointers.
>>
>>60258595
Why not add a C target to coq extractor instead?
>>
>>60258608
Even if I decide to do so, my questions still apply. I would need to make the code as fast as humanly possible.
>>
>>60258595
Stop being so fucking naive. Your program should NEVER have UB in it.
>>
>>60258624
Why is that? I don't care if the compiler produces utter garbage as long as I can detect it, which I can.
>>
>>60258618
Use fortran, it's faster than C. But what are you realliy doing? I'm curious? Or produce asm directly.
>>
File: 1481145585304.jpg (153KB, 1777x1754px) Image search: [Google]
1481145585304.jpg
153KB, 1777x1754px
>>60258458
May your anus always strive for the truth, brah
>>
>>60258595
>And he was using C++
Most of the stuff mentioned applies to C too.
>I don't remember your response being 2000 characters
Maybe not. But I'm prone to make very long responses on these topics.
>half the video
I suggest watching the second half. He's starting with examples at that point. Those promote understanding of what you can do a bit more.
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html
This article series is pretty good too.

But really this is all rather unnecessary because if you're having trouble with your compiler not producing the ASM you were wanting it's often easier to just use intrinsics or inline assembly to optimize it yourself than to fiddle with the reasons why the compiler doesn't get it. It's worth trying to do stuff like restrict or change types or whatever but you shouldn't dig too much into that. It's not going to get you all the way there.
Most compilers are terrible at vectorizing code for instance. So what's the point in transforming your code so it actually does it when it's so fragile? Just write it yourself.
>>
I need to use template function to find max element of dynamic array. Is this good?
#include <iostream>

using namespace std;
template <class T> T findMax(T arr[],int n)
{
int i;
T aMax;
aMax=arr[0];
for(i=0;i<n;i++)
{
if(aMax < arr[i])
aMax=arr[i];
}
return(aMax);
}
int main()
{
int z;
cout <<"Array Size: "; cin>>z;
int* iarr= new int[z];
cout << "Integer Values \n";
for(int i=0; i < z; i++)
{
cout << "Enter integer value " << i+1 << " : ";
cin >> iarr[i];
}
cout<<"Generic Function to find Maximumfrom Array\n\n";
cout<<"Integer Maximum is : "<<findMax(iarr,z)<<"\n";
return 0;
}


also now i should add that max element index needs to be even number
>>
>>60258686
Yeah it works.
        int i;
T aMax;
aMax=arr[0];
for(i=0;i<n;i++)

Most prefer to declare i inside the loop using
        for(int i=0;i<n;i++)

because having local variables around which you weren't aiming to use isn't really all that good. But it's not wrong to do it this way. Some don't like declare anywhere.
>>
File: vomit.jpg (90KB, 650x650px) Image search: [Google]
vomit.jpg
90KB, 650x650px
>>60258686
>>
>>60258642
>Use fortran
I don't know it. How much faster is it and can I use UB to exploit the language?
>But what are you realliy doing?
A consistent type theory which given any proposition (within certain limits) determines whether it's true, false or undecidable.
>Or produce asm directly.
Wouldn't it be even harder to optimize?

>>60258677
>He's starting with examples at that point. Those promote understanding of what you can do a bit more.
So he shows direct examples of optimizing code by introducing UB?
>This article series is pretty good too.
Thanks, I'll read it.

>it's often easier to just use intrinsics or inline assembly to optimize it yourself
I guess I'll learn about assembly too. I'm assuming it doesn't have exploitable UB?
>>
>>60258686
or you know.. you could just use std::max_element
>>
>>60258740
>So he shows direct examples of optimizing code by introducing UB?
That's the wrong view to take but yes he utilizes the knowledge that there's UB to give the optimizer in the compiler liberties to produce more efficient code. So in a sense yes.
>I'm assuming it doesn't have exploitable undefined behavior
No. What you write is what you get.
>>
>>60258740
>can I use UB to exploit the language?
That's wrong way of going about things.
In general performance comes from efficient algorithms and making your program cache friendly.
Fortran kind of has the cache friendlines in the language because it operates on vectors.

You should not try to exploit UB but if you for some reason need extra performance you could use C and inline assembly.
>>
>>60258762
>That's the wrong view to take
But why? Nobody else is using my code and it isn't intended to be portable. Silent errors are also pretty much impossible.

>>60258765
>In general performance comes from efficient algorithms and making your program cache friendly.
If I do that, there is still some extra speed to be gained from UB, isn't there?
>>
>>60258740
>A consistent type theory which given any proposition (within certain limits) determines whether it's true, false or undecidable.
Stop right now. You don't understand the time complexity of that task.
>>
>>60258777
>still some extra speed to be gained from UB, isn't there?
You need to know what kind of assembly your compiler outputs.
UB does not necessarily make the outputted assembly code more efficient. That's why you would rather inline assembly in C if for some reason the compiler outputs bad assembly.
>>
>>60258777
It's the wrong view to take because when you say introducing UB it implies that you do have runtime circumstances where you run into the UB case.
But if that wasn't what you meant you're absolutely correct. The examples he shows (which aren't negative examples of where UB hurts) are circumstances where he uses the fact that the compiler doesn't have to care about a case because it's UB.
https://youtu.be/yG1OZ69H_-o?t=2358
This is probably the most obvious case. Doesn't take long, 7 minutes approx. You can start there. It even gives you a general tip on when to use unsigned vs signed integers.
>>
>>60258686
Nope, use the std function.
>>
File: 1375670617230.jpg (233KB, 503x503px) Image search: [Google]
1375670617230.jpg
233KB, 503x503px
>>60258797
>C Preprocessor Convention
>It's about C++
What the fuck? Why would you lie like that?
>>
>>60258808
C and sepples have basically the same preprocessor.
>>
>>60258808
>C Preprocessor Convention
Who are you quoting?
>It's about C++
It's about undefined behavior, much of which is shared between the two (C and C++). I don't remember the exception, but there is one.
>>
File: ss_012.png (35KB, 704x378px) Image search: [Google]
ss_012.png
35KB, 704x378px
>>60258805
>>60258755
>std::max_element
are you talking about doing it something like this
>>
File: 14568627524615.jpg (27KB, 519x519px) Image search: [Google]
14568627524615.jpg
27KB, 519x519px
>>60258784
Which is why I need all the performance I can possibly have.

>>60258794
>You need to know what kind of assembly your compiler outputs.
That makes sense, I'll start learning it then.
Is being able to read and comprehend it enough to write some parts of my program in it?

>>60258797
>It's the wrong view to take because when you say introducing UB it implies that you do have runtime circumstances where you run into the UB case.
Assuming UB messes something up I will know pretty quick.
>This is probably the most obvious case. Doesn't take long, 7 minutes approx. You can start there.
Thanks, I'll watch it now.
>>
>>60258777
>If I do that, there is still some extra speed to be gained from UB, isn't there?
No.
If anything it will make your program slower because you trip up the optimizer which generally works by recognizing common patterns.
Uncommon or 'weird' code tend to generate worse machine code.
>>
>>60258832
makes no sense, so no.

>declares static function to pass in where you can pass a lambda

Spend 5 minutes reading the pages you're consulting before making your dumb posts.
>>
>>60257554
Came back to check on the thread and this is what I had as well. Thanks mate.
>>
>>60258879
If anyone feels like pointing me in the right direction. I'm implementing a bubble sort but I'm not sure how to reference the value for a particular key from a particular item in my list?

My list is set out as so

[ {number: 123, ratio: 3}, {number: 456, ratio: 5} ]

Etc...

I want to sort by ratio so I know I need to compare the value of each ratio in each dictionary but syntactically I'm not sure how to do that.

I know how to get values based on keys, but considering they have identical keys I'm not sure.
>>
>>60258854
>Which is why I need all the performance I can possibly have.
No. It's too colossal. Even if I gave you a computer 100x faster than today computers, it won't help. Stop it.
>>
New thread:

>>60259082
>>60259082
>>60259082
>>
>>60257565
>Python
>braces
what
Thread posts: 314
Thread images: 57


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