/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

pastebin.com/2RLefem8
github.com/FasterXML/jackson
fsf.org/news/2009-07-mscp-mono
twitter.com/SFWRedditVideos

I'm attempting insertion sort without copying psuedocode, what am I doing wrong?

void insertion_sort(int *arr, int len)
{
int i, j;
for (i = 1; i < len; i++)
{
j = i;
while (--j)
{
if (arr[j] > arr[i])
{
int tmp = arr[i];
memmove(&arr[j + 1], &arr[j], i - j);
arr[j] = tmp;
break;
}
}
}
}

Porting dwm to wayland.

iirc dwm is a single 2k loc file

Way too early edition

Replace that while with a for.
Create a swap function.
Don't use fucking memmove.
Use RAII, i.e. declare variables where they're used, unless you're writing C89.

mine will have even less code since I'll be using libweston. it's the equivalent of libxcb or libx11 that dwm uses except it's lighter.

I wish I was an accompilshed science fella
that way I could be an edgelord like nigguh Edsger

Is there an easy way to simulate manual reset events under linux?

I have a circular buffer implementation that I wrote for windows and it uses SetEvent and ResetEvent to make the producer and consumer threads block when the buffer is full or empty.
How would I port this to linux without just polling?

Is it weird that I find Dijsktra kinda hot?

He isn't exactly a trap

(therefore you are gay)

>use RAII
There's no opportunity to use RAII at all here. He can't construct an object lifetime for the incoming array. That'd be madness.

But I'm a girl..

Can any rust fags recommend me a book?

Tons of young girls like older not obese men for whatever reason. And yes it's weird and you should be ashamed.

i totally believe you are a girl(boy)

>tfw finished remaking my shit algorithm
>it's now much less shit
is there a better feeling lads?

>Hurr Durr girl devs don't exist.
Retard.

now make the code more concise and the comments more verbose

[citation needed]

>now make the code more concise and the comments more verbose
on it
this mess is spread amoungst 3 different functions and makes no sense whatsoever

prove it then.

pro tip: you can't.

>What are you working on
Watching and reading about politics in America all day long.
Why can't I get away from this shit?

nice blogpost how can i subscribe

Don't forget these

is he just hoping that the uninitialized data section he's reserved for the string will have the input terminate with a 0, or does fgets append a 0 to the end of the user's input? if the former, what if the user puts in exactly the maximum number of characters to fit in the section?
pastebin.com/2RLefem8

Post penis then or no one will believe you

I'm reading book on C before my semester starts.
2 chapters in, did bunch of programming exercises from that book using Pelles C and now at the end of the 2nd chapter they decided to talk about common errors?
Seems kind of dumb since I encounters almost every error they're describing during those exercises.
But the other thing is that author says that he has a compiler that tries to fix syntax errors automatically. Wouldn't that be a bad thing for students to have auto correct on?

/dpt/ is such a great thread for reminding myself that no matter how dumb I sometimes feel when programming, even me five years ago was much, much smarter than most /dpt/ posters

>he has a compiler that tries to fix syntax errors automatically
Why would anyone want that?

>programming for at least 5 years
>still coming to /dpt/
That's like winning special olympics

I am glad my self confidence isnt bad enough to come to threads to compare myself to others to feel better.

This desu senpai baka
The guy can't even banter without making a fool of himself.

they are rare in the wild, something akin to a galapagos turtle. they only appear to breed and then they disappear afterwards

If I am doing this: card test = new card{.rank = ranks[Rank::King], .suits = ranks[Suit::Heart]}; in the main function, do I have to delete test? test is a struct.

#include
using namespace std;

enum class Rank {
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Jack,
Ace,
Queen,
King,
count
};

enum class Suit { Club, Diamond, Heart, Spade, count };

int ranks[Rank::count] = {Rank::Two, Rank::Three, Rank::Four, Rank::Five,
Rank::Six, Rank::Seven, Rank::Eight, Rank::Nine,
Rank::Ten, Rank::Jack, Rank::Ace, Rank::Queen,
Rank::King};
int suits[Suit::count] = {Suit::Club, Suit::Diamond, Suit::Heart, Suit::Spade};

struct card {
int rank;
int suit;
};

void print_card(card this_card) {
// unimplemented
}

int main() {
card test = new card{.rank = ranks[Rank::King], .suits = ranks[Suit::Heart]};
return 0;
}

Oh, there's plenty of female devs these days... but female 4channers? Much less likely.

is it true OSGTP is a Haskell shill now?

Go back to plebbit, fucking faggot

Sup Forums's majority userbase is school going girls actually

Have you seen /u/ or /cgl/?

why create enum classes if you are going to declare the arrays like that, use a loop bro

Exceptions to the rule. /soc/ also has a few girls, but boards like Sup Forums? Pretty much just men and traps.

>and

Just started learning Java coming from C and IntelliJ is comfy as fuck

sauce on pic?

I'm sure he has a nice firm ass and giggles when you grab it though.

