/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1542756450052.jpg (600x812, 383K)

Other urls found in this thread:

mooc.fi/en/
youtube.com/watch?v=Mc_0zkjfNR4
docs.oracle.com/javase/7/docs/api/java/lang/StringBuffer.html
github.com/andersonmontor/ecosim
twitter.com/SFWRedditImages

How do I program a mommy's milkies?

Attached: milkies.jpg (3840x2160, 819K)

>applied for a job that will require strong knowledge of machine learning and mathematics expertise
>dont know shit about machine learning nor mathematics
>somehow got an interview and bullshitted my way through it
>landed the job
>starting in 3 weeks

how fucked am i? can i learn everything about machine learning and the required math in 3 weeks? i really need the money

Attached: 1539025473354.jpg (540x545, 51K)

You have a week each to learn linear algebra, statistics, and deep learning.

is it possible? i did well in my math classes in school but didnt retain anything

>keep trying to learn to program
>it never clicks
>for five fucking years
>cs major

It's not fair. It's not fucking fair. I don't know what's wrong with me. I'm not even doing this for a job I don't care about the development job. I just wanted to learn for me I wanted to make something and I can't muster fucking anything


There's nothing I'm good at. And starting anything new now I'd never be as good as I'd want at it.

I've only ever had computers in my life as escapism. And books but then I ran out of money for those and stopped reading in highschool. My entire fucking life is just a black hole. A disco ball shows me ever mistake I've made in my life. I regret every single aspect

Nothing is my calling . At this point I don't want a job in technology at all. I hate technology and believe modern development causes more harm than good. And is just a method for business owners to line pockets with fake forced "progress"
I would kill myself if I did IT. I want to kill myself now.

....I have no interests . I literally have been focused on computers since I was a kid . I'm an adult and even after five years of purposeful concentrated learning I'm tech illiterate.
I
Have
Nothing


I'm a failure

Nice blog post, but where can I unsubscribe?

Fucking this, we don't need every thread to have this bullshit

>falling for the programming meme

nice pasta

nice catch

Does anyone know why std::ofstream would throw an exception when i feed it the third string literal I pass it? I feel like I don't even have space to make errors here.

c++ programs are only allowed to make 2 i/o calls per program. gotta go fast!!!

You're error is using c++

sup negroes. so I'm currently working on a project that will pull files from an API of various sizes, analyze them, and upload them to Virus total API. I usually just script basic stuff in go/python and I've never needed to do anything this efficiently. Do you have any advice on how the queueing should be handled?

Also it would be nice if I could feed the results into some sort of visualization. categorize it under phishing/executable/etc.

Not pasta. I'm the same user from last thread

I'm coming around to this idea. I've never had something this odd happen to me with FILE*.

Go sounds straightforward, just use channels and goroutines to split the work out. If you have to worry about rate limiting I would be surprised if no one made some kind of rate limited channel. For python using the async event loop and zero mq is a good bet. If possible output the results to some parsable format that can be interpreted by some python frameworks.

Nice thanks. Already have a mock up of sorts in go that is checking the hashes on VT and placing results in a database but I want to do the full upload. Rate limiting probably won't be a huge issue as pulling the files is extremely slow but it can vary depending on the file.

Didn't virus total limit the amount of queries against it you could do unless you contributed something to the db? What kind of project are you doing?

>go

you're beyond fucked and wont be able to understand any of the literature

Please consider posting code and the error message (for maximum assistance).

How do I write a phishing program? I would like to phish for bass to cook a nice bass.stew();.

It's C++. How would he have any hope of fitting an error message in

I'd like to read that.

Does this fill you with joy?

Attached: DD47D8C7-7F22-4125-B832-57623A1283A0.jpg (286x145, 8K)

wtf of course not, jfc it's hideous
what language is that, it's ovtuse as fuck and not self-documenting or expressive at all

It’s the newest addition to the Forth esoteric family which includes False and Brainfuck. This new one is designed to be more Assembly based with gotos and stack pointers used for control flow. I think I might name it Sinister.

