/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1492871915834.png (1000x1071, 120K)

Other urls found in this thread:

t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/
m.xkcd.com/2048/
hyperphysics.phy-astr.gsu.edu/hbase/Math/gaufcn.html
introcs.cs.princeton.edu/java/11gaussian/
terpconnect.umd.edu/~toh/spectrum/CurveFitting.html
twitter.com/NSFWRedditVideo

JavaScript rocks!

Attached: js-rocks.png (1000x494, 286K)

first for rust is shit

Kotlin is comfy

second for your crazy uncle c++

>write program that takes 10 seconds to run
>users complain because they think the program hangs
>add a gui progress bar
>nobody complains anymore, even though now the program takes 30 seconds to run

Attached: 1541842525934.png (300x250, 26K)

People hate uncertainty.

>take out the GUI progress bar
>add stdout dumps that describe what the program is doing
>nobody complains anymore and now the program takes 11 seconds to run
oh wait i forgot:
>now everyone complains that the program is a virus

Run the UI on a different thread so your main logic is only sending messages to it so it's not affected by whatever crud the UI has to do.

That's actually a good idea

#define onion union

>UI multithreading
Might as well kill yourself at this point. There‘s no decent framework that handles it well (except uwp/wpf i guess).

>What are you working on, Jow Forums?
Trying to get a handle on Rust for a third time. I came back stronger, more determined, and with more time available.

First project: a file manager. With the backend as a proper library to hopefully make it easy to make GUIs for it.
I've used a bunch of file managers on linux over the years, all of them sucked in one way or another. Or they didn't suck but crashed too often. I guess here's to one more.

Also, I've never made a file manager before and I'm mostly winging the architecture, so if anyone can offer tips or point me to helpful resources, that would be great.

Attached: Rust.jpg (1354x768, 276K)

onion my_onion {
int smelle;
};

this
const list = (a, b) => Array(b-a).fill(0).map((_,i) => a+i);

const revrev = (matrix) => matrix.map((row) => row.reverse()).reverse();

function spiral(n) {
if (n === 1) return [[1]];
let temp = revrev(spiral(n-1)).map((l) => l.map((k) => n*2-1+k));
return [list(1, n+1)].concat(temp.map((l,i) => l.concat(n+1+i)));
}

Why dont you fix'em crashes? that would seem more optimal than starting from scratch.

JavaScript rocks!

Attached: javascript rocks.png (1000x494, 134K)

File manager or file browser, is there a difference?

Why is JavaScript loli an n word?

Learning a language (especially a tricky one like Rust) can be a struggle for me, I've given up several times already. I need a simple passion project I can see through to its end to hopefully come out having learned a lot about how to actually program real software in Rust.
A file manager is simple enough to be surmountable, difficult enough to make me think a bit, and it's something I can actually use myself which is also a motivator.
When I get a project idea like this I have to run with it because it's a productivity goldmine.
I learned Qt that way, released my first program with it. Some people even use it.

Kinda? "File manager" sounds more suited for moving files around, which is pretty important for me.

why would it take a year

Give me the quick rundown on the GO programming langauge.

You're a moron man

>nobody complains
I would complain. I just don't complain at you because you've made it perfectly clear your software is shit and you're not interested in making it better.
It's like when you're using something like open office or ms office. They're slow as fuck to start for no good reason, the user experience is horrid. But you know they don't care about that because of who they are.

You adding the progress bar is an admission of defeat.

Lisp is the most powerful programming language.

trying to emulate bcd clock in c

Even in my own programs I'll add some progress indicator. I absolutely hate it when scripts and such run without indicating how long something is going to take or what it's doing (looking at you dd).

Attached: 1544040876715.png (997x315, 37K)

How long do you think will take you to finish it?

should I work through K&R or do the famous CS50 course ?

i already know how to program in javascript

CS50 would probably be more beneficial. K&R is like reading Jane Austin, absolutely great but nobody writes like that anymore.

Not sure. I might get smothered by the compiler in a week, totally possible. Otherwise it would probably take somewhere from three weeks to a month and change for the solid backend and a simple TUI (like ranger).
I'm still getting a grasp of the Rust beast, basic things are going to be slow until it all clicks.

If I have some code like
int a = 2*(x + y);
int b = 3*(x + y);
int c = 5*(x + y);

can I assume that an optimising compiler will probably generate an intermediate to avoid repeat calculations like so:
const int tmp = (x + y);

int a = 2*tmp;
int b = 3*tmp;
int c = 5*tmp;

It's the second coming of C, now with good concurrency and without legacy crap like make files or header files.

The only way you'll know is if you compile it and then check the output.
In practise though common subexpression elimination is a pretty common optimization.

Is there anyone here who is familiar with Unity ECS? I don't need/want help with it. I want to know about the origin of the fundamental concepts used. You see, I think I might have been the first person to implement an engine which works in that particular way, and I want to see if there were others that came before mine. I know component based design has been around for awhile (before I ever implemented my engine). However, I know I was before Unity with the concept of splitting it up so that the components only hold the data and separate classes called "systems" would do all the processing and iterate over the components they care about to do whatever. I literally used the exact same terminology that Unity is using and I can't help but wonder if they actually drew inspiration directly from my engine or if my idea is more common than I thought. My engine was started in June of 2014 and I did not base that design decision off of knowledge of any existing engine. Everything I had read at that time seemed to indicate that components themselves should be self-containing and not require anything else other than an entity to function.

I'm not going to pretend like my engine is some great product that people should use. It was an open source project that I never really took far enough to make a game with. However, the basic ECS framework was fully functional. I was only stalling on implementing proper systems to handle rendering and input and physics and whatnot.

