[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: 346
Thread images: 28

File: timetocode.webm (2MB, 1152x648px) Image search: [Google]
timetocode.webm
2MB, 1152x648px
This is /dpt/, the best subreddit of /g/

Umaru-chan edition, the best of all editions.

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

code of conduct:
no racism
no insult
no sexual harassment
no gender discrimination

wat r u working on, anon-chan ?
>>
First for Free Pascal
>>
That code of conduct sounds pretty fucking gay.
Some mighty faggotry is going on in the OP.
>>
Thank you for including a code of conduct.
>>
File: Dlicious.jpg (840KB, 1580x3422px) Image search: [Google]
Dlicious.jpg
840KB, 1580x3422px
obligatory pic related post
>getting your CoC slapped by the D head
>>
File: You.png (349KB, 710x615px) Image search: [Google]
You.png
349KB, 710x615px
>>52247542
>Guess which one is you
>I wonder which one has a job and does not watch anime

>I did this for my wifes son
>>
File: 1451787124294.png (481KB, 626x988px) Image search: [Google]
1451787124294.png
481KB, 626x988px
>tfw you make something that actually works
what is this feeling?
$ ./base 21871281 16
21871281 -> HEX: 14DBAB1
>>
>>52247580
Does it do negatives, two's complement and floating point?
>>
D > C > C++ > C#
>>
>>52247542
>r/programming
>r/compsci
>r/ReverseEngineering
>r/softwaredevelopment
>code of conduct:
>no racism
>no insult
>no sexual harassment
>no gender discrimination
Fuck off faggot
>>
>>52247593
do those fit in an unsigned long long?
>>
>>52247595
F# > D
>>
File: dear god why.png (342KB, 604x566px) Image search: [Google]
dear god why.png
342KB, 604x566px
>>52247611
>this fucking question
>>
>>52247595
Go >>>>> C > normie languages
>>
>>52247595
Those languages aren't even comparable.

Different tools for different jobs.
>>
File: 1451553795827.jpg (21KB, 500x500px) Image search: [Google]
1451553795827.jpg
21KB, 500x500px
>>52247635
>>
>>52247635
>muh different tools for different jobs
fuck off
D is perfect for all jobs
>>
Where are my nim buddies at?
>>
>>52247649

> it doesn't have pattern matching
> it can't extract recursive calls
> it doesn't have function operators
> it can't manually allocate a class
>>
Is "transistor whisperer" an acceptable occupation name?
>>
>>52247673
LITERALLY PERFECT
DEEEEEEEEEEEEEE
>>
auto x = new someClass(); // calls constructor
delete x; // calls destructor

this triggers the D fags
>>
>>52247707
B-but D has a GC, right?
>>
>>52247707
>CURRENT_YEAR
>new

I'm triggered too.
>>
>>52247649
does D do tail call recursion elimination?
>>
So I wrote a simple Python script that uses PyCrypto to encrypt multiple files using AES. For the time being I'm using a specific constant key and IV. Now the same script has also decryption mode which reuses the same key and IV to get the data back to plaintext. It works perfectly fine. Now I also need to write a C++ function which will take care of decrypting the encrypted data, I've used OpenSSL using EVP API and the same key and IV in the C++ function, however, my output file seems to always contain random bytes, what gives?
>>
> it doesn't have currying
> it can't do type provision
> it doesn't have custom operators
> it can't be extended by the user
>>
>>52247106
>>52247219
meme sin test:
import math
import time

msg = 'OSGTP !!Ju67JuF6jBe sucks dick+++++++++'
freq = 0.01
amplitude = 40
speed= 0.02
i = 0
while True:
s= amplitude*(math.sin(2*math.pi*freq*i)+1)
print(int(s)*' ' +msg)
msg = msg[1:]+msg[0]
time.sleep(speed)
i+= 1
>>
File: memes.jpg (50KB, 696x434px) Image search: [Google]
memes.jpg
50KB, 696x434px
>>52247785
>amplitude *(math.sin(2*math.pi*freq*i)+1)
>>
File: tWKDp41.png (100KB, 1707x918px) Image search: [Google]
tWKDp41.png
100KB, 1707x918px
Finally, easy maths for post analysis.

Going to start applying scores to posts from various standpoints, starting with shitposting.

I'll train my Bayes algorithm to recognize certain words common amongst shitposters.

Hell, I could probably have it learn tripfag posting phrases and word styling to identify when they remove trip to samefag.

I'll start building lexical profiles and separating anon posts into various probable entities, so I can basically give everyone a trip.

NSA here I come.
>>
>>52247721
implementation specified. i know that gdc does it.
>>
>>52247928
C E N S O R + S H I P
E
N
S
O
R
+
S
H
I
T
>>
>>52247937
I'm not trying to censor anyone, I never use the filter.

It would be interesting to see if I can accurately predict who a particular poster is across weeks based on their phrasing and keywords.
>>
>>52247928
None of this will bear fruit.
>>
O C A M L
C
A
M
L
>>
>>52247673
Neither do any of the other listed languages.
>>
>>52248232
https://www.youtube.com/watch?v=9GJd1hLWPbM
>>
>>52247673
D doesn't hav epattern matching? Even java has it in the standard library

import java.util.regex.Pattern
>>
File: medal.jpg (17KB, 305x378px) Image search: [Google]
medal.jpg
17KB, 305x378px
>>52247785
I must confess, it's simple but absolutely awesome.
>>
>>52248280
1/10, that's the best I can do.
>>
>>52248280
Not regex pattern matching, things like
fact 0 = 1
fact n = n * fact (n - 1)
>>
File: 1449902438494.png (444KB, 800x600px) Image search: [Google]
1449902438494.png
444KB, 800x600px
>>52248507
>Variable names starting with a number
>>
Are there major drawbacks if I learn Elixir instead of Erlang?
It's just for fun but I always check if the language I want to learn is worth learning... I find Erlang interesting but Elixir syntax look comfier at a first glance...
>>
>>52248588
>being this retarded
I hope this is bait.
>>
>>52248590
>meme languages
>>
>>52248672
Why?
>>
>>52248672
erlang was released in 1986. it's literally older than java. how is it a meme?
>>
I'm nearing the end of my degree.
Should I put my focus into Java so it's easier to get a job or do I put my focus into C++, which I like better, and hope I get a job?
>>
Yo guys should I keep learning C# and Python, or switch to C/Rust/Go/D and Perl 6/Python/Ruby?
>>
>>52248740
I'd say choose a niche that you'd like to work in, and learn whatever languages or frameworks you need in order to do that.
>>
>>52248726
https://www.youtube.com/watch?v=rRbY3TMUcgQ
>>
File: nissin-beef-flavour.jpg (81KB, 615x422px) Image search: [Google]
nissin-beef-flavour.jpg
81KB, 615x422px
>>52244696
this
>>
>>52248590
http://lfe.io/
>>
>>52249100
>http://lfe.io/
>.io
no
>>
>>52249100
fuck off lispfag

i bet you like anime too, fag
>>
If making a portfolio, whats some stuff that looks good in it?
>>
>>52249175
Lisp programmers are smart. Why would they be involved in anime, which is for disgusting NEETs?
>>
>>52249175
>blubfags on suicide watch
>>
File: 1436550309041.png (491KB, 724x674px) Image search: [Google]
1436550309041.png
491KB, 724x674px
>>52249175
yes so what ? at least i can code, i.
>>
>>52249286
NEET and LISP are synonymous, so anime fits right in.
>>
>>52249357
Not really. There's being a lisp programmer/enthusiast, and then there's being a fucking neet weebtrash that read sicp's first chapter once and thinks that gives him the right to say he knows scheme, like >>52249322

Lisp Wizards > Blubfags > Weebtrash
>>
for (int i=0; i<player_count; i++){
Actors[i].render(gSpriteSheetTexture, &gSpriteClips[], gRenderer);
}


produces

error: expected primary-expression before ']' token


and the method in question

void Agent::render(LTexture* gSpriteSheetTexture, SDL_Rect* gSpriteClips, SDL_Renderer* gRenderer){
if(loyalty == 1) gSpriteSheetTexture->setColor(30,110,200);
else{ gSpriteSheetTexture->setColor(200, 100, 0); }
gSpriteSheetTexture->render(this->getPosX(), this->getPosY(), gRenderer, &gSpriteClips[1]);
}


>motherfucking pointers
I just want to separate code out of main into respective classes. Why's it gotta fuck with me after not sleeping for 20 hours? And yea, this started as lazyfoo sdl tutorials and I never changed the variable names weeks later.
>>
>>52247542
>subreddit
I don't get why mods allow ironic shitposting on /g/.
>>
>>52249380
No index on gSpriteClips, or just remove the [].
>>
>>52249100
>lisp-2
Into the trash!
>>
File: quite a ruff victory.jpg (46KB, 653x510px) Image search: [Google]
quite a ruff victory.jpg
46KB, 653x510px
>>52249286
>smart
lmrvo
>>
>>52249378
OCaml magi >>>> Lisp wizards > Blubfags > Weebtrash
>>
>>52249408
>2016
>still using a lisp-1 for any reason other than working through sicp with scheme

yikes!
>>
>>52249421
>2016
>using a functional language with second-class functions and still pretending they're first-class despite the fact they need to be wrapped to be used in any way in exactly the same way as function pointers in fucking C

Gulp!
>>
>>52249434
>>52249421
>2016
>using functional anything

Welp!
>>
>>52249314
the fuck is a blubfag

and why is my gjewgle chrome fucking retardedly slow when i have almost 600 MB memory available
>>
>>52249444
>2016
>still stuck in the stone-age of programming

Sigh!
>>
>>52249418
Lispers are archmagi of the arcane, you can't be above them.

>>52249434
>Lisps
>FUNCTIONAL

>2 namespaces -> second-class functions

>comparing #'(lambda (x) (+ x 1)) to function points in C

are you memeing me

>>52249444
Lisps are not functional. They HAVE function elements.
>>
>>52249473
>Lispers are archmagi of the arcane, you can't be above them.
pffffffHAHAHAHahaha oh you're serious.
Promptly off yourself, pedophile.
>>
>>52249473
> (funcall some_func dicks)
>not literally worse than (*some_func)(dicks);
>>
>>52249447
blubfags are delusional non-lispers

>>52249488
why are blubfags so aggressive? is it that their affinity for primitive languages causes them to regress to a more primitive state themselves?
>>
>>52249522
(g(o(k(i(l(l(y(o(u(r(s(e(l(f(kike)))))))))))))))
>>
>>52249515
How is it any worse? The first one removes an entire layer of abstraction and allows for much more versatility in the arguments list without become an unreadable mess
>>
>>52249563
EVAL: undefined function G
EVAL: undefined function O
EVAL: undefined function K
EVAL: undefined function I
EVAL: undefined function L
EVAL: undefined function L
EVAL: undefined function Y
EVAL: undefined function O
EVAL: undefined function U
EVAL: undefined function R
EVAL: undefined function S
EVAL: undefined function E
EVAL: undefined function L
EVAL: undefined function F
EVAL: undefined function KIKE
>>
Machine learning question:

Could you design a Bayesian system to circumvent other Bayesian spam filter systems?

>setup gmail account
>have program send test spam emails
>emails get filtered
>program gets emails from gmail API and adds results to Bayes result set
>any emails in spam folder are altered slightly, wash and repeat until emails aren't being flagged as spam
>>
>>52249567
Common lisp way is still at least when compared to scheme
(let ((x (lambda () (display "penis"))))
(x))
>>
>>52249585
kike.kill(kike);
>>
>>52249594
granted, but the comparison was between lisp(s) and C
>>
>>52249563
'(g(o(k(i(l(l(y(o(u(r(s(e(l(f(kike)))))))))))))))
>>
>>52249619
Why not just
kike.kill();
?
>>
>>52249643
Problem with kikes is that you need another kike to kill them otherwise they won't die to death.
>>
>>52249661
But in that case, you're using that particular kike to kill himself.
>>
>>52249567
More words, same abstraction. You can't really say either is first-class since they have to be wrapped for use. Just because pointer semantics are abstracted in lisp does not magically make function pointers any less first-class than lisp-2 functions. You're not REALLY passing a function around, you're passing a function pointer, with an abstraction. The same of course is true in lisp-1, but the difference is that at the language level, there is no difference between the treatment of an integer (say), and a function. The same can't be said of lisp-2's. That's what marks the difference between first-class and second-class functions. After all, with a proper FFI and wrappings, you can manipulate C pointers in lisp as if they were primitive objects, including function pointers. Does that mean that C functions are first class? Of course not. Yet the abstraction level is identical.
>>
>>52249587
In theory yes, but in practice, plain bayesian nets most likely don't have enough capacity to adapt like that. Look into adversarial nets instead; they're basically designed for that kind of setting and will result in much more realistic emails.
>>
how do u average 3 ints in C
>>
>>52249632
Don't ever reply to me again.
>>
>>52248486
Thanks, btw it was an idea of this guy >>52247106 so thanks to him too.
>>
>>52249632
Don't ever fucking reply to me again unless you're post will actually contribute to the thread.
>>
>>52249643
the kike can kill others than itself. you could have
kike.commitSudoku();


which could be implemented within the class as
kill(this);
>>
>>52249418
>ocaml
>not haskell
>>
>>52249763
Good job replying to yourself, fucking lispshitter.
>>
>>52249713
how do u average 3 ints in normal math

The only thing you have to understand is the difference between integers and floating point numbers, and when to convert. This isn't rocket science ffs.
>>
>>52249817
>hasklel
>ever
>>
>>52249842
>what is overflow
Congrats, you're fired!
>>
>>52249860
What is overflow?
>>
>>52249842
it's fairly difficult to get the exact same result as (a + b + c) / 3 using integer arithmetic efficiently without overflow and without converting to larger integral or floating point types
>>
>>52249860
>not using bignums for every variable
>>
>>52249860
fuck off dude we're not doing this again
>>
>>52249890
>using strings for math operations
The overhead is massive.
>>
>>52249908
they are not my friends
>>
>>52249908
Your forehead is massive.
Cunt.
>>
>>52249906
Fuck off yourself, the solution is trivial: just chain it. It's ((a+b)/2)+c)/3 + ((a+b)/2)/3 with fixes.
>>
>>52249924
That's because my brain couldn't fit inside my cranium otherwise.
Human.
>>
>>52249937
>the solution is trivial
now implement it in C programmatically with only using ints
>>
>>52249922
Bignum: 12345 (5 bytes)
Int: 12345 (4 bytes)
My floppy disc is not amused.
>>
>>52249970
That's what the primitive averaging function we defined before is for.
>>
>>52249687
The distinction between function pointers and first-class functions is fizzy at best. At some abstraction level, it becomes irrelevant whether you're passing in a function pointer as a parameter or an actual function.
>>
>>52249977
6 bytes, to account for the type-tag, no?
>>
>>52250006
and why would i want them?
>>
>>52249991
we have (a+b)/2 but not (a+c)/3+a/3==(2*a+c)/3
>>
>>52250005
Usually, first-class means it includes closures and carries around anything it has captured. Basically, function pointer and void pointer.
>>
>>52250005
>>52250035
Though to make sure the capture doesn't get invalidated, you should probably copy it or otherwise ensure that the closure can't outlive its capture.
>>
>>52250005
>it becomes irrelevant whether you're passing in a function pointer as a parameter or an actual function.
That's my point. Whether or not you're passing a function v.s. a function pointer is irrelevant. What matters is if the object is treated the same way as other objects of that class. This isn't the case in lisp-2's (since they don't even live in the same namespace; but also since there's no namespace chaining for name resolution).
>>
I had a patch/pull request accepted to a major open source project.

It was only tiny but I feel pretty good about it.
>>
>>52250131
POST LINK FAMBLIE
>>
>>52250031
(avg(a,b)+c)/3 + avg(a,b)/3
Thus, 2*(avg(a,b)/3) + c/3.
avg(a,b) doesn't overflow, thus 2*avg(a,b)/3 doesn't overflow (and is capped at MAX_INT*2/3). c is an int and is thus capped at MAX_INT/3. Thus, the addition can be performed. Finally, the fix is (avg(a,b)%3)+(c%3)>=3 which can be obtained efficiently (mod in the same instruction as the division, and one add plus one cmp on top).
>>
>>52250141

I don't want 500 autists shitposting all over gitter.
>>
>>52250035
>>52250052
You can have closures in lisp-2 though

>>52250056
From wikipedia
>Specifically, this means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures.[1] Some programming language theorists require support for anonymous functions (function literals) as well
You can do all of this except passing functions as arguments to other functions if you want to be really anal about having to issue a funcall before the function name.

>namespace chaining for name resolution
what do you mean
>>
>>52250165
Post your change then. Please use code tags, as this is the /dog petting thread/
>>
>>52250176
>/dog petting thread/
dude that's disgusting

if you pet your dog you better wash your damn hands

cats > hamsters/gerbils/guinea pigs > ferrets > goldfish > snakes > dogs
>>
>>52250174
>You can do all of this except passing functions as arguments to other functions if you want to be really anal about having to issue a funcall before the function name.
You need to (function X) to pass the function and (funcall X) to use it. You can neither pass a function nor return one.

>what do you mean
If the name is not found in the variables namespace, look it up in the functions namespace. The reference can be substituted at processing time when no eval is used.
>>
>>52250211
I pet my goldfish every morning. It's so soothing.
>>
>>52250152
i'll believe it when i see it
>>
>>52250233
Nobody cares what you believe faggot
>>
File: a ruff victory.jpg (65KB, 500x368px) Image search: [Google]
a ruff victory.jpg
65KB, 500x368px
>>52250211
lispfag shitpaw detected.
get out of my /dog petting thread/, and go clean up your cats box of piss and shit.
>>
>>52250231
i wasn't saying you pet all of that shit anon

but dogs...

>just got done rolling around in dirt and whatever the fuck is on the ground
>cannot self groom
>please pet me!

>just ate some of my own shit
>time to lick your face!
>>
>>52250269
k fag
>>
>>52250290
I bet your mother yelled at you every time you got dirty and now you have a shitty immune system.
Rolling around in the dirt builds character, but most importantly, it marks territory.
Dogs eat their own shit because they know shitting outside is not the way of the man, its best and loyal friend.

>hey man, left you this neat pile of puke on your floor, and I'm too much of an asshole to re-eat it. Now I'm gonna go lie on the back of the couch for 6 days, have my tin of food that smells like dicks ready for me when I awake, servant

>don't mind me, just coughing up hairballs because I like my small cat dick all day with my leg up in the air while your company stares in absolute disgust.

>60/40 percent chance if you even fucking pet me I'll climb you like a makeshift tree, unless you're mean enough to have me declawed so I can't claw the shit out of your gay couch.

Shitpaws everyone.
>>
>>52248590
So nobody use them... meh
>>
File: BJBFWTj.webm (1MB, 426x240px) Image search: [Google]
BJBFWTj.webm
1MB, 426x240px
Ask your beloved programming literate anything.

>>52247542
thank you for umaru
>>
>>52250453
Literate programming is synonymous to fizzbuzz programming, since it's the only scale at which it's applicable in any capacity.
>>
>>52250453
What di you think of >>52248590 #
>>
>scroll through thread
>no one posting about programming
>just arguing over who's obscure language is better


You keep sinking, /dpt/
>>
>>52250580
We need more dog chat and less lisp cats
>>
>>52250580
>lisp
>obscure
typical blubfag hahahaha
>>
>>52250536
>Literate programming
literate programming and a programming literate are two different things.

>>52250549
elixir is more interesting than erlang: it has updates while erlang is no more evolving and it's intended for other things than distributed message based programs (morphing an algorithm into its message based counterpart is very hard).
>>
>>52250675
A programming literate is a retard who uses literate programming unironically.
>>
Can someone tell me how close I am to actually writing this correctly?
from requests import session
USERNAME = 'what'
PASSWORD = 'cd?'
stuff= {
'username': USERNAME,
'password': PASSWORD,
'keeplogged': '1',
'login': 'Login'
}

with session() as x:
x.post('http://what.cd/login.php', data=stuff)
response = x.get('http://what.cd/index.php')
print(response.headers)
print(response.text)


What am I doing wrong?
>>
>>52247730
Oh my fucking god. Fuck C++, or fuck my lack of knowledge how it works, 5 hours of battling with it later I finally found the solution, apparently when you construct an std::string with the data that you get from os.urandom(32) in Python will not get you what you'd expect.
>>
>>52250211
>hamster only second place
Kill you're self
>>
>>52250893
this is why python is not a suitable starting language
>>
>>52250977
>this is why python is not a suitable language
FTFY
>>
>>52251066
What's wrong with splatlang?
>>
>>52251066
* > swift
>>
« 1 1
WHILE 3 PICK 1 >
REPEAT SWAP OVER + ROT 1 - 3 ROLLD
END 3 ROLLD DROP DROP
»
>>
>>52251066
I think you mistyped Rust
>>
>>52250977
Perhaps you're right.

Anyway, given this:
>>> import os
>>> s = os.urandom(32)
>>> len(s)
32
>>> s
b'r0\xd8\x08\x94\xe6\xc34D\x91\x8d\xecI\x82;l~\x04\x155\x05\xb1\xbc\x99\x15\xb4"\x8c\xadT\xcf5'
>>>


How come this results in 28?
#include <cstdio>

static const std::string test = "r0\xd8\x08\x94\xe6\xc34D\x91\x8d\xecI\x82;l~\x04\x155\x05\xb1\xbc\x99\x15\xb4\"\x8c\xadT\xcf5"

int main(int, char **)
{
fprintf(stdout, "Size: %d\n", test.size());
}
>>
>>52251103
Perhaps I did.

Swift influenced and is influenced by Rust.
>>
>>52251008
>this is why python is not a language
FTFY
>>
>>52247634
anything by google is the epitome of normdom
>>
>>52251127
>influenced by Rust.
How so?
>>
I like how emacs is smart enough to color code output that is different in shell-mode
>>
« 1 SWAP
FOR A
CASE A 15 MOD 0 ==
THEN "FizzBuzz"
END A 5 MOD 0 ==
THEN "Buzz"
END A 3 MOD 0 ==
THEN "Fizz"
END A
END
NEXT
»
>>
>>52251242

>drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list

Chris Lattner, inventor of swift
>>
>>52251251
the only trivial part about fizz buzz is knowing what modulus does.
>>
File: 1426331552526.png (11KB, 470x454px) Image search: [Google]
1426331552526.png
11KB, 470x454px
>>52251251
>MOD 0
>>
>>52251286
It seems to be reversed.

arg1 arg2 func result operator
>>
>>52247785
nice man, the memeing is real
>>
>>52251286
It's glorious RPL
A B MOD 0 ==

means
mod (a, b) == 0

.
>>
>>52251276
But what ones? It looks like ocaml/F# for iOS dev. They pauched people from the F# team at MS to develop it.
>>
>>52250826
Why aren't you just using cookies?
Also, you'll probably want to send a proper header.

        headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:42.0) Gecko/20100101 Firefox/42.0',
}