Attached: EB23A8C7-C291-44A0-89D1-D17298D88563.jpg (750x725, 95K)

get off Jow Forums and start studying. You don't have time to waste.

Attached: chadandbetalaughing.jpg (600x532, 40K)

If it was it would literally cuck every single engineer student considering those are all separate courses, often with other courses as requirements.

no I hate meme languages

you don't hate Haskell though do you?

Attached: 1547421442644.jpg (580x580, 196K)

Help me come up with an AI project idea. I want to do something but can't decide. I've already done the image classification meme. I'm thinking something unsupervised.

nice try

C, ML and Lisp are the most important language dialects.

I had this idea for a program called something like bot or not.
It is a two player game, it can be two humans, two robots, or one human and one robot. The task of both players is to figure out whether the other player is a bot or not as fast as possible. If you guess correct before the other player you win, otherwise you lose.

haskell is gay as fuck, seriously the syntax is pure crap and it's too restrictive as a language

>it's too restrictive as a language
surely you mean not enough
unsafeCoerce

>unsafeCoerce
OK that's actually kind of cool, maybe I'll try Haskell once I learn to program this weekend.

size = 4
main :: IO ()
main = do p >= print
free p

fillBuffer :: Ptr Word8 -> Int -> IO ()
fillBuffer ptr size = go 0
where
go i | i == size = return ()
| otherwise = do pokeElemOff ptr i (fromIntegral $ 0x41+i)
go (succ i)

Attached: 1540178528237.png (454x404, 158K)

I find Haskell easy to read, since the language is very consistent. It can get ugly with some GHC extensions.

>the syntax is pure crap
I thought the syntax was a bit frustrating to deal with at first but I really learned to love it, now all other languages feel very verbose.

def max([]), do: raise("Can't find max of an empty list")

def max([head | []]), do: head

