/dpt/ - Daily Programming Thread

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

Attached: 1559529836731.jpg (1280x720, 655K)

Other urls found in this thread:

github.com/lilsnooker/visualsr/blob/master/linmath.h
github.com/lilsnooker/visualsr/blob/master/main.c#L79
github.com/lilsnooker/visualsr/blob/master/camera.h
en.wikipedia.org/wiki/Operators_in_C_and_C++
mattwarren.org/2019/03/01/Is-CSharp-a-low-level-language/
twitter.com/NSFWRedditVideo

karen!!!!

Attached: BC15A166-27A0-43E4-B913-69264B669642.png (433x713, 557K)

Operator overloading sucks
Function overloading sucks
Default parameter values suck

Attached: 1530171790370.gif (866x866, 1.18M)

don't foget to use const

Attached: 1559162969093.webm (1280x720, 1.93M)

fuck you popuko, they are needed to write readable code

Big data XML parsing. I hate to say it, but C++ doesn't cut it when the file is 1.2 TB big. We're talking 6 straight hours for one pass here, but only when I use C. I broke off the C++ implementation after a day.

Attached: index.png (225x225, 3K)

>he doesn't write his programs-for-old-cpus by writing it in modern c++17, compiling it to x86 and then translating it to the target CPUs assembly
honestly why do you even program?

fizzbuzz is intended to weed out non-programmers who don't know modulo operator
but i'm a non-programmer so did it without using one
from functools import reduce

def devisibleBy3(num):
num_str = str(num)
sum_digit = reduce((lambda x, y: x + y), map(lambda x: int(x), list(num_str)))
if sum_digit in [0, 3, 6, 9]:
return 1
elif sum_digit >= 10:
return devisibleBy3(sum_digit)
else:
return 0

def devisibleBy5(num):
num_str = str(num)
if int(num_str[-1]) in [0, 5]:
return 1
else:
return 0

def fizzBuzz():
fmt_str = ["{}", "fizz", "buzz", "fizzbuzz"]
for i in range(1, 100):
print(fmt_str[devisibleBy3(i) + 2 * devisibleBy5(i)].format(i))

fizzBuzz()

Attached: 121065408.png (820x1034, 1.22M)

I wasn't finished discussing what being a wagie means >yay for karen

Attached: 1557605964542.jpg (1000x1181, 130K)

Kys

i want to nakadashi karen

I really want to change the frequency of some audio files using java

what if multidimensional arrays and arrays of numbers followed matrix/vector rules out of the box?

matrix = float[3,3]
vector = float[3]
vector2 = matrix * vector

Attached: cute-smile-dva-art.jpg (1280x900, 261K)

t. brainlet

Now you're thinking with portals

Also, for all the people who think match libraries are shit in c, github.com/lilsnooker/visualsr/blob/master/linmath.h It's not that bad.

github.com/lilsnooker/visualsr/blob/master/main.c#L79

mat4 projectionMatrix = {0};
mat4 rotateMatrix = {0};
mat4 viewMatrix = {0};


mat4_identity(rotateMatrix);
mat4_perspective(projectionMatrix, FOV, window[0]/window[1], 1.0, 2000.0);
mat4_look_at(viewMatrix, cam_position, cam_look_at, cam_up);

those 3 function calls are constructors not operators

This guy is the constexpr wizard, everything he does is more and more batshit crazy.
He did a contexpr ARM assembly emulator ffs

github.com/lilsnooker/visualsr/blob/master/camera.h

Verbose and expressive

vec3 cam_position = {0.0f, 1.5f, 70.0};
vec3 cam_look_at = {0.0, 0.0f, 0.0};
vec3 cam_look_pos = {0.0, 1.5, 0.0};
vec3 cam_look_dir = {0.0, 0.0, -1.0};
vec3 cam_up = {0.0f, 1.0f, 0.0f};
vec3 cam_norm = {0.0f, 1.0f, 0.0f};
//...
vec3_norm(cam_up, cam_norm);
vec3_add(cam_look_at, cam_look_dir, cam_position);

wow it's so much better than operators

>using iostream in C++
>laughingsnakes.gif

