/dpt/ - Daily Programming Thread

Old thread: Spambot killed it.

What are you working on, Jow Forums?

Attached: 1548642826925.jpg (826x610, 60K)

Other urls found in this thread:

youtube.com/watch?v=N05yYbUZMSQ
support.sas.com/kb/24/590.html
twitter.com/SFWRedditVideos

>Spambot
And captcha did what?

first for 3 star programmers!

Attached: dpt 3 star programmer.png (868x1228, 884K)

...

nth for Nim!

just suck days of your life away slowly year after year
you know, nothing much

Refactoring my syscall-based windowing system to be message-based. Getting closer and closer to being able to run the window server in userspace rather than in the kernel, which is going to make everything (especially debugging) so much nicer.

Attached: Screenshot at 2019-02-14 09-41-14.png (1920x1080, 745K)

What OS is that for? Is it something you wrote yourself?
I happen to be somewhat of an expert when it comes to windowing systems, but that's only for Linux.

Attached: 1548751212813.jpg (1065x1375, 129K)

Yeah it's for my own Unix-like OS. I started out with the windowing system in the kernel since it was easier to access mouse, keyboard, video memory, etc. Now I'm reworking it piece by piece to work in userspace (accessing keyboard and mouse through /dev/ files, etc, using shared memory for bitmaps, etc.)

Do you have any thoughts on how to implement efficient window resizing? That's something that's gonna come up eventually. I'd like the window contents to be visible and updating as you resize. :)

what add-ons do I need to make vim helpful in programing c++ ?

>What are you working on, Jow Forums?
fun things.

It just walks (tm) (not exactly stable, because this was just hacked in 10 minutes)

Attached: itwalks.webm (1280x720, 1.14M)

>It just walks (tm)
hue

