/dpt/ - Daily Programming Thread

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

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

Other urls found in this thread:

linux.die.net/man/3/qsort
en.wikipedia.org/wiki/Row-_and_column-major_order
github.com/crawl/crawl/blob/master/crawl-ref/source/dungeon.cc
github.com/CleverRaven/Cataclysm-DDA/blob/master/src/map.cpp
rogueliketutorials.com/tutorials/tcod/part-2/
cs.cmu.edu/~quake/robust.html
isocpp.org/get-started
stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
twitter.com/AnonBabble

was looking at linux.die.net/man/3/qsort

return strcmp(* (char * const *) p1, * (char * const *) p2);


how big of a difference is there between char * const * and const char **

I'm going to force my self to do a project thats over my head and blog here

whats the project?

mediaPlayer.setPlaybackParams(new PlaybackParams().setSpeed(1.5f));

By using this my game will go from hours of music to thousands of years of music


1. write jingles of different lengths
2. Put two on at the same time
3. Modulate the speeds

With 92 jingles of an average length of 241 seconds, and combining every combination of two gives about 15 years of music from only 6.1 hours of base tunes. Then with 101 increments of speed the combinations go to 150000 years of music.

I’m about to start a project in Java before I forget how to Java. I’m going to make either an interpreter or compiler for an fp that’s basically ML with a significantly simpler syntax. Here’s a theoretical Fibonacci function in it.
fib x if x < 2 = 1
| x = fib(x-1) + fib(x-2)

nothing, not for a long time now. stuck as a shitty web developer. severe depression and I'm slowly losing the little skill I have left.
I don't know how to even become a mediocre dev let alone ever meet the standards of a good software engineer

Sorry to hear that buddy. Depression sucks. Sucked away my acting talent and more recently my persuasion. Idk wtf I would do if I lost my programming skills too.

The position of where the const is refers to what is actually const.
#include

int main()
{
char buf;
char *s = &buf;
const char *cs = &buf;

const char **ptr1 = &cs;
// **ptr1 = '\0'; // Bad
*ptr1 = NULL; // Good
ptr1 = NULL; // Good

char *const *ptr2 = &s;
**ptr2 = '\0'; // Good
// *ptr2 = NULL; // Bad
ptr2 = NULL; // Good

char **const ptr3 = &s;
**ptr3 = '\0'; // Good
*ptr3 = NULL; // Good
// ptr3 = NULL; // Bad

const char *const *const ptr4 = &cs;
// **ptr4 = '\0'; // Bad
// *ptr4 = NULL; // Bad
// ptr4 = NULL; // Bad
}

I wanted to make a program that could read manga pages panel by panel and place them into focus individually for a certain length of time in a slide show for immersion.

That's actually pretty difficult. Seems appropriate for an "over your head" kind of project.

fuck dude good luck! that sounds really interesting

Wait, does Jow Forums actually not follow tab-stops when expanding tabs, and just replaces it with 4 spaces?
That's pretty fucking shit. I don't know how I've never noticed that before.

Attached: 1369446960901.png (256x310, 20K)

Put it on github so I can use it.

>tfw it is this easy to make windows ignore windows key
Also ignores alt+tab and a bunch of other key strokes, only ctrl+alt+delete still worked.


LRESULT CALLBACK MyTaskKeyHookLL(int nCode, WPARAM wp, LPARAM lp)
{
return 1;
}


SetWindowsHookEx(WH_KEYBOARD_LL, MyTaskKeyHookLL, NULL, NULL);

Attached: 1479007291730.gif (230x290, 3.45M)

Attached: CppCon 2016 - Jason Turner “Rich Code for Tiny Computers - A Simple Commodore 64 Game in C++17”- (1280x720, 1.93M)

Brainlet here. I'm getting confused by eager evaluation vs lazy evaluation in practice?

You link says it goes like
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));


The const part says that the compare function can't alter data by itself.

awesome

that's a cool idea, and should be doable... if your's is web/browser based there out to be javascript frameworks for slideshows

The rule is: const qualifies whatever is on the right, unless there is nothing there; in which case it qualifies whatever is on the left.
char *const means the pointer cannot be changed, but the pointed to value can
const char * means what is pointed to cannot be changed, but the pointer can
const char *const means that neither can be changed.
Worth noting that const qualifiers don’t mean the value can’t be changed elsewhere on the program, only that it the user of the pointer cannot change it.