>/u/
For some reason I'm convinced that most of those posters are men whose lesbian fantasies have deluded them into posting as "women".

What is the best programming language if both my development time and my hardware resources are limited?

wanna port posix to sel4 on aarch64 together?

What's your excuse for not using Go?
>super comfy to program in
>strong concurrency
>expressive like a scripting language, fast like a compiled one
Literally no reason to not use Go.

Prolog

haskell

kill yourself

>What data types would you use to represent the following items: number of
children at school, a letter grade on an exam, the average number of school
days a child is absent each year?
I answered int, char, int.
Solutions says. int, char, double.

Who is right here?

Go is for literal brainlets, it's been well established. Furthermore it's a mediocre language, only alive because of google pushing it, Now fuck off

>retarded vermin: the language
I'll pass

Don't post your homework here.

I'm going to be honest... as fun as that might sound, I'm starting a PhD program in 5 days, and my advisor has recommended that if I want to become a professor (which I already told him), that I should publish a paper every semester. I'm going to be very, VERY busy with research.

Nobody, how you choose to represent data is up to you.

>average
double

I mean double isn't wrong in that case but just because it's average doesn't mean you have to use double.
>average amount of students in school at any given time
>75.4
Not aesthetic

int, float, float

Lolol no generics

even if it had you wouldn't use it

lmao

Using go is like a statement. A declaration that says "I'm an idiot"

Just tried the Jackson JSON library for the first time. Recursive object (de)serialization is refreshingly concise and flexible.
github.com/FasterXML/jackson

Nim... assuming it's not a large project

why?

Go is a disservice to intelligent programmers. It's an insult to human brain

not an argument.

try again, kid.

The fact that it has less support of generics than C89 is pretty embarrassing
>Let's take the control away from the devs
>Also let's take the abstraction away too
>lul u don't need them
>"Our language is made for people that don't understand brilliant languages"
Go is the true cuck language

And what are we supposed to do, create our own vector type for every type parameter we'd want?

dumb brainlet

>Go
>Expressive
Damn, google shills

Lolol fgt who doesn't meta program detected

C#, seriously

0/10

its ok ruby senpai, i'll wait for you

Memes aside, Go is basically the new Java. It eschews a lot of important modern concepts like generic programming in order to make it easy to use for the idiot code monkeys that Google usually hires. The end result is a potential increase in code complexity instead of a decrease.

Not an argument.

You mean python, right? It's lighter than C#

>hardware resource limited
>lmao let's shill him our rebranded java that spawns a 300 Mb GC before even doing anything xd

.NET Core is objectively superior to Python in multiple metrics.

>python still lighter than botNET core

>lmao let's shill him our rebranded java that spawns a 300 Mb GC before even doing anything xd
I work with C# and this is true, sometimes the GC doesn't work as efficiently as it should. It is still a pretty easy and quick language to develop to though.

You can make that argument when Microsoft relinquishes their software patents.

In Java's defense, it was originally created a long time ago, and they've tried to keep it backward compatible.

Go has no such excuses.

>expressive
i dont think you know what that means

Thanks all, will consider (except ).

Why would they need to relinquish their patents? They've already given you free license to use their product however the hell you want, and to modify it as you please, so long as you don't try and claim a patent over their shit (Apache 2 License)

>write any program more complicated than a simple exercise
>main class ends up being >1000 lines
What can I do to stop this from happening?
If I try to split the main class into smaller classes then I run into the issue that methods from the smaller classes all need to use certain functions.
Then I run into the issue of having to make a header file full of static functions to include in all those classes and it seems kinda stupid.

Apache 2 has a patent grant clause as well so... they already kind of have relinquished their patents?

Just making everything static famlam. Objects are for losers.

Guess so. .NET Core is sort of a mix between MIT on some parts and Apache 2 on other parts. Either way, it's all GPLv3 compatible.

fsf.org/news/2009-07-mscp-mono
>guys we super duper promise not to sue you for technically violating our intellectual property rights, pinky swear

Nah. No one's that stupid. There's a reason Mono hasn't even taken off with official backing.

There's probably no difference if you only develop for Microsoft platforms though.

>use OOP
>code is ugly and overengineered

really makes you think

I'm kind've getting to the point where I don't like even using enums because it's a huge pain in the ass to have static casts riddled everywhere throughout the code.

They legally can't sue you for it now though. In releasing .NET Core under a permissive license, and buying up Mono and continuing to release it under a permissive license, they have revoked their right to sue for patent infringement for using or modifying those products. Your article from the FSF is out of date because all of these products are in Microsoft's hands. You can't just give someone something and then sue them for using it under the terms that YOU agreed upon.

You make it sound like a Java problem and then go on about header files. What exactly is your problem? "the smaller classes all need to use certain functions" doesn't explain shit.

fgets writes a string, so it is always null terminated
It will only read up to the storage size minus 1 byte for the null terminator, so the last character will still be in stdin if that's where you're reading from