/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1524658603334.jpg (1920x1080, 290K)

Other urls found in this thread:

dev.stephendiehl.com/hask/#monadic-myths
numerical.recipes/
kdnuggets.com/2018/05/poll-tools-analytics-data-science-machine-learning-results.html
kaggle.com/stardust0/python-vs-r
github.com/giraffe-fsharp/Giraffe/blob/master/samples/SampleApp/SampleApp/Program.fs
archive.rebeccablacktech.com/g/search/subject/dpt/
twitter.com/NSFWRedditVideo

First for anime.

second for C the best programming language in the world

Third for suicide

But now I don't get pattern matching, and tailoring things to specific patterns becomes increasingly unwieldly to deal with

>C the best programming language in the world
>C

That's a weird way to spell Java.

I'm writing a GUI program with OpenGL.
Is it worth going all-out with a proper scene graph and all sorts of shit, or is that just overcomplicating things for 2D?

Attached: 1538030883202.jpg (400x400, 40K)

Define your criteria for best

>A GUI program with OpenGL
I'm gunna need you to take a big, titan-sized step backwards and explain why you're building a gui in opengl

Attached: 1546608035831.png (900x753, 171K)

Quit your job
Make video games

Attached: silt strider.png (800x497, 85K)

"Because".
I'm writing a program for GNU/Linux, and I don't want to use GTK or Qt cancer. I'm using libwayland-client and EGL directly, but that's something I'm already quite experienced in.
I could do it in software, but I decided to do OpenGL instead. I also want to get good at creating graphical programs that actually have structure; everything I've done so far as been very ad-hoc.

You are absolutely insane but sure.
You want some level of scene graph. You've conveniently avoided the horrifiying OOP problem of "whats a window" and "whats a button" and etc and then how to overlay them because that's part of your rendering process

Your biggest problem will be interaction detection. OpenGL doesnt work well outside of its classic context unless you do pixel-exact rendering, and then scalability goes out the window.

hey guys im writing a php website for a school project. trying to make a social media website. i have a post class that i've got a function that echo's out a string with html including variables for the post information etc.
the issue im having is that the function isn't being called even tho im explicitly calling it in the body of my index.php and i know it isn't because i have a print statement at the first line of the function to see what the deal was and nothing is happening.

pls help

Attached: 1548584295125.jpg (613x559, 62K)

From the last thread, your teacher either wanted a lookup table of tallys (only reasonable within limited range) or to sort and count.

Here is a sorting solution.

Attached: count_rand.png (480x756, 29K)

don't just give it to him user, you're enabling pajeet behavior.

If you posted code it would be help, also this might be a question for

Working on a arduino powered near-space photography project, always been more of a hardware guy than soft, but im having fun and learning a lot! Individually the program can be broken down into a bunch of functions, a function to pull GPS co-ords from the module, a function to collect sensor data for temp/pressure etc, thats all easy stuff on it's own. But getting it to work all together is the issue im having, the project is quickly getting bigger than I planned. Is this normal in programming?

>YOUR MAIN RESPONSIBILITIES WILL BE

>Produce solutions which compete in an extremely latency sensitive environment
>Research and prototype state-of-the-art machine learning models
>Design terabyte-scale data pipelines
>Transform machine learning models into trading strategies

here's where i call it in the html

Attached: Screen Shot 2019-04-17 at 8.25.24 PM.png (1620x612, 112K)

but i don't have a job and i'm already working on a CS degree at videogames school
kind of what to graduate and go into a developer job at a boring normal non-videogames office building though

Attached: .png (1359x847, 684K)

here's where i init some variables and attempt to print

Attached: Screen Shot 2019-04-17 at 8.26.15 PM.png (1606x1212, 197K)

>dev.stephendiehl.com/hask/#monadic-myths
>The purple book is your best bet. Haskell is a language your brain has to chew on, just as any FP language is. The biggest adjustment is procedural to FP, except Haskell FORCES you to stay in the FP realm. Look up exercism.io and absolutely refuse to google the solutions to their haskell course, it's actually a really good way to get used to it.
Much appreciated, user. Figures I'd find better advice here than on the dumb shit official wiki.

Hi, I'm a math undergrad and want to learn to code. What language you guys recommend? I'm on Linux and am already playing around with C if that helps.

and heres the string im trying to actually get to print. didn't include a bunch of stuff i used to evaluate time elapsed

Attached: Screen Shot 2019-04-17 at 8.26.22 PM.png (1568x770, 101K)

python is simple to learn and useful in man situations

what do you want to DO?
python with numpy is pretty popular if you just want to write short scripts to calculate some numerical value or automate other minor things