ok

>is this variable immediately needed by the function / will be used every time the function is called
eager
>is the variable only needed in specific cases that rarely come up (like logging)
lazy
Though, most of the time you could break out lazy variables and their uses into their own eager functions.

Eager means to fully evaluate expressions immediately, this is the default in almost every programming language. Lazy means to only evaluate expressions when needed, this is usually accomplished with a thunk or streams/generators. Laziness is an advantage when you may not need a value or only need a part of it.
There is also something called weak head normal form (WHNF), this is a partially evaluated expression and what Haskell does by default. It only evaluates the bare minimum needed and leaves everything else as unevaluated thunks to be potentially evaluated later.

i wanna fug karen

I guess what I'm trying to wrap my head around with lazy evaluation the sort of scenarios where it can fuck you over.

Should I access array with

a[row][col] or a[col][row] ?
a[x][y] or a[y][x] ?

Thanks in advance.

Just use a 1d array.

The obvious one is that you may defer too much work. You can write programs in Haskell which will do nothing until you need to print a result to the screen, and then it will try to evaluate everything.
It can be to reason about the space complexity of your program. For example, you may have some large expression which should evaluate to an integer, but because it isn't needed it is left in its expanded form and takes up more memory.
There are other subtleties, in eager evaluation foldl is always at least as efficient as foldr, and usually better; but with lazy evaluation it which is better depends on the context what is being evaluated.

Oh, and it's objectively

data_2d[y][x]

&(a + row * col)

Depends on which order you want to access the members. If you are iterating through the entire multi-dimensional array, then you will get better performance by increment the left most index in the outermost loop and the rightmost index in the innermost loop. Traversing the array in the order it is laid out in memory will improve your cache performance.

JavaScript accepts both. If you’re having issues I would suggest switching to JavaScript.

That’s literally just the Assembly way in C.

It's not supposed to fuck you over, it's just supposed to not do work if the work doesn't have to be done.
However, if you are using a non-declarative language, and you have a method with a side-effect, you're probably going to have a bad time if you try to lazily evaluate it, because you won't know when the side-effect is going to happen.

install Elm instead

have anyone here followed ldd3? I cant compile shit man, missing headers everywhere

I like to think in a[row][col] first, which will result in a[y][x]. But this tutorial's source code is using a[x][y] first, that's why I'm asking the question.

I guess it's time for some refractoring.

Anyway, thanks for the answer everyone.

Attached: source code.png (1920x1040, 243K)

It's me, brainlet 128 bit san again.
I've moved over to trying double-double arithmetic. It seems more straightforward, but a ways into the paper I get really confused. They say their 256-bit number is 4 doubles. Then they say they need to be renormalized. Then they say the input for the normalization algorithm is a 5 component expansion. which is "produced". They don't say how we go from a 4 component to a 5 component, and all I'm looking for is 2 components anyway. It seems the entire thing hinges on this normalization happening but they don't explain it at all. They say the algorithm is "priest's" but that doesn't tell me anything useful either since his paper is much more complicated and doesn't deal with epansion at all.

Why can't math niggers ever explain themselves properly. Do mathematicians have telepathy?

Attached: f6cad5172e2e8d44da168d71b28d04bd.gif (647x363, 650K)

Is inferred typing combined with operator overloading a bad idea. Unlike most languages Haskell chose to use ++ instead of + for list concatenation. Is there a good reason for this or was it just autism?

autism.

Attached: autismcontainment.png (1006x1368, 90K)

++ is shit.
Use ~ or

>click on a youtube video that has an interesting programming project
>Oh yeah, this part MATH and you guys don't like it so I'll just skip
>Basically I'm created an algorithm, but I know the word algorithm scares you guys and it has nothing to do with AI so I skip explaining it
>Okay you guys told me code is boring, so I'll only flash it on screen for one frame, you can pause it if you care

Attached: 1532703285129.jpg (1024x576, 32K)

youtube programmers and game devs are mostly trash.
Only Jblow and brian mckenna are decent.

please respond

