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

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

Thread replies: 255
Thread images: 28
File: timetocode.webm (2 MB, 1152x648) Image search: [Google]
timetocode.webm
2 MB, 1152x648
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 (840 KB, 1580x3422) Image search: [Google]
Dlicious.jpg
840 KB, 1580x3422
obligatory pic related post
>getting your CoC slapped by the D head
>>
File: You.png (349 KB, 710x615) Image search: [Google]
You.png
349 KB, 710x615
>>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 (481 KB, 626x988) Image search: [Google]
1451787124294.png
481 KB, 626x988
>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 (342 KB, 604x566) Image search: [Google]
dear god why.png
342 KB, 604x566
>>52247611
>this fucking question
>>
>>52247595
Go >>>>> C > normie languages
>>
>>52247595
Those languages aren't even comparable.

Different tools for different jobs.
>>
File: 1451553795827.jpg (21 KB, 500x500) Image search: [Google]
1451553795827.jpg
21 KB, 500x500
>>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 (50 KB, 696x434) Image search: [Google]
memes.jpg
50 KB, 696x434
>>52247785
>amplitude *(math.sin(2*math.pi*freq*i)+1)
>>
File: tWKDp41.png (100 KB, 1707x918) Image search: [Google]
tWKDp41.png
100 KB, 1707x918
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 (17 KB, 305x378) Image search: [Google]
medal.jpg
17 KB, 305x378
>>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 (444 KB, 800x600) Image search: [Google]
1449902438494.png
444 KB, 800x600
>>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 (81 KB, 615x422) Image search: [Google]
nissin-beef-flavour.jpg
81 KB, 615x422
>>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 (491 KB, 724x674) Image search: [Google]
1436550309041.png
491 KB, 724x674
>>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 (46 KB, 653x510) Image search: [Google]
quite a ruff victory.jpg
46 KB, 653x510
>>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 (65 KB, 500x368) Image search: [Google]
a ruff victory.jpg
65 KB, 500x368
>>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 (1 MB, 426x240) Image search: [Google]
BJBFWTj.webm
1 MB, 426x240
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 (11 KB, 470x454) Image search: [Google]
1426331552526.png
11 KB, 470x454
>>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 (96 KB, 500x300) Image search: [Google]
Borderlands Gun.png
96 KB, 500x300
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 (31 KB, 720x406) Image search: [Google]
mpv-shot0025.jpg
31 KB, 720x406
>>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 (241 KB, 645x363) Image search: [Google]
eee.png
241 KB, 645x363
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 (6 KB, 133x63) Image search: [Google]
logo.gif
6 KB, 133x63
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 (137 KB, 610x475) Image search: [Google]
1409849616097.png
137 KB, 610x475
>>52252269
>>
File: 1450869444024.jpg (8 KB, 200x200) Image search: [Google]
1450869444024.jpg
8 KB, 200x200
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 (77 KB, 694x801) Image search: [Google]
1404168936983.png
77 KB, 694x801
>>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 (2 KB, 146x75) Image search: [Google]
234234.png
2 KB, 146x75
>>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 (590 KB, 1558x1130) Image search: [Google]
radstudioseattleheroshot.png
590 KB, 1558x1130
>>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 (33 KB, 320x300) Image search: [Google]
28.jpg
33 KB, 320x300
>>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
Thread replies: 255
Thread images: 28

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.