/dpt/ - Daily Programming Thread

Pythons are lovely snakes, but terrible programming languages.

What are you working on, Sup Forums?

Old thread: Remember to be nice to Ruby and OSGTP!

Other urls found in this thread:

brum.itch.io/breakweapons
lenkaspace.net/blog/show/111
softwareengineering.stackexchange.com/questions/15468/what-are-the-drawbacks-of-python
youtube.com/watch?v=LMxuDrVs0HE
twitter.com/SFWRedditImages

I like python

I killed them both

I like ruby

Python is cute snek.

fuck opengl

reposting for (You)s
>rewriting the winapi headers
>remembered I tried doing the same thing a while ago but shift-deleted a couple days of progress because I realised it was dumb
end me

Dynamic types have overhead.

What's the best UI library design you've ever seen?

Trying to write a 3d platformer in webgl without using three.js
I want to fucking hang myself, javascript was a mistake

Also, you have more overhead from looking the asset up in the asset manager every time you create an entity instead of just using a reference obtained when the asset is loaded.

blender

>webgl
web browsers were mistake

It's admittedly a pretty fucking cool bit of framework, and when it works it works well, but having to write it in vanilla javascript is the biggest WHY.png I have ever encountered in my fucking life.
This shit would be about 30,000x faster and easier to write for if they utilized TypeScript, instead of having every dipshit custom-make all their objects or god-forbid have everything straight hardcoded.

What language is the most likely to bring me a job even if it's pajeet work?

Java and/or C#.
Javascript if you want to get paid like shit.

Indian

What is the best way to handle floating point errors when precision is relevant?

By not using floats when precision is required.

Indian isn't a language you retard.

I'm applying for a software tester position at an electronic/embedded software company.

I self taught myself C# enough to do gamedev, am quite comfortable with it.

Currently in an admin job. Any advice on what to add to my application/CV. Should I write something to demonstrate what I can?

Then why am I fluent in shitposting?

Yes it is. It also goes by the name "C"

Use integers

I thought it was bad when Americans got Australia confused with Austria, but now they're getting Australia confused with India. Embarrassing desu.

>creating an extra struct for every entity, filling it with asset handles from multiple different resource managers and passing it to the entity constructor
>this is somehow inherently better than just letting the entity constructor get whatever assets it needs from a single resource manager
>muh dynamically typed resource manager is bad because if you do the former you don't need to do the latter!
>muh hash table lookup is very expensive
Fuck off, retard.

>I don't care about performance
Use a garbage collected language.

>Missing the obvious poo joke

@63390572
tough luck pal

@63390875
Fuck you

>m-m-muh performance
In what universe is doing a few hash table lookups per entity creation going to be the bottleneck for your application, or even non-negligible compared to the cost of allocating and initializing the entity?

>implying GCs give bad performance

>*Blocks your path*

>In what universe is doing a few hash table lookups per entity creation going to be the bottleneck for your application
>it's only worth optimizing if it's a bottleneck

>or even non-negligible compared to the cost of allocating and initializing the entity?
Individual entities wouldn't be individual heap allocations, that's just dumb.

They give worse performance than allocating on the stack or reusing heap allocations when possible.

>allocating on the stack
Not the same use case, also limited in size.
>reusing heap allocations when possible
You can do that with a GC.

>Not the same use case
Assuming you still want the safety that comes from borrowing or a GC, allocating on the stack only works with borrowing. Your mind is poisoned by GC.

>You can do that with a GC.
You still eat some overhead.

>You still eat some overhead.
>You don't when using a system allocator.
Your mind is poisoned by retardation.

Be rational.

>Individual entities wouldn't be individual heap allocations, that's just dumb.
Depends on various factors. Not everything is easily poolable.

>it's better to introduce a bunch of boilerplate than to miss out on the occasional micro-optimization
Cool opinion, but doing a few hash table lookups upon entity creation is never going to be a performance issue. Modern games use in-house scripting languages for gameplay code and do it dozens of times per entity on every frame without breaking a sweat. Enjoy your verbose trash.

Yes, because the GC is still chasing pointers. I guess it's possible to achieve the same performance as an optimal non-GC program if you have statically checked or unsafe weak references, but at that point you are bypassing everything the GC does for you.

It's still overhead. Whether it matters enough to you to do the work to avoid it depends on your use case and personal preference.

>it's only worth optimizing if it's a bottleneck
Yeah. That's basically the long and short of it.

>you shouldn't increase your FPS by 1 even if you already know how just because there's something else that would increase it by 2 even if you have no idea how to implement it