>i have a print statement at the first line of the function to see what the deal was and nothing is happening
What happens if you put an echo before the $post= line? Does it show up in the output? If not, the problem isn't your function but some server configuration. Do you have php set to output errors? It's usually off when not debugging because those error messages contain information that people could use to exploit shit PHP code(extremely common).

>four things that have nothing to do with each other, and each require a PhD to do well
Good luck user.

Python or matlab, R for visualization.

X = int(input())
Y = int(input())
z = 0
if Y > X :
z = X
X = Y
Y = z
sum = 0
for x in range(X, Y + 1, 1) :
if x % 13 != 0 :
sum += x
print(sum)

why does this always return zero?

Attached: 1540697059000.jpg (482x322, 23K)

Keep going with C for one, check some books that specifically target math topics: numerical.recipes/ this is cool shit, Modeling With Data by Ben Klemens is ok kind of basic, I'd like more "C for math" texts actually.

I would suggest R, though it will be slower for grinding heavy computations but it's very well suited for a lot of other computational tasks, and the repository CRAN is full of high quality libraries. If you need heavier performance, you can of course drop to C or fortran, and there's also the Rcpp library.
It's great at visualizations, has functions as first-class which is good, vectorized operations which is quite nice.

Attached: neat2.png (731x594, 71K)

it should return the sum of all numbers between x and y divisible by 13 btw

>python
why the fuck did this meme ever get started
it's a garbage language that will teach you "how to code in python" not "how to code"

it does show up the output

python is the language all the math dopes use for numerical shit
unless it's super heavy duty extreme processing power shit in which case you probably use C or fortran

your code currently is ensuring that Y is never greater than X, otherwise it swaps them
also your divisibility check is incorrect

If you are /sci/ then C is a waste of time since you can't optimize it worth shit. Your undergrad math talents are being wasted in C, find literally any other language with it's own compiler that is not LLVM/gcc, and then you can use all kinds of optimization tricks on it. dj bernstein has a talk about this, how much C is a pile of shit for optimization reasons and basically set us back 2 decades. If I were you I'd pick up the book Algorithm Design by Kleinberg/Tardos to learn how to deal with hotspots in optimization, take a compiler course after for some language that isn't LLVM/gcc, and then optimize the fuck out of it for fun and profit.

There's plenty of languages used by math people
mathematica, maple, R, matlab, octave, fortran
python is just general-purpose enough to get people with no programming experience into it, but it's just riding on inertia now, it's not a good language at all

X,Y = int(input()),int(input())
sum = 0
for x in range(X, Y + 1) :
if not x % 13:
sum += x
print(sum)

It's not a meme. Sure python won't teach you software engineering but that's not what he's asking.
He's a math guy wants to write programs to do computations for him. Python is the industry standard when it comes to scientific computation, and in many different disciplines. NPL, ML/AI, geology, whatever. They all use python.

most of those languages are abominations that try to appeal to mathfags yet are still imperative.

Ran into a situation today where previous programming knowledge of a framework was easily transferred to a new platform. Feel good because it revealed the scope of programming as a whole as finite (masterable).

Attached: W8Br7930.jpg (1080x1080, 43K)

Should we tell this guy about Haskell?

I don't know then, everything looks syntactically correct in what you posted. Test case 1 should show up. You do have errors on though, like if mysqli_query throws an exception you see it? If not try moving that echo test case 1 line to the very first line of function.

Not yet.

I don't think python is the "undisputed" industry standard by a long shot, many people enthusiastically use R as their computational language, especially since the rise of data science and ML, since R is not just computing, but specifically designed for statistical computing. So you have plenty of statistics packages and methods that you don't have in python, which is more general purpose.

I'd also argue that R is easier to pick up for someone with no programming background, python has some major bullshit gotchas that aren't clear if you haven't programmed much

R is functional

Attached: python_environment.png (492x487, 53K)

you're right, can't believe I didn't notice the first one. how are these divisibility checks different though?

if you nuke all of those shit pythons and just install conda, and only use conda religiously you never have these problems

Notice: Undefined variable: conn in /home/cse3321g9/public_html/grapevine/includes/classes/Post.php on line 52

Fatal error: Cannot access empty property in /home/cse3321g9/public_html/grapevine/includes/classes/Post.php on line 52

the conn variable its talking about is the connection variable i use throughout the class and it works fine in the submitpost function of the class.

Attached: Screen Shot 2019-04-17 at 9.01.51 PM.png (982x434, 57K)

holy fucking shit im retarded. where it ref it on line 52 i have $this->$conn im fucking retarded holy fuck

Attached: 1541730197143.jpg (660x400, 29K)

oh I see
yeah

error messages are helpful

