/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: spidey_goes_programming.jpg (650x443, 80K)

Other urls found in this thread:

docs.python.org/3/library/multiprocessing.html
twitter.com/SFWRedditVideos

hi everybody let's all be nice to each other here

>Spiderman helps Jimmy build a web crawler

Not anime. Someone make a new thread.

Don't start shit, these gay ass images are fine too.

Have compilers made Hacker's Delight _practically_ useless?

Fuck open offices

what is the thinking mans language i can namedrop on brainlets to assert dominance?

Cinnameg

All of them are like that. They offer pleasant environments for communicating and interacting with coworkers, and such spaces are uniquely ripe for innovation and efficiency. Or, you know, it's cheaper.

Assembly without a doubt.

ActionScript.

Removes privacy

Delphi

Is cheaper.

The commodisize privacy. Making it something you earn through promotion.

But they already did this with cubes.

What are some commonly mathematical formulas/functions used in general programming? What are some useful functions/formulas that should be used more often, but people don't Basically, tips/tricks.

Java

FORTH

No seriously.

x86 instructions
the ones in a basic algorithm book

There is bugs in the Rust COMPILER REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE!!!!!!!!!!!!!!!

They're intentional. There's no language spec so there cannot be any bugs implementing it.

How to make a git hook to automatically synchronize multiple repo?
I have a repo in foo machine and bar machine, each act as their "main" repo for their subdivision.

How to make Foo automatically propagate all pushes to Bar and vice versa?

XDDD

Fucking Rust fagget shits, I can't believe I took the bait.

You can't push code, only pull.

Maybe a ci/cd step where you SSH into the boxes and pull?

If you want to really ham it up you can spin up a service with an endpoint that ends up calling
>exec('git pull'). Since it's a service you can then use integrations to trigger it whenever

;)

Imagine using a new language instead of a old well-tested standarized language as C++. Lindy effect

I'm doing programming assignment from one book where I got pre-made code that I have to fill in and some function declarations look like this

void function(message)
struct mgs message;
{}

I've never seen anything like this?
Why is is there no type for function argument? How is there struct mgs message; in between function name and brackets?

This is the style used by the original, pre-standardization versions of C. The kind used in the first edition of K&R.

IT means the same as void function(struct mgs message) {}

test.c: In function ‘function’:
test.c:3:15: error: parameter ‘message’ has incomplete type
struct mgs message;
^~~~~~~


Well...

(gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0)

Ok thanks
I'm on gcc version Ubuntu 8.2.0-7ubuntu1 and it compiled without errors, just warnings

Shit, is that what they meant when they said they'd be removing support for "K&R style function definitions" or something in C20? Wasn't aware you could do that.

// heap allocates memory for thing which will need to be manually freed later
Thing * load_thing_from_file();

vs
// caller is free to control the allocation of their thing however they like
void load_thing_from_file(Thing *output);


I guess the second version is the standard C approach and I can see the advantages, but when would one prefer to use the first version instead? I do see it sometimes.

deleted and reposted for readability

Trying to get multiprocessing to work using Python, the first process should run all the time while rest of the code gets executed by the second process. It looks like this
def main():
process_one = Process(target=first_function())
process_one.start()
process_two = Process(target=second_function())
process_two.start()
return

main()


What happens is that the program stays in the continuous loop that's supposed to be handed off to a new process called process_one instead of continuing to start the second process. How can I fix this? Please tell in simple terms, I've touched programming for the first time yesterday.

At least sin(), cos() tan() and sqrt()

Haskell

IEC 61131-3

What for?

The first approach makes sense for an OOP approach with a constructor which allocates and initializes the object paired with a destructor which cleans up and frees all the bits and pieces dangling inside.

It is "Fortran-style", ancient C. Fortran uses a similar way of declaring the procedure arguments:
subroutine f(x,a,ans)
implicit none
double precision f,ans,y,tol,c(24),w(9)

call dverk(1,faux,x,y,1.d0,tol,ind,c,1,w)

end subroutine

Howdy... How do you make default parameters in Clojure? I'm trying to make a "binary search" function that takes in an input tolerance if specified, but uses a tolerance if needed (it searches over a range of floating points).

