/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: n201jldq1pc21.png (1683x643, 166K)

Other urls found in this thread:

ourmachinery.com/post/physical-design/
github.com/bottlepy/bottle/blob/master/bottle.py#L2752
twitter.com/SFWRedditVideos

first for huge fukin anime tiddies

how long until they make keyboards with emojis on so I can code properly?

Why do Rust hate monads so much?

how long until I can use emojis as pointers in C+++++

JavaScript rocks!

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

how long before they make keyboards with anime girl keys?

Attached: 1545222660165.gif (640x360, 439K)

What if I added a >>= operator to my language such that x = a >>= b; was equivalent to
x = a ? b(*a) : none;

where a is an expression producing a value of maybe type.
Which, I don't claim to know Haskell, seems pretty similar to Haskells monadic error handling I saw when I spent like a few minutes looking into Haskell.
Good idea?

they already do.

Python is the most powerful programming language

start a fucking blog I dont want to hear about your attempts to recreate Haskell

I'm not recreating Haskell, I just want to create an efficient systems programming language with good zero overhead abstractions and good error handling.

how about you learn to program first you fucking dunning-kruger idiot

I already did.

It's compiler-dependent. I think you could use emojis as pointers with gcc by defining a charset and passing it to the preprocessor with ' -finput-charset='.

C++ is SHIT-tier.
>Inb4 t.brainlet.

t.brainlet.

>inb4 t. brainlet
>t. brainlet

what are actually good use cases for Nim? it seems nice, but I can't really tell if it's supposed to be fast low level language (like rust or C/C++), middle level lang for business logic (like java or C#) or quick'n'dirty high level lang (like python or js)

Mostly boosting its author ego.

that's Haskell >>= specifically for Maybe
but Haskell uses >>= for all monads

What does >>= do in general?

this, it's not particularly terrible but it's pretty obvious a personal project

gives you aids

it depends on the monad

What's it like to program in VBA, is it awful?

lets you endofunct monoids

>What's it like to program in VBA
Have you ever had sex with three women at once?

>mfw found and fixed bug in one of st patches
I've not used C for years. It's shit, but it's still fun.

Attached: 400.jpg (409x400, 88K)

I haven't even had sex with 1 woman

Well it doesn't matter because VBA is nothing like that

Plough the hottest woman first... the other two... nope...

What if the woman has an std?

i want to get a job, Jow Forums told me to use C
so ive been using C on my hobby projects
but all the jobs seem to use java or javascript
and they ask to see examples of projects built in either
the problem is i dont understand the purpose of java
why on earth would i choose to build anything in that over C?
i guess for javascript i could make a personal website, but id rather try doing that in C too
...
did i get memed?

You're talking about C++.

You got memed into thinking that programming is about mastering a language.
Good programmer knows many languages and don't see them as good or bad, but as set of paradigms with syntax sprinkled on top of them. Different languages are suitable for different tasks and you as a programmer should be able to pick proper tool for given job. Programming skills transcends mere languages.

Anyone have an "up to date" method for extracting a bitmap from a WebView? The way I'm doing right now doesn't work and every other way I found online is full of deprecated references.
fun getBitmapFromWebView(webView: WebView): Bitmap? {
try {
val widthMeasureSpec =
View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)

//Measure WebView's content
webView.measure(widthMeasureSpec, heightMeasureSpec)
webView.layout(0, 0, webView.measuredWidth, webView.measuredHeight)

val measuredWidth = webView.measuredWidth
val measuredHeight = webView.measuredHeight

//Creates the bitmap and draw WebView's content on in
val bitmap = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888)

val paint = Paint()

val canvas = Canvas(bitmap)
canvas.drawBitmap(bitmap, 0.toFloat(), bitmap.height.toFloat(), paint)
webView.draw(canvas)
return bitmap
} catch (e: Exception) {
e.printStackTrace()
return null
} catch (e: OutOfMemoryError) {
e.printStackTrace()
return null
}
}

This. But we're gonna make it, user. You must always have faith.

Attached: feels solidarity 1.png (833x768, 37K)

I once wanted to make games and heard C++ is good for that but then I found out it encourages the usage of "STD vectors"!? What the hell is this kind of FUCK UP SHIT?!

>why on earth would i choose to build anything in that over C?
Java is a language with a higher productivity rate.

sorry for your loss

Says Pajeet that gets paid two rupees a month for copying and pasting Java from SHIT overflow.
Try harder.

t. suckless cultist

What do the clocks do?

Don't you ever post wojaks at me ever again. And no I don't want to touch filthy 3D, get that away from me.

There's nothing to argue here. I'm not talking about the quality of the code or the speed of the app itself. Languages like Java and Python are just faster to learn (so training is less costy) and they can produce commercial products faster due to the number of libraries at their disposal.

Allow you to wait for an asynchronous part of the code to finish.

>Allow you to wait for an asynchronous part of the code to finish.
Jesus christ.
Is it common to use emojis in code? I mean I know that image is probably a joke, but do people normally use emojis (either in comments or as identifiers) in their code?
Obviously I'm talking about github project-tier stuff and not enterprise code.

I don't think so. At least I never seen it.

I've seen emojis used in comments.

sure if i were to build a website for a client i would pick php or node.js, if they wanted a desktop app i would pick c#. each of those options would be the quickest and easiest way to build what they wanted
but when programming on my own time for myself, i would rather pick the language that will let me write the best code, be it elegance, or lightweightedness
but i recoil at the idea of writing some shitty app for literally nobody so i can say; "see look i did stuff in X lang"

