/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1492875349374.png (1920x1080, 1.81M)

Other urls found in this thread:

harmful.cat-v.org/software/c /linus
stackoverflow.com/questions/46163607/avoid-memory-allocation-with-stdfunction-and-member-function
twitter.com/NSFWRedditVideo

JavaScript rocks!

Attached: js_rocks.png (1433x779, 473K)

C++ forever

Lua

Cyclone

Rust is cool and not gay

Help requested.

So I'm setting up a UDP server on public ipv6. When I fire client locally and send message,everything works flawlessly.
When I try to reach server from internet server is not found. I've whitelisted port in firewall, do I need to do something else as well,or am I just retarded for thinking I can hit public ipv6 without ip forwarding from router ?

>just retarded

I suppose I could use pygame.
The assignment just says we have to make a simple app utilizing an external library from the list of the following:
Selenium
Scrapy
Pygame
Pyglet
Kivy
Pillow
Django
Flask
Pyo

I am pretty new in all this so I just decided I'd do something with kivy but I'm having a hard time with this. I don't have much time left to finish the assignment either cause I was busy with other stuff before.
Considering dropping kivy and picking up something else. Any suggestions?

I'm working on a project in C++/SDL with Lua integration.

Attached: no_birds.jpg (360x480, 36K)

>sdl
>not sfml
I've never understood this meme

isn't it better to just use window's own threading library? no need to use third party shit

Merkle tree in C for absolutely no purpose. I just read the wikipedia article and thought it might be interesting, I'm also refreshing Jow Forums threads at an incredible rate.

I just remembered why I don't drink coffee, this is actually really unpleasant.

pthread API is portable to Unix though

>proprietary
>global executables
no thanks

I'm going to try implementing vectors in Assembly soon and my future self will probably never forgive me.

Fuck that future nigger man.

Attached: index.jpg (275x183, 5K)

better at different things

your future self is an even bigger loser than you are rn, so who cares?
bully him even harder I'd say

I was wondering if you could clarify something for me.

Is the purpose of the Scanner function to turn the usual input-output method of a Java program into an input-input-output format on a given line? So, for example, if I were to simply print:

>System.out.println("What is your favourite colour?")

That would give me an output, but would not ask me a question in the console that I can respond to (simple input-output), whereas if I were to say,

>sc = sc.nextLine();
>System.out.println("What is your favourite colour?"),

The program will print a question to the console I can answer before the program continues (input-input-output)

why aint this werkin!

def isPerfectNumber(n):
divisorSum = 0
for i in range(1, n):
if (n % i == 0):
divisorSum += i
return divisorSum == n


def nthPerfectNumber(n):
found = 0
guess = 0
while (found

nvm, i just gotta do nthPerfectNumber(0) to get 6 :^)

I'm working on link previews for image hosting. And image hosting in general.
xarql.net
It's a work in progress. The sister site with the same name but .com is more interesting.

I am not sure what the fuck you are referring to by input-output vs input-input-output.

Scanner is an object. Its job is to do input, not output. Incidentally, if sc is an instance of java.util.Scanner, then the line
sc = sc.nextLine()
will not compile due to a type error. The variable sc is a scanner, and is being reassigned to a string. Furthermore, your interpretation of what would happen is wrong. The question would be printed only after the input was read.

They're both simple input/output, it's still simple IO even if you change the order of the operations.

The purpose of Scanner is to parse input. You're using nextLine(), which will get everything to the next newline but there's also other methods like nextInt(), nextByte(), etc.

This was answered for you in previous threads.

Yeah, sorry, I'm still a newfag. The sc variable would be a new instance of the Scanner object in this case.

What I mean by input-input-output is that you input the question, the question prints to the console, then you input an answer and get an output

Was it? Sorry, I was too tired to continue that thread and I must have missed the answers