public String fizzbuzz(int input) {
String catcher = "%s";
int total = 1;
int two = 2;
int three = 3;
double test = input;
for (int x = -1; test > 1; x++){
test = (test/3);
}
if (test == 1){
total = total*two;
}
test = input;
for (int x = -1; test > 1; x++){
test = (test/5);
}
if (test == 1){
total = total*three;
}
if (test == 2){
catcher = "fizz";
}else if(test == 3){
catcher = "buzz";
}else if (test == 6){
catcher = "fizzbuzz";
}else {
catcher = String.format(catcher, input);
}
return catcher;
}

me too

You did something very, very wrong.

does "big data" mean "waste of data"?

PSA: Some programming languages don't have a modulo operator, only a remainder operator. Those include C, C++, Java. So if you're being asked about the modulo operator in those languages it might be a trick question.
Or the interviewer is just as clueless as the average Jow Forums user.

I had to use popen, yielding a FILE *, and I did cstdio on that, using my own 8kB buffer.

Yes but what? Maybe I used classes too much, my own and std::map.

It's a planet file. It contains every road on this planet.

yes and you used XML to store it instead of a binary format, which increases your parsing time by 1000% and your filesize by 200%

In computing, the modulo operation finds the remainder after division of one number by another (sometimes called modulus).

en.wikipedia.org/wiki/Operators_in_C_and_C++
Modulo (integer remainder) a%b

Made me google.

Believe me I tried ProtoBuf before that and for many fucked up reasons, that didn't work out at all.

>1.2 TB
>big data

>ProtoBuf
what the fuck is that? you need some special libary just to do basic file IO?

convert it to JSON

this.
if it fits on a single hard drive, its not big data.

>its not as big as my data so its small data

stop using XML
split your file into smaller files like countries for ex
have your main program launch multiple parsing programs on all the files
merge all the result in your main program
stop being retarded and blaming the tool you can't use properly

You don't know Google ProtoBuf? It's what big companies use for their binary data. It's the other format in which the planet file is available. Basically you have a format description and then you compile your stream accessors in vadious programming languages. Among them C++, Java, JavaScript, Python. But Google usess deprecated features for that, and their programmers refuse to update, so there's a ton of problems with that format. I tried, and I couldn't get it to work.

It's not tagged in a way that it splits up easily. To do what you suggest, you basically need a polygon outline of every country, and then you need to calculate for every node if it's within that outline.

no definition of "big data" includes a single terabyte worth.

Before web programmers took over we just had a file format and a spec and wrote our own importers and exporters but I'm sure having a big framework for a simple task that doesn't work is much better

If I had to load 1TB of data I'd consider it pretty big

My dongle can hold more "big data" than that.

Attached: 1557976485721.png (338x355, 218K)

I don't care how big your dongle is

well you could try parsing the file with multiple threads at different positions inside the file
but you should find a way to reorganize your huge ass file. I doubt Google uses a multiple terabytes fucking XML file for Google Maps

That's not my problem, is it, then?

Attached: 1509342388844.jpg (460x460, 57K)

thought that guitar was his ass before opening the thumbnail

and you still opened it

thats the joke

Wow no fucking way user
First day on the internet, I guess

Yikes

Jow Forumswoosh
learn 2 irony, newfriends

lol baited, thanks for the (you)

I wasn't being ironic.

ez bait
thx for attention

i put the browser in the other browser

Attached: 1559857406595-g.gif (746x620, 336K)

So, been taking C++ classes for a year. I appreciate all the computer science algorithms and history and etc that I'm learning... but I would like to build something. What am I suppose to do to move beyond console programs?

Attached: asciid.png (621x561, 6K)

learn a GUI toolkit like Qt, or learn graphics programming

>toolkit
use win32

win32 api is absolute cancerous aids
it doesn't even have a sane sepples binding

>watched at least 50 hours of videos on c++
>still haven't written a single line of it
h-haha at least I'll be ready when the time comes, r-right

>learning via videos
brainlet

that's why it will make you a man

>looking for project ideas
>70% of time I'd spend on it would be spent on the interface or parsing shit
why even bother

I don't see the point in unit testing.

Let's say you're testing some web service. There are various potential points of failure - the application, the database, the server, front-end end. Performing an integration test, i.e. a simulation of what a user would actually do, will test all the components realistically and tell you where the fault is.

