/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

math.stackexchange.com/questions/1270814/bounds-for-n-th-prime
twitter.com/AnonBabble

can a memelang like python or go do anything this powerful?

data Cow = Cow {
name :: String
, age :: Int
, weight :: Int
} deriving (Eq, Show)

type Valid = Either [String]

noEmpty :: String -> Valid String
noEmpty "" = Left ["Input cannot be empty"]
noEmpty str = Right str

noNegative :: Int -> Valid Int
noNegative n | n >= 0 = Right n
| otherwise = Left ["Number cannot be negative"]

mkCow :: String -> Int -> Int -> Valid Cow
mkCow name age weight = Cow noEmpty name
noNegative age
noNegative weight

*Cow> mkCow "" (-1) (-1)
Left ["Input cannot be empty"]

Is there a reason Either's Applicative doesn't mappend Lefts?

thanks for using anime image

What's the worst code you've ever written?
Triangle:= VideoBuf^[(((mposx-155) div 8)-1)+(((mposy-167) div 9)-1)*ScreenWidth] shr 8 and 15;

>Man, I'm too lazy to write a function to put pixels on the screen, I'll just edit the buffer directly and test this real quick
t. me a couple of years ago

you should turn that into a bitsieve, friend

also, for future questions these bounds are nice in conjunction with a sieve math.stackexchange.com/questions/1270814/bounds-for-n-th-prime

wow what the fuck rand() is not [0.0, 1.0] ?
C has no such function for floats?

I am starting to hate this language.

Are you literally too dumb to breath by yourself?

Because it needs to be applicable across all types, not just monoids. There's no way to specificy in Haskell "mappend if its a monoid, or do nothing if it isn't", mainly because you could have some parametric type where you don't know if its a monoid or not.

They could have just tacked on the monoid dependency, like the instance for tuples does.

(float)rand() / RAND_MAX
That sure was difficult.

If you want to use some random functions that aren't completely shit, but the POSIX drand48() or some shit.

a = Identity a
Either e a = Except e a
r -> a = Reader r a
(a,w) = Writer w a
s -> (a,s) = State s a

For the majority if cases, you don't need your exception type to be a monoid. But you always want your writer type to be a monoid. That's why the tuple has that dependency.

does not change the fact that C is very easy to dislike

probably like ~year ago when i was using crystal with it's strange type system, so e.g. you have an int var, then assign a string to this var so it becomes like [Int | String] and now you need to do .to_string to use string methods. At least that's how i remember it

>that doesn't change my stupid opinion
ftfy

That's fair; I'd assumed that monoids for plural failure would be a common or intuitive use case, though.

Does anyone know of any good resources or tutorials for learning software security?
I'm a brainlet who's only ever done shitty math scripts in python and I want to branch out.

How does Sup Forums feel about the trend of new compiled languages that try to feel like scripting languages? Nim as fast Python, Crystal as fast Ruby, etc. They seem popular on shithub but I'm skeptical whether they have a chance to take off.

The one I think was most interesting was some bizarre free-software Rebol kind of thing. Seems like it's being written by an idiot though, he's implementing the UI toolkit before the rest of the standard library.

>the trend of new [...] languages
This is natural, everyone likes building languages. It feels like the second most complicated things to do after operating systems. The issue is the design is actually way more complicated than the implementation. Syntax has to serve semantics and all modern languages feel like they are built around syntax. See Pascal or older ML for an example of programs with a grammar that try to describe the semantics. Homoiconicity is the ideal version of this but it limits possible optimization.
tldr they're unironically all memes.

retard

That doesn't really address the idea behind them though, it looks more like they want to rehash existing designs intentionally.

Then there's Rebol and it's new freetard dialect. That language is just fucking weird.

Nim somewhat reminds me pascal. At least it has some nice features like templates and work with AST in it's standard library. Also, LLVM basically removes the difference between compiled and interpreted languages cuz it's so fast and you can interpret AND compile llvm IR

How does one accurately control the difficulty of a blockchain mining algorithm? I've tried sha256, md5 and a number of other methods but they're all "uneven." i.e. increasing/decreasing the target has random effects on the difficulty of the mining procedure. I need to be able to tell the mining difficulty for sure.

Trying to understand programming but never done it before I feel like I got into something i shouldn't have.

>Also, LLVM basically removes the difference between compiled and interpreted languages cuz it's so fast and you can interpret AND compile llvm IR
If this means they could just develop an implementation of Python that compiles to fast native code, they must be fucking morons, then.

Hm eratosthenes sieve is quite basic, you could do much faster by using quadratic sieve. At any rate it may not be in your best interest to use fixed-width types. If you want to ensure at least 64 bit ints then use unsigned long long. Also, don't forget to use the same type for indices as that which you compare them against in the predicate of your loops.

>LLVM basically removes the difference between compiled and interpreted languages cuz it's so fast and you can interpret AND compile llvm IR
There is an overhead from what you call interpreting. Then there's the very efficient JIT module, but again it pretty much requires having LLVM installed on the client computer.

Carmack was right.
The true path to enlightenment is to write everything yourself, at least once. No matter how trivial, write your own libraries for everything, from string manipulation to vector matrixes.
Only then will you truly understand what's what.

I did a couple of attempts of writing my own graphics rendering from scratch and even that small experience gave me many insights to WHY things are done the way they are.

>couple of attempts of writing my own graphics rendering
Tell us more about your GPU driver

There is one by dropbox, but it's 2.7 and deprecated

>computer graphics = hardware acceleration
Retard.

That's why I'm smarter than you.

what if you are a lazy fuck?
I wish I had your drive, I feel like a hack...

>to write everything yourself
You sure are.

