/dpt/ - Daily Programming Thread

Charles Martinez
Charles Martinez

Old thread: jowforums.com/thread/69791055/technology
Spambot killed it.

What are you working on, Jow Forums?

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

Other urls found in this thread:

youtube.com/watch?v=N05yYbUZMSQ
support.sas.com/kb/24/590.html
youtube.com/watch?v=xuB1Id2Wxak
nim-lang.org
wiki.openjdk.java.net/display/valhalla/L-World Value Types
youtube.com/watch?v=_26KZAegYRM
graphics.stanford.edu/~seander/bithacks.html
jowforums.com/thread/69801449/technology

Luke Cox
Luke Cox

Spambot
And captcha did what?

Angel Sanchez
Angel Sanchez

first for 3 star programmers!

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

Hudson Perry
Hudson Perry

//boards.4channel.org/wsr/thread/629736#p629736

Jackson Lopez
Jackson Lopez

nth for Nim!

Lucas Long
Lucas Long

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

Alexander Edwards
Alexander Edwards

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 (745 KB, 1920x1080)

Liam Watson
Liam Watson

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 (129 KB, 1065x1375)

Parker Roberts
Parker Roberts

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. :)

James Morales
James Morales

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

Landon Hill
Landon Hill

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 (1.14 MB, 1280x720)

Lincoln Powell
Lincoln Powell

It just walks (tm)
hue

Nolan Green
Nolan Green

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.

Nathaniel Morgan
Nathaniel Morgan

coc.nvim and call them plugins negro

Xavier Thomas
Xavier Thomas

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.

Gabriel Kelly
Gabriel Kelly

nice but a bit creepy

Leo Ross
Leo Ross

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

John Long
John Long

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 (129 KB, 489x424)

Gabriel Green
Gabriel Green

this is why programming sucks and is also sort of pointless

Cameron Baker
Cameron Baker

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

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

Christopher Young
Christopher Young

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.

Bentley Brooks
Bentley Brooks

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

Anthony Bailey
Anthony Bailey

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.

Adam Stewart
Adam Stewart

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

Oliver Hall
Oliver Hall

yes, definitively.

Isaiah Gonzalez
Isaiah Gonzalez

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)

Landon Johnson
Landon Johnson

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

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

Thomas Torres
Thomas Torres

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.

Nolan Lewis
Nolan Lewis

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

Levi Martin
Levi Martin

why is cirno so small?

Liam Lopez
Liam Lopez

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

Attached: --cirno-touhou-drawn-by-pilky--0f341c9cd89ec76666ca16ec040d9cee.jpg (229 KB, 1000x754)

Joshua Gray
Joshua Gray

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

Jacob Rogers
Jacob Rogers

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

Justin Jones
Justin Jones

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

Jackson Howard
Jackson Howard

Cute++

Robert Hall
Robert Hall

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

Angel Bell
Angel Bell

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?)?

Jason Jenkins
Jason Jenkins

learncpp.com is pretty good.

Jack Williams
Jack Williams

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.

Aaron Gomez
Aaron Gomez

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.

Nathan Baker
Nathan Baker

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.

Samuel Nelson
Samuel Nelson

hundreds of useless pointer indirection

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

Tyler Bennett
Tyler Bennett

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.

Parker Morgan
Parker Morgan

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.

Tyler Jackson
Tyler Jackson

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

Justin Bell
Justin Bell

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?

Brody Smith
Brody Smith

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.

Leo Barnes
Leo Barnes

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.

Easton Smith
Easton Smith

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

Luke Myers
Luke Myers

daily reminder to stop using floats.

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

Carter Morris
Carter Morris

What if I want to have an overflow?

Chase Bell
Chase Bell

NaN is good, though.

Samuel Clark
Samuel Clark

youtube.com/watch?v=N05yYbUZMSQ

Cooper Lopez
Cooper Lopez

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

Joshua Nelson
Joshua Nelson

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

Blake Myers
Blake Myers

good post

Angel Roberts
Angel Roberts

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

Christian Bennett
Christian Bennett

What about div by 0?

Grayson King
Grayson King

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.

Jack White
Jack White

Funny because posits are faster than floats.

James Sanders
James Sanders

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.

Matthew Anderson
Matthew Anderson

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.

Connor Fisher
Connor Fisher

ini file with list of sites to ignore?

Kevin Gray
Kevin Gray

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.

Thomas Morris
Thomas Morris

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

Hunter Russell
Hunter Russell

not unless they're implemented in hardware like floats are

Bentley Gomez
Bentley Gomez

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

Zachary Perez
Zachary Perez

pointers
2019

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

Benjamin Morris
Benjamin Morris

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 (37 KB, 493x174)

Juan Peterson
Juan Peterson

Which they will be

Samuel Butler
Samuel Butler

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.

