/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

blog.filippo.io/rustgo/
youtube.com/watch?v=yeh7D0zz8G0
github.com/edwinb/idris-php
youtube.com/watch?v=rX0ItVEVjHc
twitter.com/NSFWRedditVideo

Daily reminder that the JVM is dead.

Why does this book in English have a Russian addition?

When will rust btfo c++
I need an exact date

Like 5 years later if it continues improving.

May 15, 2015.

Kotlin is awesome.

>nearly 50 threads filtered thanks to NN shitstorm
>just want to talk about programming

hold me /dpt/

kotlin is a joke

cyкa блять

im holding you senpai

If I were a burger I'd move the fuck out with zero hasitation.

literally never visited Sup Forums lol
only Sup Forums.org/g/dpt shortcut

cпacибo зa oчeвиднyю шyткy

wtf

Good thinking
Especially if you can work remotely, downshifting is extremely convenient

you are welcome

>we aren't compatible
blog.filippo.io/rustgo/

you need to go back

>while(true)
Fuckin' horrendous. Not even sure what you were trying to do with your hash maps.
Scanner reader = new Scanner(System.in);
ArrayList words;
HashMap count = new HashMap();
HashMap followers = new HashMap();

String line = "";
while(!line.equals("end")){
line = reader.nextLine();
words = new ArrayList(Arrays.asList(line.split(" ")));
for (int i = 0; i < words.size(); i++) {
if(!count.containsKey(words[i])){
count.put(words[i], 1);
} else {
count.put(words[i], count.get(words[i])+1);
}
if(!followers.containsKey(words[i])){
followers.put(words[i], new ArrayList());
}
if(i + 1 < words.size()){
followers.get(words[i]).add(words[i+1]);
}
}
}

>language-tan fan-fiction
now this is pod-racing

Oh, it's that guy who got buttblasted when asked to inverse a binary tree on google interview

> the Rust community inadvertently discovered a new paradigm of software development: Autism-Driven Development
Will they ever recover?

>override fun
already dropped

Why does the Rust community remind me of the sonic autists? Are they just the same people?

>sonic autists?
It's called ctards.

>russians
>fun

>she doesn't feel euphoric when writing code in her favorite lang

I'd like to know more about thread safety

I like how you cannot criticize rust without resorting to shitposting like a 12 y/o these days.

>Rust is bad for prototyping and scripting
>but im in love with it
but how

A тo, тyт бeз фaнa нe выживeшь.

Kotlin is a hellscape

>Oh, you will not survive without you.
o-okay ivan

Reminds me of this:
youtube.com/watch?v=yeh7D0zz8G0

>inb4

Java is. Kotlin is awesome.

Oh, boy. No amount of booty-bandaging can help one recover from such anal annihilation. Rust eternally BTFO.

C is the perfect example of autism driven development though.

Your samefagging is painfully obvious

I have a struct. It will contain a string, around 10 characters in length. However, it can be up to 4095. Should I use char str[4096] or char* str?

>b-but C! C, guise, m i rite!
And here we can observe the rustlets coming out of the woods, deflecting desperately.

>when I write code it feels as if I'm writing a poem

>C
>Development
Please, the language is dying. Let it rest in peace.

C is for normies compared to rust/c++

C is a tool made by men for actual use.
Rust is a language nobody needs or asked for made by autistic soyboys.

>normies
brainlets*

>FP languages
>not pure distilled autism

What would be a perfect programming language for a chaddudebro type?

C is the normies language out there. If you want an example of a really autistic language, see Haskell or Idris.

He replied while typing on a machine, which primarily runs on programs written in C, even including userland.

>Finally understand all the intricacies of using Quaternions
>Decide to peek at the source code to see how it all works
>It's a clusterfuck of pointer hacks, 4 dimensional transformations and bit shuffling
Well thank fuck I don't ever have to touch that stuff. Here's a typical helper function

FORCEINLINE void VectorMatrixInverse( void* DstMatrix, const void* SrcMatrix )
{
typedef float Float4x4[4][4];
const Float4x4& M = *((const Float4x4*) SrcMatrix);
Float4x4 Result;
float Det[4];
Float4x4 Tmp;

Tmp[0][0] = M[2][2] * M[3][3] - M[2][3] * M[3][2];
Tmp[0][1] = M[1][2] * M[3][3] - M[1][3] * M[3][2];
Tmp[0][2] = M[1][2] * M[2][3] - M[1][3] * M[2][2];

Tmp[1][0] = M[2][2] * M[3][3] - M[2][3] * M[3][2];
Tmp[1][1] = M[0][2] * M[3][3] - M[0][3] * M[3][2];
Tmp[1][2] = M[0][2] * M[2][3] - M[0][3] * M[2][2];

Tmp[2][0] = M[1][2] * M[3][3] - M[1][3] * M[3][2];
Tmp[2][1] = M[0][2] * M[3][3] - M[0][3] * M[3][2];
Tmp[2][2] = M[0][2] * M[1][3] - M[0][3] * M[1][2];

Tmp[3][0] = M[1][2] * M[2][3] - M[1][3] * M[2][2];
Tmp[3][1] = M[0][2] * M[2][3] - M[0][3] * M[2][2];
Tmp[3][2] = M[0][2] * M[1][3] - M[0][3] * M[1][2];

Det[0] = M[1][1]*Tmp[0][0] - M[2][1]*Tmp[0][1] + M[3][1]*Tmp[0][2];
Det[1] = M[0][1]*Tmp[1][0] - M[2][1]*Tmp[1][1] + M[3][1]*Tmp[1][2];
Det[2] = M[0][1]*Tmp[2][0] - M[1][1]*Tmp[2][1] + M[3][1]*Tmp[2][2];
Det[3] = M[0][1]*Tmp[3][0] - M[1][1]*Tmp[3][1] + M[2][1]*Tmp[3][2];

float Determinant = M[0][0]*Det[0] - M[1][0]*Det[1] + M[2][0]*Det[2] - M[3][0]*Det[3];
const float RDet = 1.0f / Determinant;

Result[0][0] = RDet * Det[0];
Result[0][1] = -RDet * Det[1];
Result[0][2] = RDet * Det[2];
Result[0][3] = -RDet * Det[3];
Result[1][0] = -RDet * (M[1][0]*Tmp[0][0] - M[2][0]*Tmp[0][1] + M[3][0]*Tmp[0][2]);
Result[1][1] = RDet * (M[0][0]*Tmp[1][0] - M[2][0]*Tmp[1][1] + M[3][0]*Tmp[1][2]);
// char limit
}