Interactive resizing is probably going to end up being demanding no matter how you do it.
Wayland clients (what I'm familiar with) are expected to just keep up and post full frames as it gets resized. If it doesn't keep up, then their content just doesn't change, and their content will finally be updated when they're done.
When it comes to shared memory, instead of having one shared memory object per buffer, they get allocated from a pool. If you're smart enough with your pool allocator, you may be able to reuse some of your buffer contents while shrinking, but you'll probably have to redraw everything when expanding. Basically, make sure you have the option of having your buffer-stride != buffer-width.

coc.nvim and call them plugins negro

Yeah, that makes sense. I've definitely been playing it fast and lazy with assuming "buffer-stride == buffer-width" in a bunch of places, knowing that it's gonna bite me eventually :|

A pool allocator for the buffers is definitely something I'm gonna wanna do. I'm also thinking I would use an oversized buffer during the resize, so that there's room to grow without reallocation. Then when the resize is committed, I can carve out a perfectly-sized buffer for the longer-term.

nice but a bit creepy

That's because it walks the creep gait (literally)

>Want to implement A
>That is going to require implementing B
>Try to implement B
>That is going to require implementing C
>Repeat
This always seems to happen. My one change is probably going to change the entire codebase.

Attached: 1548897321647.png (489x424, 129K)

this is why programming sucks and is also sort of pointless

Is void* slower than C++ templates in terms of achieving function parameter polymorphism

Attached: 1546186216676.jpg (400x393, 49K)

It depends. Templates easily result in code bloat if you overuse them, which results in poor instruction cache utilisation. But in most cases the lack of indirection and inlining optimizations will improve performance.

Hahaha, good question. The answer is a plain yes. Ctards will try their best to control the damage.

>templates were a mistake
>regress back to void*
C boomers don't understand their own code

Void pointers don't lead to multiple copies of a function being generated (i.e. bloat). If I'm trying to keep a stable ABI for other languages to FFI to, I'm staying well-away from your template garbage.

void* lead to hundreds of useless pointer indirection and also makes you allocate memory needlessly. If I'm looking for performance I would stay the fuck away from that type unsafe, slow, unreadable and inefficient dumpster fire and use C++ that has Itanium ABI

yes, definitively.

There are a variety of differences between void* and C++ templates, a better comparison would be macros and templates. If you used templates to do pointers, you would probably get the same performance (but multiple instantiations doing the same thing)

What lang is the best lang and why is it C++?

Attached: 1402864310190.jpg (96x96, 5K)

There's a difference between the language ABI and library ABI. C++ does (defacto) have a stable language ABI on most platforms but most libraries (including the standard one) don't care or are unable to have a stable ABI.

Basically you don't have a stable library ABI unless you use pimpls everywhere - which aren't much different from void pointers.

>What are you working on, Jow Forums?
Wondering how to get travis+deployment working on my repo.

why is cirno so small?

For speedy posting. Here's the full size version.

Attached: __cirno_touhou_drawn_by_pilky__0f341c9cd89ec76666ca16ec040d9cee.jpg (1000x754, 229K)

What's a good C++ book that doesn't act like you've never seen a computer before and isn't 2+ decades old?

>good C++ book
That's an oxymoron, because C++ is a horrible language.

Well I'm a horrible person so it all works out in the end.

Cute++

Attached: 1542400413958.png (810x1000, 67K)

typedef struct {
int a;
short s[2];
} MSG;
MSG *mp, m = {4, 1, 0};
char *fp, *tp;
mp = (MSG *) malloc(sizeof(MSG));
for (fp = (char *)m.s, tp = (char *)mp->s; tp < (char *)(mp+1);)
*tp++ = *fp++;

I understand everything except
tp < (char *)(mp+1)

part. What's the purpose of testing tp, which is a pointer to s in the *mp struct on heap, is it smaller than (mp+1), which is pointer to next address after mp (second MSB byte of a?)?

learncpp.com is pretty good.

Accelerated C++. It's old as fuck, but 99% of it is the same shit as now and the other 1% is easily supplemented. Plus seeing how shit used to be done will give you a better understanding of the problems the more modern features are trying to fix, which is helpful since they haven't actually managed to fix any of it.

Templates weren't meant as a replacement for void* use. They were a replacement for the 'macro template' use and copy/pasting the same function for every type.
The cost of void* use is visible in the function you write.

Elaborate those points.
>hundreds of unnecessary pointer indirections
That's just any use of references as far as I can see. Even if you nest void* functions it's still just single indirection.
>allocate needlessly
Maybe you're talking about discriminated unions here? It's not a general void* problem.

>hundreds of useless pointer indirection

x86 architecture supports true indirection so the cost of "useless pointer indirection" is roughly zero.

This is why people are addicted to being generic. They don't view the tradeoffs well. Planning your entire code base be robust to change in this way is a huge cost. But I think people have an easier time accepting that because they convince themselves that the system they're making is difficult to make.
Going back and changing things is less appealing because you felt you were done last time. You have to strike a balance.
Abandoning this notion of having future proofed your code perfectly should also help. To spend your work hours wisely you should either know that your requirements won't change and just write the minimum, or you should find what's likely to change and write that in a way that accounts for some of the likely changes.
Comes with experience.

Education pushes the idea of generic programming because they're trying to make you employable and employers want generic code that can be reused indefinitely in any number of projects.

>Even if you nest void* functions it's still just single indirection.
a single indirection but on every call.

How do key protect an API? I mean google check for things like IP, URL and APP, but I can't do all that.
The way I figure is you create a pair of keys on login, give one to the user and keep the other one. Everytime the aplication calls your api, it would send you the user's key and you'd combine with yours in order to validate the key.
You'd be able to invalidate your half of the key or do things like pushing a new key to you and the user on update.

Did I get it right?

Apparently, people in Jow Forums accept and even vist reddit, nowadays.

Which of their board is good for asking intermediate /dpt/ questions? Because, what I found so far is dumber than facebook.

>Going back and changing things is less appealing because you felt you were done last time
Nah, I don't feel that way about this code. I don't have any qualms about burning it to the ground and starting over until it's perfect. It just takes bloody ages.
Unfortunately it's a library that actually has some users, so I need to be a bit more careful. We haven't promised API stability yet, though.

Part of the changes I need to make are to make things a bit more extensible, so I don't have to keep breaking APIs and shit in the future. Trying to stay on the bleeding edge of features doesn't help, as sometimes the fundamental assumptions in your code change.

It'll probably be cached, so it'll be fast as fuck.

mp+1 increments mp by the size of its entire struct, so it's just checking if tp is out of bounds

daily reminder to stop using floats.

Attached: beating-floating-point-at-its-own-game-posit-arithmetic-23-638.jpg (638x359, 67K)

What if I want to have an overflow?

NaN is good, though.

youtube.com/watch?v=N05yYbUZMSQ

Yes, let's slow down all computing because you can't be bothered to check you variables.

Keep using format from 1914.
Im willing to bet that you are also C tard.

good post

With hardware support, it should be faster, not slower.

What about div by 0?

This iterative process will help you start to learn why certain patterns exist, when you should use them, and how to better plan your software’s architecture. Be glad you recognize those needs, because there are people out there that will shoehorn anything into what they already have.

Funny because posits are faster than floats.

Templates are ran at compile time to create code. void* allows lookup at run time. There are cases where either could be used, but I would try to use them for different things. Templates do slow down compilation.

I'm working on a bash script to fetch links for a particular pornstar given her name as parameter.
It looks up on several sites, but some return spurious results (videos that are not related to the input pornstar) and the program has to be adjusted.
Given how sites tend to change, I would like to make the script more robust, allowing the user to disable certain sites, and enable the rest.
Which is the best (more readable or user friendly) way to achieve this? I use a switch statement with a case for each porn site.

ini file with list of sites to ignore?

Yes. The compiler can optimize much better with the type information avaliable and potentially collapse a lot of code. void* generics can't do that. They're not allowed to make any assumptions, so their codegen is pretty horrible and inefficient.

I don’t understand why they did that anyway. Why not use memcpy?

not unless they're implemented in hardware like floats are

>poor instruction cache utilisation
will never be any slower than a void pointer

>pointers
>2019

Attached: no.jpg (816x488, 186K)

If any of you guys are familiar with SAS, I'm learning and having a problem. I have a txt file that I'm reading in and I'd like to also create new variables and have them included in the table, all within the data step.

Here is my code without the new vars added

data currency2;
infile '/folders/myfolders/sasuser.v94/currency.txt';
/*SET sasuser.college*/
INPUT CurrencyNotes$ PurchaseDate$ PurchaseValueperUS SellDate$
SellValueperUS NumberOfNotesPurchased;
run;

I'm reading the date in as a string because in my output, if I do date mmddyyyy.10 then it breaks the table. Everything prints fine if I do it based on strings, except when I create the new variables. One of the new variables I'd like to make is TimeHeld which is two dates subtracted from each other. I don't know how to do this if they're in string format. Remember that all of this has to be in one data step.

Attached: Capture.jpg (493x174, 37K)

Which they will be

This. A white list and a black list. If you want, you could even give your site lists ranks to prioritize them, and log unsuccessful download attempts.

You can't avoid pointers user

just finished automate the boring stuff with python. loved that it felt like I was using stuff on real world problems. what book do I read next?

also why is Jow Forums missing 6 pages of posts

if script works only for set of specific sites I'm not sure whitelist would be a good idea, since someone could put there a site that the script doesn't handle and then be confused why results don't include that site

>he doesn't know about functional programming, garbage collection, or logic programming

Attached: qOJAKMb.jpg (992x744, 89K)

Please only reply with relevant content to the post you're responding to.

Pointers are a fundamental "type" for CPUs. Hiding it behind shit and slapping a smiley face on it doesn't hide the fact that they're still there.

when?

>Pointers are a fundamental "type" for CPUs
no theyre just ints

Which is why I used the scare quotes. CPUs and assembly don't actually have types.

>2019
>still writing code for the machine, not for people to read

Attached: church_alonzo.jpg (340x282, 18K)

Who cares about the CPU? What matters is the semantics of the programming language.

Yeah, blacklist.txt next to the script would make the most sense. Thanks.

I don’t know SAS and had never heard of it outside of limey special ops, but check this:
support.sas.com/kb/24/590.html
>The following code starts with a character string "12JUL2016", creates a SAS date, and then formats it with the DATE9. format. The end result is a SAS date that looks the same as the original variable, but can be analyzed and manipulated by the date functions:

It seems like their example code is different from what you posted in terms of creating a variable and calling format on it.

HTH

They already are in some processors. Once they prove themselves they'll probably replace floats in all processors at some point.

>CPUs don't have types
False. They're just really weak types and are specified by the instruction rather than tied to the data.

learning Haskell

penis :: Int -> String
penis 1 = "Penis is One!"
penis x = "Nice Penis"

they have floats and ints

and pointers

yeah a new data type of questionable improvement is going to completely replace the old one that millions of programs depend on
that's such a Jow Forums thing to say

>questionable improvement
definite improvement
And I said, once they prove themselves.

they're ints
floats and ints different types of data with different operations, pointer operations are int operations

what's the improvement?

Nearly all programs that use floats could instead use posits (if float instructions are translated to posit instructions) and expect an improvement.

You don't know what types are. Types != data representation.
If CPUs don't have pointer types, then tell me how the CPU knows to dereference the address in mov eax, [ptr] instead of loading the value of ptr itself into eax.
That's right, because CPUs have types that are just really weak and specified by the instruction rather than tied to the data.

Speed, precision, and robustness

See

thats one hour long

Ok?

You expect me to watch a one hour video when you could answer the questioin in 5 seconds?