hello /dpt/, today I learned
>the size of R (T::*func)() != void *, but is up to the implementation
>inheriting from an abstract base class to add runtime polymorphism adds sizeof(void *) to a class.
// type-erased notifier
struct notify
{
notify() = default;
template
notify(T *ptr, void (T::*func)()) : m_model(in_place(ptr, func)) {}
void operator()() { (*m_model)(); };

private:
struct concept {
virtual void operator()() = 0;
};

template
struct model final : concept {
model(T* ptr, void (T::*func)()) : ptr(ptr), func(func) {}
void (T::*func)();
T* ptr;
void operator()() override {
(ptr->*func)();
}
};

template
auto in_place(T* ptr, void (T::*func)()) {
static_assert(sizeof(model)

Jesus, what a clusterfuck of a language.

Yeah, that's all normal. In particular the extra pointer that comes with inheritance is the vtable pointer and you should know about it if you're writing C++.

Anyone got any inspo for final year projects that would be impressive?

>member function pointer
When was the last time anyone ever used this?

Prove P != NP.

They're useful in the same way function pointers and function objects are. If you're starting a std::thread you might want to use one, for example.

Isn't the question embedded into the program and not part of user input though?

wait until you see the real generic version:
template
struct notify;

template
struct notify
{
notify() = default;
template
notify(T *ptr, R (T::*func)()) : m_model(in_place(ptr, func)) {}
R operator()(Args&&... args) { return (*m_model)(std::forward(args)...); };

private:
struct concept {
virtual R operator()(Args...) = 0;
};

struct empty {};

template
struct model final : concept {
model(T* ptr, R (T::*func)(Args...)) : ptr(ptr), func(func) {}
R (T::*func)(Args...);
T* ptr;
R operator()(Args&&... args) override {
return (ptr->*func)(std::forward(args)...);
}
};

template
auto in_place(T* ptr, R (T::*func)(Args...)) {
static_assert(sizeof(model) notify;


the idea behind this is to use a smaller type-erased function object when you don't need the full flexibility of std::function, since it does not require heap allocation.

How do I separate the team names from the score?

Attached: teams.png (734x515, 13K)

oops, theres a mistake in the constructor, since it requires taking a R (T::*func)(Args...), but you get the idea

You kys

By not being shit.

I'm pretty sure that std::function already guarantees small object optimization for function pointers.

nice cancer language.

Not generic yet. You need to add a bool template parameter for function pointers and member function pointers for noexcept. Also I'm not sure if T carries the cv qualification or the ref qualification for the member function pointer.

just write some random REST service with flask

is it guaranteed when capturing by reference? my use case would be something like
struct Foo
{
void foo() { puts("foo"); }
};

struct Bar
{
void invoke() {
client();
}
void subscribe(const std::function &func)
{
client = func;
}
std::function client;
};

int main()
{
Bar b;
Foo f;
b.subscribe([&](){ f.foo(); });
b.invoke();
return 0;
}

harmful.cat-v.org/software/c /linus

That's a capturing lambda, not a function pointer. This only works for function pointers - maybe also member function pointers, probably up to the implementation.

I was mostly joking with that post, but you're right ofc.

Is Learn You a Haskell a good introductory book to Haskell?

I checked. It doesn't carry the cv or ref qualification. Which means there's no way to fully template over member function pointers.

This is why I completely ban member functions in my C++.

Can you recommend a smalltalk compiler (not interpreter) for linux?

dug a bit more, seems I can get by without allocating by using std::function and capturing the client object by reference
stackoverflow.com/questions/46163607/avoid-memory-allocation-with-stdfunction-and-member-function

what book do I have to read to get started on python

You may be overthinking things.

System.out.println() will immediately print something to std out when the line executes.

Scanner's (sc) readLine() method will immediate read a line from stdin, i.e. it will take for or block on input. I think. Haven't used Scanner in a while.

So if you want to print some arbitrary text and then wait for input, you would do the print method and then the wait for input method:

// Ask user for input.
System.out.println("What is 1 + 1");

// get user input
String userAnswer = sc.nextLine();

// print a string using previous user input
System.out.println("You answered " + userAnswer);

Why is my localhost/phpmyadmin/ all in code and messy?

I don't even remember last time I needed one. If I want to start a thread I just pass a lambda to it. One might argue that it's a wasteful allocation, but damn, you are starting a thread. Compared to that, malloc is nothing.

I just checked, and the size of a lambda is 1 byte (!?) when not capturing anything, and 4 bytes per element captured by reference. The limit for the small object optimization for gcc is given by the size of this union:
class _Undefined_class;

union _Nocopy_types
{
void* _M_object;
const void* _M_const_object;
void (*_M_function_pointer)();
void (_Undefined_class::*_M_member_pointer)();
};

which allows up to two objects to be captured by reference in a lambda without allocating anything.

In C#, I'm trying to draw a form in a absolute position relative to the Desktop, but for some reason he completely ignores my Rectangle's X and Y and sets some apparently random values (in this case 156, 156).
I get the same result with either DesktopBounds or Bounds. Any idea why?

Attached: Screenshot_2.png (495x150, 11K)

I just learned how to use lambdas in Assembly. This is horrifying.

How to make cute minimalist gui?

Wouldn't that just be a relative call?

Ah, got it, I have to set f.StartPosition = FormStartPosition.Manual;

Tk?

import (gui)

>all in code
Do you mean it's spitting out php code? Your server isn't configured to use php, also

when you parse each line, split the line by by spaces to get the team name and scores separately then sore them in parallel arrays or dicts or whatever you use in python idk

Why are so many inexplicably employed programmers so bad at programming? To the point where modern mainstream statically typed languages are being designed without even first-order generics in order to accommodate what is presumably a significant number of programmers who are seemingly unable to understand them?

thinking of taking a course in machine learning in university. but I feel its a meme

what do?

Generics are a crutch for stupid programmers who don't know how to live without them and are literally just a bloat generator.

Monads have been around for decades. At this point you have no excuse for not understanding them.

consistency is valued over quality
>just show up

it's a 50+ year old running meme
they keep changing the name of it though to get funding

All I do at work is typical web/REST bullshit. It's absolutely soul crushing, and I've been on this path for years. How can I pivot to systems programming?

>generics
>bloat
hahahahahahahaha

Prepare to be disappointed.

>Doesn't know how most generics implementations are implemented
Why do you think most C++ programs and libraries are like 10 times larger than everybody elses?

Monads are like a...

Attached: monads.png (793x670, 797K)

I suspected you didn't understand generics. Now I'm certain. Thanks for confirming.

Lisp is the most powerful programming language.

MONADS ARE LIKE A MONADS

is there such a thing as a world class software developer? Or are we all just high level pajeets

>Why do you think most C++ programs and libraries are like 10 times larger than everybody elses?

because with C++ you can actually finish a project in the real world

What's a moenad?

Attached: 1545777847077.jpg (374x374, 41K)

Reminder: Java, Python and homework questions belong in

Monads are like semicolons.

don't let those nerds steal our posts, dumb ass questions and pajeets that can't speak english make for good entertainment.

Attached: 1548384107944.png (780x717, 455K)

>is there such a thing as a world class software developer?

not anymore.

Attached: tad.jpg (900x900, 112K)

At this point, the wagies should just make /wpg/ / /epg/ to contain all java/C++/and How 2 get job??? shit.

Exactly what Jow Forums needs, more generals.

Attached: 1545803863012.png (1920x1080, 3.69M)

It was half a joke anyway.

Honestly, the best analogy I've heard for monads describes them more like a split in a railroad track.

I just had a phone interview where they said they said they were roughly 2 hours away from me, and would this be a problem? I instantly said yes even though I'm open to relocation.
If I have to talk to another woman from HR I'm going to lose it.

Attached: 1390353918237.jpg (261x260, 40K)

Does it work on java?

mspaint.exe

Still amazes me how people can willingly commute more than a half an hour.

meh I knew people who loved 2 hour commutes back into the rural areas

Is there anything creative you can do with a mixture of Javascript and Python? Never really did much with scripting languages.

It's ok on a train or something when you can read or shitpost, but if you're driving it's just 2 hours of extra work.