I know I can re-factor this, but I just wanted to create this as a proof-of-concept:
;; Binary search, but not for a list... For a specified numeric range
;; and a specified function, and a specified "key"/"tolerance"
(defn pseudo-bin-search [start-range
end-range
curr-guess
input-fn
target
tolerance]
(defn midpt [a b] (/ (+ a b) 2))
(let [curr-value (input-fn curr-guess)]
(println "Value: " curr-value " | Guess: " curr-guess)
(if (< (- end-range start-range ) tolerance) 0
(if (< (Math/abs (- curr-value target)) tolerance) curr-guess1
(if (< curr-value target)
;; Otherwise, go with range [curr-guess, end-range
(pseudo-bin-search curr-guess end-range (midpt curr-guess end-range) input-fn target tolerance)

;; Then go with the range [start-range, curr-guess]
(pseudo-bin-search start-range curr-guess (midpt start-range curr-guess) input-fn target tolerance)

) )))
)

(defn get-unity-gain [poles zeros]
(defn midpt [a b] (/ (+ a b) 2))
(let [transfer (make-transfer-fn zeros poles)]
(pseudo-bin-search 1 1e9 (midpt 1 1e9) (fn [x] (* 3e4 (transfer x))) 1 0.1))
)

Attached: Screen Shot 2019-02-05 at 10.23.56 AM.png (1748x1222, 485K)

docs.python.org/3/library/multiprocessing.html

Your images suck, please stop making threads; thank you.

>43 posts
>2 files
shit thread

Attached: 1537292930560.jpg (843x720, 81K)

cute

Would this please you

Attached: FG42.png (750x420, 343K)

>muzzle velocity
what does this mean

Posting best rifle

Attached: L85A1.jpg (600x338, 72K)

They meant nuzzle velocity

12 hours to make code compile
1 sec to delete it all.
No code is best code.
Fuck Rust.

ok
what about the length part

What language and engine should I choose if I want to make a simple video game? The only language I know is Python, but apparently it sucks for making games. Pls advice.

Attached: 15491148970950.jpg (192x220, 19K)

What sort of game?

Python is fine.

Your first_function and second_function probably execute too fast, so first_function finishes before second_function even has time to start. Try something like this:

import multiprocessing
from time import sleep

def a(p):
for i in range(50):
print(p, i)
sleep(0.1)
def b():
x = multiprocessing.Process(target = a, args = ["X: "])
y = multiprocessing.Process(target = a, args = ["Y: "])
x.start()
y.start()

b()

Penis length

Nothing wrong in making a small game with python. Javascript is also great for that purpse.

C++

Attached: eqwq.jpg (530x402, 42K)

that's 37 inches...
is that really a girl

Attached: 1548599962663.png (400x400, 107K)

>python
godot or maybe unity

>snek w gui
>tetris w gui
>interpreter
>calculator with precedence, RPN or whatever u call that
>compiler
>query language
>thumbnail image viewer
>conway game of life w gui
>other games like sudoku (w solver), picross, minesweeper
>chess with AI and gui
>poker hand evaluator
which of these should i put on my new github, i also have other small, but relatively fun shit in those categories

should i just do it thematically like
>cli games
>gui games
>image scripts
>languages
>one_use_scripts

Yes, can't you tell by the tits

How is Javascript great for games? Isn't it interpreted scripting language just as python is?

>C

I bet >she could titfuck herself

Yes, it is. Scripting languages are exactly what you want to use for small games. In fact, for larger games you want an integrated scripting language, and python is great for that too. You don't want to do game logic in C, because it's just a ridiculous amount of extra work for little benefit.

That's kinda hot

The idiomatic C way to do version one is:
int load_thing_from_file(Thing **output)

Allocating memory inside the function is the standard use case for double pointers so it will be understandable what you're doing just by looking at the function declaration, without any extra comments.

i've basically done the majority of Jow Forums's programming challenges pics some of which are somewhat useful projetcs
so some advice to make them presentable w be nice, come on i'm not gonna steal your job

would potential employers care that my programs are small to medium sized at best

Put everything you're proud of.

In my experience the idiomatic C way is to do this.
// opaque handle
typedef struct thing_impl *Thing;

int load_thing_from_file(Thing *output);

Idiomatic C is to stab yourself before programming to ensure maximum suffering

Well okay, mine is idiomatic if you're playing OOP in the sense said.

But in a wider sense C itself isn't idiomatically OO so it's still more normal to do what you (or the second version in ) did.

Lisp is the most powerful programming language.

Reminder that all programming is stringing libraries together. It's the dirty little secret no one dares to admit.

But I make the libraries

>tfw have to write my own libraries to string together

meanwhile every other big C project implements their own hash tables, heaps, etc.

I import your libraries, cuck.

Attached: frog.jpg (499x499, 44K)

dumb frogposter

Java Android people, short question:
Starting out with app development, I've written a simple app that displays my GPS coordinates. Is there a way to instead, in the background 24/7, make it send those coordinates out via a HTTP request every n minutes, without having a big ass notification around all the time?

I just need the correct keywords to google for.

Big C projects use a shitload of libraries as well.
You know, containers are not the only things libraries provide.

>in the background 24/7, make it send those coordinates out via a HTTP request every n minutes, without having a big ass notification around all the time
>need the correct keywords to google for
It is called google services

Attached: 1549325444914.jpg (635x351, 36K)

jokes on you i dont use anything besides the standard library period.

does batch have fallback for variables? in bash I just use ${var:-var2}. anything similar for batch?

>painting is just stringing paint together
>building is just putting bricks together

>using the standard library

yes

Will my memory overflow Jow Forums? The suspense is killing me

Attached: Capture.jpg (660x539, 45K)

Python is the most powerful programming language.

C++26

What's a good name for a function which shrinks a data structure to only fit the currently stored contents? e.g. if I have some list with a large pre-allocated capacity which I want to cut down to only the current elements.

I was thinking of just calling it "shrink_foo" or "shrinkwrap_foo" but there's probably a conventional name for this sort of function.

_soy

in sepples-land, they call it shrink_to_fit

>Wonder why I've been working so effectively all day
>Realize I took amphetamine this morning
Every time

>What's a good name for a function which shrinks a data structure to only fit the currently stored contents?
Shrinkwrap.
>but there's probably a conventional name for this sort of function.
Well std::vector uses shrink_to_fit, but shrinkwrap is shorter, similar, and means the same thing.

Thanks guys.

Attached: brain gremlin.png (766x432, 392K)

>programmer """humor"""
cringe

Attached: behead object oriented programmers.png (590x448, 202K)