This will by default also incorporate what you would normally test during unit tests, which makes unit testing redundant and inferior if done alone.

Plus 90% of unit tests are really obvious shit that is basically written for the purposes of TDD, not for actual use case analysis.

would honestly rather make my own graphics toolkit using vulkan as a backend

>vulkan
>for a gui
brainlet

immediate mode > retained mode

imgui is a complete meme unless you need a quick hacky gui for testing purposes

I also suggest Qt. It's free, unless you want to sell your application. It's platform independent, you can run and compile it on Windows, Linux and Apple. And it comes with a ton of helper classes and data structures that make life easier.

Attached: Qt_logo_2016.svg.png (2000x1467, 60K)

>we're open source but please donate to keep the project alive
It's called selling. How is "free but donate if you use it" any different to "pirate but buy if you like it"?

>I also suggest this magic box
just use java instead

it's not; it's merely an issue of branding

Also comes with hundreds of examples that you can just edit and adapt to your purposes while still learning.

the difference is it's legal to download and use without donating

for the love of god just give me beginner project ideas

Attached: d.jpg (1024x768, 97K)

compiler

Attached: r2cbx1LAGb-12.png (300x250, 14K)

Finally learning to use docker, looks neat so far

i'm not kidding
llvm has a pretty good tutorial for writing a compiler frontend

Added a new way of telling the current context.

Attached: context2.webm (904x510, 1.2M)

>It's free, unless you want to sell your application.
It' still free if you want to sell your application. Even if you don't want to give the source code to your customers you just have to provide the Qt source code (even if you don't change it), you may not statically link and not use their GPL-only components (embedded stuff, web assembly and other web shit and data visualization).

Neat, user.

here's something i've never understood about free software (free as in freedumb). the main idea is that proprietary software restricts a user's personal liberty and should therefore be illegal, but what about the business's freedom to sell restrictive software? i mean, a customer can very simply not buy proprietary software if they believe it's impeding on their freedom.

>Hahahahahahahaha How The Fuck Is NonFree Software Freedom-Denying Hahahaha Nigga Just Walk Away From The Screen Like Nigga Close Your Eyes Haha

Oh, OK.

Got to learn Qt during my last project at the university and loved how well it's all documented.

>i mean, a customer can very simply not buy proprietary software if they believe it's impeding on their freedom.
Correct. I don't see what your bait is trying to provoke.

Karen!

Attached: 1458338231681.jpg (600x485, 174K)

I was considering learning SDL2 to mess with video game development. Would I be able to use that to make applications also? In my mind there isn't much of a difference between what is essentially a game and an application.

Attached: 1551510651754.png (416x638, 35K)

it's pretty fucking simple, your freedom begins where another's ends
you don't have the right to restrict the rights of others
also businesses are literally states and are no different from governments and should be treated the exact same

mattwarren.org/2019/03/01/Is-CSharp-a-low-level-language/

spoiler: yes

Attached: smallone.net.png (290x447, 118K)

SDL2 Abstracts stuff like input, output and setting up a window. You could use SDL2 without making a game. You could use it to aid in cross-platform functionality.

well will it allow me to get to the point of writing compilers on obscure architectures?

I'm asking why some people think it should be a criminal offence to make nonfree software. I don't want to make a silly real life analogy but isn't it like selling a fridge without the electrical blueprint etc.?

And so the pain and suffering begins

Attached: Screenshot_2019-06-07_11-19-16.png (844x32, 5K)

Thanks.

frontend, not backend
it will let you write a language that supports any of llvm's supported backends
some of which might be obscure?

>I'm asking why some people think it should be a criminal offence to make nonfree software.
How many people do you think those are?

i think even having a vaguely positive opinion of the concept of intellectual property should be punishable by death, does that count?

Turn back now, user. That road leads to madness and deadlock.

Interesting, well I appreciate all the information. I think I'll start playing with both QT and SDL2

Oh fugg don't remind me.
>day of the presentation for one of my semester project
>wanted extra points so implemented a multithreaded solution
>from the beginning to the day before it was working perfectly
>deadlocks 5s into the demo
>oh_no.jpg