That way, you can just do

response = x.get(LOGIN_URL,headers=headers,cookies=cookie)
>>
>>52251326
the latter is obviously superior to the former
>>
>>52251326
>>52251341
I prefer
a % b == 0
>>
>>52251341
The former will come back and rules the world.
>>
>>52251349
I prefer
!(a%b)
[spoiler]:^)[/spoiler]
>>
>>52251349
Mod wasn't a good example.
>>
File: Borderlands Gun.png (96KB, 500x300px) Image search: [Google]
Borderlands Gun.png
96KB, 500x300px
This is a long shot but is anyone here familiar with the game Borderlands? I'm trying to simulate the random gun generation but can't come up with a good class hierarchy. So far I have an abstract class called Gun and all the gun manufacturers extend it. Problem is when I set the fields I want to set them ( int damage, double accuracy etc.. ) based on what type of gun it is i.e assault rifle, sniper. This would force me to put a lot of logic into each gun manufacturer class. Can anyone come up with a good class hierarchy for this or something similar?

pic related
>>
File: mpv-shot0025.jpg (31KB, 720x406px) Image search: [Google]
mpv-shot0025.jpg
31KB, 720x406px
>>52251337
>Why aren't you just using cookies?
I have no idea what I'm doing.
>>
>making a roguelike with DF-style combat (lots of choices to make so lots of menus)
>have to make menus before I get to the fun part

