/dpt/ - Daily Programming Thread

youtube.com/watch?v=J2vqeKd8Vos

Previous thread: What are you working on, Sup Forums?

Other urls found in this thread:

boost.org/doc/libs/1_36_0/doc/html/program_options.html
benchmarksgame.alioth.debian.org/u64q/python.html
github.com/socketio/socket.io-p2p/
socket.io/blog/socket-io-p2p/
stackoverflow.com/questions/6395923/any-way-to-speed-up-python-and-pygame
twitter.com/SFWRedditImages

First for OCaml.

>spent 2 hours installing VS15 just because while building Python 3.5 extensions for Windows it does not recognize any other version of VS

This language wasn't made for Windows was it?

>What is object oriented programming?

...

like if you have a toaster irl, you just insert the bread, maybe adjust the heat/timer setting, and push to start. the toaster is an object. instead of you being like a caveman collecting logs and inventing fire etc just to toast some bread

am i the only one who fucking hates python? i understand it's a powerful language and all, but i really don't like it, could be that i'm really bad at it but it just looks so stupid to me

fuck the sensitive whitespaces

you're far from the only one. python is truly horrible

>python
>powerful language

why is that so? i don't really know why i hate it, i just do

i thought it was pretty powerful with all the math libs and all that stuff

you can take pretty much anything in python and point out something shitty about it. it's just incredibly shit, the entire thing. it's especially bad for beginners to learn programming. it doesn't really teach you anything, after several months the average python shitter will know basic control flow and functions and that's about it. you learn those things in literally the first 1-2 days of java.

i have to use that shit in uni for my cryptography course and it's just a pain in the ass. i'm okay with java but i don't seem to understand this python shit, it's driving me crazy.
i feel like you can create the most absurd constructs there are and all they do is add two variables

I dislike it because van Rossum is a jew.

Why haven't you implemented malloc() yet /dpt/?

can't average 2 ints yet

Anyone programmed a cli in c++ before?
Considering having a massive if/else if tree that compares given command with each program command string. A "clever" way of doing this is with a std::map and using map::find to call a system command function that handles the command and arguments from given stringstream, but this feels like over-engineering.

>clever
>std::map
elegant as fuck! :^)

It kind of is, I could use map.find(cmdstring)->second(stream); in that case instead of an if/else if.
But I'm going for the if/else if option right now.

I fell for the python meme when I first started because I use R/was interested in biostatistics, but I just couldn't deal with it. Then I was forced to learn Ruby and never looked back.

boost.org/doc/libs/1_36_0/doc/html/program_options.html

If you want to do it yourself make a function that returns an int. Define each valid argument in an enum and process them in order. Then make a switch on the return of that function. Default case prints help and an error message.

So I have to find an algorithm and I can't get it.

I have an array of x objects. I can getValue() them, and that returns true or false.

The first time it has to return the first occurrence of true, the second time it has to be the second, etc. If the last in the line is found, it has to start in the front again. An example of the result:

I have 5 objects with states: true, false, false, true, false.

Result should be:

1
4
1
4
1
4
1

Then the array changes to: true, true, false, true, false.

The result then changes to (previous true value was on the 1st spot):
2
4
1
2
4
1
2
4

Anyone has an idea?

thank god i'm not the only one

Fell for the python meme when I first started learning how to program as well. It's not a terrible language but I've yet to see it be taught to someone with little to no programming experience well.

Slowly achieving Lisp satori, guys.

>he spent 2 hours installing VS15 when all he had to do was to set a temp env variable before invoking pip

all of my kekeronis

I want to make vidya gaems. Is C a good fast and portable language to make vidya?

C is a terrible choice for video games unless you're planning on writing some simple classic vidya clones.

Save the previous return value, start back from there, and wrap at the end. Now where do you store it? That's where the algorithm stops and the program starts IMO: depends on your language, whether it has feature X,Y,Z, whether you're writing a procedure or a class etc...

What would you recommend? Java? Python?

>C
>portable
nah, man, try C# for that

>there are people in this thread RIGHT NOW that don't know how to get the first byte of an int
JS babies should leave muh /gee/ forever!
>inb4 REEEEE

Both Java and Python are also terrible choices because they're too slow for stuff like physics simulation and such (just look at Minecraft, multi billion dollar game and it can barely hit smooth 60 FPS on modern hardware). You want to use C++, even if you don't like it, because it's a good compromise between language features that make it easy to deal with common practices in video game development (like entity component systems) and the speed (although if you were pushing hardware to the limits like some modern titles you'd probably have to roll own standard implementation for some stuff but I doubt you'd ever reach that point).

Alternatively try , C# is a decent language that can offer a lot and is relatively fast but you're tied to MS ecosystem.

In a portable manner? In C? Impossible.

> webserver in Clojure
> GC is getting buttfucked

I fell for the immutable meme, send help.

Are you talking speed as in AAA titles or vidya in general?

>(just look at Minecraft, multi billion dollar game and it can barely hit smooth 60 FPS on modern hardware).
10 years old hardware here and i have constantly +200 fps

>Both Java and Python are also terrible choices because they're too slow for stuff like physics simulation and such (just look at Minecraft, multi billion dollar game and it can barely hit smooth 60 FPS on modern hardware).
It's just Notch being a shitty programmer. Java is lightning fast

AAA

Specs?

What are some good ways to practise pointers and memory management in C?

dat
boi

intel core2duo e8400 (2008)
2gb ddr3 (2008)
ati hd 5770 (2009)

What's the difference between python and Java?

