/dpt/ - Daily Programming Thread

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

Attached: DPT.png (934x1000, 389K)

Other urls found in this thread:

paulgraham.com/avg.html
micropore.wordpress.com/2011/03/02/python-1d-mass-and-spring-system-with-friction/
hg.libsdl.org/SDL/file/default/docs/README-dynapi.md
feh.finalrewind.org/examples/⟩
infoq.com/presentations/Simple-Made-Easy
twitter.com/NSFWRedditVideo

Invalid thread.
Proper thread here:

good thread

For me, it's Blub.

>let's design some trivial VM and make a retarded simple instruction set for it and then call ourselves h4x0rs for using it
Esolang were a mistake

Making a moddable game is a special kind of hell, basically I want to avoid using scripting languages at all cost, my approach so far is shared libraries and a lot of function pointers, each mod is a shared library and is loaded at runtime, I expose the game's functions by passing function pointers, but how do other engines do this? in source engine it seems that they can pass classes and use all kind of stuff, is there a better way? is using function pointers still faster than something like Luajit?

I think you're overthinking it. Modding is essentially about gameplay and behavior, otherwise they'd use their own engine. So rather use the scripting language imo.
>how do other engines do this
The ones that don't suck developer time use scripting engines. There's a reason no one uses Source SDK anymore.

I was referencing this:
paulgraham.com/avg.html

Oh, right, I forgot about this. I guess that's what it got named after though.

Yeah, most likely.

I honestly don't care if it's easy to mod, I only care that it can be modded, the problem is that I already invested in a low level language and a lot of planning to squeeze every last bit of performance I can, it's a simulation that should run even on old hardware after all, switching to function pointers already breaks my heart, but it's not that bad since it can be optimized and that's how people do OOP on C anyway.

Having mods as shared libraries will set a good entry bar, and I imagine performance would still beat the best JIT interpreter, I have to throw safety out of the window for the sake of speed but I can force that all mods should be open source or something, being moddable on its own grants bonus points.

It saddens me that C# and .Net languages in general can be simply modded by disassembling it and inject code easily, I thought of embedding mono but at that point I may use C# for everything, Luajit is still an option, but I wanted to learn more about shared libraries.

Lisp is the most powerful programming language.

Working on a small cli interace prompt that operates on an out of memory geospatial data file and does filters groupby and that sort of shit and hooks up to a websocket in the brower.

Currently I'm to brainlet to write a small interpreter logic for the core functionality I'm looking for. Anything that isn't a implementation specific hack runs into issues where I think the maintability would just get ridiculous.

TL:DR interactive out-of-memory mapping using flat file formats.

I was reading Eloquent Javascript but gave up after a couple hours, what a garbage language. Not only do I hate Javascript now, I actually hate HTML and the DOM tree structure of web pages. The whole web is a clusterfuck of bad ideas piled haphazardly on top of a good protocol. This must be what Jesus was warning about when he said don't cast your pearls before swine.

I'm trying to get exif 1.0.1 to compile on freebsd the fucking thing builds but then when i go to run rails (inb4 rails meme) the fucking thing fails due to some missing header, which means that something is fucking breaking during compile. god fucking dammit Jow Forums

If you're gonna criticize a whole language and interface structure, at least give some specific examples.

>Not only do I hate Javascript now, I actually hate HTML and the DOM tree structure of web pages.
Welcome to the club of literally everyone. You can add humans writing and reading XML to that list.

It's an asymmetric Frankensteins's monster with greedy type coercing that relies on loosely defined conventions to maintain any semblance of having any design philosophy at all. It's half a language that couldnt decide whether it wanted to be TCL or Lisp and ended up being Fortran without the structure, performance, or concurrency.

I was hoping the things I had heard were hyperbole. I would rather write and ship native clients than build web interfaces, and I know that quite a few of our customers want native clients because they've discussed it with CS before. We recently changed management at work and the new guys "Can't believe we're not using web clients in 2018!" They haven't once asked why, and we're all hoping they fail so nobody has explained it to them yet. Our customers are going to be pissed off and likely drop out of their contracts, so I'm already looking for another job, but in the meantime I have to learn this trash.

>post open source project on github
>300 stars in a week
>still feel dead inside
what do i do

What matters is the journey, just keep moving the goalpost further and further.

Nothing.

I'm new to programming. Trying to make a simple function in R.
I have 3 square adjacency matrices, matr1, matr2, matr3. matr1 is related to matr2 and matr1 is related to matr3. For the sake of simplicity, we will only focus on matr1 and matr2. I want a vector such that it is filled with 1 if the [i,j] entry in both matrices is 1. Otherwise fill it with 0. There's a few problems I ran into while making this
>How do I know which nodes connect to which?
>How do I even store the value in the correct position?
My attempt:
vec