Attached: Cirno-nee.full.131792[1].jpg (492x815, 106K)

Racket is a blast. I understand why Clojure is more popular - given the power of the JVM infrastructure, but Racket is nice and light and DrRacket is handy, pleasant tool.

do I roost or hasgool?

eyedros

Just checked and apparently two of the most popular roguelikes : DCSS and Cataclysm-DDA are using grid[x][y] system, which means grid[col][row] or column-major order.
The tutorial that I follow also use column-major order, too.
well, whatever. I don't like it, but I'll just follow that convention.

Source:
en.wikipedia.org/wiki/Row-_and_column-major_order
github.com/crawl/crawl/blob/master/crawl-ref/source/dungeon.cc
github.com/CleverRaven/Cataclysm-DDA/blob/master/src/map.cpp
rogueliketutorials.com/tutorials/tcod/part-2/

Attached: 170px-Row_and_column_major_order.svg.png (170x227, 10K)

What power does the jvm have? only few ancient libs are useful like hadoop and spark but nothing more.

what makes a good youtube programmer? i’m trying to learn it

Isn't data stored row-majorly, making this slower?

Enterprise use

1. Knowledgeable and informative
You know exactly what you're talking about, and can inform the watcher on any level (be it shallow tldr - in depth). Please don't attempt to bullshit out of your depth or joke through incompetency.
2. minimal editing and decent production
I want to see the code, if you facecam, that shit better be tiny and in the corner. Most people watching programmers aren't braindead zoomers, so i don't want to see any WHACKY jumpcuts or LMAO XD zooms.
Honestly can't even think of a major third point, but Bisqwit is also good.
And also, don't become the failed programmer who only makes shitty tutorials. Absolutely abysmal.

Don't make videos longer than 10 minutes

idk, probably because some of them are just major mathfag and like to see array[x][y] instead of array[y][x].

In sensible languages you can redefine operator [][]

Never heard of what you're talking about but found this, check out the first footnote too. cs.cmu.edu/~quake/robust.html

You can store your matrices in either order, the order you choose depends on how you access data, in most cases it probably doesn't matter unless you know beforehand how the data will be accessed and if it favors one format over another.

Sometimes if you're working with another program it's best to just use their existing convention or else you run into some very annoying things if you have to convert between your type or another.

Also if you're doing something like this with matrices and working in c++ id probably just use Eigen.

why am I supposed to use static_cast ?

Attached: 1559351973975.png (726x694, 207K)

Any video, from crap to mediocre to quality will take a long time to produce. Maybe 10 hours of work to upload a 15 minute video...

Even as a hobby, and not getting much YT-bucks, getting demonified for any reason or no reason at all is highly demotivating.

Since it takes so many hours to prepare a video and write a script and edit and reshoot any scenes and redo bloopers... You might as well make fancy slideshows instead of handwriting with a stylus. Might as well make it nice.

You don't need animations as nice as the Brown & Blue math folks, they have a whole team making those....

Know that taking more than a week off will lose you many views! Consistency consistency consistency! That is the rule! Webcomics folks live and die by that too. Even die-hard fans drop away incredibly easily if you don;t keep them enticed. :/

restricted semantics and easier to grep, so others can find your idiocy faster (although this is more important for reinterpret_cast).

Any software developer here? How do you guys manage to spent time on this shit when you're coding for 40 hours a week already

there are 112 hours in a week

>demonified
I'm pretty sure the word you were looking for is "demonetized".

Easy, I spend half the day browsing 4channel and sitting in meetings.

I spend 2 hours working for my job and then I just do whatever lmao

Help a python brainlet out?

Should I use regex or map here? How can this be optimally condensed?

[str(i).replace('', '').replace('', '').replace('', '').replace('', '').replace('\n', '') for i in table]

k i'll continue ignore them then

>using regex to parse html
kys