def max([head | tail]) do
max(head, max(tail))
end
[

How does this work? Why is this working? my brain is about to explode

guys just be honest is it comfy? what other languages do you have reasonable proficiency in?

Haskell is comfy once you're familiar with it, but it takes a while
other languages, C++

Max of a list is the max of the first item and the max of the rest of the list.

Is there a nice list of canonical C libraries? Specifically I'm looking for game related libraries like a wrapper around different 3D frameworks, a game loop, an ECS framework, and also things like networking frameworks, vectorised math libraries, input handling libraries, imguis and so on.

>(for maximum assistance)
(for any assistance at all)*

I find Haskell very fun, since my day job is in embedded SW (c, sepples, arm asm mostly).

It is.
besides haskell I mostly write C and C++, did a bunch of Scheme and C# in uni too.

C, Python, Scala

nth for Fortran

sdl2, sockets, if you want more then go with a C++ engine

runtime errors, not compile time ones

Sdl2 doest properly abstract over different 3D technologies as far as I know. For shaders you have to use openGL or whatever you want.

if you're serious stop with this "I'm not good at anything and a failure" bullshit
I don't know you, your past, your life or what color your asshole is, but I started programming out of curiosity and never been particularly good at anything myself
at the start it all felt so fucking massive and overwhelming, and even today I find topics or I stumble something while working on a project that I don't know exactly the best way to accomplish
still, because I wanted to learn it, thought it was interesting and had nothing else to do, I made my way through
so stop bitching and go after your goals
no one is going to hand you a perfect solution

What's the best book for learning Java?

Attached: 1523565847975.jpg (2433x3300, 1.5M)

the only thing on your list that can be considered close to 'canonical' is a math library, the rest are open to interpretation
also ECS is a meme

mooc.fi/en/ is a great book

What do I read after that? I actually just finished that. Some fella asked me what the difference was between a string and a string buffer and I didn't know.

>ECS is a meme
Lol what's the alternative? Just make everything objects that run their own code?

Any clue on whether this one is good? The reviews and word of mouth on it seem good.

Attached: 51sgPootxCL._SX383_BO1,204,203,200_.jpg (385x499, 41K)

You should use components, but your components should be inside their parent object and not in a relational database

>make everything objects
Why would you conclude that?

youtube.com/watch?v=Mc_0zkjfNR4
It uses different example, but can be helpful to understand how recursion works.

>I actually just finished that.
Neat!
>Some fella asked me what the difference was between a string and a string buffer and I didn't know.
docs.oracle.com/javase/7/docs/api/java/lang/StringBuffer.html
In short, you use stringbuffer/stringbuilder if you're concatenating a string in a long loop or something, as appending strings is a costly operation, then at the end when you're done you get a string from stringbuffer/builder.

No idea. I finished the course on that website for uni and we continued with object oriented programming, which is absolute garbage but if you're learning java it's probably a natural next step.
In general you might try to look up the theory as you go, and soon enough you should try to do your own programs. It will be difficult so try to do as trivial applications as possible to begin with.
With that said, if people say it's a good book I'm sure it's good. And if it's java 9 it might have some more modern and up to date design philosophy in it.

>trying to make an economy simulator
>only 1000 entities with basic AI, simple 2D graphics
>40 FPS
Thats what I get for using python

Attached: economy simulator.webm (882x611, 2.99M)

What's the benefit of this? If components are inside parents, each parent will be massive, or alternatively each parent will only keep pointers to the components, but then you have to follow pointers all the time to get anything you want.

What's the alternative?

are you doing any n*2 operations?

I don't think so. They just run to a target, then choose another with random.choice() when reaching then

I love the idea of this, and I wrote it down so I can try it out whenever I think I'm at that level.

Typical game object access patterns are that the components of one object generally like to talk to each other. Iteration over every one of a single component is far less common, which means it's kind of stupid that ECS is considered a good idea

Then I guess I'll just have blame it on Python, I can do something similiar with 300,000 objects at 40 FPS

What level? Just do it now and experiment with your ideas.

github.com/andersonmontor/ecosim
If you want to take a look at the code. Feedback is appreciated.

Help me understand Haskell typeclasses here

xxx :: Monad m => m Integer
xxx = return 5

main =
do
let a = Just 1 >> xxx
let b = [1] >> xxx
print a
print b


To me it seems xxx can be two kinds of values at the same time: it's both a "Maybe Integer" and a "List Integer". How is that logically possible? I always though you'd need to put generic functions like "return" inside an expression so that the context would lock the function into one concrete implementation, but that doesn't seem to be the case.

>What level? Just do it now and experiment with your ideas.
I'm a newbie. I just finished .

Attached: Screenshot_18.jpg (477x365, 32K)

head first, if you know what I mean

That obviously depends on the game.
Most likely you've got a mix of both and could separate them based on how the fields are used if you want.
The reason I think people favor the layout by component type is because that's where many games feel the stress. Systems like audio, physics and rendering.
If you've got the nasty highly interdependent field situation you've probably got a very interesting game. Most games aren't that interesting.

Your game architecture is fairly good. You aren't really doing anything to kill performance apart from creating vector objects every frame. Python just looks slow. You might want to try Lua with Love2D

I have never sucked on a girls toes before, user, so you'll need to explain what you mean!

You might be able to do it now. Some small projects in pygame can be fun and good exercise. They can be made pretty simple.

All games are "nasty highly interdependent field situations"
Having things laid out in sequential memory is good for some things like rendering, it's not good for a general use case for all your objects though, it might end up even making things slower having to jump around memory all the time, it certainly makes things more awkward to program

List implements the monad typeclass, as does Maybe. Therefore both return types are valid, list integer or maybe integer.

When I say nasty interdependence I mean it in the context of that making up the most of your processing so you have to optimize for that case. Not that most games don't have those kinds of structures at all.

I'll stay with Python for now, I'll probably not even use 1000 agents other than testing performance. If it ever become a problem, I'll try C++ with SFML. Thanks for the feedback though

And when I say 'most likely you've got a mix of both' its referring to specific fields. Not the overall program. Maybe that's where the confusion came from.

But what's the alternative?

Except for a small number of components like position, or systems like general AI, components generally mind their own business. In the cases where you do need to access multiple components any good ECS will have multiple join/interleaving storages to handle it. In fact if you want every system to have access to every component you can store them all in either a referential join, or a single interleaved storage, so ECS contains that as a special case anyway.

then if you want speed I suggest you inline your math instead of using a vector object

the parts of a game that really benefit from being memory aligned are animation, particles, maybe AI, maybe rendering if you have a large amount of objects. Everything else is an interconnected mess. That's why I wouldn't recommend ECS. Make the parts where it helps aligned in an array and use a normal object model for the rest

The alternative is your components are either stored by value or by pointer in their parent object. Most components do not mind their own business at all - that's the biggest lie being told about ECS. Most things need to communicate with each other

I get how it "works" but I don't get how it manages to compare the numbers without ever actually doing a comparison?

I might be sounding retarded now but there's no naming conflict with the max function defined in the prelude, right?

It's the opposite of what you're used to with interfaces.
xxx is anything that can be a Monad with an Integer inside.
ofc xxx isn't just one value in memory (we're doing functional, remember), so a and b are different values.
If that helps, typeclasses are implemented as dictionaries where your xxx is transformed into
xxx :: Monad m -> m Integer
xxx d = (return d) 5

