/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: comfy lain.jpg (1300x1244, 809K)

Other urls found in this thread:

youtube.com/watch?v=DO_rqyt0xKQ
flutter.io/.
open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf
twitter.com/NSFWRedditImage

Lisp is the most powerful programming language.

IMGUI just pushing the entire mess that is GUI state into other parts of your codebase rather than keeping it isolated.

GUI programming is universally shit

Ruby a comfy language.

I've written and am continuing to work on a wayland compositor.
Does that count as GUI programming?

Attached: yuno_is_cute.png (1530x1212, 222K)

>wayland compositor.
this guy again

I don't really know shit about programming but having a CRT and a PC case that close to a kotatsu seems like a bad idea.

>having a CRT and a PC case that close to a kotatsu seems like a bad idea
why?

Have you got a problem with that?

>wayland

Attached: 1469843979355.png (304x366, 231K)

heat buildup

I wish I could be that proud of something I wrote that I bring it up in every post I make

Forced air heating is uncommon in Japanese houses, and the ~500W of a computer is not much heat.

I'm sure it's been over a month since I've brought it up. I'm just contributing to the Gooey shitposting.

Isn't that the point of the kotatsu thing? It's cold but its but warm under your table. Having your CRT and PC acting as space heaters seems an added bonus.

whats the point in a kotatsu just use a heater

I seriously hope you're not using X11 in 2019.

Attached: 1542923104480.jpg (650x576, 60K)

Is it immoral to write company code in Lisp and then let them realize they need a Lisper to maintain it once you leave?

Yes; they likely didn't hire you to create problems.

why should i use wayland instead of x11

No; they likely hired you to solve problems.

no, companies are meant to create jobs because not everyone can be a farmer. you'd be creating value.
not many jobs actually create value outside of artificially created problems.
clothing? we could wear rags. cars? who built the cities so we all need cars? who forced us to buy cars that require insurance? now i need insurance on my big house?
who changed the building codes so we need mcmansions or high rent?
need a job? now you need to move to the city where the only option is a rental unit designed to leech off your labor.

you were hired to create problems, do your duty user.

I'm saving my eyes by using redshift which doesn't work with wayland

Technically I did solve the problem.

ok im dumb, just saw, sway supports redshift now.

Because it's better.

It does, though.
But saying something "doesn't work with wayland" is disingenuous. The core wayland protocol is extremely bare-bones and basically only provides some buffer sharing and a few other things.
Most of the real functionality in Wayland comes through extensions, so you can extend it to do whatever the fuck you want.

how the h*ck do you port something this complex to windows,linux,mac,win CE and fucking palm os

youtube.com/watch?v=DO_rqyt0xKQ

Attached: 1ce.jpg (225x225, 6K)

I have C program, it has
>shared data structure
>single threaded event loop
>clients ask for thing from internal structure
Is there a pattern to manage client state etc and allow access to the internal in memory data structure without using globals? Just throw it in big struct and pass pointer around?

in what way is it better

from termcolor import colored
from subprocess import call

def grepcut(inputRaw, grep, delimit, field):
for line in inputRaw:
if grep in line:
output = line.split(delimit)[field]
return output

def function():
print(colored("[+] ", "green") + "Here we go!")
with open('output1') as inputRaw:
var1 = grepcut(inputRaw, grep = 'grep this', field = 6, delimit = " ")
var2 = grepcut(inputRaw, grep = 'grep this', field = 3, delimit = " ")
call(["clear"], shell=True)
print("\n")
print(var1, var2)
#if var1 or var2 is None:
# print(colored("[-] ", "red") + "Not found, bitch!")
#else:
# print(var1, var2)

function()


By the way, this is the content of output1:
A B C D E F G
H I J grep this K L M N
O P Q R S T U


Look at the pic for the output of this code being run '''on my machine'''
Why the second time grepcut() gets called it returns None?

Attached: Screenshot_2019-01-12_07-03-15.png (114x42, 833)

why the fuck would you not use globals for a problem perfectly suited for using globals

- Client resources are isolated
- Fully asynchronous protocol
- Buffer sharing is always done via zero-copy means, whether shared memory for CPU or dmabufs for GPU
- State is synchronised with frame submission, preventing partial-state updates for frames
- Frame submission always align with vsync, making tearing impossible
- Putting the display server and window manager in the same process allows a shitload more potential for optimisations
- Putting the display server and compositor/WM in the same process reduces a shitload of the variable delay that X11 has

not that user,
That sounds great, but what are the cons, because there is a tradeoff, right?

i may have to check out wayland on my void install, i'm legitimately curious why everyone's using it, i just haven't tried it out on my own yet. thanks user

What's more important for making video games, programming or art?

inputRaw is a file, you’ve reached the end of file in your first grepcut call, in the second call there’s nothing left to loop over