What is wrong with my simulation of an harmonic oscillator?
import numpy as np
import matplotlib.pyplot as plt

# Parameters for the simulation
ST = 1 / 1000
# Length of the simulation in seconds
duration = 5
# Physical parameters
M = 1.0
k = 2

# Initialization
t = np.linspace(0, duration, int(duration / ST) + 1)
ddtheta = np.zeros(len(t))
dtheta = np.zeros(len(t))
theta = np.zeros(len(t))

ddtheta[0] = 0.0
dtheta[0] = 0.0
theta[0] = 1.0

# Main loop
for k in range(1, len(t)):
ddtheta[k] = (1 / M) * (k * (0 - theta[k-1]))
dtheta[k] = dtheta[k-1] + ddtheta[k] * ST
theta[k] = theta[k-1] + dtheta[k] * ST

plt.figure()
plt.plot(t, theta, color='blue')
# Axis labels
plt.xlabel('t')
plt.ylabel('')
plt.show()

Beside the fact that I use the worst numerical integration method, why does the frequency of oscillation increases and the amplitude decreases?

>99% coverage
>one line not covered
>decide to check it out of interest
>find a bug

Attached: 4894849.jpg (788x685, 72K)

So let's say two people use a custom built application to communicate with each other over IP over UDP/TCP using multiple-encryption where the secrets for encryption/decryption are pre-established in person then what would the secret vulnerabilities be?

There's obviously the vulnerability if attacker has physical access to a device. There's obviously social engineering. What other flaws could be abused?

I copied something from the internet, modified it to use the same scheme and same parameters
import numpy as np
import matplotlib.pyplot as plt

# initial condition, constants
h0 = 1.0 # initial deviation from equilibrium in m
v0 = 0.0 # m/s
t0 = 0.0 # s

# constants
time = 5.0 # duration in sec
dt = 1 / 1000 # time step in sec
nstep = int(time/dt) # number of time steps

k = 2.0 # spring constant in N/m
m = 1.0 # mass in kg
k1_drag = 0.0 # kg/s
Energy = 0.5 * m * pow(v0,2) + 0.5 * k * pow(h0,2)

# array definitions
h = np.zeros((nstep,), dtype=float) # height in meters
v = np.zeros((nstep,), dtype=float) # velocity in m/sec
a = np.zeros((nstep,), dtype=float) # acceleration in m/sec^2
t = np.zeros((nstep,), dtype=float) # time in sec
K = np.zeros((nstep,), dtype=float) # kinetic energy
V = np.zeros((nstep,), dtype=float) # potential energy
En = np.zeros((nstep,), dtype=float) # total energy

#—initial conditions ———
i = 0
v[0] = v0
h[0] = h0
K[0] = 0.5 * m * np.power(v0,2)
V[0] = 0.5 * k * np.power(h0,2)
t[0] = t0
En[0] = K[0] + V[0]

for i in np.arange(1,nstep):#—main loop ———
a[i] = -(k/m) * h[i-1] - (k1_drag/m) * v[i-1]
v[i] = v[i-1] + a[i] * dt
h[i] = h[i-1] + v[i]*dt
t[i] = t[i-1] + dt
K[i] = 0.5 * m * np.power(v[i],2)
V[i] = 0.5 * k * np.power(h[i],2)
En[i] = K[i] + V[i]

tz = [0, time]
hz = [0, 0]
plt.figure()
plt.plot(t, h, tz, hz,'k')
plt.xlabel('Time (s)', fontsize=18)
plt.ylabel('Amplitude (m)', fontsize=18)
tex = r'$F\,=\,-kx\, -\, k_dv$'
plt.text(5, .4, tex, fontsize=24)
#savefig('spring_oscil.png', dpi=100)
#——————————————————
plt.figure()
plt.plot(t, K, t, V, t, En, 'r', tz, hz,'k')
plt.xlabel('Time (s)', fontsize=18)
plt.ylabel('Energy (J)', fontsize=18)
plt.legend(('Kinetic', 'Potential', 'Total'),'upper right', shadow=True)
#savefig('spring_energy.png', dpi=100)
plt.show()

now it works. Why?

I copied from micropore.wordpress.com/2011/03/02/python-1d-mass-and-spring-system-with-friction/

>I already invested in a low level language and a lot of planning to squeeze every last bit of performance I can
Well that's where you're mistaken. As long as the underlying architecture is well-implemented, the performance impact is going to be irrelevant for scripting gameplay behavior. In fact, providing some bytecode VM might actually be better since you have more opportunities to chose how your engine will run the code.
>I can force that all mods should be open source or something
Do you expect your average player to be fluent enough in your programming language to understand what's going on in the mod source files? Also what makes you believe every modder out there will accept to release his project as open source, given your game becomes popular? Historically that hasn't been the case.
One last thing about function pointers which you probably are aware of, but every non-inlined function call involves jump overhead, and gameplay-related inlined function calls involve icache rape anyways. Your game engine won't know about the mod's content at compile time either way. There is no optimization possible on the basic block anyway. It's actually fine to use your dynamic loading approach, although much more unsafe as you said.