Welcome newfriend

>Whether it matters enough to you to do the work to avoid it depends on your use case and personal preference.
Exactly, so maybe you should consider that before you yell that X is a symptom of "bad design". I consider introducing a bunch of boilerplate for performance gains that are hard to even measure, let alone perceive, to be bad design.

Also, efficiency isn't just about speed but also power consumption when you're talking about mobile or if you generally want to be environmentally conscious.

Okay, you got me, I'm wrong purely because I used the wrong word.

#include

void changeVariable(int *changenumber)
{
*changenumber = 7;
}

void main(void)
{
int number = 5;

changeVariable(&number); // modify 'int number' to 7, outside of main()
printf("%d", number);
}

this is pretty cool desu, no need to copy variables twice, modify it directly instead

So...it's like a property in C#?

It's adorable that you think that adding a layer of dereferencing to highly abstract classes passed a few thousand times per second is going to cost a whole FPS? You really have no idea the power under your fingertips. And because of that, you're going to optimize nano-seconds while losing seconds.

People who optimize typing are like people who obsessively wash their car because they have no idea how the engine works.

Use references you dummy.

Are you mentally retarded?

meant to quote obv

>it's possible to achieve the same performance as an optimal non-GC program
In fact, it's the opposite. An "optimal" GC implementation performs (way) less than one allocation per cell and this has been known for decades (see Appel's work). The GC also only chases pointers that are marked at a given stack point. Adding hardware support for GC as some research currently focuses on would definitely blow manual management out of the water. The only real, demonstrable overhead in GCs is requiring some more memory.

>Dynamic typing tards are THIS retarded

>highly abstract classes
They're just structs if you take away the Any part which is what depends on indirection and RTTI.

An optimal non-GC program wouldn't use fine grained heap allocations all the time, obviously. If it did, it wouldn't be optimal.

>like a property
You mean ref?

>impure mutation
S T O P

>Remember to be nice to Ruby and OSGTP!
No, why should I? You are not nice to Pythons either.

sorry, brainlet learning C here, i don't get the problem

>They're just structs if you take away the Any part which is what depends on indirection and RTTI.
Just wanted to let you know that you're arguing with a different tard there who probably doesn't know what you're referring to. Personally, I prefer to keep "highly abstract classes" away from my engine core.

I think it's a C++ thing, where you can just use ref instead of dealing with pointer and address symbols

>I get to choose the variables the program uses.
God I wish.

How do I see how a built in function is defined in Common Lisp? Wanna see #'floor.

Integer division isn't that bad If you use it correctly.

Also
>>I get to choose the variables the program uses.
>God I wish.
Stop using python

>How do I fix X guys
>By avoiding X from being broken in the first place.

Real useful advice.

Well, sure, if you optimal program never frees any memory...

>allocating and freeing without GC means malloc() and free()
Like I said, GC has poisoned your mind.

C++ references are non-nullable pointers (with - why, oh why - value syntax but reference semantics), so I don't see how that's relevant here.

I'm just spitballing, honestly, because that looks like the right way to modify something by reference in C. I just assume sepples has some less obtuse way to do it.

>What are you working on, Sup Forums?

Since someone complained about me only using if/else chains in my dialogue scripting, I decided to implement switch/case statements in my LoliScript parser/interpeter.

By default there is no fall-through since that's usually not what you want 98% of the time.

Maybe I'll make there be fall-through if you have an empty body for a case label though?

And now tonight I'm working on adding in dumpsters for putting bodies in (like in the Hitman series), since I realized I had some dumpster sprites sitting around for decorating the urban areas of the town, and I figured I might as well make them interactive since I had both an open and a closes sprite...

..whatcha makin there, user?

write it like normal and export it to js/html5

A simulation.

...

>fine grained heap allocations
And a GC prevents doing the same thing because?
>I don't have anything smart to say so I'll just invent quotes no one said.
I see.

>write it like normal
No, see, there is no "like normal"
You can either write it in vanilla javascript, by hand, line by line, or not write it at all.
WebGL utilizes the HTML5 standard. It's all in-browser insanity.

are you looking for beta testers

i mean write in C++ or whatever and export it, what's the point of writing javascript and using webgl directly. unity engine, godot, libgdx and probably some others export to html5

I'll make the logo.

UE4 too

Because most of those export to WebGL like total unusable dogshit. As far as writing the vertex and fragment shaders goes, that's still in C++, but the rest of it has to be in vanilla JS for it not to be some nightmarish pile of shit.