(ruby)
table.map! { |s| s.gsub(//,'').strip }

what wrong with reggex

You're an idiot

You failed language theory 101 if you think that it's a good idea.

Attached: gOPS2.png (771x717, 73K)

parse
/pɑːz/

verb
verb: parse; 3rd person present: parses; past tense: parsed; past participle: parsed; gerund or present participle: parsing

1.
resolve (a sentence) into its component parts and describe their syntactic roles.

str(i).replace('', '') # resolves (a sentence) into its component parts and describes its syntactic role.

If i wanted to learn C++ from scratch nowdays what courses/books/videos/whatever are uptodate to teach "new" C++ instead of shit used in dinosaur code from 30 years ago? Should i even bother instead of just learning Rust, God they should just make C++ lite

Attached: 1541816120850.jpg (780x846, 53K)

learn c++ like everyone else, if you don't learn the old ways of doing thing you won't be able to read most of the code out there

You gotta think about the worth of putting such time into it and the results of doing so, especially since C++ jobs are actually quite sparse compared to your Python/C# shit

[i.replace(j, k) for j, k in dict(zip(['', '', '', '', '\n'], [''] * 5)).items() for i in [t.text for t in table]][-len(table):]

Isnt reggex slow as shit

isocpp.org/get-started
stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list

learn modern c++ or it'll make you want to kill yourself

Thats exactly what i want to do and thanks for the links user but how do i differentiate between old C++ and new C++ when searching for things?

I'm a remote contractor who works from home.
So I spend like 20 hours a week programming, and then charge for 40.

Attached: 1545170238526.gif (280x280, 171K)

A properly implemented regex engine is extremely fast. Too bad most languages fuck that up.
grep -E is an example of a well-implemented regex engine.

Regular expressions should only be used to parse regular languages. HTML is not a regular language.

How do i get a freelancer job that will give me atleast minimum wage (can even be webshit which i am decent at) ?

Modern c++ is basically c++11 and upwards, lots of things changed at that point. So if it doesn't use c++11 features it's shit.
Those books should show you how to write it in "modern" way and maybe let you know of what the old way was
if you see any C or C-style code in it it's shit
if it doesn't use RAII it's shit
if it uses new and delete it's shit
if it doesn't use STL whenever possible it's shit (algorithms and data structures)
I was looking for some projects the other day too, just search for "modern c++ projects" or something and people will list out some interesting ones

>if you see any C or C-style code in it it's shit

Cringe

C++ is not "C with classes and std::string", either use it properly or use your ancient piece of shit instead

I'm not a freelancer, I'm a contractor. My contract is indefinite, and basically functions like a normal full-time job, but is just set up that way for legal reasons (my employer is not in my country).
Basically, get good. And not just at anything, get good at something specialised that people will actually pay you for.

Sepplesfags are delusional.

Attached: 1493563363403.gif (740x416, 2.94M)

But C++ is also an ancient piece of shit

thicc loli

Thanks for your thoughts user!
>1. Knowledgeable and informative
I am probably more knowledgeable than informative at the moment. It would be good to strike a balance between these two.
>2. minimal editing and decent production
My editing is definitely minimal and so is production. It's essentially pre-recorded livestreams at the moment. I could probably cut out a lot of pauses and thinking, but I feel like that would take away from the authenticity. Oh and definitely no zooms or jump cuts, roger that.

Attached: oi1vh76mxsoz.jpg (720x960, 113K)

10 minutes is usually not enough to see a complex programming task through to the end.
I'm trying to show the entire process of programming, not just the "entertaining" parts.
I appreciate your input though, user.

If I use Xlib and I specify font as "fixed", how can I get bold, italic and other variations of that font?

Attached: 1559646810491.jpg (750x706, 134K)

>Using the deprecated library to the deprecated display server

nani

Attached: 1502250128955.jpg (530x800, 58K)

Is CS 61A a meme or will it actually help me learn?

>work at SaaS company
>the only bits of our back-end that aren't a horrid buggy mess are FOSS tools which do all the heavy lifting
>our job is to keep the bloody mess of script glue holding them together intact

HELP

there is no reason to choose one over the other and you're a fool for doing so because someone else does
computer video is tradtionally row-major because that's how monitors drew pixels but it doesnt matter now obviously

This shit is the brainlet filter that kept me from learning C.

Parsing a specific restricted set of HTML using regex can be perfectly valid and elegant, it's merely not up to the task of parsing arbitrary HTML, which you rarely need to do (e.g. if you're implementing a browser or some markup edit tool).

Write a C program, without using any (third party) library, that turns the central pixel of your monitor red.