Evan Moore
Evan Moore

You can't avoid pointers user

Christian Roberts
Christian Roberts

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

William Phillips
William Phillips

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

Daniel Ortiz
Daniel Ortiz

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

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

Joshua Morris
Joshua Morris

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

Hudson Taylor
Hudson Taylor

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.

William Powell
William Powell

when?

Zachary Miller
Zachary Miller

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

William Bennett
William Bennett

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

Angel Sullivan
Angel Sullivan

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

Attached: church-alonzo.jpg (18 KB, 340x282)

Jacob Nguyen
Jacob Nguyen

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

James Campbell
James Campbell

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

Cooper Hall
Cooper Hall

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

Gabriel Lee
Gabriel Lee

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

Isaiah Rivera
Isaiah Rivera

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

Jace Gutierrez
Jace Gutierrez

learning Haskell

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

Wyatt Foster
Wyatt Foster

they have floats and ints

Lucas Morales
Lucas Morales

and pointers

Sebastian Edwards
Sebastian Edwards

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

Landon Sanders
Landon Sanders

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

Gavin Phillips
Gavin Phillips

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

Michael Baker
Michael Baker

what's the improvement?

David Lopez
David Lopez

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

Connor Jenkins
Connor Jenkins

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.

Adam Ross
Adam Ross

Speed, precision, and robustness

Josiah Sullivan
Josiah Sullivan

See

Ethan Evans
Ethan Evans

thats one hour long

Adam Martinez
Adam Martinez

Ok?

Easton Clark
Easton Clark

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

Logan Evans
Logan Evans

They will likely exist along side them for a very long time. Processor manufacturers do introduce new instruction sets and sometimes increase the precision of floating point values under the hood (like computing 64 bit doubles with 80 bit precision). It is not out of the question that a new data type (or new representation of an existing type) could’ve introduced. I do agree that they won’t drop current style floating point support, but if it proves better, then I can see it being adopted. My suspicion is that the earliest adopters will be on graphics cards.

Aaron Phillips
Aaron Phillips

There's lots of improvements, including efficiency and better mathematical consistency. I'm not fucking spoonfeeding you, go watch the video you dumb nigger. Until you do you're not allowed to have an opinion on posits.
You could also try not purposely ignoring

Justin Barnes
Justin Barnes

I dont have an opinion on posits, only retarded technology hipsters like you

Isaiah Barnes
Isaiah Barnes

In Java can I make a method that just accepts any type of object? String, list, whatever

Liam Walker
Liam Walker

Stop slowing down computers please.

Oliver Williams
Oliver Williams

I doubt you've ever written a program where it matters and you just read hackernews to find the next thing to act elitist about

Easton Baker
Easton Baker

That's nice and all but stop slowing down computers please.

Asher Rogers
Asher Rogers

What do you think about using <cstdio> in C++ instead of <iostream>?

Brandon Johnson
Brandon Johnson

id use them if hardware supported them

Gavin Gray
Gavin Gray

Idiotic. Just go back to C if you want to be retarded.

Camden Richardson
Camden Richardson

Then you're just gonna have to wait. Posits are still pretty new.

Lucas Bell
Lucas Bell

Can you argue for your strong views?

Luis Morgan
Luis Morgan

i dont care

John Wright
John Wright

tfw no VLIW CPU with scratchpad and posits

Ryder Sanchez
Ryder Sanchez

No, learn C++ yourself or fuck off.

Jonathan Wright
Jonathan Wright

wait a minute
shouldn't that be

*mp+sizeof(mp)

since mp contains a pointer to (address of) mp that is on the heap, say 1234, shouldn't mp+1 be 1235?

Parker Phillips
Parker Phillips

hurt durr, I want to deal with null bytes and want slow algorithms
C++ string and C strings are two separate things. If you don't know the difference, just use C++ strings

Owen White
Owen White

sorry i meant

mp+sizeof(mp)

Liam Cook
Liam Cook

Java’s Object type is the superclass of all objects, so your method could accept Object as a parameter. You may want to look into Java generics.

You also may want to ask yourself why a single method should accept any type of object.

Christopher Edwards
Christopher Edwards

They are tools, use them as you see fit. I feel like the C++ standard library does not have a suitable replacement for the scanf family, and printf can be much more clear than using the various ostream manipulators. Use what you need.

Landon Martin
Landon Martin

The user is casting the object back to the original later. Is it possible to store a generic variable too? From what I'm reading it doesn't seem so

Parker Rogers
Parker Rogers

Pointer arithmetic in this case means that mp + 1 moves one whole sizeof(mp) over. Note that:

(char*)(mp + 1) == (char*) mp + sizeof(mp) => true

Andrew Thomas
Andrew Thomas

Java has type erasure, so I’m not sure about storing a generic. However, you know what the type is and cast it back, wouldn’t overloading be a better choice?