My info is a bit dated so you might be right. My understanding was that R is the king of visualization. I didn't think it had the breadth of libraries that python has for scientific computations.

>if you do this you solve the problem
>if you do that you solve the problem
>some random tutorial: do it this way
>oops that's not python3
etc
you're just adding to the spaghetti, you know? It's fine that it makes sense in your mind but to a newcomer there's a massive amount of bullshit that doesn't smell like bullshit at all until everything's a big mess

checked yea thanks for reminding me to turn that on. im still not really used to using php and i usually can figure it out without them but this is the first big project ive worked on.
thanks a ton user

Attached: 1542138863389.gif (540x501, 1.56M)

Last night I got this working. I like the encapsulation, I may play with moving the internals of the struct into another file and making it opaque+accessors.

Attached: compiling.png (2362x1281, 217K)

if you want to code for reasons other than just doing math work, Haskell may be interesting to you
it's a functional language based on lambda calculus rather than the more traditional imperative langs and there's a lot of math stuff going on in how the language works

>I may play with moving the internals of the struct into another file and making it opaque+accessors
if you're really into this sort of stuff you should into c++ and do more oop

I have never considered tutorials to be a valid method of learning any subject, from 3D, to programming, to basket weaving.

blacker boxes

Attached: yes.png (1645x1015, 123K)

No! I'll have to learn it anyway for work eventually.

Attached: Based_Chen.png (4001x2850, 725K)

Why not use visual studio or Qt creator?

This is fucking disgusting

you can literally start off by doing "C with classes and you have to cast malloc's return type)

Why not use cairo?

So, I just discovered tgmath.h is a thing.
Looks neat as a workaround for not having proper generics number types.

It's pretty neck-and-neck really, though really I hate this race analogy with languages in problem domains, but anyhow...

Python has grown a lot in general popularity I believe as a result of its general acceptance in academia and elsewhere as a general purpose high-level language, which results in it growing in the fields of statistical/machine learning and computation.
But, that has always been R's specific problem domain, and it excels in certain aspects of it. Since they are quite "neck and neck", I don't believe it matters much which one a person picks up, though I find R's functional attitude and vectorized operations to behave more how I think, as a math-guy, while still being quite approachable as a high-level language. I don't think that python is probably a "bad" choice though, despite how much I dislike it, I mean it is quite popular and that's probably not a coincidence.

imo: prototype and model and visualize with R, profile, drop to C at bottlenecks.

Don't need them. I do my own makefiles too.

That's basically what I was planning, I do not want to deal with polymorphic homosexualmorphisms template trash, ever.

And you should cast the return of malloc, otherwise someone will fuck over your functions.

polymporhism and templates are bretty good though
just don't use inheritance for "code re-use" or any purpose other than polymorphism, and don't have inheritance trees more than 1 deep.
if you need more code re-use than that just use composition -- put the old object inside the new one as a member variable

trying to make a text editor using SDL and realizing that I basically have to do collision detection to see if I am mousing over text lmfao

Attached: 10gallon.png (1045x847, 792K)

I'm writing a python module for easily converting between markup languages

If I was going to write something something with software rendering, I probably would. Or maybe pixman, which is a lower level drawing library that Cairo uses internally.
Cairo's OpenGL backend seems to be in a pretty weird place; I wouldn't bother trying to use that.

>Don't need them. I do my own makefiles too.
Of course you don't, but you also don't need a keyboard. Why don't you just use the on-screen virtual keyboard if you're going to intentionally make things more of a slog than it needs to be?

kdnuggets.com/2018/05/poll-tools-analytics-data-science-machine-learning-results.html
>Python seems to swallow not only R, but also most other languages, except for SQL, Java, C/C++ which remained at about the same level.
and again I'd argue that this is due to a widespread acceptance as a general purpose high-level language, NOT specifically due to the merits of python, but that is just my opinion (though I think it wouldn't be hard to support with some data on general programming job postings)

kaggle.com/stardust0/python-vs-r
OP didn't specifically say data science/ML, rather general math though, but I'm just looking at that side of things. Without knowing what area of math, and likely as an undergrad he's not yet sure himself, it's hard to recommend a language.

Your text windows should be in a predictable spatial coordination, in 2D, and your mouse is locked 2D. You can always immediately go from mouse to "what am I above" by having a function that maps a full screen coordinate to the location of an entry in your text viewport

Using an IDE is more of a slog for me than not. Since I got my function structures working, I should be able to turn on autocomplete and work with those.

>Using an IDE is more of a slog for me than not.
Cnile incompetence never ceases to amaze me. If you can't even get a simple IDE like Visual Studio working, I don't think programming is for you.