never mind, I'm retarded beyond repair.
I named the iterator k and the stiffness is also named k

something types something

Nobody is going to mod your game if they have to compile a fucking dll to do it
Make it data driven, make it use a scripting language

>hg.libsdl.org/SDL/file/default/docs/README-dynapi.md
>SDL devs thought it's a good idea to put a backdoor in their library to go around static linking even if it meant adding a level of indirection to every function
wew

Explain like I'm five this too a brainlet like myself.

The problem with being a programmer is that you will find lots of beautiful ways to manage memory, but will never manage to have beautiful memories.

I'm making simple OCR in python. (matter of learning i suppose)


The only difficulty i encountered by now is that i don't know how could i take image input and change it(by touching with cursor) in real time.

>dynamic linking
libraries resides in separate files (.dll,.so) and can be loaded at run time
+your program don't need to ship those files since the system can provide them
+you can update the libraries by replacing the files without recompiling your program
-you can have version incompatibility and program crash
-people can provide modified files and alter your program (game cheats, malware)

>static linking
libraries are compiled into your program
+guaranteed compatibility and safety
-you will have bigger binaries
-you can't update the libraries without recompiling your program

SDL devs said fuck it, even if you use static linking, you can still make it load a separated file like with dynamic linking, even worse, the cost of that is turning what should be a direct function call (which is fast) to a call to a table of functions (which is slow) for every function, making it a shittier dynamic linking.

How do programmers get paid? Is it $/KLoC like IBM used to do back in the days?

>$/KLoC
i dont see how this could possibly backfire

...

I'm writing a web server in Haskell. It's very fun and cute!

Attached: Screenshot from 2018-10-29 22-13-39.png (684x257, 32K)

the last bit can be
maybe notFound html result

Is there a UML diagram for languages such as Go?
Need to make some design documents for uni and class diagrams don't seem to fit well.

What does "symbol" means in the context of a shared library? windows have something to get procs, but can you get a variable or a type?

A string that identifies a particular portion of the code object. Maybe it's a function or a global variable or whatever. Learn about them with objdump and readelf.

> previous commit somehow fucked up a good portion of the entire project
OH NONONONONONONONONONONONONONONONOONONONONONONONONONONONO
git reset --hard HEAD^

I'll report back later

Attached: images.jpg (225x225, 9K)

OH NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO

Attached: Screenshot from 2018-10-30 01-22-19.png (1604x1182, 265K)

kek

>hard head
owo

I kind of want to write an image viewer that follows the unix-philosophy. Would anybody be interested in an one that lets you run arbitrary shell commands?

Stuff like calling imagemagick, mv, etc. You could also use grep or find to reload the current list of files to display. Viewing zip/cbz files can be done with: unzip book.zip "$tempdir" && imageviewer "$tempdir" && rm -r "$tempdir"

Attached: 956138615641272326.jpg (2000x1500, 298K)

nvm fixed it

Attached: avatar.png (200x200, 18K)

Shit, how do I write in CV that I used Scrum at my previous job? Migrating from code monkeys to managers. "Software development in accordance with Scrum methodology"?

where did you get that picture of me?

just say that you're scum

Thank you for posting my avatar

>what should be a direct function call (which is fast) to a call to a table of functions (which is slow) for every function
Which is an imperceptible difference considering what most SDL functions actually do - having an extra indirect jump in front of say SDL_RenderFillRect will disappear as measurement noise.

you use instead of a pic of yourself

what about pipes?

What am I supposed to feel, anons?

Attached: 10b61Z5.png (430x441, 86K)

I did. Enjoy staying monkeys, though.

once a monkey, always a monkey.

Not sure what you mean for that particular case but you would be able to do things like find . -iname "*whatever*" | imageviewer or imageviewer | do-something-with-last-viewed-file, though.

Attached: 1540780768177.jpg (720x480, 92K)

You need to alert the investors.

Write what you would want to see if you were hiring.

>"anime"
>haskell
>>girl

The SDL devs are actually retarded. Anytime they're faced with the slightest inconvenience, they come up with an insane macro solution.

What's your opinion on ORM?
Does it make your project more manageable, or is it just a bait for SQL inepts?

feh?
you can do feh -, curl | feh -, even feh for convenience

FEH(1) BSD General Commands Manual FEH(1)

NAME
feh — image viewer and cataloguer