Nathan Moore
Nathan Moore

thanks

Ryder Young
Ryder Young

Yeah this is much better thanks

Jeremiah Hughes
Jeremiah Hughes

can std::function be guaranteed to be equivalent to a pointer to a free function or should i just use plain old function pointers?

Isaac Mitchell
Isaac Mitchell

std::function is guaranteed to provide the small object optimization for a function pointer. That means it definitely won't allocate if you only store function pointers in it.
It won't be as efficient as a raw function pointer (the object will probably be significantly larger, extra cmps will be necessary to determine if the object is in the small state for invocation and in the destructor) but it shouldn't be a wide gap. Heap allocation is the biggie and that definitely won't occur.

Nicholas Gonzalez
Nicholas Gonzalez

Type parameters are not checked when you cast in Java. You can do it but it'll raise warnings because it can fail later.

If you want to add checks, see if you can use reflection and Class parameters.

Luis Allen
Luis Allen

im making a steam account manager because the ones that are out suck. how do i get c++ to do web things like check the account vac status?

Nolan Gray
Nolan Gray

use an http library and read the steam api documentation

Jaxson Johnson
Jaxson Johnson

Spent the last 4 hours implementing Unix domain sockets and porting my window server to communicate with clients using those.

that comfy feeling when the sun starts to set outside as your code comes together and everything starts working

Attached: Screenshot-at-2019-02-14-17-25-12.png (822 KB, 1920x1080)

Parker Richardson
Parker Richardson

Haskell is pretty fun to write. Not at all fun to read.

Ethan Carter
Ethan Carter

depends desu

Zachary Flores
Zachary Flores

Programming microcontrollers with C is maximum comfy
interrupts
no dynamic memory allocation

Attached: UGZ.jpg (58 KB, 800x913)

Xavier Rodriguez
Xavier Rodriguez

Unix domain sockets
sun
heh

Attached: 1547343221111.jpg (36 KB, 550x550)

Jeremiah Gray
Jeremiah Gray

best crash course on github?
is ti complicated

i want to upload my shit

Luke Harris
Luke Harris

which http library should i use? there are a lot

Blake Collins
Blake Collins

Femjeet on the tubes will spend roughly the first two-thirds of the video explaining Version Control, What It Is, Why You'd Want It, Why Linus Wrote Git, differences between local and central repositories, yadda yadda, blah blah. Gives a real-world example explaining why Dominion uses Github. Toward the last third she covers the creation of your Github account (pretty dummy-proof). I paused at this point to create an account and followed Github's very-short tutorial. Then covers using Git locally as far as making branches, adding changes, committing them, pulling/pushing from your Github, setting up SSH/GPG for verified/signed access to Github via Git, etc.

Decent tutorial on getting started but extremely long-winded (1h45m) due to all the introduction.

youtube.com/watch?v=xuB1Id2Wxak

Adam Brown
Adam Brown

does sepples have something like std::invoke_result but for arguments?

Thomas Wood
Thomas Wood

int foo(){
static int bar = 0;
return ++bar;
}

bar only gets initialised (set to 0) only once right?

Jace Rivera
Jace Rivera

imma skip the intro stuff, just do the git tutorial then maybe i might look at this vid, like you did

thx for the input, also i kind of got horny

now i got horny, somehow

Zachary Carter
Zachary Carter

yes

Gavin Rodriguez
Gavin Rodriguez

bar only gets initialised (set to 0) only once right?
Yes
And there is a race condition if called from multiple threads.

Ian Mitchell
Ian Mitchell

I'm I the only one who writes c++ here with the

if (condition)
{
statement;
}

style? It reads so much better than having your bracket right after the closing parenthesis....

Kayden Price
Kayden Price

yes and you should end yourself

Brandon Brown
Brandon Brown

i do

if  (condition && 
statement)

Benjamin Lee
Benjamin Lee

I do this

if( condition )
{
statement;
}

At least in my own code. I have never been in a collaborative project that has let me keep to that style.

Charles Diaz
Charles Diaz

What are you asking?
Do you want a type trait that will reflect what types an invokable type will take as arguments?

Kevin Morgan
Kevin Morgan

i basically want to write a function called invoke where i can do

int foo(int a, int b) {
return a * b;
}

int main() {
std::cout << invoke<decltype(foo)>(foo, 1, 3);
}

this code works for no argument functions but i want to be able to do arguments

template<typename Fn>
typename std::invoke_result<Fn>::type invoke(Fn f) {
return f(args);
}

Jacob Stewart
Jacob Stewart

return f(); *

Dylan Cook
Dylan Cook

Update to C++17. It has std::invoke, which I think is what you want.

Gavin Adams
Gavin Adams

yeah i think thats what im looking for

Christopher Walker
Christopher Walker