I (technically) know how to program in a few different paradigms but i don’t actively understand the difference in practice. Can someone post canonical examples of how different programming paradigms result in different code and processes? The only discernible difference my conscious mind picks out is declarative vs imperative.

Next topic in my blog:
I hate python but it seems like anytime I need to do anything it’s always the quickest path (in terms of development, not performance) to a working product from nothing. Excluding quick and shell scripts using linux tools. It’s disappointing because I really don’t enjoy Python.

Specifically, I’m working on a craigslist scraper. Using anything but Scrapy would’ve been retarded. And I’ll probably be using BeautifulSoup next for further parsing. I’ve got a couple other projects that I feel similarly about. A lot of my hobby stuff involves web crawling and working with the data, and unfortunately Python alone reigns supreme in that domain.

Attached: 5802ABC3-0812-480A-9F2D-276284238F88.jpg (2048x1536, 256K)

>but what are the cons, because there is a tradeoff, right?
- Writing clients are somewhat more complicated and boilerplatey, but overall isn't too bad if you know what you're doing.
- The compositor itself becomes a lot more complicated, as it is now fulfilling the role that the X server was before, which includes low-level graphics and input. This can lead to varying quality implementations for this type of shit, but efforts to creating libraries has alleviated this issue. For example, literally everybody uses libinput to handle input, which was originally split out from weston.
- X11's very lax security was allowing clients to get away with some dodgy stuff which they can't do as easily or at all in wayland, which appears as missing features to users. For example, a client cannot look at the contents of another client, which makes things like screenshotting and colour-pickers not work. These types of things have to be added back through wayland extensions or other compositor-specific means.
- Due to the way buffer sharing works, Wayland doesn't even try to pretend it's network capable. Note that modern X11 isn't network transparent, and actually runs like pure garbage over the network, so you're not actually losing something here. A network-capable Wayland would be more VNC-like than anything else.
- The core wayland protocol is very bare bones, so extensions are unavoidable. This isn't a bad thing, but if cooperation between different parties doesn't happen, it'll lead to a very fractured ecosystem where a lot of shit doesn't work across different compositors. Overall, this hasn't been an issue yet, but Gnome are currently the worst at this.

>why everyone's using it
default on ubuntu
good security against keylogging
everyone believes it will replace x11

i think i'll install wayland tomorrow and give it a go. thanks again user

...if you have infinite time.

Pong says programming.

That said, unless it's text based, you need art pretty hard.

programing is a art

working on my jav downloader. since the video servers are wonky i've implemented resuming partial downloads.

Attached: hpfl.jpg (2693x392, 56K)

Holy shit. You may be onto something.

Attached: 1516012086370.jpg (452x364, 45K)

THIS!
Just having a gui triples your apps complexity. That is just not normal.

Crazy idea, keep your GUI and your program logic separate and then there's no additional "complexity"

dumb frogposter

Art will make or break your game, whereas even an idiot can program something that works.

Attached: 1525244463932.png (828x801, 102K)

retarded frogposter

Yandere dev is not just bad at programming... he bought his game assets from the Unity store.

Where is this from?

lurk moar

No. It is your duty to explain me your stupid meme pictures.

gameplay > art > programming (?)

Look into some of the aspects that make games fun (check out Mark Brown or something). Implementing them shoddily or not doesn't matter too much. Also, art itself can be the whole game, see ABZU or, any visual novel.

My weekend project'll be a poor man's Anki written in Haskell using Brick.

you can have a game with no art but no game with no programming

Woke af

Anyone who doesn't like it simply doesn't understand it.

Attached: 1546063689619s.jpg (230x250, 15K)

This

dumb dumb frogposterposter

racist

public int doSomething(int a, int b, String[] args) throws SomeException, SomeOtherException


holy fucking dogshit

visual novels are interactive content, not games.

programming, many hideous games had great success.

>meaningless method called "doSomething" that does not carry any idea of complexity, looks too long when adding equally meaningless parameters and exceptions

I FUCKING HATE CODE INTERVIEWS

Descriptive method signatures are better than undescriptive signatures.

And now you know why Electron has exploded in popularity.
The MVC model makes sense in a web application, its only a short step away from abstracting it into a regular application.
Tada! Even worse garbage!

Web apps fixed that.

You can not make a game with art alone unlike programming. Never forget that.

Attached: javascript.jpg (659x317, 41K)

&((int*) 0)[0]
Does evaluating this expression invoke undefined behavior?

yes, you are deferencing a null pointer.

>webapps fixed that
I wouldn't say "fixed" per se
Electron is what drove this flood of """good""" gui applications (all of which are unapologetic dogshit) and thats because webdev allows you to just import mistake overwrite yourself 2400x times without consequence because fuck speed