Fuck me menus are terrible. Are there any gooey libraries for sfml?
>>
>>52251341
No, the correct one would be

== 0 MOD A B

RPN is a meme, PN is where it's at
>>
>>52251423
>== 0 MOD A B
I don't think it's possible to make an expression more convoluted and backwards. I mean you could train yourself to read this without effort, but then again why would you?
>>
>>52251419
SFGUI is alright but currently it uses two deprecated API from SFML (sf::Text::setColor and sf::Shader::setParam? hasn't been updated) and doesn't support texturing for controls (only colors).
>>
File: eee.png (241KB, 645x363px) Image search: [Google]
eee.png
241KB, 645x363px
What books does /dpt/ recommend?

It doesn't have to be programming related.
>>
>>52251386
>Problem is when I set the fields I want to set them ( int damage, double accuracy etc.. ) based on what type of gun it is i.e assault rifle, sniper
make AssaultRifle, SniperRifle etc extend Gun instead of the manufacturers if the types of gun will have substantially similar properties regardless of manufacturer
>>
>>52251487
also you can have a class for each manufacturer and then create the guns using some sort of factory/object composition pattern
>>
>>52251469
Sorry I don't think I can recommend you any books for your reading level. I'm sure you can graduate from reading chinese comic books if you try hard enough, though!
>>
>>52251419
Just use CEGUI and SDL.
>>
>>52251487
I thought of this but then I would have to have something like Manufacturer1AssaultRifle extends AssaultRifle and Manufacturer1Sniper extends Sniper etc..

This would be around 50 classes by the time I finished. Would that be acceptable in the real world?
>>
Working on a CLI calculator, I made one of these when I first started to learn programming but it was complete shit.

Also had the idea to store my intermediate results as fractions using structs. So my calculator would calculate 1/3 as (1/1)*(1/3) and store the result as (1/3), then if I multiply that by 3 it'll give me one instead if .999999999...
>>
Umaru best girl
>>
might want to log out, YoogieYoogie
jesus christ
but thanks, this will help tons
now I'm going to get all of the torrent hashes and search for them on public trackers :3
>>
>>52251630
oh fuck i meant to blank that out.
ah well, already changed pass/logged out
>>
>>52251645
I think he used your cookie, I don't see your login anywhere.
>>
>>52251645
kak
>>
>>52251419
gwen has backends for sfml 1 and 2. it's a GUI library made by the author of garry mod
>>
>>52251667
yea but he could have used that cookie to get my login info. gotta be more careful next time ;o

>>52251630
>get all of the torrent hashes and search for them on public trackers
why? it's probably going to be unseeded and you wont find much
>>
Does anyone know a website where I can quickly create a UML diagram without having to download anything?
>>
>>52251758
draw.io
>>
>>52251590
it's going to be more or less complex regardless of what you do if you want a lot of variation in the guns

>>52251590
it's going to be more or less complex regardless of what you do if you want a lot of variation in the guns

you could have for example
>randomize Manufacturer
>randomize stat coefficients. these don't need to be specific to each type of gun, they can be in the range of 0.0 to 1.0 or 0 to 255 for example to indicate how good they are relative to other guns of the same type. one Manufacturer could generate the stats with a bias toward for example higher accuracy and slower rate of fire.
>randomize type of Gun and instantiate with the generated coefficients + manufacturer-specific components
that's just one idea, there is not just one correct solution
>>
>>52251386
You should only create a subclass if you need to add or override methods.

In this case, you probably want to create your own class system. Create two classes: Gun and GunClass. Each Gun instance would contain a pointer to a GunClass instance which describes the "model" of gun, while Gun itself holds instance-specific data (e.g. what ammo it's loaded with, state of repair, whatever).

Then your 50 classes become 50 instances of GunClass which you can generate semi-randomly, load from a file, etc. You'd probably generate those from templates (assault rifle, sniper rifle, etc).

You'd only use actual classes where the cases are qualitatively different. E.g. if a grenade launcher creates a ballistic projectile while rifles just use an instantaneous ray-cast for hit detection, you might use distinct subclasses for those.
>>
>>52251590
Model the gun as the realization of a sample from a tree-structured probability distribution.
>>
>>52251608
The thing about rational arithmetic is that the numerator and denominator grow as you add more terms. E.g. (a/b)*(c/d)=(a*c)/(b*d), (a/b)+(c/d)=(a*d+b*c)/(b*d). So for two N-bit inputs, you need a 2N-bit or 2N+1-bit result

Reduce fractions to their lowest form using Euclid's GCD algorithm after each operation, and use at least 64-bit integers (if you use an arbitrary-precision integer library, it will probably include support for rationals).

Hard mode: write one which uses constructible numbers so that you can also have a square-root function without needing approximation.
>>
>>52251904
>Hard mode: write one which uses constructible numbers so that you can also have a square-root function without needing approximation.
How do you compare two numbers if there are square roots?
>>
>>52251386
It should be compositional. Each gun component could be a simple hierarchy (e.g. BumpStock extends Stock).
>>
>>52247673
>list of features that only matter to stallman-tier aspies
>>
>>52252057
1/10 that's the best I can do for you.
>>
>>52252057
They are useful features. If you're going to consider using a hipster language that fuck all people use like D, you might as well go right ahead and learn one that's actually good.
>>
>>52248246
C# has pattern matching
>>
>>52252057
this
>>
>>52252145
Explain
>>
>>52252093
>They are useful features
kek
The features that are "useful" are not the same as the features that matter or that anyone gives a shit about. For instance
>it doesn't have pattern matching
Wow just like every other language that is actually useful in the real world, oh no
>>
>>52252145
Lmao no.
>>
>>52252213
>java is the only language used in the real world!
L
POO IN
O
>>
>>52252218
>>52252202

not him but
public static int Evaluate(Exception e, IDictionary<string, int> vars) {
int res;
try { throw e; }
catch (Constant n) { return n.Value; }
catch (Variable v) when (vars.TryGetValue(v.Name, out res)) { return res; }
catch (Variable _) { throw new ArgumentException("Variable not found!"); }
catch (Add a) { return Evaluate(a.Left, vars) + Evaluate(a.Right, vars); }
catch (Multiply a) { return Evaluate(a.Left, vars) + Evaluate(a.Right, vars); }
}
>>
>>52252145
No it doesn't.
>>
>>52252213
Have you ever considered that the most popular languages are not necessarily good languages?
>>
File: logo.gif (6KB, 133x63px) Image search: [Google]
logo.gif
6KB, 133x63px
Daily reminder that Free Pascal is a fast, portable compiler for a fast, beautiful language.
Read more at http://www.freepascal.org/advantage.var
>>
File: 1409849616097.png (137KB, 610x475px) Image search: [Google]
1409849616097.png
137KB, 610x475px
>>52252269
>>
File: 1450869444024.jpg (8KB, 200x200px) Image search: [Google]
1450869444024.jpg
8KB, 200x200px
Will true AI solve P=NP?
>>
>>52252319
(princ1 "Hello World")
>>
>>52252319
print('Hello world!")
>>
>>52252333
You are assuming that P=NP is solvable.
>>
>>52252333
It already has.
You can pay a mexican to sit in a cubicle and solve the travelling salesman over and over.
>>
File: 1404168936983.png (77KB, 694x801px) Image search: [Google]
1404168936983.png
77KB, 694x801px
>>52252349
>'Hello world!"
>>
>>52252261
Have you considered that your definition of 'good language' is entirely subjective? For me, languages that are useless, impractical wastes of my time are not good languages. The best part is I don't even give a shit about D and what features it does or doesn't have, but if you're going to criticize a language that list of missing features should actually make you laugh out loud.

It is a list of features no one is actually missing or cares about, so the criticism is kind of hilarious
>>
File: 234234.png (2KB, 146x75px) Image search: [Google]
234234.png
2KB, 146x75px
>>52252376
only a mistype my friend
>>
>Is OOP a failure? I would generally say "no". I also strongly dislike most of what gets passed off as OOP. I'd say that it endured a fate worse than failing. It evolved into a caricature of bad programming practices that are antithetical to what it was originally invented to do.
>>
>>52251965
sqrt() is monotonic, so sqrt(a)<sqrt(b) iff a<b, and sqrt(a)<b iff b>=0 and a<b^2.

Given a+b*sqrt(c), if a and b have the same sign, the expression has that sign. If the signs are different, squaring both sides preserves the sign, i.e. sgn(a-b*sqrt(c)) = sgn(a^2-b^2*c). This can be applied repeatedly to arbitrarily complex expressions until the sqrt()s disappear.
>>
>>52252352

Can you prove that it's unsolvable?
>>
>>52252447
truth.

Main reason OOP is so terrible is because so many shit programmers use it.
>>
File: radstudioseattleheroshot.png (590KB, 1558x1130px) Image search: [Google]
radstudioseattleheroshot.png
590KB, 1558x1130px
>>52252269
Just use Delphi, pleb.
>>
>>52252261
have you considered that you are a smug hipster faggot?
>>
>>52252496
Yes, but I'm running out of space in this margin in which to type my proof.
>>
File: 28.jpg (33KB, 320x300px) Image search: [Google]
28.jpg
33KB, 320x300px
>>52252505
>Shilling for the company that killed Pascal
>>
>>52252528
I think you meant the only company that still supports Pascal. If Delphi disappeared Pascal usage would drop near to zero.
>>
>>52252495
Ah, you forbid nested square roots or things like that.
>>
>>52252563
Nah, everyone would move to Free Pascal like they should, since it's Delphi compatible.
>>
>>52252511

Tell you what: if you show me a proof that P=NP is unsolvable, I'll show you a proof that P≠NP. We'll split the million.
>>
>>52249860
what is typecasting
>>
what are even the requirements for a proof of P=NP

what kind of proof will convince people
>>
>>52249880
when a buffer goes "this nigga aint gon fit here you take it"
>>
Why is there no Nobel for programming/computer science?
>>
>>52252792
At a "Nobel prize level" CS is just mathematics
>>
>>52252792
because cs wasn't a thing in nobel's time
>>
>>52252241
It's confirmed! C#fags are beyond retarded!
>>
>>52252319
print_endline "Hello world!"
>>
>>52252800
Then how does he have a website you idiot?
>>
>>52252732
>what is performance
>what is memory restriction
>what is not being retarded
>>
>>52252319
>writing a terse hello world is what matters in programming
epic meme
>>
>>52252241
I think this is the worst C# code I've ever seen. >>52252241
od have mercy on anyone who thinks this is a good idea to use in production.
>>
>>52252792
>programming
>any prize ever
Top kek, janitor!
>CS
It's generally math nobel, but it depends on which CS field. For instance, advances in qCS can lead to a physics nobel.
>>
>>52252319
printf "Hello world!"
>>
>>52252870
Lack of boilerplate to do simple tasks matters a hell of a lot in programming.
>>
>>52252904
for simple tasks you have gay scripting shit like python

for serious applications you have """"""""boilerplate""""""""
>>
>>52252918
>for serious applications you have
Only if you're stuck using garbage like Java
>>
>>52252904
there is literally nothing wrong with boilerplate unless you're a pleb
>>
>>52252582
No, you just apply those principles recursively. If you have a nested square root, squaring removes one level of nesting.

Given an arbitrarily complex expression involving integers, +, - ,* ,/, and sqrt(), you can determine its sign using only integer arithmetic.

This means that you can convert it to a float to any desired precision by bisection.

You can also use some tricks to convert it to a float using a mix of integer and floating point arithmetic that's more accurate than direct evaluation of the expression using floating-point arithmetic.

There are also some cases where a nested sqrt() can be de-nested. This can simplify some calculations, but isn't necessary.
>>
>>52252918
>for serious applications you have """"""""boilerplate""""""""
Kill yourself
>>
>>52252929
other languages like C# and C++ have """"""""boilerplate"""""""" too you retard
>>
>>52252929
>garbage like java
wewlad
>>
>>52252918
DEDICATED rajeesh detected.
>>
>>52252933
>there is literally nothing wrong with boilerplate
It makes code needless long to read. Brevity is the soul of wit anon. Everything should be as simple as possible but no simpler.

Boilerplate by definition adds nothing to the code, it's just useless cruft.
>>
>>52252933
Yes there is if your programming language doesn't have macros
>>
>>52252952
>>52252943
kill yourself fucking sperglords

your """"""""functional"""""""" programming languages are fucking garbage and you will never use one to develop a serious application
>>
>>52252951
Everyone knows x86 Assembly is the mastercode.
>>
>>52252967
Who said anything about functional programming?
>>
>>52252946
Yes I know. Those are not the only other languages you know.
>>
>>52252961
literally kill yourself fucking retard

if something is contained in a class then you gain brevity when using said class. some people do more than use fucking trivial built in meme functions.
>>
>>52252967
>Thinks lack of boilerplate means "functional"
you're a funny guy Rajeek
>>
>>52252977
it's implied. either that or you and people like >>52252978 are talking about FUCKING SHIT DISGUSTING GARBAGE like python
>>
>>52252886
>>52252798
and there is no Nobel in just math; chemistry, physics, literature, medicine, peace, and kind-of mathematics

>tfw solve P=NP and don't get a Nobel
>>
>Javafags
Every fucking time
>>
>>52252985
>if something is contained in a class then you gain brevity when using said class.
agreed. I never claimed otherwise.
>>
>>52252995
see >>52253001

>>52253008
>look mom i'm trolling on the internets! i made this guy really butthurt xDDD
>>
>Defending both a stripped down and unnecessarily verbose langauge
>>
>>52252967
Abhishek please go back to india.
>>
>>52253006
>kind-of mathematics

whoops, meant to type kind-of economics
>>
>>52253019
Well, you are getting pretty butthurt over a generally accepted fact
>>
>>52253001
F# and Swift support functional stuff, but you can write absolutely anything you can write in Java in the same OOP imperative style, and still have it be far more concise and readable.
>>
>>52253028
What language are we talking about? Because that description covers basically all the BASICs.
>>
>>52253013
it's things like class declarations and namespaces that people refer to as """"""""boilerplate""""""""
>>
>>52253006
The Field medal is what people refer to when they say a math nobel.
>>
#include <stdio.h>
#include <muh_datastrutures.h>
#include <muh_algorithms.h>
#include <muh_gplfreedumbs.h>

const volatile static char *hello_world = "Hello, world\n";

unsigned char main (void *hi) {
int p, np;
printf("%s\r\n\r\n", hello_world);
return p == np ? 0 : -0;
}


its like you guys dont even program
>>
You literally don't need to know any other languages than C++ and Python. These will get you anywhere in 99.9% use case scenarios. Everything else is literally hobbyist waste of time shit.
>>
>>52253040
>implicit types and no semicolons is more concise and readable
kill yourself
>>
>>52253032
>indians love oop and are bad programmers
hahahAHAHHahHahAHah EPIC mememe EMEEME MY firnwedn lqwellqWLWELL MMEMED MEMELROD XDDDDDDDDDDDDDDDDDDDDDDDDDDDDD HAHAHSHSHADHAHhahahahHHAHAHAHaha

fuck you racist piece of shit
>>
>>52253042
Java
>>
>>52253059
>volatile
>doesn't change
>const* instead of const*const
0/10
>>
File: 1451020874138.jpg (17KB, 250x245px) Image search: [Google]
1451020874138.jpg
17KB, 250x245px
>>52253059
>>52253061
>>52253065
>>
>>52253045
No, it's having to make those things needlessly and verbosely in languages like Java.

A simple Java program needs to define a namespace, class and main function, even if it's only a few lines of actual logic. Why? What's the point?
>>
>that code of conduct

Get your faggot PC bullshit out of here nigger.
>>
>>52253065
Calm down, Pajeet. It's common sense to assume that people who can't even use toilet properly are bad at programming.
>>
>>52253065
POO
IN
LOO
>>
>>52253061
>implicit types and no semicolons is more concise and readable
Sorry to upset you Rafeek, but it's true.
>>
>>52253053
Uhh more like the Fields Medal is what people refer to if they are aware there is no Nobel in maths
>>
>>52253085
>A simple Java program needs to define a namespace
no, it can be left out and then it will just be in the default package

>class
problem?

>main function
entry point because how else would you run it dipshit?

>even if it's only a few lines of actual logic
some people are interested in developing applications that have more than a few lines of code...
>>
>>52253076
>>>52253077 >>52253093 >>52253095
disgusting
dunno why all those quotes are up there but im too busy programming c to remove them
>>
>>52253090
it's not as bad as the anime tá Žbh, umaru is literal cancer
>>
>>52253110
OK rajesh.
>>
>>52253101
joke's on you; you're an idiot.
>>
Can we all agree that no matter how much you like or dislike Python, implicit variable declaration is a pretty stupid idea?
>>
>>52252938
Ho I see. I goona try it. Thx anon.
>>
>>52253130
yes, absolutely. if it's done in a very limited manner like in nim i can tolerate it but var/auto is fucking disgusting
>>
>>52253108
>problem?
it serves absolutely no purpose?

>entry point because how else would you run it dipshit?
how about the first line of the file like other languages?

>some people are interested in developing applications that have more than a few lines of code...
And those people can build modules, namespaces and classes. But why not have the language support doing short programs too?
>>
>>52252792
turing award
>>
>>52253142
and entirely implicit declaration like in python is just... indescribably retarded
>>
>>52253121
Somehow it feels like you're much more upset than i am :^). I can smell your insecurity from here.
>>
>>52253151
THERE IS NO FUCKING POINT IN HAVING JAVA "SCRIPTS"

IT'S ENTIRELY INCONSISTENT AND POINTLESS

JUST WRITE A CLASS NAME AND A MAIN METHOD HOLY SHIT HOW CAN YOU BE THIS LAZY. THE IDE EVEN GENERATES IT FOR YOU FOR ******FUCK'S****** SAKE
>>
I'm building a full-blown web crawler. I've already discovered some pretty fucked up sites with my first version.
>>
>>52247561
OP is a nigger faggot from plebbit
>>
>sqlite
>Everything is stringly typed
>MS SQL Server CE
>Windows only
Fucks sake.
I just want a flat-file database I can bundle with my application.
>>
>>52253170
>THERE IS NO FUCKING POINT IN HAVING JAVA "SCRIPTS"
>Scripting is useless
lol, I doubt even you believe that. Funny watching shit programmers try to defend their limit grasp of the subject.

It's invariably Java and web dev fags though that are this dumb.
>>
File: holy shit.jpg (61KB, 322x252px) Image search: [Google]
holy shit.jpg
61KB, 322x252px
>>52247542
>code of conduct:
>no racism
>no insult
>no sexual harassment
>no gender discrimination

Holy shit OP, you are such a massive fucking faggot. Un-fucking-believable.
>>
>>52253142
>var/auto is fucking disgusting
I didn't say type inference. I disagree with this, type inference is the bomb. I said implicit variable declaration.

blah = "something"


In Python I just implicitly defined the variable blah
>>
>mfw people say that composition comes from OOP
And yet OOP has no way to do composition of code, just data.
>>
>>52253202
sqlite.
>>
>>52253204
KILL YOURSELF

USE THE RIGHT TOOL FOR THE RIGHT JOB

IF YOU WANT TO WRITE THE TERSEST FIZZBUZZ FOR WHATEVER RETARDED REASON THEN DON'T USE JAVA

OR JUST WRITE A CLASS NAME AND A MAIN ENTRY POINT LIKE A REASONABLE PERSON
>>
>>52253170
I don't use an IDE though
>>
>>52253207
>newfag
>>
I'm looking for a book to help me program based off of algorithms instead of random shit that just werks. Has anyone read Introduction to Algorithms, 3rd edition? Is it any good? Any other good books you could recommend on the subject?
>>
>>52253224
>USE THE RIGHT TOOL FOR THE RIGHT JOB
Why would anyone ever use Java, then?
>>
>>52253227
Why do you intentionally cripple your productivity?
>>
>>52253224
If I wanted a terse program in general I wouldn't use Java
>>
>>52253227
USE THE RIGHT TOOL FOR THE RIGHT JOB

AND YOU CAN STILL WRITE IT QUITE TRIVIALLY BY HAND

KILL YOURSELF IDIOT
>>
>>52253142
>var/auto is fucking disgusting
>language feature that literally only Java doesn't support these days is disgusting
 L
POO IN
O
>>
>>52253249
OK HOW FUCKING FASCINATING

WHAT AN INCREDIBLE INSIGHT

THANK YOU FOR TELLING ME THIS
>>
>>52253202
postgresql
>>
Is this the shortest and fastest way I can make toggle in C++?
if (pause == false) pause = true;
else pause = false;
>>
>>52253224
>THEN DON'T USE JAVA
I don't.

But I do use F#, which is better at everything that Java does as well. So I don't see the benefit of Java being so boilerplated.
>>
>>52253247
Because a text editor and compiler work just fine? I don't need something that has more shit than I need like an IDE
>>52253251
>>52253269
Calm down Javafag, sorry I insulted your shitty language
>>
>>52253282
>>52253282
>>52253282
NEW
>>
>>52253277
Lolno. Git gud, CS graduate.
>>
>>52253276
>you want to use my program? yeah just install a pgsql server on your machine
>>
>>52253278
F# has fucking retarded syntax and it falls for the FP meme just kill yourself hipster fag
>>
>>52253277
see: >>52253059
for c++ help
>>
>>52253277
pause = !pause
>>
>>52253322
pause ^= 1
>>
>>52253277
pause ^= true;
>>
>>52253202
>I just want a flat-file database I can bundle with my application.
>>52253276
>postgresql
pls be bait
>>
>>52253306
>F# has fucking retarded syntax
Typical small brained indians. These discussions must really hurt you.

If you really don't like F# syntax, please explain why it is bad. I have explained to you why Java's boilerplate is bad. You seem to agree it makes it shit for small programs without providing any benefits.
>>
>>52253320
>>52253322
>>52253342
Alright, thanks.
>>
>>52253355
typical millennial pisskid
>>
>>52253322
xor is faster
>>
>>52253410
>Dem salty Java fag tears
>>
>>52253490
implying i give a shit that java has """"""""boilerplate""""""""
>>
>>52253555
"""""""""""""""MEMES"""""""""""""""
>>
>>52253555
I wasn't implying that at all. I was just saying it's bad. You seem to agree and are just angry about it.
>>
>>52251105
The quotation mark before the last 4 characters probably
>>
>>52253624
no it's not bad

it provides encapsulation and modularity

F# is what's bad
>>
>>52253704
>it provides encapsulation and modularity
Not even a little
>F# is what's bad
You keep saying that without any explanation as to why you think that is true.
Thread posts: 346
Thread images: 28


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