[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: 328
Thread images: 25

File: daily programming thread2.webm (2MB, 600x338px) Image search: [Google]
daily programming thread2.webm
2MB, 600x338px
old thread: >>52527563

What are you working on, /g/?
>>
>>52530057
Faggot manchild.
>>
>>52530057
Also, not safe for work you fuckin' pedophile.
Delete this shit.
>>
The kernel can't pack a struct, can it? The compiler would have to do that.
>>
Thank you for posting an anime webm.
>>
>>52530057
Fuck off back to /pol/, OP.

Nobody wants to see anime here.
>>
Tell me why I shouldn't use goto for all error handling duties?

As long as I explictly surround goto statements with brackets, there should be no problems, right?
>>
>>52530057
Delete this thread.

MOOOODS
>>
>>52530057
that's a trap, isn't it?
>>
>>52530132
there's nothing NSFW in that webm
>>
>>52530163
>>52530163
You can't goto across modules.
>>
>>52530057
Fuck off weeaboo
>>
>>52530178
what tipped you off?
>>
>12:59:44
>thread created like 20 posts before bump limit

reported
>>
File: jjj.png (78KB, 982x465px) Image search: [Google]
jjj.png
78KB, 982x465px
Going to start learning JavaScript even though I used to always bash it to look cool on /g/.

These books will teach me everything, right?
>>
>>52530326
What do you mean exactly? Any constraint enforced using this method would have to be enforced with a "defensive programming" (i.e. redundant run time checks) or simply left entirely up to the programmer (like in C) otherwise.
>>
What does it mean when codeeval gives you a perfect score and claims your solution is unique but doesn't give you any ranking points?

>>52530329
just download them
js the good parts is not worth owning physically
>>
best resource to learn c++?
>>
>>52530356
ppp2
>>
>>52530329
Just get a physical copy of the definitive guide, don't waste money on the other two.
>>
>>52530356
just go to a site like tutorialspoint

no sense in getting a book.
>>
>>52530356
Drugs.
>>
>>52530356
LSD or peyote.
>>
File: numbersiguess..png (201KB, 3755x645px) Image search: [Google]
numbersiguess..png
201KB, 3755x645px
>>52529955
static void PrintOddNumbersVerifiedByMicrosoftSQLServer2012()
{
SqlConnection thisConnection = new SqlConnection(@"Data Source=localhost;
Initial Catalog=default;
Persist Security Info=True;
User ID=user;
Password=B1GT1tti3z");
thisConnection.Open();

string Get_Data =
@"DECLARE @start INT = 1;
DECLARE @end INT = 100;

WITH numbers AS (
SELECT @start AS number
UNION ALL
SELECT number + 1
FROM numbers
WHERE number < @end
)
SELECT *
FROM numbers
WHERE number % 2 <> 0
OPTION (MAXRECURSION 0);";

SqlCommand cmd = thisConnection.CreateCommand();
cmd.CommandText = Get_Data;

SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
var ayy = dt.AsEnumerable().ToList();

foreach(var number in ayy)
{
Console.WriteLine(number.ItemArray[0]);
}
}
>>
>>52530194
Memory allocation is NSFW.
>>
>>52530345
Which is better than failing to compile at every pre-condition, that's not too broad to be useless.
>>
>>52530479
You can obviously mix and match, but that means you will have to then be able to be able to handle the possibility of "no result" and not "invalid input".
>>
File: SjpjGZw.png (21KB, 258x88px) Image search: [Google]
SjpjGZw.png
21KB, 258x88px
>>52530132
>the current banner at the top of my page
You might want to reconsider what website you visit, anon. This doesn't seem like your kind of place.
>>
>>52530416
NOOOOOOOOOOOOOOOOOOOO
>>
>>52530499
It works, anon, and it's safe as long as you have a stable connection to your database!

I trust Microsoft SQL Server 2012™ to verify if my numbers are odd. Don't you?
>>
>>52530497
You're one deluded cunt.
>>
>>52530530
*hugs you*
Awwwh, don't be so mean, anon!
>>
>>52530530
Explain?
That banner exists m8, I've seen it along with many other anime themed possibly NSFW banners.
I think your the deluded one here thinking this isn't an anime website.
>>
>>52530479
>>52530496
Also, the issue at hand was whether or not the type system could do this, not whether it's a good idea to do this for everything that could possibly fail.
>>
>>52530132
>>52530497
#REKT
>>
>>52530496
>mix match
So that it does check at runtime?
>>
>>52530565
>Also, the issue at hand was whether or not the type system could do this, not whether it's a good idea to do this for everything that could possibly fail.
And it obviously can't. It can't check statically if a pre-condition like x < 10 is fulfilled. It can only give you "It possibly could" or it can't.
That's not what I understand under checking for a pre-condition.
>>
>>52530057
What is this pedo bullshit
>>
>>52530624
>normalfags
>>
>>52530587
A certain degree of run time checks have to be done, no matter what.

This particular technique allows you to make the programmer's responsibility to pass valid inputs explicit, by reducing the scope of what is considered a valid input using the type system. They then have to prove that their inputs are valid, such as with the (x < y) predicate.

You seem to think that this is bad because now you have to do this for every possible function that could fail, which is not true. You can fall back to regular defensive checks inside the function if you value code simplicity over performance potential in that particular case.

>>52530619
I don't understand your grievance. How do you expect to be able to get a value x from the user and be able to tell that (x < 10) without doing any work?
>>
>>52530619
>I don't understaaaaand waaaa ;_;
>>
>>52530648
>pedos
>>
>>52530662
>I DONT LIKE THING
>>
>>52530677
>I DON'T LIKE LITTLE GIRL NIPPLES LIKE SOME SORT OF SICK FUCK
>>
>>52530724
>GIRL
anon...
>>
>>52530724
Those are boy nipples, faggot.
>>
javascript >>>>>>>>> any other language
>>
>>52530748
>>52530764

Marginally better, but still degenerate
>>
>>52530651
>They then have to prove that their inputs are valid, such as with the (x < y) predicate.
Which is what I don't want to do.
The point of having a pre-condition like x < 10 is to not have me think about how it can fail with x>=10.

This is only useful when I actually want the proof, which outside academia is almost never.
It's much much cheaper just to check at run-time.
>>
>>52530765
java > node > javascript >>>>>> all others
>>
>>52530765
JavaScript is just a bad version of scheme so that means
Scheme > javascript >>>>>>>>> any other language
>>
>>52530775
>>52530724
normie anon just awkwardly came out as being gay
>>
>>52530851
it's not gay if they're wearing a skirt anon
>>
>>52530851
marginally better because little boy nipples aren't lewd you pedo fuck degenerate
>>
>>52530798
>>52530651
>>
File: Untitled.png (24KB, 1495x515px) Image search: [Google]
Untitled.png
24KB, 1495x515px
Trying to get MonoGame set up.
Why do all my models show up as completely black when I do
effect.EnableDefaultLighting();
? I've tried a bunch of different models from different sites/tutorials but every single one becomes pitch black when lighting is enabled.
>>
>>52530883
>little
he's in high school
>>
>>52530807
Scheme is just an academic-wankery version of CL so that means
Common Lisp > Scheme > javascript >>>>>>> any other language
>>
>>52530885
>I'm such a genius for sucking my prof's coq
>>
>>52530901
>no it's not a little boy he's actually a 9000 year old demon

keep digging yourself deeper
>>
>>52530899
>being this dumb
>on my /dpt/
It's more likely than I thought!
>>
>>52530906
In general you can do the same things in scheme and common lisp.
Scheme has lambdanative and Carmack is pushing scheme to vr though, what does common lisp have?
>>
>>52530913
>I'm so superior for not understanding basic logic
>>
>>52530925
anon, it's just a drawing
>>
>>52530927
Thanks for your help.
>>
>>52530798
>The point of having a pre-condition like x < 10 is to not have me think about how it can fail with x>=10.
Exactly. If you have some x and a proof that (x < 10), you have satisfied the precondition and the function WILL NEVER FAIL.

>This is only useful when I actually want the proof, which outside academia is almost never.
In a non-constructive language (which you need for performance anyways), the proof would almost certainly be "irrelevant", i.e. it would be erased at compile time.

>It's much much cheaper just to check at run-time.
Cheaper in what way? Maybe in LoC, but not in performance terms. One way of getting high performance in C is that typically libraries will assume that the programmer is not going to pass invalid inputs, and simply crash if they mess up. This system allows you to safely make these assumptions.

>>52530913
I'm not him, but getting into arguments over this stuff when you are completely ignorant of type theory is pretty silly.

>>52530947
Ironic.
>>
>>52530949
>moving goalposts
>>
This is the average /dpt/ user.

https://www.youtube.com/watch?v=kR1k5PZ7l2o
>>
>>52530971
>complaining about anime in the programming thread
>>
>>52530965
Wait, I messed up. >>52530947 is on my side.
>>
What are the haskeller and the non haskeller arguing about right now? Can't tell if user input is less than 10 at compile time? Guys, you can't even tell if user input is going to be a number at compile time. You can, however, make the assumption that if an assertion succeeded, then the value is in whatever subset of values you wanted.
>>
>>52530057
MOOOOOOOOOOOODS
>>
>>52530988
>endorsing pedophilia
>>
>>52530497
she's eating a hotdog in the original pic.
>>
>>52530995
>You can, however, make the assumption that if an assertion succeeded, then the value is in whatever subset of values you wanted.
What I'm on about is a formalization of that idea.
>>
>>52530497
>le 4chan is a bunch of edgy paedophiles may may

go back to reddit tb᠎h
>>
>>52530976
Don't bully, anon. He seems like a chill guy.
>>
File: index.jpg (6KB, 268x188px) Image search: [Google]
index.jpg
6KB, 268x188px
>>52530976
>>
>>52531037
can we post desu again?
>>
>>52530935
CL has a standard that defines actually useful primitives and carmack is pushing racket - not scheme - to vr because scheme is too shit for any realworld task. Moreover, CL is significantly faster and has significantly more and higher-quality libraries available in all areas, not just anesthetic medical equipment control (lmao).
>>
>>52531059
newfag get out tb᠎h
>>
>>52530935
>Carmack is pushing scheme to vr though
That doesn't even make any sense. What does Scheme or not-Scheme have to do with a monitor with special lenses and head tracking?
>>
File: Interviewer.jpg (17KB, 350x244px) Image search: [Google]
Interviewer.jpg
17KB, 350x244px
>alright, for this next part, go up to the whiteboard and write fizzbuzz without using your language's inbuilt modulo operator or library function.

wat do?
>>
>>52531104
>f
>i
>z
>z
>b
>u
>z
>z
>>
>>52531092
Only newfags say newfag, anon.
>>
File: 1453276321853.png (8KB, 690x460px) Image search: [Google]
1453276321853.png
8KB, 690x460px
I already know the essential parts of C++ that were useful to me while writing stuff when I was self teaching.... But I'm thinking of learning stuff properly.

A tour of C++ or Principles and practices?
>>
>>52531104
int mod(int n, int m)
{
while (n > m)
n -= m;
return n;
}


can i have job now?
also can you buy me a mechanical keyboard for company use?
>>
>>52529481
Reply to your question.

>>52530504
>>
>>52531093
Well to oculus at least.
http://sdtimes.com/oculus-cto-john-carmack-is-developing-scheme-scripting-language-for-vr/
>>
>>52531150
Doesn't work for negative values
>>
>>52531104

Keep a running count of the modulo with each iteration.
>>
>>52531104
>durr build a house without nails or a hammer


sure, you could, but what's the point?
>>
>>52531171
I don't really get it.
>>
>>52531189
It's just for fizzbuzz which doesn't have negative values you fucking retard
>>
>>52531222
>not writing a general fizzbuzz
>>
>>52530965
>you have satisfied the precondition and the function WILL NEVER FAIL.
Which is what defensive programming let's me do easily.

>Cheaper in what way?
Manpower

>This system allows you to safely make these assumptions.
So does the classic defensive style.
Should it introduce some bottleneck, I can always optimize it after actual measurable results.
If the compiler can figure out invalid input statically it can just as well optimize the run-time check out.
Instead of forcing the programmer to do the optimal thing.
>>
>>52531104
for i in range(1, 101):
if i == 3:
print "Fizz"
elif i == 5:
print "Buzz"
.....
else:
print i
>>
>>52531250
I can't believe people this retarded actually exist in this world, let alone are able to post on 4chan without assistance. Hell, how do you even remember to breathe?
>>
>>52531250
>b-but premature optimization :(
Whatever, man. Keep your head down and get back to your Java work, your manager is getting impatient.
>>
>>52531150
Works, but O(n) time.

how's this attempt?

#include <math.h>

double modulo(double a, double b) {
return a - b * floor(a/b);
}
>>
>>52531200
Carmack wants you to be able to script simple "apps" for vr devices with scheme.
Of course there will be other scripting languages working for it like python and js but Carmack promoting use of scheme should net it more user. Also to the original discussion common lisp vs scheme, this adds new niche for scheme where common lisp has no foot in.
>>
>>52531274
>u dumb
>>52531285
>pajeet

Wow, I wish I could reach your heights of intelligence so I could come up with such a high level of reasoning too.
>>
currently rewriting faceberg in ocaml
>>
>>52531288
It's racket, not scheme.
>>
>>52531287
Why not just use integer arithmetic?
>>
currently rewriting firefox in ocaml
>>
>>52531250
Not like you've ever even thought about language implementation, but I can assure you that in order for a compiler to be able to "share" runtime checks automatically, to the same extent as proof-passing does, it would require an extreme amount of analysis (every time you compile, too, whereas programming it only requires effort once), and even then, it would only work for predicates that the compiler knows about.
>>
>>52531344
At some point it was tinyscheme, shit man I follow every fucking that faggot makes.
>>
Is Breadth-first search almost always better than Depth-first? Are there any cases when Depth-first is better?
>>
>>52531378
There's a reason he left scheme.
>>
>>52530057
Sauce?
>>
>>52531250
>>52531365
The overarching point here is that you are advocating for a super-smart compiler that lets the programmer be dumb/lazy while producing the same results as a smart programmer. This is trending towards the problem of human-like intelligence. And why stop at optimization? The compiler should really just take a design document as input and output an optimal program, right?

The compiler should be dumb and fast, but it this doesn't stop it from also being very thorough in its expectations of the programmer. The programmer should be clever, but can be slower, since code only has to be written once, and compiled many times.
>>
No real need to roll your own modulo function here.

#include <stdio.h>

int main(void)
{
int mod3 = 1;
int mod5 = 1;
for (int i = 1; i <= 100; ++i) {
if (!mod3) printf("Fizz");
if (!mod5) printf("Buzz");
if (mod3 && mod5) printf("%d", i);

putchar('\n');
mod3 = ((mod3 == 2) ? 0 : (mod3 + 1));
mod5 = ((mod5 == 4) ? 0 : (mod5 + 1));
}
return 0;
}
>>
File: 164.jpg (18KB, 300x100px) Image search: [Google]
164.jpg
18KB, 300x100px
>>52530497
>>the current banner at the top of my page
literally pic related lmao
>>
>>52531501
top kek
>>
>>52530497
>258x88
the new banners seem to be 300x100 no way that's actually your current banner unless you hacked it
>>
>>52531591
Ugh the hacker 4chan strikes again.
Off yourself weebshit.
>>
>>52531499
Boku no Pico
>>
>>52531612
you fucking idiot i used that term ironically

i obviously meant in case he replaced his banners on the client side
>>
>>52531591
>What is scaling
You do realize he just took a screenshot of it right? the actual image is a gif.
>>
>>52531634
>I was merely pretending
Okay weeboh.
>>
>>52531612
and since you're a total sperg i'll make it clear:

i'm accusing the weebshit >>52530497 of lying
>>
>>52531365
>it would only work for predicates that the compiler knows about.
What do you mean?
How can you decide something about a predicate you don't know anything about?

>to the same extent as proof-passing does
It doesn't need to be the same extent.
It has to be fast enough(TM).
Again I can always optimize parts it doesn't do well manually. And I wager that on the whole it will save everyone more time.

>>52531501
I'm really not.
I'm advocating a compiler that let's me be dumb when I want to be and then just puts out dumber results.
>>
>>52531638
lmfao why wouldn't you just save the gif or take the screenshot without scaling it what the fuck tard

and what's with the imgur file name then huh weeb?
>>
>>52531650
Damn hackers.
>>
>>52531667
I don't fucking know I'm not the tard who took the image fuckface.
If I where him I would've saved the actual gif instead of taking a screenshot like a fucking retard.

His point still stands though, this is an anime website, no amount of delusion will change that.
>>
>>52531657
>How can you decide something about a predicate you don't know anything about?
The compiler could know about (x < y), for example, but not (x > y). The programmer can deal with both, and even make up new predicates.

>Again I can always optimize parts it doesn't do well manually.
And what I am talking about is a way to do that that retains the safety of defensive methods.

>I'm advocating a compiler that let's me be dumb when I want to be and then just puts out dumber results.
Which this does not go against. Have you been ignoring all the times I said you can fall back to defensive programming to simplify the code?
>>
for i in range (1, 101):
if i % 3 == 0:
s = 'fizz'
else:
s = ''
if i % 5 == 0:
s += 'buzz'
if len (s) == 0:
s = str (i)
print (s)
>>
>>52531701
doesn't mean you need to post fucking traps

you get them deleted and perhaps even banned if you post 3d traps

2d traps are even worse than 3d traps because they aren't even real have fun fapping to cartoons lmfao
>>
Kek.

I just found Google's recursion Easter egg.
>>
>>52530899
So you set a light mode but did you place a light
>>
>>52530899
Csharts everyone
>>
>>52531657
>>52531706
Also this conversation has shifted completely out of the scope of the original issue.

You seem to be okay with the fact that the type system can do this, and that's all that matters. Whether or not it's a worthy tradeoff is subjective.
>>
You guys hear of the new Brötli algorithm?
>>
>>52531770
This website is for people 18+.
>>
>>52531748
Recursion is a meme.

Everything you can do with recursion can be accomplished with a simple for loop.
>>
>>52531790
doesn't seem to apply to >>52530899
>>
>>52531771
You seem to have confused this guy's disbelief that it's possible with him not caring unless it is practical.

Saying that a car can do 250mph is pretty pointless if that requires 5 miles of perfectly smooth straight road.
What people really want to know is how quickly can it go from 0-60, and what's the mpg.
>>
File: 29.gif (9KB, 300x100px) Image search: [Google]
29.gif
9KB, 300x100px
Here's the banner in question btw.
>>
>>52531820
Walk a tree with a simple for loop.
>>
File: 1430853197680.png (331KB, 474x432px) Image search: [Google]
1430853197680.png
331KB, 474x432px
fib(8) using iteration: 1 1 2 3 5 8 13 21

fib(8) using recursion:
fib(8) = fib(7) + fib(6)
fib(7) = fib(6) + fib(5)
fib(6) = fib(5) + fib(4)
fib(5) = fib(4) + fib(3)
fib(4) = fib(3) + fib(2)
fib(3) = fib(2) + fib(1)
fib(2) = 1
fib(1) = 1
fib(3) = 2
fib(4) = 3
fib(5) = 5
fib(6) = 8
fib(7) = 13
fib(8) = 21

which is more elegant and useful?
>>
>>52531820
This isn't true, there are some special cases where recursion fits, but your partially write, 99% of the stuff people use recursion for can be done more efficiently with loops.
>>
>>52531787
the one that will compress the web more than 25% yeah that one.
>>
when was /g/ flooded by dumb children? everyone crying about anime on an anime board, isn't it naptime?
>>
>>52531771
>You seem to be okay with the fact that the type system can do this, and that's all that matters.
But it can't.
It can't enforce an arbitrary pre-condition at compile-time. At best it can tell you a "maybe", or not.
That's like saying the Halting problem is decidable with a machine that just puts out "Maybe" for anything but trivial cases.
>>
>>52531850
it's actually really simple with an explicit stack if you have the correct mental model for it. you basically just store the path you've taken down the tree in a linear stack.
>>
>>52531857
>write
kek
>>
>>52531826
He's learning and doing something, you're being a shitposting underage faggot. Guess which one is better.

>>52531871
Wow, the irony in this statement is absolutely laughable.
>>
>>52531881
>It can't enforce an arbitrary pre-condition at compile-time.
It doesn't enforce the precondition. It enforces the enforcement of the precondition.
>>
>>52531885
I'm not saying that it's not possible, but recursion is way fucking cleaner.
Some problems just beg to be done recursively.
>>
>>52531871
dude. look at that webm over there. it's fucking autistic and childish as shit with all the gesticulating, bright colors and dead simple dialog. look at who you're calling children. fucking manchild autist.
>>
Ugh, I hate retrofitting code to use a new version of a dependency. I do that for a C XML comparative tool and memcpy fails 70% into analyzing the file and it says I'm going over the file size for some reason in Valgrind, even though the file size is listed correctly.

Time to do a deep dive in memory...
>>
>>52531861
>mfw the weissman score is real now
>>
>>52531820

Correction: everything that can be done with tail recursion can be done with a simple for loop. Backtracking and other forms of recursion are much harder to do using simple loops, and consequently, compilers can't optimize them.

>>52531857

>more efficiently
In the eyes of an optimizing compiler, there's no difference between tail recursion and for loops. Both become conditional jumps.
>>
>>52531898
you can use words like "irony" all you want to appear smart but we still see the truth kid, keep crying
>>
File: 1453327174.png (627KB, 1756x961px) Image search: [Google]
1453327174.png
627KB, 1756x961px
>>52531834
Sure is a lot of anime for a non-anime website.
This isn't even half of them.
>>
File: 1429139562092.jpg (99KB, 873x1079px) Image search: [Google]
1429139562092.jpg
99KB, 873x1079px
>>52531852
>not making an iterative process
Do you even read your SICP?
>>
File: 1436716300-574407.jpg (106KB, 1280x720px) Image search: [Google]
1436716300-574407.jpg
106KB, 1280x720px
>>52531938
you watch things like pic related and you're calling us kids
>>
>>52531937
Not all recursive functions can achieve TCO.
>>
>>52531820
You can't do this with a simple for loop.

function power(base, exponent) {
if (exponent == 0)
return 1;
else
return base * power(base, exponent - 1);
}


Check mate.
>>
>>52531871
>on an anime board
If every board is an anime board, why does /a/ even exist?
>>
>>52531982
false
>>
>>52531982
And in those cases, the iterative method would require an explicit stack, or accumulator, or whatever.
>>
>>52531982
but all recursive functions that can easily be written as loops can.
>>
>>52531982

Which is why I explicitly stated tail recursive functions.
>>
>>52531972
Umaru a cancerous shit.
- weeb
>>
>>52530057
Is there anyone that actually gets laid on a regular basis that still has an interest in images like these?

Improve yourself and pursue the vagina. It'll make you a better person.
>>
>>52532001
Yes and the opposite is true too.
>>
>>52531972
it's better to do childish things than be childish, like crying about how there's content you don't like on your escape from real life internet board, hopefully one day you'll grow up and learn to deal with the world.
>>52531916
>complains about autistic childish people
>on 4chan
you aren't the sharpest tool in the box are ya :D
>>
>>52531993
>Not a tail call
It's fucking shit.
>>
>>52531706
>I said you can fall back to defensive programming to simplify the code?
And my claim is that you end up doing this so much that you end up being better off with a language actually made for defensive programming.

>>52531706
>It enforces the enforcement of the precondition.
You could describe inserting run-time check for that in such a way.
>>
>>52532022
you're the one crying about how /g/ is flooded by dumb children
>>
>>52531820
Iteration is a meme.

Everything you can do with iteration can be accomplished with a simple recursive call.
>>
>>52532017
i'm not even a weeb but spending time on the vag is a waste of time unless you're a kid with raging hormones who literally only thinks with his dick. get money, THEN fuck bitches
>>
>>52531993
Why does 0 ^ 0 = 1?

It doesn't make any sense.
>>
Friendly reminder that recursion and iteration are indistinguishable at low levels (e.g. where flow control is done with goto).

If either is faster than the other it is a failure of the (high level) programmer and/or compiler.

>>52532084
>And my claim is that you end up doing this so much that you end up being better off with a language actually made for defensive programming.
That's entirely subjective. I would prefer to do this over defensive programming for any critical software.

>You could describe inserting run-time check for that in such a way.
Again, only for predicates that the compiler recognizes.
>>
>>52531790
Don't bother, it's the same 12 years old every single thread.
>>
>>52532017
>Life is all about muh dick.
Fuck off Jamal.
>>
#include <stdio.h>

int main(void)
{
int rem;
for(int i = 1; i < 101; ++i)
{
asm("movl $0, %%edx; movl %1, %%eax; movl $15, %%ebx; divl %%ebx;" : "=d" (rem) : "g" (i));
if(!rem)
{
printf("FizzBuzz\n");
continue;
}
asm("movl $0, %%edx; movl %1, %%eax; movl $5, %%ebx; divl %%ebx;" : "=d" (rem) : "g" (i));
if(!rem)
{
printf("Buzz\n");
continue;
}
asm("movl $0, %%edx; movl %1, %%eax; movl $3, %%ebx; divl %%ebx;" : "=d" (rem) : "a" (i));
if(!rem)
{
printf("Fizz\n");
continue;
}
printf("%d\n", i);
}

return 0;
}


I-i did it sir, no modulos as requested

Also inline assembly is painful as fuck to work with
>>
>>52532118
Mathematical convention.
>>
>>52532118
the function is allowed to define its own value for that input you fucking sperg
>>
>>52532118
>>52532151
so it isn't even undefined it actually is 1 apparently nice bait lad
>>
>>52532147
A stupid convention.

0 ^ 0 obviously does not equal 1.

It should return a compile error like dividing by 0 does.
>>
>>52532164
http://www.wolframalpha.com/input/?i=0%5E0
undefined

>>52532178
no it shouldn't it's perfectly correct for all valid input and even for 0^0 the function is allowed to define a result you insufferable sperg
>>
>>52532178
>being this shit at maths
>>
>>52532178
Prove it
>>
>>52532123
>Again, only for predicates that the compiler recognizes.
What do you mean? In this case nothing stops you from having arbitrary code in your pre-and post conditions.
>>
lim x ^ 0 when x -> 0 is 1
lim 0 ^ x when x -> 0 is 0

so 0^0 is undefined
>>
>>52532123
except iteration is much more readable, and a loop can be self-contained as part of a single function, and recursion can lead to algorithmic mistakes such as the naive recursive fibonacci number function
>>
>>52532208
0 * 0 = 0

There, I proved it. You can times 0 by 0 an infinite number of times and you'll still get 0.
>>
>>52532229
0-^0- = 0+^0+ = 1.
>>
>>52532229
in a computer program you might be perfectly happy with not crashing and rather getting a result of 1 if the input happens to be 0^0 at some point
>>
>>52532246
0 * 0 is 0 ^ 2, not 0 ^ 0
>>
>>52532261
Seriously I'm happy when such a thing create a core dump. I do not like when errors are hidden. It's unsafe.
>>
>>52532246
3^0=1
2^0=1
1^0=1
0^0=?
-1^0=1
-2^0=1
-3^0=1
>>
>>52532219
What do you mean by "arbitrary code in pre- and post conditions"?

>>52532242
Sometimes iteration is more readable, sometimes recursion is. Whether or not the most naive implementation of an algorithm is faster with one or the other is irrelevant.
>>
>>52532279
check for 0^0 and throw an exception then. but a function can be perfectly valid if it says right there in its documentation that it returns 1 for 0^0
>>
>>52532293
>Sometimes iteration is more readable
No. It really depends of the developer. I never find iteration more readable.
>>
So, what do they expect you to know at a C++ job interview? Do they just make you do linked lists and then they're satisfied?
>>
>>52532293
Some expression that evaluates to a boolean I define as the pre-/post-condition of my function.
>>
>>52532273
So basically 0 ^ 0 is the same as 0 * null?

Do you honestly think it makes sense for 0 * null to equal 1, anon?
>>
>>52532375
0 * null is 0 ^ 1
>>
>>52532375
0^0 can equal 1, very similar to how 0! = 1.

Just because it's not intuitive doesn't mean it's not correct.
>>
>>52532375
you fucking idiot

it makes perfect sense

think of it like undefined behavior in C/C++, the compiler is allowed to do whatever the fuck it wants

and you can program any power function the way you want, it can crash on 0^0, it can return 1, it can return 0, it can return -1

fuck off sperg
>>
>>52532375
>>52532420
I take that back actually, 0 * 1 would be 0 ^ 1
Either way, every other number raised to 0 is 1, why is 0 any different?
>>
0 shouldn't be classed as a number to be honest, typeof 0 should return NaN.
>>
Threadly reminder that you should not refer to the act of programming as coding. It is improper and makes you look like a 16 year old

You are a programmer, not a coder

Software Alchemist is GOAT
Developer is okay
Magician is okay
Software Magus is okay
Software Engineer is okay
Software Architect is okay
Code Guru is okay


Archmage is reserved for only the most senior of programmers

Writing in HTML and CSS is not programming, therefore it should be referred to as designing
>>
>>52532506
>Software Alchemist is GOAT
FUCKING FAGGOTS TAKING MY TITLE REEEEEEEEEEEEEEEEE
>>
>>52532471
This, 0 is just the absence of numbers.
>>
>>52532506
That's code monkey shit.

I design software, Indians do the programming.
>>
>>52532459
>every other number divided by 0 is infinity, why is 0 any different?
>>
>>52532506
STFU
>>
>>52532359
That's not how pre/post conditions work. They're indexed types (predicates, by Curry-Howard). When they're inhabited, they're true. When they're not, they're false. I.e., if you have a value (proof) of a condition (predicate), it's true.
>>
>>52532431
0! = 1 because Г(1)=1
>>
>>52532459
0 raised to the power of any other number is 0
>>
>>52532359
>>52532574
And computers are very good at type checking.
>>
>>52532584
No. Because there is exactly one permutation of empty set.
And yes Gamma confirmed it.
>>
>>52532574
>What is Design By Contract
>>
>>52532588
0^n, n > 0
>>
>>52532603
An enterprisey name for an expressive type system.
>>
>>52532531
enjoy your shit quality software lmfao
>>
>>52532605
0 * -1 = 0
>>
>>52532569
Fair, but anon has yet to actually prove why 0 ^ 0 isn't actually 1
>>
>>52532617
...which uses arbitrary boolean expressions for conditions.
>>
>>52532506
threadly reminder that you're a sperg coder trying to make himself feel good by entitling himself with arbitrary words
>>
>>52532671
https://en.wikipedia.org/wiki/Exponentiation

this is elementary school math bruh
>>
>repeat zero zero times and you get one
Literally worse than common core.
>>
>>52532642
enjoy having to use it
>>
>>52532675
A boolean value being true or false is literally the same as a type being inhabited or uninhabited.

https://ncatlab.org/nlab/show/propositions+as+types

proposition = type
proof = value
1 = unit (one value)
0 = bottom (no values)
and = pair
or = union
function = implication
predicate = type family
etc.
>>
>>52532724
Then say it in English.

Also what does that have to do with the "compiler not knowing about predicates"?
>>
Real world haskell or learn you a haskell?
>>
>>52532751
K&R
>>
>>52532751
real world haskell if you insist on learning this useless meme lang

learn you a haskell is the most autistic book name i've ever seen
>>
File: 1323373781515.jpg (14KB, 300x300px) Image search: [Google]
1323373781515.jpg
14KB, 300x300px
>>52532717
Why the fuck is this so fucking funny?
>>
>>52532142
Well, if you're going to use the side effect of another operation, you may as well just use
#include <stdio.h>
#include <stdlib.h>

int main()
{
for (int i = 1; i <= 100; ++i)
if (div(i, 15).rem == 0)
puts("FizzBuzz");
else if (div(i, 5).rem == 0)
puts("Buzz");
else if (div(i, 3).rem == 0)
puts("Fizz");
else
printf("%d\n", i);
}
>>
>For a=0, a/0 falls into a different category; 0/0 is referred to as indeterminate, which means that, depending on the circumstances, the expression 0/0 may be defined, or may be left undefined as a matter of experience.

0^0 is indeterminate, not undefined. 0^0 is not necessarily a complete fuck up like dividing by 0, it can be defined to be 1 or whatever.
>>
>>52532804
because the guy basically shat on the "enjoy writing bad software hurr" guy
>>
>>52532747
The difference is that DbC works by asserting those conditions at run time, since they are just code that evaluates to true or false. You have to disable the checking for release builds (or suffer poor performance), which means that unless your tests have covered all cases, the code could still have a bug.

The proof method doesn't sacrifice an ounce of performance, and works at compile time to PROVE that the program is correct. DbC only SHOWS that the program is correct, for whatever inputs you test.
>>
>>52532776
>learn you a haskell is the most autistic book name i've ever seen

Your advise is based entirely on the title of the book?
>>
>>52532017
I get laid frequently but prefer anime porn. As those who are more familiar with this site than you would say: "3DPD"
>>
>>52532830
No. 0^0 is defined and is equal to 1. a/0 is what's indeterminate when a -> 0.
>>
>>52532846
So what? It's still "enforcement of enforcement of pre-conditons at compile-time" or whatever that guy said.
Keep up.
>>
>>52532922
>runtime is compile-time
OK kid
>>
Does noone here program fun shit like games or graphics? I always see some fizzbuzz functions in various langues but never any cool stuff
>>
>>52532922
DbC was brought up well after I said that.
And >>52532938 is right, you just ignored my last statement.

I'd rather stop arguing about this, since it's just boiling down to "well, this other way is good enough if you don't care about performance or fast build times..."
>>
>>52532776
Learn You is a great beginners book, Real World is a little more advanced but very practical. I'd reccomend starting with Lean You.
>>
Are strings normally immutable in programming languages, senpai?
>>
>>52532938
Run-time check is the enforcement part
Inserting them into the compiled code is the enforcement of enforcement part

I didn't think it would be that hard to get.

>>52532959
>DbC was brought up well after I said that.
To counter the claim that you can't call asserts pre-/post-conditions.
I'm not sure what you're trying to argue at that point.
>>
Help brehs, I'm trying to do an English-Morse translator in Java, I made 2 arrays, one all the English letters and the other the Morse equivalents.

Now, It's supposed to display the first word in one line, then when it detects a " ", the next word will be printed on the next line. That part would be easy, except I can't display a word in one line, because it prints one letter per line instead of one word per line.
Now I could print the entire array but it looks ugly with the [ ] and plus it'd be wrong, since it's supposed to be one word per line. Is there a way to print array objects inline until a space is detected?
>>
>>52532920
>No. 0^0 is defined and is equal to 1.
Or zero. You can sensibly define it either way because in the log domain you're multiplying negative infinity by zero (note that *other* results are crazytalk ruleslawyering) so it is indeterminate.

C-like languages define 0^0 to be -1 (on signed types).
>>
Why is there so much dick waggling over preferred languages in here?

Do we need a seperate /dpt/ for each language so we can get to the good stuff?

> like dick waggling over Zen vs Symphony in /dpt-php/
>>
>>52533011
>To counter the claim that you can't call asserts pre-/post-conditions.

YOU: In this case nothing stops you from having arbitrary code in your pre-and post conditions.
ME: What do you mean by "arbitrary code in pre- and post conditions"?
YOU: Some expression that evaluates to a boolean I define as the pre-/post-condition of my function.

The "compiler can insert checks" started off when you complained that it was a lot of work to manually pass around proofs, and I assumed that you were talking about the compiler doing the same thing. You even said "in this case". So until you brought up DbC we were never not talking about proofs.
>>
>>52533060
No, it's 1.
>>
howdy
>>
>>52533072
Some people are too immature to accept OCaml as their lord and savior, so they try their hardest to justify their choice of unsafe, slow, unportable, ill-behaved languages. That's just how it is.
>>
>>52533060
0^0 is 1

get out and learn how to do limits before coming back with your terrible math.
>>
>>52533141
Looks like we have a new tripfag.
>>
File: 1409124670496.jpg (6KB, 152x225px) Image search: [Google]
1409124670496.jpg
6KB, 152x225px
Holy shit, HashTable lookup times are so fucking fast
why don't programming books emphasize their usefulness enough? There's always the issue of hash collisions, but in most cases they're super easy to work around.
>>
>>52533180
How new are you?
He's the resident racemixing cuck here.
>>
>>52533180
>new

What the fug
>>
>>52533094
>started off when you complained that it was a lot of work to manually pass around proofs
All I'm doing right now is defending my statement in "You could describe inserting run-time check for that in such a way in response to the "enforcement of enforcment" stuff
It has nothing to do with such complaints.
>>
>>52530057
Sauce please
>>
I made a dragon curve generator in Java.

The screenshot shows a 12th iteration curve.
>>
>>52533201
hint hint, no one gives a fuck about tripniggers.
>>
File: The-Break-Up_english.jpg (143KB, 650x743px) Image search: [Google]
The-Break-Up_english.jpg
143KB, 650x743px
Re-asking for new thread:
What are some schema for verifying the legitimacy of a client who's connected?

Also, does anyone have any good reading for (specifically java) implementations of public/private key encryption?
>>
>>52533212
You're absolutely right, but then you're back to the matter of it simply being worse for performance.

This is going nowhere.
>>
>>52533230

Damage control because you're new.
>>
>>52533201
My bad, it's just the first time I've seen you posting here.
>>
File: mpv-shot0014.jpg (259KB, 1920x1080px) Image search: [Google]
mpv-shot0014.jpg
259KB, 1920x1080px
Working on a lisp-os!
>>
>>52533230
you cared enough to respond, you must really want his attention
>>
>>52533231
The only way to prevent a client from tampering with things is to simply not trust the client at all.

Legitimacy checks can always be spoofed.
>>
File: dfg.jpg (104KB, 1280x720px) Image search: [Google]
dfg.jpg
104KB, 1280x720px
>>52533230
Why must you ruin my shitposts with your insufferable shitposting, anon?
>>
>>52533253
So there's literally no way to prevent clients spoofing?
darn. Should I just have checkers for bizarre behavior on my backend, then? Is that the best I can do?
>>
don't forget to filter /^!/
>>
>>52533280
>So there's literally no way to prevent clients spoofing?
none whatsoever.

There are ways to deter it slightly, but they're ultimately not worth the effort. Assume your clients are all out to get you always.
>>
>>52533280
The only thing you can do is have the server be responsible for carrying out all important operations.
>>
>>52533244

Care to show source?
>>
>>52533225
Cool, somehow. I like it.
>>
>>52533232
No, that stuff only mattered in the derailment: "theorem provers da best - no u"
Performance has really nothing to do with the claim of enforcing arbitrary conditions at compile time.
>>
>>52531345
To calculate float remainders

but yeah with fizzbuzz i could've just done int arithmetic
>>
>>52533304
Oh, I am assuming that. The thing is fairly locked down, thankfully. I was just wondering if there was any way to absolutely prove that a client is legitimate even if you're being listened to. Guess not, oh well.
>>
>>52533352
You not caring about performance doesn't make me wrong.
>>
File: mpv-shot0015.jpg (223KB, 1920x1080px) Image search: [Google]
mpv-shot0015.jpg
223KB, 1920x1080px
>>52533328
I will when I finish my lisp interpreter, probably by Sunday.
>>
>>52533377
It doesn't make you right, either.
Especially something that has nothing to do with performance whatsoever.
>>
>>52533376
There is not.
>>
>>52533426
>this has nothing to do with performance
You are dense as fuck.
>>
>>52533426
I'm sorry that you're retarded.
>>
>>52533225

Pretty neat. How'd ya do it?
>>
>>52533450
I followed the steps in the link below to produce an array of booleans to indicate the turns of the curve. Then it draws it out like the gif (but all at once in a few milliseconds).

http://mathworld.wolfram.com/DragonCurve.html
>>
>>52533225
Rad, whatd you use for the drawing and gui bits?
>>
>>52533493

Neat. Thanks for the link.
>>
>>52533494
Swing. I'm a java pleb.
>>
>>52533494
>whatd you use for the drawing and gui bits?

If I had to guess, he probably used Graphics2D and Swing.
>>
>>52533436
>>52533439
How does performance matter when you're talking about how the claim "you can check arbitrary conditions at compile-time" is wrong or at best highly misleading?
>>
>>52533537
I never claimed that you can check arbitrary conditions at compile time. I claimed that you can have a type system such that a program that compiles will never crash.
>>
>>52533506
I am also one myself, my only experience is with javafx and lwjgl though
>>
>>52533551
Then, it wasn't your claim. Someone brought up the original point of the original thread.

>you can have a type system such that a program that compiles will never crash.
Don't remember ever saying something against that.
>>
>/dpt/ doesn't write total functions
>>
post the image with programming ideas
>>
>>52533616
https://better-dpt-roll.github.io
>>
>>52533605
I make that claim a lot in /dpt/. Maybe I didn't make it the first time.

My first additions to the topic were:
>>52529768
>>52529950

I said "statically verify preconditions". Which I guess I should have expanded to "statically verify that preconditions will be satisfied".
>>
post your github pages losers
>>
>tfw getting better at programming but still scared as hell that I'm committing untold programming sins because when I look back at my old programs I can't help but ask "what the fuck"
Anyone else know this feel?
>>
>>52533650
Get involved in open source projects
>>
>>52533644
*this time.

I can't write right now.
>>
>>52533650
Every day of my life.
>>
>>52533650
All the time. Even though I'm doing it for years.
>>
>>52533415

Well, if you're already working on the interpreter, then presumably you have the other, low-level features of your Lisp-OS worked out. How are you handling memory management? Paging? Segmentation? A flat model a la Terry A Davis?
>>
>>52533644
>To all you retards who don't understand how you can statically verify preconditions even for runtime values
And that's what I had the problem with.
This isn't true if you think of preconditions as an assert, i.e. you have arbitrary code and no kind of "maybe" value.
>>
>>52533650
Every single day. Yesterday's code is shit, always.
>>
File: 1362163615228.gif (327KB, 640x472px) Image search: [Google]
1362163615228.gif
327KB, 640x472px
>use VS2013 for whatever reason
>shutup I like VS
>working on project all day trying to get it to actually debug
>it completely freezes VS whenever I do
>"Ohshit I fucked up", spend hours undoing and redoing bugfixes
>nothing changes
>decide to open a new empty project that just enters main and returns
>VS freezes
>mfw

Either I fucked up something hard in settings or I got Microsoft'd.
>>
>>52533650
same goes for learning anything.
>>
How do you distribute python programs to Winfags, /dpt/?
Winfags just want to double click an .exe and have shit just werk, they don't want to (or don't know how to) install python, add it to their path, and install dependencies with pip.
>inb4 rewrite it in C
>>
File: 1419224427969.png (47KB, 600x438px) Image search: [Google]
1419224427969.png
47KB, 600x438px
>>52533650
Here's a question for those that do professional work:
Do they actually care that your code is committing "code sins" so long as the rest of the team can work with it and it runs efficiently enough?
>>
>>52533715
Right now I have a flat memory model as it is the simplest and most straightforward solution. While it seems a bit backwards, I do not think that it would be a problem at all since lisp does not have pointers or anything like that. Swap space and other stuff could be handled by the interpreter without the need of paging.
>>
>>52533772
Package it with an installer that checks for python and does all that shit for them
I'd be surprised if such a program didn't already exist
>>
>>52533721
A segment like
def f(x) = y where x > 0, y < 0 ->
-x
end

def g(x) ->
if(x > 0) then f(x) else x end
end

allows static verification of runtime values because the if guards calls to f no matter what value is input.
>>
>>52533822

If you work on a team, there will already be some style guide and design outlines set up. As long as you don't throw any curveballs in there, you should be fine.
>>
>>52533721
>if
Yeah, if.

And you're totally misinterpreting the use of Maybe. The Maybe stands in for the Boolean result of the runtime check, where Nothing is false and (Just proof) is true. Since the only way you can get the proof is if the precondition is true, you cannot call the function without the precondition being satisfied.

Consider this:
-- xs is a 10-element array of numbers
y = case (lt? x 10) of
Just p => index x xs p
Nothing => 0

In the end, it compiles down to something like
y = if (x < 10) then (index x xs) else 0
via proof irrelevance and/or dead code elimination (the latter in this case).
>>
File: terrysays2.png (24KB, 988x631px) Image search: [Google]
terrysays2.png
24KB, 988x631px
>>52533715
>Terry A Davis

My hero.
>>
>>52533875
================================================================================
Huck says, "It's NIST certified random numbers."

Nigger Jim says, "It ain't random numbers if it speaks, Huck."

Huck says, "NIST is the whitest of the white scientists, Nigger Jim!"

Nigger Jim says, "It's hackers -- man in the middle neural nets calling Watson
with a hacked firmware router and interception by quickly breaking encryption
with super computers and a satellite link from caves under your house with a
Markov engine mined for bitcoin."

Huck says, "NIST is a government site, you fucken nigger! Check the numbers
yourself!"

Nigger Jim says, "You're real good with computers, Huck."

Huck says, "I'm turning you in, Nigger Jim!"
================================================================================

================================================================================
Nigger Jim says, "You put a markov on your SETI."

Huck says, "You fucken retard-nigger! That's fucken stupid."

Nigger Jim says, "If your finger presses the button, Huck, it's your brain doing
it."

Huck says, "Your MIT neural scientist says my car can do a million RPM."
================================================================================

================================================================================
Huck says, "What's 2 plus 5, nigger Jim?"

Nigger Jim says, "I don't know."

Huck says, "It's seven."

Huck says, "Your wife has seven children."

Nigger Jim says, "You can get pregnant by kissing."

Huck says, "ROFLMAO"
================================================================================

================================================================================
Huck says, "It's God, Nigger Jim."

Nigger Jim says, "It's 3 a.m. in Rome. He's asleep, right now."
================================================================================
>>
>>52533639
>>52533639
>>52533639
new thread
>>
>>52533859
>Yeah, if.
Is that so abnormal? I'd think it's what most people understand under pre-condition.

And with "maybe" values, I meant something like "it could be true" to distinguish values that the compilers knows are invalid and ones where it doesn't. IIRC someone mentioned something like this.
>>
>>52533752
>VS2013
2015 is out now m8
>>
>>52533133
>>52533155
>>52532920
0^0 is indeterminate
>>
>>52532506
Not all programmers are developers, engineers, or architects.

>thinking any of these are interchangeable
>>
>>52532531
So what you're saying is, you can't code.
>>
>>52533772
py2exe. Bundles the Python runtime with it's libraries.
Thread posts: 328
Thread images: 25


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