What's wrong with Makefiles?

What isn't wrong with makefiles? The point of computers is their supposed to figure out how to do shit for you.

>I just don't complain at you because
Because you have an avoidant personality, and would rather suck it up and endure his problems than be confrontational

dumb frogposter

And you wonder why Go hasn't taken over the world yet

I like header files, they are comfy

i have an n x n matrix and want to find the average curve, as function of the radius, that you get by rotating around an element in that matrix.
any idea what would be the easiest solution?

Attached: asd.png (1002x706, 99K)

>The point of computers is their supposed to figure out how to do shit for you.
Isn't that what makefiles are? They streamline the build process so you don't need to write out the build commands yourself.

There is literally nothing good about header files

you shouldn't need to write out any build commands you idiot. You should be able to type go build and it's done.

...Instead of make build
Am I being trolled?

>hur dur you just have to write an entire makefile with -l for every library your using and other superfluous nonsense and then it's the same
Am I?

Attached: brainletcastle.jpg (645x1000, 107K)

t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/

No. I just replace the software asap. Why waste time on someone who doesn't want to improve?
Though admittedly as days becomes months/years without replacements am I really replacing? I'm not saying I never complain to people I don't think will improve, just most of the time.

Why is C# so hated on?
Language is amazing.

C# is Microsoft Java

You want to make about n/2 circles and take average value of each circle.

i

There any programming books for intro C that weren't written by programmers with Aspergers?

Pakistani dogs hating on us poor Indians

C# is nice and Visual Studio rocks.

Better Java.

hello newfriend. every language sucks

C# is garbage for brown people.

Why are you trying to learn C? What do you expect to gain from this?

It’s C but slower than Java.

lies . It's faster than Java.
The C programming language

lol no generics

Is there a relevant language faster than C?

C++.

Assembly for any given architecture.

Haskell

x86 Assembly, ARM assembly

first in a new class of programming languages designed for high turnover rate of subpar coding monkeys

Assembly, occasionally Rust, a good compiler you build yourself.

Nim

Impossible.

What the fuck garbage GUI are you using? I'd expect an extra second at most.

Proficiency so I can dick around in graphic APi and game scripts without losing my shit.

>he doesn't factor development/debug time into the equation

He's probably updating the UI at an absurd frequency.

>scripts
>C

that would just make nim even slower

nims compile times are also leagues above C.
Also how is python-with static types slower dev time than sugar'd asm?

>python
that explains it

By python i mean purely syntax-influence.
As Nim is self-hosted.

no wonder its userbase are so shit and retarded

How so?

What's your take on competitive programming contests dpt

its for special type of autists

>stackoverflow
>ask specific question
>"this question is not clear"
>ask broad question
>get useless broad answer
why even bother

>why even bother
this question is not clear

First for Python

post it here

ruby is basically javascript with a (relatively) non-shit POO model and syntax that isn't awful

Attached: Mfw+his+chest+hair+_84e7870d7f858633e885db56522de470.jpg (283x200, 10K)

ok
why are broads useless?

does it have closures

>asks specific question
>"this question is not clear"
>asks less specific question
u wot m7
clearly this outcome is your fault for not understanding what "clear" means

Fuck off funnyjunk nigger.

After coming from python, c is kicking my butt.

Attached: 1347526353304.jpg (782x581, 70K)

Curve fitting usually assumes a parameterized function and adjust the constants to minimize RMS error.

You probably wanted a guassian distribution i assume... m.xkcd.com/2048/

How to do that, how to do that... Mathematically, the most dumbed-down technique would be Hill Climbing. Basically guess-and-check with smaller and smaller adjustments until fairly converged. I don't know an optimized closed-form equation off the top of my head.

The guassian would be, uhh A*exp(-b*r*r); You could make a rough estimate of A from average values near the center, and if A = a/sqrt(2*pi*sd*sd)... Forget that, look up how many standard deviations from the mean it takes for normal distribution to drop 1/2 from max. That way you can compute average of rings around center and estimate standard deviation! ;) Then hill climb to improve the estimate! Or even just hill climb without doing an estimate first.

hyperphysics.phy-astr.gsu.edu/hbase/Math/gaufcn.html introcs.cs.princeton.edu/java/11gaussian/

If you are trying to emperically determing a blurring point-spread function (PSF), blurring from a real photo can have streaks from movement and rotation. A guassian won't fit the data precisely.

Go here terpconnect.umd.edu/~toh/spectrum/CurveFitting.html and search/find "Fitting Gaussian and Lorentzian peaks". It always pays to know more math...

It says to curve-fit a quadratic a*x^2 + b*x + c where x = ln({y | r}); Hope that helps.

Yes.

Technically it doesn't even have first-class functions, in the sense that the language construct that usually serves as a function -- the method -- is not directly first-class. However, it does have another language construct, called a procedure, that fills the role of a first-class function, and its procedures are indeed closures.

It's also quite easy to convert between methods and procedures.
class Example
def mymeth(x); puts x + 1; end
end
e = Example.new
e.mymeth 4 # outputs '5'

# converting a method to a procedure
m = e.method(:mymeth)
m[4] # outputs '5'

# creating a method from a procedure
y = 5
pr = -> {puts y} # captures y, ergo a closure
Example.define_method(:myothermeth, &pr)
e.myothermeth # outputs '5'

baka akari

in JS this is just
class Example {
myMethod(x) { console.log(x + 1); }
}
const e = new Example;
e.myMethod(4);

const m = e.myMethod;
m(4);

const y = 5;
const pr = () => console.log(y);
Example.prototype.myOtherMethod = pr;

You mean diversity contests

What's the problem?