/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous Thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Forward_secrecy
signal.org/blog/asynchronous-security/
github.com/calccrypto/uint128_t
twitter.com/NSFWRedditGif

I love anime

Java or Javascript for cross-platform application development? (Mobile/Desktop/Web stuff)

Java

Javascript if you want to put things together quickly. Java if you're doing something large or if performance is a serious concern.

In C, can I create integers of arbitrary width and have their arrays packed (i.e. no padding), such as 19 bit integers? Can I use a struct and force it to be X bits large?

>Java or Javascript
They don't have anything to do with each other.
>Mobile/Desktop/Web stuff
They don't have anything to do with each other.

>performance is a serious concern.
>java
user, stop trolling. I appreciate Java for being cross-platform but I know where it fails

my php+mongodb porn search site

If you think Java is slow, Javascript is generally far worse, especially on mobile.

Javascript is emerging as a cross-platform solution with Electron and React Native. Both languages and frameworks are huge and very detailed so i want concentrate in one only.

Employed Haskell programmer here

...

Java or Go.

correct the colors and the hair outline

And the record

Employed Haskell programmer here

Go is a meme toy language.

What is your typical day as a software developer?

8:00 - wake up, decide to leave home immediately, so I can leave earlier
9:00 - actually leave home after masturbating and wasting time otherwise
9:30 - arrive at work
9:31 - open IDE, get coffee, chat with colleagues
12:00 - oh, I just opened the IDE and it's dinner time already!
13:00 to 16:00 - actually do something resembling work
16:00 - can't concentrate anymore and start doing all kind of shit
17:00 - leave, pretending to have worked full 8h

Glad that no one seems to notice how much of an underperformer I am. Some people get paid far less for far harder work.

but user java is fast. It just take some time to make it fast because of how the JVM works internally once your iterations starts to get bigger it often has the same performance of its' c++ counterpart.
Also you can fine tune the JVM to gain a even bigger performance. And considering that many good engineers already have a Java background it's a really good choice for large performance systems.

>mobile
Native.
>web
The current year meme framework.
>desktop
Lol >money on desktop. Proably java or c++

with a really sound concurrency model.

Tell that to all the huge companies using it.

>its'
>gain a even bigger performance
>many good engineers
>a Java background
>large performance systems
I wonder who could be behind this post?

Employed COBOL programmer here.
This is my first time on this image-board, my usual IRC closed, please be nice kids :).

Huge companies are also using Lua and it still a toy language.

> muh channels

Just tons of abstraction of something which already existed.

Haskell has a sound concurrency model.

7:00 - Wake up
8:00~20:00 - Rice and shitpost
21:00~22:00 - Porn
22:00 - Sleep

>Huge companies are also using Lua and it still a toy language
Lua is not a "toy language" within its niche of embeddable scripting.

const bool check_anagram(const std::string &s1, const std::string &s2);
So what does this const specifier mean? It's not producing a constant boolean

kek

test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test

I also forget the part where I ...

16:15 - ... ask on StackOverflow for advice regarding my current problems and get downvoted by the Pajeets
16:20 - Delete the question so I don't lose reputation and give up

I am trying to develop a multiplatform instant messager for work, so the users on our platform can communicate easier with each Hother.

Boss man says end to end encryption isn't necessary, and wants the messages to be stored in plaintext (so we can read them later, probably for platform intruige purposes).

Seeing as this is a small team effort, with me as team lead, I am going to circumvent this, and follow my morals.

Problem is, I can't figure out how to store the messages, without us being able to read them.

My plan so far is to store two copies of messages, each encrypted with one user's private key.
I'll generate this private key on login, using a unique salt, and store it client side. No keys server side.

This introduces some UX annoyances though, with users sometimes potentially having to retype their passwords.
It also requires metadata, so the user can fetch all messages in a conversation at a given time.

Does anyone have some books or articles on this? Or maybe some expreienced advice?

>It's not producing a constant boolean
It is producing a constant boolean, but the boolean just gets copied when you assign the return value. That const is completely pointless, but it's syntactically valid.

But is an unsound language.

with a hard syntax.
a white male engineer that hates Java, but love the JVM, that sometimes have to do recruiting.

are you trying to imply that a white male defending java would somehow be less of an insult than a pajeet defending it?

>send message
>randomly generate key
>encrypt message with key
>encrypt message key with each user's key
That's how you usually do it.
>This introduces some UX annoyances though, with users sometimes potentially having to retype their passwords.
Store the messages locally then, if they remove the app they delete the messages. If that's not possible, you have to store their keys. You could encrypt the keys with their password though. (in practice, you generate a key, use the password to encrypt the key, then encrypt the message with the decrypted encrypted key)
Use a password-safe hash function, you can generate it on the client, then just apply one round of unsalted sha256 on the server.

One key per message? Isn't that a bit excessive?

Keys are 32 bytes anyway, and this way you can easily implement group chats. It's also piss easy to implement.

en.wikipedia.org/wiki/Forward_secrecy

Once per session is usually enough, though

Yeah makes sense, thanks

That's apparently pajeet writing style, can't you spot it?
How do you have "sessions" in async messaging?
signal.org/blog/asynchronous-security/

Say I want to have a 120-bit integer array in C. What's the best way to do this? Should I use bitfields/structs, or is it easier to use char pointers and mask manually?

>120-bit integer
???
github.com/calccrypto/uint128_t

Just an example. Arbitrary width, not a power of 2, known at compile-time. 128-bit ints would waste 6.25% memory.