>perfect programming language for a chaddudebro type?
PHP.

Java obviously.

Java, C#, or C++.

>He read this post from an infrustruture written by Javascript, HTML and CSS, and his browser is written in C++, which is also used to compile C programs.
hmm

>PHP
Now you can use Idris!
github.com/edwinb/idris-php

Will you alloc the struct? Consider flexible array members.

Actually, most of the modern software like web browsers, games and GUI applications are written in C++. But yeah, there's a lot of legacy C code down there, that doesn't mean C isn't dying tho.

Use a flexible array member.

>Here's a typical helper function
Completely trivial if you understand the intent. It's just doesn't look nice as code when you have to spell out what are otherwise simple operations.

>hmm
Have I said anything about those languages?
Stop moving the goalpost.

Optimization.
Yes, and pass it around. Isn't there an upper limit of one?

>Have I said anything about those languages?
Do you have to?

No limit. A flexible array member simply "runs off" the end of the struct, and the only limit specified in one is how much extra space you mallocd.

But what if I have two of them?

>most of the modern software
Yes, and most of modern software sucks.
Is it a coincidence?
Many game developers would like to just stick to C.
Listen to this talk here by mike acton of Insomniac games.
youtube.com/watch?v=rX0ItVEVjHc

>Completely trivial if you understand the intent.
Even if you consider the function trivial, there are a couple dozen of those functions happening just to perform a simple subtraction. Variables are constantly switching spaces into vectorregisters, matrices, and a bunch of other structs. There's nothing trivial about the operations going on under the hood.

struct Foo
{
int x;
char str[];
};

struct Foo *a = malloc((sizeof *a) + 20); // *a has space for 20 chars
struct Foo *b = malloc((sizeof *a) + 40); // *a has space for 40 chars

>Do you have to?
He wrote on a machine that runs mostly on C; relying on infrastructure that is mostly written in C.

Fucked up the copypaste but I think you get the point.

>C
He mentioned a language that which itself is implemented in C++ and not self hosted.

struct Foo
{
int x;
char str[];
int y;
char str2[];
};

What now?

user means two flexible members dumass @user you can only have one flexible array member

>Yes, and most of modern software sucks.
No? Well, maybe the parts written in JS do, but overall modern software is reasonably good, considering it's 100x times more complex than the primitive *nix stuff C was used for. You see, there's a reason gcc and gdb devs switched to C++ from C, you would think they know how to use C properly.

Fails to compile.

O(1) insertion
O(1) retrieval, but only at the head
doesn't waste abhorrent amounts of memory

What data structure do I use? The keys are unique and relatively small, but not compact.
>array
wastes memory
>linked list
slow (O(n))
>binary

Just use a decent hash map implementation.

Around Russians, bad repercussions!

Just allocate one on the stack.

>>array
>wastes memory
what

array is literally the most memory-efficient way there is for storing data

>array is literally the most memory-efficient way there is for storing data
He wants to look things up by key.

>and not self hosted.
Are you stupid?
There are many C compilers, and not every one of those has an llvm backend.
Also llvm is really shitty, bloated and slow, quite typical of C++ projects.

I don't care what he wants to do,
>wastes memory
is false

it's "Yeah, you can not survive without fun here"

GCC and MSVC are C++ too. Sucks using a non self hosted language, doesn't it?

GCC is written in C++ too, m8.

>No?
One day you will realize how wrong you are.

>considering it's 100x times more complex than the primitive *nix stuff C was used for.
It sucks because it is 100x more complex than it needs to be.

Too slow.
Not if it's sparse. The keys are unique, but not compact.

a[0] = ...
a[1] = ...
a[4] = ...
a[49] = ...
Then 46/50 slots are wasted, if a[] is 50 units large.
No, I only want to get the first element.

And I want to do that. So should I use char* and have a custom free() for only that struct? Or is there a better idea?
I want to pass it around.

>*nix shell is all you need
Whatever you say, grandpa, just stop shitting your pants, ok?

>>wastes memory
>is false
It's not false in the context of his post, where he's probably referring to the space wasted by unoccupied array elements.

deque?

>implying these are the only options.

I would use a char* if memory efficiency is a concern.

Enjoy your abandoned compiler for your abandoned language.

>hurr durr too slow, too much memory
You're not providing any objective requirements.

Who are you quoting?
I didn't say anything like this.
The software you are referring to as "modern" is just shitty and bloated.
You can only say anything else because you never looked at their source.

You can still pass it around by reference.

It's simple. I want a data structure that solves world hunger and does each and every operation in O(1) xDD

When is it a good idea to start learning how to use vim? I've been learning C using nano as my editor for a little while now and was wondering if it was worth making the jump yet. It seems pretty overwhelming.