SYNOPSIS
feh [options] [files | directories | URLs ...]

VERSION
This manual documents feh 2.18

Compile-time switches: libcurl support enabled, Xinerama support enabled,
builtin EXIF support enabled

DESCRIPTION
feh is a mode-based image viewer. It is especially aimed at command line
users who need a fast image viewer without huge GUI dependencies, though
it can also be started by (graphical) file managers to view an image. By
default (unless arguments or a filelist are specified), feh displays all
files in the current directory.

feh supports filelists, various image sorting modes, image captions, HTTP
and more. Configurable keyboard and mouse shortcuts are used to control
it.

feh can also be used as wallpaper setter.

EXIF tags are supported either using exiv2 / exifgrep via --info (see the
USAGE EXAMPLES section), or as a builtin feature by compiling feh with
exif=1. In this build of feh, builtin EXIF support is enabled.

...
-f, --filelist file
This option is similar to the playlists used by music software.
If file exists, it will be read for a list of files to load, in
the order they appear. The format is a list of image filenames,
absolute or relative to the current directory, one filename per
line.

...
USAGE EXAMPLES
Here are some examples of useful option combinations. See also:
feh.finalrewind.org/examples/⟩

feh /opt/images
Show all images in /opt/images

feh -r /opt/images
Recursively show all images found in /opt/images and subdirecto‐
ries

...

It looks like what you want to make.

Prove it

Attached: 1530811044624.jpg (640x495, 52K)

>Be CS student
>All my projects are back end focused (emphasis on data structures, algorithms, memory and all that good shit)
>Apply for front end internship thinking "hey, HTML/CSS/JS is easy and react is pretty comfy, I'll send them my resume."
>"Can you send us examples of your front end work?"

FUCK

Attached: help.jpg (900x900, 56K)

fuck that fraud.

Attached: 1512185415689.jpg (729x828, 126K)

Haven't posted progress of this on /dpt/ in a while, but here it goes.

Implemented kawase blur and added it to refractions.

Attached: blur.webm (1360x768, 2.31M)

Attached: glass.webm (1360x768, 2.55M)

pretty nice but it needs more dimensions

>ORM
mandatory viewing
infoq.com/presentations/Simple-Made-Easy

anyone here happen to know assembler for motorola68k?

don't take this post seriously

What do you mean?

see

No, but seriously, because my engine supports 4D tetrahedral meshes. Is that what you meant?

Attached: swh.webm (640x360, 2.53M)

I have a higer-order function which returns the succ()/next() which computes the next value to be used. What name should I give it?
all I could think of was
>mk_next(...)
but that kinda sucks doesn't it?

Attached: 1510752448810.jpg (612x716, 313K)

I was just trolling ya.

It would be cool if you could show the 11 dimensions from string theory though. I could finally find out what they look like.

I have a singleton of Class A that chooses an object from Blass B randomly. Class B has an array, contents are different for each object. Class A makes heavy use of elements of said array. Should I copy the array from objects of Class B to the singleton of Class A every time an object is chosen to work with?

I used the 4D from Einstein (5D - time), String theory is pseudo science bullshit, miss me with that.

probably. anyway, your program looks pretty cool. nice work.

ha gay
stupid nerd

Attached: 1540057717416.jpg (825x795, 128K)

>The benefits of simplicity are: ease of understanding, ease of change, ease of debugging, flexibility.
>Complex constructs: State, Object, Methods, Syntax, Inheritance, Switch/matching, Vars, Imperative loops, Actors, ORM, Conditionals.
>Simple constructs: Values, Functions, Namespaces, Data, Polymorphism, Managed refs, Set functions, Queues, Declarative data manipulation, Rules, Consistency.
No thanks.

Attached: a6d.png (2550x1650, 377K)

Currently in Pakistan and managed to pick these three bad boys up for a total of around £25. Not sure which one to start with.

Attached: ab0af494-4c11-4718-bb46-e0a859681f7f.jpg (1600x903, 147K)

>No thanks.
Convincing argument!

The computer networking book is pretty sweet. It's essentially Tannenbaum's book in reverse.

fanks

>it's gay to science
what are you doing in a programming thread?

Attached: cubes.webm (1280x720, 2.49M)

>it's gay to science
Correct. Computer Science is not a science (nor is mathematics), nor is all programming Computer Science.
now go back there

low quality

>implying I'm a Neil Tyson fan
miss me with that, ok?

Neil Tyson is the ultimate scientist because he doesn't fucking know anything but thinks he does

>what are you doing in a programming thread?
it's not gay if wear programming socks

lmao, I miss posting in Jow Forums

If you go by modern science advocates you'd be right, if you go by older definitions of science, you're wrong. Tyson is a braindead idiot, Newton wasn't.

nobody uses science that way these days