I'm not interested in AAA right now. I'm more interested making small indie games as a hobby

>whats the difference between python and java
Lmao

notch is decent but he rushed the development and favored features over performances which was the right thing to do.

There is none?

>What are you working on, Sup Forums?
Currently coding a project for an Uber-like startup doing it in full stack Ruby on Rails, but also using the most async version of node.js for parallel agile project so I'm picking the appropriate framework atmo and reassessing user stories. I'm just writing a Medium about my project, I'm worring about scaling though and if along hte lines I'll have to include deep learning to make it more contemporary... we'll see.

>Ruby on Rails
I loled.

xD

>trump

Prime bait.

>What's the difference between python and Java?
huge
benchmarksgame.alioth.debian.org/u64q/python.html

What are you doing to make the gc gonuts

that's cpython vs openjdk, not python vs java. he asked for differences between the programming languages.

So I'm trying to learn socket.io's p2p shit and I'm not using browserify:

github.com/socketio/socket.io-p2p/
socket.io/blog/socket-io-p2p/

So it says I'm supposed to just include the 'socketiop2p.min.js' file and use window.p2p(socket), but when I do this I get an error saying 'bind' is not a function.

What am I supposed to do?

>that's cpython vs openjdk
no, that's the Oracle's Java implementation vs regular Python 3

ayy

Nothing special. It's just that any changes to objects generates tons of garbage of intermediate results.

scene = QGraphicsScene()

scene.mouseMoveEvent = lambda mouseEvent: (print(mouseEvent), mouseEvent.accept()) # type error


def foo(mouseEvent):
print(mouseEvent)
mouseEvent.accept()

scene.mouseMoveEvent = foo # works


How is that retard guido still allowed around computers?


>inb4 inherit from QGraphicsScene
To overwrite one (1) function, how about no

Would a game in Python seriously be that slow?

no

Yes.

python sucks dick
java is pretty neat

probably not, most games don't perform such heavy computations and Python has a lot wrappers for numerical functions written in C

Retard.

Is Python more portable than Java?

yes

you don't have to announce your arrival

no

Shouldn't that be:
lambda self, mouseEvent: ...

Sorry for dual monitor pic, but any help with getting C++ compiler configured/ libraries needed configured with eclipse would be really helpful. Using C++ for everyone by Horstmann.

tried to configure eclipse for C once and I just gave up and installed Visual Studio

/dpt/ in a nutshell

Goddamn it. I'm in love with eOS and I really don't wanna have to use windows to learn this shit.

>Eclipse C++
Doesn't that just use makefiles?

I have no idea, honestly. It's saying that my iostream import is unrecognized.

Writing an R package for fetching sports data from an objectively-poorly designed API.

On that note, to what degree is it bad practice to rename fields in the objects my functions return to the user? The API is entirely undocumented and many fields (and the tables in general) have either meaningless or abstract names. I feel like, especially since there's not going to be any posting to the service, it's not a terrible idea, but my goal along the way is to attempt to document the service as well, so I'm trying to be especially careful when making decisions like this.

>Get back to an old project of mine
>See // I've no idea what's the purpose of this

I'm fucked, ain't I?

get clion

No, that would be consistent with the other mess.

TypeError: () missing 1 required positional argument: 'mouseEvent'

guys, im taking my first programming class and the instructor is using python...

what do?

Perform sudoku

There's no stupid questions thread in the catalog, so
anyone knows how to create a matrix, multiply it with a number, add another matrix to it, or multiply it by another matrix, in c++

stuff I know as of now:
integers
for loop
cin and cout

I just dont know how to make matrices and do stuff with them..

We had a lecturer who was supposed to teach in C# for a particular course. He took it upon himself to ramble and inject python into every part of that course.

By the end of the course, everyone was falling behind, on the verge of failing and had to look for help from prior students who didn't have to suffer through that, or look elsewhere.

My advice?
Run for the fucking hills.

yeah you use glm

Install Gentoo.

Barring that, actually try paying attention in class instead of being a gay fucking baby.

what's glm?
I have an exam tomorrow and I dont know how to do this, I dont know shit about programming

Pay attention, you dumb ass. If you're taking your first class, there's no reason you should be acting like you're above a fucking language just because the basement dwellers here tell you so.

ur fukt then m8

>He took it upon himself to ramble and inject python into every part of that course.
God damn, that would be annoying.

absolutely not. use java or C++. don't use C or python.

yes

stackoverflow.com/questions/6395923/any-way-to-speed-up-python-and-pygame

its an online course, and I'm studying rite now! Wish me luck!

It makes a two-dimensional array (a matrix).

It assigns values to the two-dimensional array.

It iterates through the array and multiples and adds values as necessary.

I don't understand the question.

Yeah but how do I make this? Lets say I have a matrix a[100][100], how do I multiply it by 2?
I guess I could make sum[100][100] = a[100][100] + b[100][100], but not sure how to multiply it by a single number

i'm not going to write your fucking program, but here's a hint:
- matrix is something like int x[row][column ]
- you multiply it with a number by running through a nested for loop, for example like:
for(int i = 0; i

Nested FOR loops.

for each row in matrix, for each cell in that row, multiply the value by two.

>Much of what looks like rudeness in programming circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-bullshit communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy.

> not putting your matrix in a single dimensional array
> not calling your second iteration integer i2

that was my intention

>not putting your matrix in a single dimensional array
why would you do that? a matrix is 2-dimensional and not 1-dimensional, and it would lose it's actual form

>not calling your second iteration integer i2
call it what you want, i've learnt it that way