/dpt/ - Daily Programming Thread

Welcome to /dpt/! Just remember to follow the rules and we'll all have a good thread together:

>no Windows
>no OO
>no dynamic languages other than lisps
>no Nvidia
>no webdev
>wear programming socks

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

Attached: 1200px-Commutative_diagram_for_morphism.svg.png (1200x1200, 29K)

Other urls found in this thread:

blog.cleancoder.com/uncle-bob/2016/07/27/TheChurn.html
cplusplus.com/reference/string/string/end/
stroustrup.com/bs_faq.html#prerequisite
twitter.com/NSFWRedditImage

stop making shitty OPs, neckbeard

>no Nvidia
Do I have to unplug my GPU and use my integrated graphics to view this thread?

yes
only fully DX12 compatible intel discrete vidya cards are allowed to render this web page

What about AMD?

What do I need to know in order to find a job as junior C/C++ developer?

C/C++

>What do I need to know in order to find a job as junior C/C++ developer?
hindi

is it the first DX12 compliant gpu? I don't think so

Is it true that nobody needs juniors? And the only viable salary is for middle/senior with 3+ years of experience? (outside of US)
What to do, then?

git gud

get 3+ years of experience :^)

that's not an anime girl

>tfw own a 1050Ti because all the AMD cards are obscenely expensive

If you're good with C, understand how to make your own zero-cost abstractions, you could find a place in embedded very easily.

Attached: 1492832377473.png (1052x1342, 769K)

Kind of a data science question maybe??????

For a while now, my default behavior as soon as I hop on the chons is to go to the catalog, sort by reply count, and wade through the top threads opening interesting-looking ones in separate tabs; it's my way of slowly digesting all the happenings going on currently in a given board.

It works because a ton of replies generally indicates a quality thread, obviously - probably a Law of Large Numbers thing or some shit idk. At minimum they're controversial, so I'm at the least guaranteed a solid read. But I'd like to catch some of the less mainstream threads you know, man, like, the ones that never garner enough replies to show up very high on my sorted catalog, but are still of genuine interest.

I was thinking it might be easy to whip up a simple algorithm like Reddit's "Hot" sort feature, which sorts threads according to some metric like - i.e. the avg. amount of time for each reply to be posted.

I guess I could just poll the # of replies for each thread and divide by the amount of time it's been alive to get that metric above. Any other ideas for ways to filter threads in interesting ways? I'm a very brainlet programmer and definitely no real background in big boy data science but just curious.

Attached: exhibit_2[1].png (588x476, 25K)

shit, forgot to add my question: what are your favorite macro functions, /dpt/? I'm making a library of useful/interesting C macro functions.

>>wear programming socks
good post user!

for(int i = 0; i < 10; i++){
static int n; //static initialized to 0
/*Do things with n and save value for next iteration*/
}

vs
int n = 0;
for(int i = 0; i < 10; i++){
/*Do things with n and save value for next iteration*/
}


What's the difference?

Guys I can't solve a quarter of the easy problems on leet code

I've started drinking tea but it isn't helping

Attached: 1530986416998.jpg (960x680, 36K)

I always use the second one but I'm a noob

the one with the static int will take up a little more space since the int exists forever, whereas the other one just puts the int on the stack, and it fucks off when it goes out of scope.

Also, if that block of code is called again, the static n will have whatever value it had at the end of the for loop last time, where as the stack n starts at zero each time the block of code id called.

I'm aware. The question was mostly hypothetical, couldn't think of a perfect example. I think I'll use the static version where possible to keep variable in scopes they belong in.

Try harder. Put the problem off and try to solve it later on, again. If you felt that you put 100% effort, look into discussions and take a look into posts with top rating.
If you prepare for the interview, it's better to skip the first part and just try to understand the solution.

>I've started drinking tea but it isn't helping
drink more!

i use second one

does
>no OO
mean no Object Oriented ?

OOP is objectively cancer

coffee is your answer

*POO

do you prefer functional or other paradigms?

ah, my bad. Thought you were asking as a beginner. I very, very rarely use the first one, thought I suppose it has its merits. I try to avoid both by cramming everything I can into the for loop condition itself.

not him but the real cancer is that OOP is taught and used as if it's how -everything- should be done. many programmers seem to think OOP is the end all be all with no reason not to use it, and no reason to use any other paradigm

Imperative is fine. The whole object thing is a mess.

it's used in research because scientists can't program
python is for toddlers who don't know any better. No one builds an actual software infrastructure or scalable web app in python. All the research shit is actually written in C/C++ and python is just used as a wrapper, e.g. machine learning. The output models are then used in a Java/C++ Infrastructure.
Stop talking when you have no clue, python baby.