Can you imagine an absolute madlad giving you a laughing crying emoji when you go check his comments? I reckon I would just quit on the spot.

>STD vectors
that sounds like unsafe code

Is this the best way to do this?
template
constexpr auto IsAnyOf = []() {
return (std::is_same_v || ...);
};

struct High {};
struct Low {};

template
constexpr void
pinState() {
static_assert(pin < 8);
static_assert(IsAnyOf());
if constexpr (std::is_same_v) {
PORTB |= 1

by using AST

what do you want

>someone is trying a novel way of reducing compile times in C++ for big projects
>headers can't include other headers
ourmachinery.com/post/physical-design/
>read through motivation and the details of applying this rule
>all completely sound
>they explain how tricky classes become
>explain how pimpl solves this but is a complicated way of writing everything.
>solution
>"Our solution to this is simple — we don’t use classes. Our header files are written in plain old C, C99 to be precise. Theimplementation files can be either C or C++ — whatever makes sense for that particular piece of code — but the APIs and interfaces are strict C."
>"We have several good reasons for this approach, which I will detail in a future blog post, but the main one is that it gives us better logical decoupling."

I think they're onto something when they say you shouldn't write C++.

Just define setHigh and setLow functions.

That is map.

No
void pin_state(u8 pin, bool v) {
if (v) {
PORTB |= 1

Not in code, but u often add emojis to titles of important commits because they look goofy and are easier to spot.

Also you can use emojis as reaction to GitHub comments, eg thumbs up/down for voting.

I'd still suggest to use various languages for hobby projects, just to make your life simpler.
I have my own stack(Rust, PostgreSQL, LUA, Node, React, Unity) and I pick whatever fits best out of these.

building a new cryptocurrency - it started out as a project to learn about bitcoin's blockchain but now it could be it's own shitcoin... uses a mix of proof of location using IP addresses and proof of work

> 2019
> building a new cryptocurrency
You're 5 years too late, m8.

Actually I made it simpler.
struct High { uint8_t pin; ~High() { PORTB |= 1

This is retarded.

is there a standard python3 library that can convert a string to a safe filename?

pathlib?

Just define it yourself
def string_to_safe_filename(s):
return s

>pathlib
yeah I searched for this but I don't believe it can convert strings

are you drunk?

Are you?

Strongly typed code is retarded?

You don't need High and Low structs. use bool, it's literally perfect for setting pin bits.

>convert strings
what is the problem you're trying to solve?

I use the structs because of their types.

Yeah and you don't need them.

I don't know of anything in the standard library. And there's multiple approaches to "safety".

Suggestion:
- bottle.py has custom code to do that github.com/bottlepy/bottle/blob/master/bottle.py#L2752
- url-escape it. The result should be both filesystem-safe and readable.

Why not?

Because bool is already perfect.

My script can download music files and writes them to disk with a filename based on their tags. Some tags can contain non valid characters and I want to filter those before writing. This script must be cross platform so aside from the obvious non valid chars, on Windows NULL and such must be converted to something sane, while on Unix, '.' and '..' must be converted. In addition, path length and file length must trunecated if it is too long. This can pose additional problems because in linux it must be 255 bytes long (and unicode chars can be 2 bytes) while in Windows it must be max 255 chars I believe.

So in short, I would like a library that can handle all of this. It want to keep the external libraries to a minimum so a standard library is preferred.

I earned BSc in theoretical physics. Did master thesis in biophysics. Considered going to PhD studies, but
> fuck academia, I don't give a shit
Learn to code:
> Done
Wrote a program for algorithmic calculations in quantum field theory
> Fuck Python
> Fuck deep learning/neural networks and AI hype
> Start learning C
Meanwhile, had a couple of interviews.
Should I accept a job in a bank or just kms?

enjoy writing java fizzbuzz for the rest of your life

> Fuck Java

Sorry if this is a common/meme question, but if I wanted to create a simple 2d game like Stardew Valley, what language would be best? I only have very basic programming knowledge from two college courses a few years back.

you do realise writing
>Fuck X
doesn't make people think you're cool or anything right? This isn't Jow Forumsyour_blog

Sounds like the sort of validating logic you'd have to define yourself

>master thesis in biophysics
just read this as master thesis in boipussies for some reason

No HKT lmao.

I'm not quite sure, if something like this is what you're looking for, but you could replace weird characters by using regex.
>>> re.sub("(?![a-z, A-Z, 0-9]).", "", "089uahnggəßðg{‚@£q$@32")
'089uahngggq32'

I don't understand what you're trying to do.

C# with monogame is easy and there's plenty of learning resources since it's basically xna. I'm guessing you did java so it shouldn't be too difficult to learn

yeah but they could at least have some sort of do notation, they don't need >>= to have a single
expressible type that fully captures its generality

I'm just angry, ok?
Leave me be.

another lame post

Do notation is just sugar for >>=. That's retarded.

what are some actually good programming and technology related sites

Attached: 1489100854781.jpg (669x425, 58K)

i am aware. what's retarded?

if (auto home = getenv("HOME")) {
...
}
else {
std::cerr

>Fuck deep learning/neural networks and AI hype
Successfully training a neural network to perfectly play flappy bird is the best feeling in the world, user.

in fact type info isn't even important

>Once I have been given a project I can autistically focus on it until it's perfect
>Can never think of a project on my own
I just lack creativity

yea i guess.... but it would look good on a resume though to be a founder of some alt coin