>beta

The game's not nearly that far along.

However, I will be releasing a pre-alpha-0.3 demo next month. I released 2 other ones 1-2 years ago (with full source code, etc) before, but it's been a while.

Why all this Python hate?

>Switch
>Using strings
This seems like technical debt in the making

it's shit and its users are smug tards

What's so shit about it? I'm new to programming and been falling for the python meme two days now. Mostly because i've found a guy that explains it very well on jewtube.

here's a random pre-alpha unity game. works fine.

brum.itch.io/breakweapons

What do you mean? fork() halts the execution of the loliscript interpreter (like a coroutine with the main thread in lock-step) until the user clicks one of its choice, then returns the index of the one they clicked on. This allows me to write the dialogue as it flows while having it execute as the player runs through it.

It's switching on the integer index returned.

How would you do it?

Or are you talking about writing strings in instead of retarded shit like RAPE_TEXT_ID_23525443 because 'hurrr translation', despite the fact that it makes the dialogue files totally unreadable (and it would be easy to go through and translate as-is). Any constantly-recurrsing things I can always refactor off in functions (hence cunnyWithTightness(), dickWithHardness(), etc).

Anyone know how to calculate the the total yearly payment of a loan. What is the correct formula, I tried basically everything. Here is my code and an example of how it should look like.

function computeMonthly() {

var loanAmount = parseFloat(document.getElementById("loanamt").value);
var startInterestRate = parseInt(document.getElementById("startrate").value);
var endInterestRate = parseInt(document.getElementById("endrate").value);
var years = parseInt(document.getElementById("years").value);
msg = "";
var monthlyPayment = 0;
var totalPayment = 0;

msg += "Loan Amount:$ " + loanAmount + "";
msg += "Number of Years: " + years + "";
msg += "Starting interest rate: " + startInterestRate + "%" + "";
msg += "Ending interest rate: " + endInterestRate + "%" + "";

//Starts table
msg += "";
msg += "";
msg += "Interest Rate";
msg += "Monthly Payment";
msg += "Total Payment";
msg += "";

for (var count = startInterestRate; count

with open('/path/to/some/file/you/want/to/read') as file_1, \
open('/path/to/some/file/being/written', 'w') as file_2:
file_2.write(file_1.read())
Go ahead and tell me the error in this code.
Hint: It's not related to any of the visible syntax.

>And a GC prevents doing the same thing because?
It doesn't, but you need pointer arithmetic anyways, which destroys the safety of a GC without adding statically checked borrowing or something again.

The industry standard, especially for console games, is to have only a few (or even just one) large allocations directly from virtual memory that are made and freed outside of gameplay.

The commented out totalPayment variable is some of the attempts I made.

OY VEY!

lenkaspace.net/blog/show/111
softwareengineering.stackexchange.com/questions/15468/what-are-the-drawbacks-of-python
youtube.com/watch?v=LMxuDrVs0HE

Mostly to the writing strings part. If you want to go back and change any of those dialog options you have to go back and modify all the hardcoded strings inside those forks as well.
Either that or you're using a language that behaves in mysterious ways I am unaccustomed to.

Pony's a pretty cool language.
primitive Thing
fun f(x: (U32 | String | None)): String =>
match x
| None => "none"
| 2 => "two"
| 3 => "three"
| let u: U32 => "other integer"
| let s: String => s
else
"something else"
end

actor Main
new create(env: Env) =>
env.out.print( Thing.f(2).string() )


Shame it lacks a lot of quality of life stuff, and as you can see, the syntax takes getting used to. Definitely my new favorite toylang though.

Oh fuck simlolidev? Downloaded your thing in one of the earliest demo days before they hounded you off agdg
Big, big fan!

>you need pointer arithmetic anyways, which destroys the safety of a GC
HRT has poisoned your mind.

I use RPGmaker MV

And the alternative is...? It has to be stored SOMEWHERE.

Any reusable option is stored in its own file though, similar to the one you see there. Anywhere that wants to let you grope the breasts just calls link("rape/grope_breasts") in their link{} block. It's just for things that are only called in one-place I introduced the fork() things to inline SMALL behaviour (ie what you see or less) inside a single message block, rather than having to create 1 file for each option, when each option is just a couple messages and is only referred to in one place.

>before they hounded you off agdg

What are you talking about? I still post there regularly. I post in all the recap mondays as well. It was just itch.io that banned me (the site they were using for demo days).

Cannot wrap my head around it desu. I haven't really played around with file reading and writing yet.