Friendly reminder that OOP is good and battle tested. If you fall for meme languages you are part of the problem

blog.cleancoder.com/uncle-bob/2016/07/27/TheChurn.html

t. c-hacker
t. jobless neet who never built large scale software

pretty sure the first one isnt thread safe

You're abusing the static keyword. Also, static memory is supposed to be zero init'd, but it's not guaranteed.

reminder that sepples professionals lost hard to 90s haskell learned by a college grad in a week.

in the 90s
Modern c++ is not comparable

sepples would still lose. No amount of meta-wank can save it.

>If you're good with C, understand how to make your own zero-cost abstractions, you could find a place in embedded very easily.
you could say the same of C++, though to be fair, much of the embedded industry is held back by autists who are violently allergic to the idea of learning C++ and simply prefer to comfort themselves with the braindead assumption that every abstraction beyond the handful they're familiar with must necessarily incur some performance/resource cost

>what are your favorite macro functions, /dpt/? I'm making a library of useful/interesting C macro functions.
in C++ this could essentially just be a library of actual functions thanks to constexpr. turns out it's possible to do computations at compile time with high-level language semantics and type safety instead of basic string substitution

C++ is faster than haskell, fact

>I try to avoid both by cramming everything I can into the for loop condition itself.
I hate you

at the cost of compile times, 5x LOC, and sanity.

How would I go about making a cell ref a variable in Excel?

For example, I have column A and B and wanted to sum the difference between A and B without Summing A and B separately.

I could do
=SUM(Ax)-SUM(Bx)

But I want to state it as
=SUM(Ax-Bx)
Where x is a variable formula for the row number.

Any ideas?

possibly dumb c++ question

if string::end returns the past-the-end character of a string, how do I get the actual last character of the string so my loop doesn't execute one extra time?

looked at this:
cplusplus.com/reference/string/string/end/

on second thought that probably doesn't even make sense. I'll just rewrite what I have.

Reddit programmers are mental retarder.
>plain text passwords are good idea.
Some very easy upvote vs downvote using reputation.

What are you talking about? If the condition is `it!=str.end()` then the loop won't execute "one extra time".

checked my output again and yeah I'm just dumb

>It's a 'nasally German söyboy who studied game development in college' CPPCast episode again
Why do they let these faggots on?

It's a problem from somewhere else in my method, not the loop.

i thought modern browsers would request /favicon.ico and set that as the favicon? but why is it still loading the spring leaf default ico?

HOW TO SET FAVICON IN SPRING-BOOT NONE OF IT WORKS

Attached: why wont this load favicon.png (1206x823, 104K)

Haskell is way better than C++ though
>that's not an anime girl
where is the proof?

OFFSET

QUAVO

web crawl the html pages and get the timestamp data then output the way you want. perhaps you wanna construct an addon for firefox/chrome?

Board/Catalog/Thread so thats n^3 for one instance

Where do I start with functional shit?

your favorite search engine.

best c book?

Attached: 1499366919073.png (364x599, 465K)

the browser requests the favicon on port 80, that is on port 8080.

minor correction, the browser requests the favicon on 80 or 443 depending if it's https:// or not

OR... if I'm wrong, try clearing cache and see if that works. Sorry for shitting the thread up.

can we talk about C though?

Probably a retarded question but is learning C beneficial to learning C++?

it's cache, custom favicon works fine on 8080

how? linux does not have disk cleanup? also how do i make sure that it does not save cahce at all so it doesnt mess with my debugging

According to Bjarne Stroustrup, no.
stroustrup.com/bs_faq.html#prerequisite

The browser caches it, not the OS or kernel. To prevent this, refresh your pages every time with CRTL+SHIFT+R (if on chrome). Not sure what it is with other browsers.

MOTHERFUCKER
so I spent all day yesterday and its all because the browser save a cache? fuck this shit dude, is there a proper browser for debugging purposes?

I received a job offer from a Big100 company but am unsure of whether I should actually take it or not. They have their entire workforce in a single group photo- there's absolutely no hispanic males working there. I'd feel incredibly out of place considering half of the workers are women and the other half are white or pajeets.

What do?

We're learning Java in my new CS course
What's the best book for a numbskull retard who only knows Python?

Attached: 1481793680019.jpg (1024x683, 426K)

The best book is google

Attached: 1488050865658.png (696x658, 907K)

i currently use firefox for my webdev shit.
If you already use FF, then install icecat or another derivative.