>Visual Studio
AHAHHAHAHAHAHAHHAHAHAHAHAHHAHAHAHAHHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHHA.
You should leave.

based Cnile

I have a couple hopefully simple questions. I have an Access 2016 database and a C# winforms program for accessing it. First, how would I go about making the database network accessible?

Can I just put it on a network drive and give the C# program the path to it?

Second, do I have to do anything more than enable record locking in the DB to allow multiple users to access it at once?

>hating on one of the best IDEs on the market
you're either a useless neet or a useless old fart. Either way you have no idea what you're talking about. I bet you've never even used VS

Project Euler 8 in F#. Had to snip the input.


let input = """
731...
"""

let adjacent = 13

let cleanInput = input.Replace("\r\n", "").ToCharArray()
let intInput =
cleanInput
|> Array.map (fun x -> (int x) - (int '0') )

let product arr =
Array.fold (fun s (x : int) -> s * (bigint x)) 1I arr

let euler8 =
[0..cleanInput.Length - adjacent]
|> List.map (fun i -> product (Array.sub intInput i adjacent) )
|> List.max

Go home, microcuck. We all use real operating systems here.

>Can I just put it on a network drive and give the C# program the path to it?
Yes but this is pretty insecure.
>Second, do I have to do anything more than enable record locking in the DB to allow multiple users to access it at once?
I don't know if Access has any quirks specific to it, but the databases I've worked with all allow concurrent access by default.

>We
stop trying to associate us with your useless retarded self.
>We all use real operating systems here
that has nothing to do with Visual Studio, freetard. .NET Core is open source and cross platform, thanks for proving you really do know nothing

>.NET
AHAHAHAHAHHAHAHAHAHHAHAHAHHAHAHAHAHHAHAHAHHAHAHHAHAHAHHAHAHAHHAHAHHAHA

flawless argument from a manic spastic

Nobody cares about your shitty opinion, microcuck. I'm not going to bother with someone as mentally deficient as yourself; it goes twofold because you're a retarded sepplesfag too.

how do you like F#? I'm occasionally in windows for other reasons these days and have thought about checking it out

greasy fat hands full of cheeto crumbs typed this post

as a 15+ year linux dude I'm so sorry you had to see this
If I'm not using vim I'm using VS code, because it's simply extremely good software.

Is there a folder/collection somewhere of all these Jow Forums related anime girls?

Attached: 1471911602546.jpg (852x973, 475K)

Whatever helps you sleep at night, cuckboi.
Lets just hope that daddy satay nutella doesn't take your computer away any more than he already has, but I guess you're into that.

Quick follow-up:
Do I need to install the Access DB Engine on every machine that will use my client, or just on the one with the network drive?

Yeah, see. That's why people tend to use GUI libraries to make GUIs. Not a lightweight connection to the graphics pipeline designed primarily for video games.

I'm a C# fangirl so I'm take it with a spoonful of salt, but so far I'm really liking it. I've only been learning it for a few weeks, and my only prior experience with FP was some lisp-like language.

I'm sure it's missing a lot of neat stuff compared to Haskell, but the trade-off is having access to the entire dotnet (core) ecosystem. I've had surprisingly few compatibility and interoperability issues so far, and for the most part everything just works. I had some issues with entity framework but that was probably mostly due to sqlite and not F#. The compiler is really slow though.

All in all I'd give it an 8/10 so far, and it might become my new go-to choice for personal projects when I get more used to the FP style. Here's a cool web server library (it runs Kesterl/dotnet core underneath, so top-end performance), look at how clean everything is! github.com/giraffe-fsharp/Giraffe/blob/master/samples/SampleApp/SampleApp/Program.fs

just finished a Go Fish game in Java
Why was that so fucking hard?

>muh microsoft bad and cuck buzzwords
>literally zero argument
>everyone else having normal discussions about C#, F#, .NET and .NET Core while you sperg out
you're like a parody of a Jow Forumstard. Pathetic

archive.rebeccablacktech.com/g/search/subject/dpt/
some from Jow Forums, /a/ and /jp/, make an image collection. you can use the archive too, look up the thread this image came from.

Attached: 1434575313211.png.png (1162x1737, 2.37M)

Just the one that hosts the database. You might need client libraries to access it from your code, but those should be baked into the .exe file when you compile.

By the way, I should mention that the proper way to do this is to have, on one server: Your database, and A server application that listens to HTTP requests.
And then every client communicates with the server over HTTP. That way you get better performance (server to database latency is 0 because they are on the same machine), and it's more secure (you only have to expose the HTTP port, rather than exposing the database directly to the network).

But depending on where you'll deploy this, it might not matter. For example if it's just a side project you will run on your home network, feel free to disregard this.