and so return gets the 'return' function of your passed dictionnary, this passed dictionnary is the instance of your type.
so in your case
let a = Just 1 >> xxx (mkMonad Just maybeBind)
let a = [1] >> xxx (mkMonad (\x -> [x]) listBind)
...
maybeBind Nothing f = Nothing
maybeBind (Just a) f = f a
...

etc.

Is there a modern equivalent to this? I'm new, but the fact it's Java 5 and made in 2005 is off-putting.

Attached: 9780596009205_p3_v3_s550x406.jpg (336x406, 33K)

Nope there are no conflicts, the arguments are pattern matched and whichever function matches first will be used

>then if you want speed I suggest you inline your math instead of using a vector object
Or use a language with better abstractions. Imagine your language having a difference in performance from inline and abstracted math. LOL.

It's Python
It's creating new garbage every time you make a new vector

Stored by value (interleaved storage) for all components would leave too much wasted space, every projectile or small entity would be 100 times larger than they need to be, up to multiple kilobytes for a simple arrow. Stored by pointer (referential join) amd stored by value means you are forced to always iterate by entity, where in an ECS you can pick and choose how each system should be applied, if some system does for some reason use everything just join them all and iterate over entities. But for the majority of systems that use only 1 or 2 components, you can iterate over only those components. If you always iterate over entities, and you have a component rarely used, you are forced to iterate that over your 100k entities instead of the 5 that actualy has the component. And most systems do only use 2 or 3 components, phisics uses position and material components, health regeneration uses health and regen stat components, pathfinding uses position, target, and material components, in an ECS you can for example interleave regen and health, making regen calculations faster, but changing the regen stat slower, which doesn't matter since you only change it on equip of items for example and not every frame. If you want you can literally start your game with everything interleaved, then change the storage later as you find bottlenecks and identify tightly coupled components without having to change the systems at all.

It does compare. It keeps making new calls until there is only one element in a list, which gets returned to previous call. It then goes all the way back comparing values.

I think I figured it out for myself too while taking a shower. So indeed like you said, values that depend on a typeclass _aren't pure values_, instead they're these abstract things that can take the form of different values depending on the context they're used at.

This would be the situation reduced to the simplest case:

import Data.Monoid (Sum(Sum))

xxx :: Monoid a => a
xxx = mempty

main =
do
let a = Sum 1 xxx
let b = [1] xxx
print a
print b


xxx is an abstractly typed value depending on a typeclass, meanwhile when used with Sum and List it works like a Sum value or a List value depending on its context.

Funny thing is I know what typeclasses are and I've used them a ton, but somehow my brain just farted out when this situation came along. I guess I never formed the mental model that typeclassed values are fundamentally different from regular values. Haskell is just so fucking abstract, when I started I constantly encountered these kinda situations where I had to blow up my earlier mental model because it was slightly flawed. You could save yourself a lot of trouble by having a mentor.