electron is just a solution amongst many. Flutter is the next big thing. flutter.io/.

The standard guarantees that any instances of &* will cancel out and not be evaluated.

open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf

>6.5.3.2
>The unary & operator yields the address of its operand. If the operand has type “type”, the result has type “pointer to type”. If the operand is the result of a unary * operator, neither that operator nor the & operator is evaluated and the result is as if both were omitted, except that the constraints on the operators still apply and the result is not an lvalue.
And is even directly referenced in footnote 104
>Thus, &*E is equivalent to E (even if E is a null pointer),
And going through the "transformations":
int *null = NULL; // I can't be fucked writing the cast a bunch
&(null)[0]
&*(null + 0)
&*null
null
So it's fine.

>Made by Google
Hard fucking pass, them and their AMP proprietary web bullshit can fuck right off.
>We added a single invivisble iframe over our controls on popular websites. We optimized it out of chrome though. Not on chorme? Enjoy your slow experience!
They're god damn monopolistic fascists and I hope everything they produce fails. AMP is a good intention but abused, so it won't catch on. This is no different. Fuck google and fuck all their projects.

Fascinating.

>rather than keeping it isolated
Any GUI program you find will have a layer where it transfers GUI input (edit box text, clicks, key presses) into the main program. 'Worst case' processing for the program is done in things like GUI callbacks and there's virtually no separation.
Imgui is about an interface preference. The typical button example makes this the most obvious.
if (ImGui::Button("Save")) { // do stuff }
The equivalent RMGUI interface would either push process actions into the gui layer, or have a state transfer process. It's not inherently bad. It has a much stronger separation of GUI and normal code when you just check the save button bool you've extracted or deal with a deferred call.
But that's not what imgui targets. They're not necessarily that interested in GUI even. The goal is less separation and a lack of state (from the user end of the library) makes it more easily manageable.
Imgui doesn't inherently push the state to your program either. You could easily have a makeGui() call that returns a struct with all the possible state. Or even just a dynamic array of non-default state.
It starts becoming much more like RMGUI at that point. And I would say you've lost reason to use it unless you've got very dynamic pieces of the UI.
What I find beneficial for imgui is that RMGUI has duplicate state from an interface perspective while imgui doesn't. Your editbox transfers the data to your intended location (on change ideally). In RMGUI the internal state of an edit box needs to be explicitly regarded because it's allowed to differ from your target buffer. Of course you can try to use the internal buffer of an RMGUI gui object in your processing but everyone knows that's very error prone.

We know the answer to this. Fear mongering.

I wish there was a way to write free functions with explicit limitations to which struct fields can be accessed though. Helps protect against future bad rewrites which is what usually makes this approach a little bit hard.

then just write a singleton class if your language doesnt support privacy settings for free functions

Did I miss something about oop langs? Can you now set up specific private/public settings per function?
I thought it was just public (everyone sees) or private (member functions see).
That's obviously not sufficient.
I'm excited to hear what you've got for me.

depends on the language I guess but I thought you could define privacy settings per method or field

In something like C++ you can (ab)use nested structs and friend to get whatever visibility settings you want.

Do you have an example?
I've never seen that as an explicit feature. I would want it even for normal objects.

>how the h*ck do you port something this complex to windows,linux,mac,win CE and fucking palm os

I think being russian might be the answer

It's just object composition, my dude.
struct Foo
{
Bar bar;
Baz baz;
};
Member functions of foo can only access the public members of bar or baz. You can break down your objects into subobjects. You can also define those structs inside the outer struct to avoid leaking those names.
It won't cost you anything, barring perhaps extra alignment.
And you also have friend, which lets a class grant access to its private methods to only one external function or class.

Nobody actually does this... But if you want to, it's there.

I was hoping for something cleaner.

I'm dumb, are you saying Electron is or isn't a good thing?

If you're hoping to restrict access to member variables on a function by function basis you'll never have something clean.
And if you're using C++ in any capacity you'll never have something clean either.

Electron is terrible but its popularity is understandable.

Thanks mate, I wanted to get into music programs and this program looks like what I needed.

It would be nice if Electron only run itself as daemon and every Electron app was a client to that daemon, but webshits can't into performance@optimisations.

nobody cares

It would be nice if we only used web technology for websites and not for native applications.

Electron is only so popular because every other GUI lib sucks.
But at the same time, there's too much investment in QT and friends, so no one wants to bother trying to compete because common adoption is a nightmare.

Electron does not do native applications, only websites.

nodejs is not different than java, python, ruby, ...

false

Electron is runs a website in a native window. It's an absolute joke.
nodejs is a runtime and Java, Python and Ruby are languages.

>in a native window
No, just chromium.

You eventually end up with a native window displaying a website. What's the point in that?