How do I get my interpreter to go faster? :(

Attached: 1549457206248.png (638 KB, 4760x4986)

Adrian Nelson
Adrian Nelson

Attached: the-f.jpg (7 KB, 214x190)

Thomas Wilson
Thomas Wilson

Use C++ templates and you can have this while also making it look like you know what you're doing.

Andrew Gonzalez
Andrew Gonzalez

I forgot to say 'pic unrelated'

Landon Moore
Landon Moore

are you using /ourlang/ yet?
nim-lang.org

Attached: Satania103.jpg (1.13 MB, 1920x1796)

Jordan Ross
Jordan Ross

begone nim shill

Colton Campbell
Colton Campbell

problem i have now is i have no idea how to declare a wrapper function for std::invoke

Kevin Phillips
Kevin Phillips

I'm not sure what you're asking. What are you trying to do?

Robert Jones
Robert Jones

i have structs that looks like this

struct GameObject {
VTable *vtable;

inline int foo(int a, int b) {
return this->vtable->CallFunction<int, int, int>(10, this, a, b);
}
};

whiere VTable is defined
struct VTable {

template<typename Return, typename... Args>
inline const Return CallFunction(std::size_t index, void *thisptr, Args... args) {
void *address = *reinterpret_cast<void **>(this + (index * sizeof(void *)));
typedef Return (*Fn)(void *, Args...);
return reinterpret_cast<Fn>(address)(thisptr, args...);
}

};

and instead of saying CallFunction<int, int, int> i want to be able to just say CallFunction<decltype(foo)>

Jaxon Clark
Jaxon Clark

anons pls

William Harris
William Harris

let's bring it back. Why are you constructing a "vtable" in the first place?

Bentley Watson
Bentley Watson

im not constructing anything myself im just casting pointers in memory to GameObject

Asher Roberts
Asher Roberts

drink half a glass of wine
completely unable to focus and code

Ballmer peak is a lie. There's no way alcohol makes people better coders.

Benjamin Torres
Benjamin Torres

Fuck, my brain isn't working right now. How to I traverse a tree searching for a particular element, in Haskell?

Jeremiah Harris
Jeremiah Harris

Why no one talking about python?

Attached: 1460623005667.png (37 KB, 1127x685)

Gavin Wright
Gavin Wright

yeah but I don't know what those pointers are for
I don't see what you're trying to accomplish

Ethan Russell
Ethan Russell

dumb frogposter

Nicholas Cruz
Nicholas Cruz

Uh, depends on what kind of tree you have?
Compare values, if it's less go left otherwise right?

Daniel Thompson
Daniel Thompson

A friend once told me that it's about drinking just enough to let go of your inhibitions while still retaining your critical thinking. That's when you get the briliantly creative solutions.

Mason Russell
Mason Russell

Tree with arbitrary number of children. Each node keeps a list of children.

Nolan Garcia
Nolan Garcia

It's not either or though. As much as you lower your inhibitions you also lower your general thinking. And I don't know what inhibitions people have when they're just coding. It's not like your IDE is a cute girl

Juan Moore
Juan Moore

we need to know more, e.g. is the position in the tree going to help you search somehow? if not literally check every element

Grayson Nguyen
Grayson Nguyen

Yeah but I mean it could be a binary search tree, it could be a red black tree it could be a heap etc etc. You probably need to post the type declaration to get proper help.

Jose Thompson
Jose Thompson

Not specifically programming, but I finally learned to use latex through a school assignment and I have seen the face of god

William Nguyen
William Nguyen

is there any kind of structure or order here?

Brandon Garcia
Brandon Garcia

Why do people use For loops so much?
I have always found while loops to be much more clear and flexible.
Also, when people are taught to program, emphasis is made on them all the time. Students are also taught to avoid GOTOs, when those can be quite useful sometimes.

The only time I use for loops is in their foreach modality, when I have to go through an array.
Am I missing something about them?

Attached: 1536030470868.jpg (33 KB, 480x466)

Zachary Allen
Zachary Allen

You probably need to post the type declaration to get proper help.
*and how you insert stuff

Connor Bennett
Connor Bennett

I mean it looks nice but I don't see when I would use it. I want to learn Org mode, that seems neato.

Josiah Jenkins
Josiah Jenkins

The only time I use for loops is in their foreach modality, when I have to go through an array.
Am I missing something about them?
No, that is what they are for. If you're not trying to be an overcomplicated meme programmer almost all you should be doing is iterating over entire contiguous arrays anyway.

Aaron Martin
Aaron Martin

It lets you gather all looping logic in one place, instead of as in a while loop where you split up declaration, condition and step in three different places.

Owen Roberts
Owen Roberts

What are you working on, Jow Forums?
a trade bot. a software that uses one of the most popular stock trading indicators to trigger buying and selling operations

Kevin Gray
Kevin Gray

yes
besides them being functionaly exactly the same and i could reword your questions as "why do some people say ketchup? I have always found catsup to be much more phonetically pleasing"
... anyways as far as being able to read code quickly and understand what is going on a for loop is used in distinct cases: where you wish to iterate a known number of times. for loops are used in the case where you wish to loop an unknown number of times;
for example:

//listen forever on a socket
while (true)
connection=socket.accept();

//listen forever on a socket
for (;;)
connection=socket.accept();


for something like this it would be strange using a for loop. but functionally the same. you use a for while loop because you dont know how many times to count. you use a for loop when you want to count.

Carson Miller
Carson Miller

Using it exudes professionalism

Jaxson Ross
Jaxson Ross

for (size_t i = 0; i < n; ++i)

for (int *it = arr; it !+ arr + n; ++it)

Choose.

Luke Hughes
Luke Hughes

I have always found while loops to be much more clear and flexible.
Yeah, and explicit stack manipulation is more clear (about what's happening on the CPU) and much more flexible than function calls, yet for some reason, people use functions
I don't get it either, PC gamer ethnostate user

Cooper Perez
Cooper Perez

It's just a tree. Each node has a label and a list of children.

if not literally check every element
Yeah, that's what I want to do. But I don't want to continue the search once I find the label I'm looking for.

Levi Perez
Levi Perez

!+
definitely this one

Connor Richardson
Connor Richardson

!+

Christian Parker
Christian Parker

//iteration with while loop
HashMap<Integer,String> mapper = new HashMap<>();
count=0;
max=mapper.size();
while (count<max)
//do stuff!
//done!

//iteration with for loop
HashMap<Integer,String> mapper = new HashMap<>();
for (int i;mapper)
//do stuff!
//done!

//iteration with lambda expression
HashMap<Integer,String> mapper = new HashMap<>();
mapper.forEach(e -> e.doStuff());
//done!

its all the same. its really about conveying what you are trying to do with easily readable code.
if you can read while loops and use them exclusively, go for it.
but its weird. broaden your horizens. your doing yourself a disservice

Ian Flores
Ian Flores

for (i in [0...n])

any language that doesn't have this sucks

Hunter Walker
Hunter Walker

Yep, that's why I love Python.

Aaron Russell
Aaron Russell

Python sucks for other reasons.

Aiden Brooks
Aiden Brooks

even sepples has that

Jordan Butler
Jordan Butler

I'm sure it really helps make your 30 line freshman CS assignments much easier to manage.

Parker Evans
Parker Evans

No, it doesn't.

Gavin Howard
Gavin Howard

Stfu and go back to your assembly code.

Gavin Lopez
Gavin Lopez

Started learning object oriented C++ and VHDL at university.

Michael Wood
Michael Wood

#include <vector>
#include <numeric>
#include <cstdio>

std::vector<int> range(int from, int to)
{
std::vector<int> r;
r.resize(to - from);
std::iota(r.begin(), r.end(), from);
return r;
}

int main(int, const char **)
{
for (auto &&n: range(1, 100)) {
std::printf("%d\n", n);
}

return 0;
}

Brandon Howard
Brandon Howard

vector
yikes
I can't wait for C++20 to introduce std::is_constant_evaluated

Anthony Nelson
Anthony Nelson

range(0, 10000000)

Blake Davis
Blake Davis

It has had that for almost a decade now.

Cameron Walker
Cameron Walker

Yeah, and you have to explicitly include the range function in everywhere you want to use it. It's not part of the language.

And wtf is up with those &&? Does C++ have to uglify everything?

Alexander Brown
Alexander Brown

move reference

Angel Garcia
Angel Garcia

And wtf is up with those &&? Does C++ have to uglify everything?
It is part of move semantics in C++. It exists because C++ is intended to be used for cases where people care about what the computer is actually doing, as opposed to 'import solution' in python.

Justin Flores
Justin Flores

(for [i (range n)] ...)

Chase Roberts
Chase Roberts

that's rich coming from

import everything
: the language

anyway because these are ints you can avoid it

Julian Hill
Julian Hill

I am not a language.

Andrew Rivera
Andrew Rivera

What's the best practice of querying a database in java when you have ORM, just use sql on the database itself or create objects and use streams and lambdas to filter/query it?

Attached: 1549467561333.png (61 KB, 234x236)

Zachary Long
Zachary Long

I mean this is obviously just minimal example, you'd make it proper, I'm just demonstrating you could make it like so

Isaac Price
Isaac Price

The thing with alcohol is you'll generally recall what you wrote and learned the next day. Meanwhile substances like weed cause short-term memory loss the very same hour. Sobriety is still key, though.

Jason Perez
Jason Perez

It's not like your IDE is a cute girl
his(her) IDE isn't a cute girl

Attached: 1548935222325.jpg (72 KB, 545x615)

Ayden Ross
Ayden Ross

looping over heap-allocated "objects"
No cache locality even in a list. Terrible performance.

Easton Turner
Easton Turner

I think my honeymoon period with Haskell is over.

Nicholas Perez
Nicholas Perez

How do I know if I know enough to get a junior dev job? Is there some checklist I can read to know if I have enough knowledge?

Attached: BillStickers.jpg (20 KB, 500x355)

Alexander Perry
Alexander Perry

In what instance there needs to be more than a lifetime in a struct in Rust?

Juan Foster
Juan Foster

is it possible to skip the first argument in template<typename... Args> when passing it to another function?

Parker Miller
Parker Miller

can you fizzbuzz?

Ian Hall
Ian Hall

I'm actually more productive after a beer. Usually I either suffer from analysis paralysis, or go full autist with micro-optimizations. Alcohol helps me to just solve the problem, and refine it later.

Liam Wilson
Liam Wilson

Post code.

Lincoln Sanders
Lincoln Sanders

How stacked are your monad transformers, user?

Brody Gonzalez
Brody Gonzalez

What's the best website for doing freelance work for my first time?
I'm a pretty average entry-level and I'd like to try to do freelance, rather than get a salary position somewhere, for the flexibility.

Robert Wilson
Robert Wilson

template <typename A, typename ... Args>

Cameron Green
Cameron Green

youcompleteme

You can't use templates with an ABI, that makes no sense

Carson Jackson
Carson Jackson

Of course, and I don't buy the meme that most people can't so stop it.

Attached: ijf.png (87 KB, 217x242)

Alexander Johnson
Alexander Johnson

Just match on it

template<typename Arg1, typename... Args>

Chase Jackson
Chase Jackson

When will Java get value types?

Joseph Peterson
Joseph Peterson

Hopefully never.

Dominic Hall
Dominic Hall

When Oracle can patent them

Landon Moore
Landon Moore

They're already working on them. The question is when.

Juan Harris
Juan Harris

but can you implement a recursive fizzbuzz with template metaprogramming in c++?

Attached: 1498208173734.jpg (40 KB, 500x500)

Hunter Nelson
Hunter Nelson

I want to see the design they arrive at.

Ryder Hernandez
Ryder Hernandez

Hopefully never.
Why?

Andrew Miller
Andrew Miller

Not that user but Java deserves to die and be replaced with better tech.

Bentley Moore
Bentley Moore

Isn't this what degree diplomas are supposed to be for?

Carson Walker
Carson Walker

don't you mean value classes :^)

Logan Parker
Logan Parker

Because I like knowing whether something is a reference or a value by looking at it. If the design does not preserve that, it's garbage.

Julian Nguyen
Julian Nguyen

I haven't even gotten so far as to not wtf at that question.

Cooper Brown
Cooper Brown

First you have to implement lambda calculus in templates, which can be done. Using that, you can easily create and compose functions. Using Church numerals as natural numbers and obvious representations of conditional expression and modulus operation, it is trivial to make FizzBuzz in such a system.

Jacob Powell
Jacob Powell

everything is a reference

Ian Fisher
Ian Fisher

Unless they add value types.

Eli Taylor
Eli Taylor

You don't even need to go that far. Just take advantage of template specialization and SFINAE.

Joseph Cook
Joseph Cook

std::vector
Fucking try again retard, this time do it with zero overhead.

Nolan Carter
Nolan Carter

I want to see the design they arrive at.
This is what they have so far.
wiki.openjdk.java.net/display/valhalla/L-World Value Types
youtube.com/watch?v=_26KZAegYRM

Carson Wood
Carson Wood

That's about as likely as C++ disappearing.

Nicholas Cox
Nicholas Cox

You don't even need to go that far

Attached: 1446268952202.jpg (2.02 MB, 1600x4480)

Jacob Lopez
Jacob Lopez

I think what he means is C++ already allows for what you seem to be trying to do without the use of void* or invoke wrappers. Unless you have a very large amount of functions where each may only be called by a small number of objects, inheritance is typically what's used. The vast majority of the time, between function overloading and inheritance, you will never need to create your own table of functions.

I also want to add that VTable's definition as posted has no member that holds the functions, and that functions shouldn't be held in void*

Aaron Murphy
Aaron Murphy

That's not likely?

Colton Rodriguez
Colton Rodriguez

The fact that she has to try at all is a failure on the part of the language.

Colton Perry
Colton Perry

functions being held in void* is legal if you're using a POSIX system. You're supposed to convert them to void(*)() or some other function pointer type, but I had trouble with this because I wasn't able to cast them at compile time

William Rogers
William Rogers

People may begin to build new projects on other platforms but there is so much existing code written in C++ and Java that I don't expect them to disappear anytime soon in a world where many businesses still depend on a language as old as Cobol.

Landon Cook
Landon Cook

just hacked in 10 minutes
You've been working in this for 3-4 weeks user.

Benjamin Cruz
Benjamin Cruz

he may have other responsibilities

Benjamin Reyes
Benjamin Reyes

Maybe he just means the code or the bot but not the whole project.

Michael Gray
Michael Gray

Learn OCaml or F#. All the fun of functional programming, while still having escape hatches to mutable, imperative programming if you need it.

Jason Carter
Jason Carter

what's a value type suppose to be? an immutable object on the stack?

Isaiah Wright
Isaiah Wright

Lisp is the most powerful programming language.

Eli Smith
Eli Smith

F# is underrated desu.

Sebastian Harris
Sebastian Harris

Yeah. A struct basically.

Ethan Kelly
Ethan Kelly

IIRC the goal is to let you do things akin to making an array of structs so you can get cache performance like you would get from C++

Bentley Jackson
Bentley Jackson

and the full support of microsoft

Henry Wilson
Henry Wilson

which makes it much easier to sell to your boss than haskell

Oliver Rogers
Oliver Rogers

One thing that makes it much easier to sell is also that it's on the .net platform, so if you have a C# codebase starting to use F# is not a problem, and there's also the massive ecosystem that comes with. It even has a full web stack that you can get professional support for, which Haskell doesn't. And I'm saying this as someone who loves Haskell.

Charles Ortiz
Charles Ortiz

Yeah, it's really nice. The only thing that really bothers me is no higher kinded types and no higher order modules.

Liam Roberts
Liam Roberts

Hopefully next week I can begin learning Rust. I'm getting tired of Haskell.

Oliver Lee
Oliver Lee

Anyone?

Landon Jackson
Landon Jackson

It is definitely stripped down in many ways.
Something I found myself enjoying though, and I know this is controversial, is that you have all your files ordered top to bottom and you can't forward reference. It just makes understanding the code so much easier.
I never did any larger projects in it, at one point you maybe split it up into several different projects.

Austin Walker
Austin Walker

Upwork.

Kayden Ward
Kayden Ward

So something I've been wondering. What do people code in Rust?
It's supposed to be an alternative to things like C and C++, how often is that performance actually needed? I can't think of as many use cases for it as I see people post about it.
I'm not dissing or anything, just interested.

Nathan White
Nathan White

Why use a database when you can just use a filesystem? Aren't filesystems technically databases too?

select name from table where name GLOB "*foo*";
$ for i in *foo*; do echo "$i"; done

Xavier Gutierrez
Xavier Gutierrez

because it's slow, databases are usually used when fast is needed

Luis Thomas
Luis Thomas

From what I've been told, it's a low level systems programing language like C/C++ but with better thread memory safety. The idea is to catch or prevent a lot of bugs at compile time. But I dunno, I haven't had time to look into it myself yet.

Tyler Martinez
Tyler Martinez

using a database management system provides a lot of features for accessing the underlying files

Charles Foster
Charles Foster

I meant more easily accessing the data contained in the underlying files

Owen Ramirez
Owen Ramirez

What do you guys think of this troubleshoot program I made?

print("Troubleshoot program")
choice = input("Have you tried it to turn it on and off again? (y/n): ")
if choice == 'n':
print("Try doing that")
else:
print("Look it up on Google then")

Chase Russell
Chase Russell

Here's my little C program for generating random numbers:

#include <stdio.h>

#define NUM_RAND 32

typedef unsigned int Uint;

Uint Gen_rand();

int
main(void) {
Uint rnd_num;

rnd_num = Gen_rand();
printf("Random integer is: %d \n", rnd_num);

return 0;
}

Uint
Gen_rand() {
Uint rand_data[NUM_RAND];
Uint temp /*= 0*/;
int i;

for (i = 0; i < NUM_RAND; i++) {
temp ^= ( rand_data[i] & (1 << i) );
}

return temp;
}

Anthony Bell
Anthony Bell

This solved my issue.

Nathan Wilson
Nathan Wilson

What are some dank /dpt/ memes to parrot at work? Want to look smarter.

Cooper Price
Cooper Price

try

John Nguyen
John Nguyen

very nice, user

Blake Nelson
Blake Nelson

Very good

Isaac Wilson
Isaac Wilson

Parroting /dpt/ memes makes you seem dumber.

Noah Rivera
Noah Rivera

Programming socks of course

Attached: programming-socks.jpg (70 KB, 1200x545)

Christian Ortiz
Christian Ortiz

Explain the maths please.

Charles Powell
Charles Powell

day starts
casually mention programming socks during team meeting
damn

Oliver Carter
Oliver Carter

Not random. Never assume uninitialized memory is unpredictable.

Attached: Screenshot-2019-02-14-12-52-17.png (52 KB, 362x330)

Thomas Collins
Thomas Collins

haskell

Attached: 1550069346175.png (1.12 MB, 1700x1374)

Ian Adams
Ian Adams

Upwork
Thanks, I'll check it out in a bit.

Juan Wilson
Juan Wilson

I could fix the buffer overflow or I could just allocate more memory.

Attached: 1549331418744.jpg (51 KB, 1280x720)

Owen Fisher
Owen Fisher

It doesn't look very random.

    for (size_t i = 0; i < 10; i++) {
rnd_num = Gen_rand();
printf("Random integer is: %d \n", rnd_num);
}

Random integer is: 4194304 
Random integer is: 4194333
Random integer is: 4194331
Random integer is: 4194331
[Our system thinks your post is spam.]

Brayden Watson
Brayden Watson

That can depend on who's managing the database or the software querying it
use Proprietary Enterprise CMS™ with an Oracle Database™ at work
publishing ~2000 documents out of it takes over an hour
pull out the underlying document files and create some tools based on dirent.h, standard shell globbing and stdin/stdout
get same output in less than a minute

William Reed
William Reed

This is the best way to make your colleagues jealous and get a raise.

Carson Johnson
Carson Johnson

It allocates an array of 32 integer numbers, each containing a random value.
Then it loops through all of them and checks one bit from each of them. If the bit is set, corresponding bit is toggled in the "temp" variable.

Isaiah Mitchell
Isaiah Mitchell

user, why are you spamming?

Attached: 1549651162378.jpg (85 KB, 680x680)

Nathan Gray
Nathan Gray

Memory safety
Generics and polymorphism
All fads parroted by indoctrinated CS students which will pass in time.

Dylan Richardson
Dylan Richardson

learn to code

Daniel Hernandez
Daniel Hernandez

All fads parroted by indoctrinated CS students which will pass in time.
Except for the ones I parrot, of course.

Attached: enemy-of-the-state.png (84 KB, 478x618)

Jordan Reed
Jordan Reed

noice

Jose Martin
Jose Martin

an array of 32 integer numbers, each containing a random value
Wrong.

Attached: 1547106823556.png (278 KB, 960x960)

Tyler Walker
Tyler Walker

But explain the math please.

Brayden Wood
Brayden Wood

disregarding the fact they're not random, why allocate 32 random numbers to produce just one?

Jace Bennett
Jace Bennett

Just a little fun exercise in bitwise logical operation

Christian Torres
Christian Torres

lisp > haskel

Mason Robinson
Mason Robinson

graphics.stanford.edu/~seander/bithacks.html

Benjamin Price
Benjamin Price

cniles and their UB, never gets old

Evan Ross
Evan Ross

what's the best mix of lisp and haskell?

Christian Nelson
Christian Nelson

i'm making doom (or as close as possible) for the sega genesis

Attached: smush.webm (723 KB, 588x480)

Angel Gutierrez
Angel Gutierrez

Compilers
Server shit
Data processing
Driver shit
Video games

Jose Lee
Jose Lee

nice

Attached: 1549478852836.jpg (10 KB, 238x211)

Jordan James
Jordan James

idk, common lisp with monads?

Nathan Richardson
Nathan Richardson

100% hasklel

Oliver Torres
Oliver Torres

jowforums.com/thread/69801449/technology
jowforums.com/thread/69801449/technology
jowforums.com/thread/69801449/technology

Luke Sanders
Luke Sanders

What are you working on, Jow Forums?
Well... I'm throwing GNU MP at all Project Euler problems instead of thinking of good algorithms myself and it works.

Attached: Screenshot-20190214-222056.png (310 KB, 1920x1044)

Caleb Brown
Caleb Brown

have you considered using a programming language that has bignums built in?

Julian Clark
Julian Clark

Yes, I solved them before (not all of them of course, just a couple) using Haskell.

Jason Barnes
Jason Barnes

Stub things out or do the simplest implementation. Also, aggressive YAGNI.

Anthony Hall
Anthony Hall

Qt Creator is so dang comfy :)

Mason Scott
Mason Scott

Very cool project user

Samuel Adams
Samuel Adams

Does dereferencing in this way

int &deref(int *x) {
return *x;
}

actually do anything?
I was under the impression that, assuming the function isn't inlined, this is equivalent to just returning a pointer under the hood.
Then I passed the function nullptr and GDB says it segfaulted inside the function. How is that possible?

Disable AdBlock to view this page

Disable AdBlock to view this page

Confirm your age

This website may contain content of an adult nature. If you are under the age of 18, if such content offends you or if it is illegal to view such content in your community, please EXIT.

Enter Exit

About Privacy

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. We also share information about your use of our site with our advertising and analytics partners.

Accept Exit