>look mom I can fill triangles

This is what happens when someone who doesn't even understand the topic at hand tries to argue.

Pro tip, you don't need a GPU or dedicated hardware to draw pixels to a screen.

Oh, so you're doing software rendering and calling that "graphics".
Even more pathetic.

burn in hell for not using an anime image

>when someone who doesn't even understand the topic at hand tries to argue
Except unlike you I've actually written a GPU driver. You can keep feeling enlightened, dumb frogposter.

help

Apparently, you're still too dumb to understand what "computer graphics" or you're a gamer kiddie or whom "graphics" is equivalent "vidya cards"
You went full retard, now stop trying to save face.

it's anime

>trying this hard to invert roles
You were the one acting all defensive in but whatever. Now reply to this so you can have the last word and I can be done with you.

I'm using C# to capture an image but I have it hot keyed to the print screen button (It's kinda like puush but for my own website so I'd prefer to keep it that way), but because of this I cannot copy the link to the clipboard presumably because windows is copying the snapshot instead. Can you guys think of a way around this?

I'm also lazy as shit, the trick is to do something funny and personally stimulating as an excuse to learn those concepts.
Think of it as an art project rather than something you need to be "good".

Sure, I'll humor you with a (You), if you're so desperate. Now go be butthurt somewhere else.

I bet you were born like a decade after 3dfx was founded.

Is it feasible to train a neural network with lots of censored 2D anime girls and the corresponding uncensored versions to create an automatic decensoring software?

Asking for a friend.

It is. I'd even say it's on the easier side of ML.

Would you have to stick to one specific censoring method (like mosaic)? Or would it work to train it universally for all of them.

I'm not really sure how these things work, like how big of a training data set you'd need for decent results.

I'm gonna look into that waifu2x project.

Didn't someone already do that exact thing in these threads?

If they did it must've been very unsuccessful or everyone would know about it.

What programming language goes best with pink-and-white stripped socks?

Color scheme please

LISP or any derivative like Clojure

He only posted about it a few times, and it was several months ago.
He said the vaginas it was generating looked weird.

>Le fag socks
Stop posting this fucking shitty forced meme.

...

Thanks, sexy son of a gun :33

What do you plan on moving to, after c?

>go to mediocre state school
>learn c++
>transfer to '''''good'''" school
>they use java
why

Because the language (they use for introductory stuff) doesn't matter, it's just a tool.

Why would anyone voluntarily use java?

So a raytracer. Now do photon mapping or radiosity.

I would say because of an absolutely massive number of job opportunities for Java developers which could help you, you know, get a job and earn some money (for instance to pay those ridiculous loans of yours)

doing wordpress migrations and plugin development
pls kill me

A colleague of mine had to work with wordpress for uni.

I feel your pain.

i have to do it to survive (no degree and clients want wordpress because they're retarded) i make good money but it kills me inside. i cant wait for the weekend to bust some arm64 assembly :D

dumb rust shill, don't drag lisp into your gay shitposting.

>VS Code
>Doesn't know the difference between .C and .c files
lmfao

...

wth dude

How's your first day in /dpt/?

>the procedure list-ref takes as arguments a list and a number n and returns the nth item of the list
>For n = 0, list-ref should return the car of the list. Otherwise, list-ref should return the (n - 1)st item of the cdr of the list.
Those statements clearly contradict each other!
Why would someone want to number the first element with 0 anyway?

>Posting tired and forced memes make you le oldfag
Piss off, fag enabler.

Enjoy your stay, fagboi :^)

Fucking Microsoft can't even use their own rules. People that think it's ok for their program to use .files or .folders should get gassed. The same goes for using %userprofile% or ~ to store your config files.

Which one would you prefer?
#include
#include
using namespace std;

int
main(int argc, char** argv)
{
for (int i = 1; i < argc; i++) {
cout myint))
myint = 0;

std::cout

I never understood why people use C# over real languages like C++ really

First one, but please stop using char* str style.

>please stop using char* str style
What's the alternative?

Switch to a programming language that doesn't require identifiers.

char *str
The * is part of the declarator, not the type specifier.

If the type is not declared the program is either monumentally slow or massively bloated

char* is a type, no?

For example?

Support for modules, GC, fully defined ABI for compatibility between different compilers.

Sure is, but C doesn't declare identifiers by naming their types. That's too easy.

C++ has all 3, with clang

char* is actually char *(unnamed variable). I know it's stupid but that's what C programmers like.

Scratch

Using char *x rather than char* x is mostly considered a better practice because in e.g. char* x,y one might think thay both x and y are pointers, but x is a pointer and y isn't, which is kinda confusing, but with char *x, *y everything is obvious

>fully defined ABI for compatibility between different compilers.
>C++ has it with this one specific compiler
:thinking:

Clang is a compiler, C++ is a language.
C++ does not have those things. Nothing that a compiler does can fix this.

>C#
>Compiler
:thinking harder:

Is there any way I can do something like this
#if __FILE__ == __MAIN__
int main()
{
...
}
#endif

So that I can run tests if I compile the library separately and remove them when I am compiling the library into my program?

>C++ does not have those things
Clang has modules for C++, you can add a GC to your C++ (I don't know why you need GC), and C++ has a standard ABI

The only standard ABI C++ has is extern "C".

Which is more supported than C# ever was, and will be

>C++ has a standard ABI
laughinggirls.jpg

>C++ has a standard ABI
Prove it. I know for a fact that name mangling is different for Clang and MS compilers.

>I don't know why you need GC
Me and hundreds of thousands of other programmers using GC languages*

C# defines name mangling at standard level, unlike C++ which does not.

>C# has a standard ABI
laughingpajeets.jpg