this code is what makes me feel like a pajeet and go back to /wdg/

If you're going with anything but a power of 2, you're going to waste tons of CPU cycles.

Holy shit i just discovered breakpoints, they are fucking awesome!
Can't believe i only learned about them now after so many years of coding

I don't care, I'm optimizing for memory. Is there an easier way than calculating an offset, dereferencing rootPtr+offset, and then fucking around with masking?

>bitfields/structs
That's not gonna help you. C has no support for bit arrays.

>or is it easier to use char pointers and mask manually
That's what you'll have to do, yes. (Although you should probably just use ints instead of chars)

doubt it

fuck opengl though

could use lisp tho

>use lisp when all you need is gmp
lol

Re sessions, it could be per-correspondence/conversation.

And how do you define a conversation?

A chat between two persons. One key per person you are chatting with.

Then you don't have forward secrecy.

Hey wow, Java's kinda neat.

Can someone tell me what is the endgame of programming or its purpose(beyond creating things obviously)? I want to get into it(no, not in a normie way) but really don't know if it is worth it other than for the novelty of it.

Yeah just read the article you posted.

Don't know how you'd do that.

>what is the purpose of a tool that helps you create things beyond creating things

Takes about 3 lines of code to implement bit vectors.

Okay Sup Forums, i've been programming for years now, as a hobbyist. I've made a lot of interesting shit like web servers, vector image generators and stuff. The problem is, everything was written in an awful way, using single letter variables, putting everything in the main function, absolutely no modularity or scheme. How do i learn to write code that i can actually understand a month after writing it?
Some of my projects are getting quite big, and they cannot be written in a single day, so if i write spaghetti code, i cannot finish the project at all

>putting everything in the main function
geez

read sicp

What languages?

C, sometimes C++

void vec4_multiply_vec4( vec4 *dst, vec4 *v0, vec4 *v1 )
{
vec4 v;

v.x = ( v0->x * v1->w ) + ( v0->w * v1->x ) + ( v0->y * v1->z ) - ( v0->z * v1->y );
v.y = ( v0->y * v1->w ) + ( v0->w * v1->y ) + ( v0->z * v1->x ) - ( v0->x * v1->z );
v.z = ( v0->z * v1->w ) + ( v0->w * v1->z ) + ( v0->x * v1->y ) - ( v0->y * v1->x );
v.w = ( v0->w * v1->w ) - ( v0->x * v1->x ) - ( v0->y * v1->y ) - ( v0->z * v1->z );

memcpy( dst, &v, sizeof( vec4 ) );
}


What does this do?
Isn't basic vector4 * vector4 just x*x, y*y, z*z, w*w?

>How do i learn to write code that i can actually understand a month after writing it?
Break down your problem into smaller structures and functions that can be named and reasoned about independently from the whole. If you can't figure out how to do it for a particular problem or subproblem, then do it the way you're used to, but when you're done, analyze it and see if there are any common patterns and bits of code that are useful on their own and abstract them away.

You can literally do whatever you want with it. Automation and computerized systems will take over everything in the next 50 years and one of the largest existing job markets is going to be programming and computer maintenance. You might as well get in now while the gettins' good. This is the modern gold rush my friend.

Make a game, make a OS, automate your emails, build a smut site, and have fun doing it.

That looks like a cross product to me.

>programming
>on wangblows

what did you seriously expect you fucking mong

Try ditching C and falling for the OOP meme. In a modern language packing everything neatly into modules is generally enough.

>vector4 * vector4
yields a 4x4 matrix

it returns vector4 though.

>Try ditching C and falling for the OOP meme
And this is why OOP projects are always such a cluster-fuck. OOP brainlets unironically believe that their project becomes magically organized if they break it down into "objects".

This makes a lot of sense

Well desu differences between C and C++ aren't too big, so i've been thinking of using C++ as my main language for some time now.

Bruh, that's a 4D cross product.

>4D cross product.

Java.
Javascript is never an option.

Yeah, that was probably the wrong way to put it. It's a cross product on homogenous coordinates.

>I am trying to develop a multiplatform instant messager for work, so the users on our platform can communicate easier with each Hother.
Why the hell are you doing this internal?

There are many messaging platforms already.

>There are many messaging platforms already.
there is no good messaging platform though

Force yourself to use long variable names, limit functions to 24 lines, that should get you thinking in the right direction.

true

So for some time now, i have been wanting to implement an FTP server and client. Do i have to read the whole RFC? Its very long and i will have to take notes, is there any simpler way?

I am asking about this project in specific and also in general how to get familiar with protocol internals

>there is no good messaging platform though
And I'm sure you're the one who's finally going to solve that problem.

segfault in a nodejs server
This could be my lucky day.

What features are you missing?

Why do you think your (single-person?) team can create something more intuitive and secure than what exists?

What drugs does your boss purchase to make him think that the cost-benefit on this is acceptable? I'd like to try some.

Just look at what bytes they send and copypaste it, it should be simple enough. Use ftp:// and web inspector in FF

strawman

no one believes this

>no one believes this
Except your answer to his question about how to properly structure code was literally "fall for the OOP meme", and not any useful and generally applicable principle, because you don't know any.

Signal+self hosted server

why not slack? or telegram?

i had once a segfault in the init process (1) on my pc

>your answer
You're talking to different people here. And the person there didn't say that it would make their code "magically organized".

In other words, who are you quoting?

>In a modern language packing everything neatly into modules is generally enough.
>the person there didn't say that it would make their code "magically organized"