Chrome/chromium is what I use... if you want you can open the dev console with CTRL+SHIFT+J, go to the Network tab, and you will see a checkbox that says Disable cache. If you select it, the browser will not cache anything (while dev console is open). OR, you can just press CTRL+SHIFT+R every time which clears cache, then refreshes the page.

haha, this shit happened to me a while back too. you have to delete the fucking icon database (icons.sqlite or something like that) for it to refresh

Not him but C is better than either tbqh fampai
>extremely terse
>lightning fast
>zero bloat
>little to no """type safety""" (which is in practice nothing but a pointless obstruction to efficiency spun on the misguided principle that values shouldn't be freely reinterpreted between types or else "hurr durr oh noooo BAD things will happen"; newsflash assholes, safely operating on the underlying byte representation of data by construing the same data in terms of different types is fucking TRIVIAL if you know what you're doing, and can also easily be done portably and without violating the standard)
>has mostly all the features one needs (things you do not need: lambdas, because you can just use pointers to static functions; closures, because you can just use extra parameters; generics, because you can just use void pointers; overloading, because you can just use higher order functions)
>despite its limited type system and lack of overloading it manages to be highly expressive just because of how succinct it is and how much shit it lets you slip past the radar
>why do you even need to work with multiple types anyway, there are really only two types you ever need to concern yourself with, int and char*

>there are really only two types you ever need to concern yourself with, int and char*
don't you mean three, can't forget the all mighty void*
but
>the absolute state of cniles

>prefer to comfort themselves with the braindead assumption that every abstraction beyond the handful they're familiar with must necessarily incur some performance/resource cost
This. At least you've never seen embedded people's code on desktop.
>mfw trying to explain that sleep(1) on Windows and Linux doesn't actually sleep 1 ms due to how scheduler works
>"But it worked for me!"

>don't you mean three, can't forget the all mighty void*
don't need it, char* serves the same purpose

>char* serves the same purpose
jesus christ c is so awful.

how is that awful? it makes perfect sense in every way that a pointer to a byte is by extension a pointer to any arbitrary kind of data, since all data (or at least all data that can have a type) is stored as an integer number of bytes.

>much of the embedded industry is held back by autists who are violently allergic to the idea of learning C++
Until ARM, even the tiniest abstractions were too much. It wasn't uncommon for an 8051 to have 1K of RAM. That said, the newer generation of embedded engineers (e.g. me) who have only ever known an industry with ARM are pushing embedded towards higher-level C (yes, malloc is a big deal to these people), C++, and even a little Rust.

Also you can do a hell of a lot more with C macro functions than "string substitution." I use them at work to implement compile-time checks for all kinds of shit, mostly by using the GNU builtins and pragmas.

user is right, google is actually a good source for java. It's extremely well documented.

because real types are good and make your life better.
But there's absolutely no point in trying to talk to the crumbling brick wall that is the c programmer.

>decide to learn vulkan by following a tutorial
>find out my computer is to old to support it
fug

>closures, because you can just use extra parameters;
Closures capture state, that is why they are useful. You can in theory have struct state, but you'd have to manage it yourself, which defeats the whole point of closure. You might have argued that it necessiates hidden heap allocations, which is why it is undesirable to have it in C, but you chose the most fucktarded reason as the cnile you are.

>because real types are good and make your life better.
Yeah, and there are two reasons for that.
1) You can use them to organize stored data, rather than just storing it (i.e. ADTs). This can just as well be accomplished with structs.
2) You can use them to define roughly the same operation on many different kinds of data, but for each in terms of more granular operations specific to said kind. This can just as well be accomplished with function pointers.

>you'd have to manage it yourself, which defeats the whole point of closure.
Says more about how pointless closures are in the first place, seeing as that's not even difficult or troublesome.

>>no Windows
>Starts talking about DX12
How about fuck off.

You want to callback a function that takes an int, for simplicity. One time you want to pass a callback that has as a state an int, the other - a double. How do you pass it without turning into an ungodly mess of void*?

>no dynamic languages other than lisps
Why?

Maybe they're talking about ReactOS?

ignore lisplets

(me)
type safety isn't an obstruction to efficiency as long as it's implemented as long as the other abstractions in the lang are sufficient. It would be disastrous if it were implemented in C since there's no abstractions for working with it, but it makes sense in other langs where you have no real reason to be trying to implicitly cast shit.


C requires an adept hand, and the willingness to build up all your shit from the ground up. When that's practical/beneficial, C is great. When that isn't helpful, C isn't a good choice.

Using void * is considered type safe.

C doesn't have byte pointers.

>>lightning fast
lmao

>rants of a retard with little to no experience with Haskell

atleast in performance it is.