/dpt/ - Daily Programming Thread

Anime edition

old: What are you working on today Sup Forums?

Other urls found in this thread:

stackoverflow.com/questions/20600497/which-c-version-is-used-in-the-linux-kernel
doc.cat-v.org/plan_9/programming/c_programming_in_plan_9
plan9.bell-labs.com/sys/doc/comp.html
ia601503.us.archive.org/32/items/vmss16/titzer.pdf
quora.com/Which-are-the-best-books-to-learn-C
learn-c.org/
gist.github.com/Wunkolo/039f8c727edfa6cdddec#file-pxpack
twitter.com/SFWRedditVideos

Continue my journey with Elixir.

putting stuff up my butt

What is the best dialect of C to program in?
What dialect of C is the Linux kernel programmed in?
Why does dwm not use the stdint.h library?
Why do some projects not use the stdint.h library?
Isn't int16_t much better than just int because it is more specific?

>Write for programmer first, for compiler second. Your co-worker will not be easily convinced, so I would prove empirically that better organized code is actually faster. I would pick one of his worst examples, rewrite them in a better way, and then make sure that your code is faster. Cherry-pick if you must. Then run it a few million times, profile and show him. That ought to teach him well.

I find it suspicious that advocates of object-oriented programming find it necessary to deceive critics to convince them of its superiority, or that this kind of behavior is acceptable at all in an academic and/or professional environment.

>What dialect of C is the Linux kernel programmed in?
Mostly C90 see
stackoverflow.com/questions/20600497/which-c-version-is-used-in-the-linux-kernel

>What is the best dialect of C to program in?
Plan9 C. Nice, small libraries with pleasingly simple names (dprintf -> print), automatic inclusion for linking, simple conventions, best toolchain, a no technical debt environment, etc. The only thing is that it didn't take off, sadly.

See doc.cat-v.org/plan_9/programming/c_programming_in_plan_9 et al.

>What are you working on today Sup Forums?
experimenting with rust
extern crate rand;
use rand::distributions::{IndependentSample, Range};

#[derive(Debug)]
enum Number {
Prime(T),
MaybePrime(T),
Composite(T)
}

fn witness(a : u64, n : u64) -> bool {
let mut d = 1;
for i in (0..64).rev() {
d = (d*d) % n;
if ((n-1) & (1 3);
let mut rng = rand::thread_rng();
let between = Range::new(2, n-1);
for _ in 0..s {
if witness(between.ind_sample(&mut rng), n) {
return Number::Composite(n);
}
}
Number::MaybePrime(n)
}

fn isprime_primitive(n : u64) -> Number {
assert!(n > 0);
let mut i = 2;
while i*i Number {
if n < 1000 {
isprime_primitive(n)
} else {
miller_rabin(n, 100)
}
}

fn main() {
let mut i = 2;
loop {
println!("{:?}", isprime(i));
i += 1;
}
}

>dprintf -> print
Not true sorry. It's still the nicest environment to do system programming in C tho. Also see plan9.bell-labs.com/sys/doc/comp.html

Novice here, I decided to try and program the game Bang! in Java.
For those who don't know the game: it's a card game for 3-8 players, each has a role card (determines victory conditions), a character card (determines special power), and a bunch of playable cards. At the beginning of your turn you pick up 2 cards, then you can play blue cards for equipment, green cards for temporary equipment and orange cards for immediate actions. There are many different types of cards for each of these 3 categories.

Now here's my (main) problem: how should I go about implementing the "character cards" functionality?
There are like 80 different cards of this type and each has a different power that can influence a different aspect of the game. For example, one card could let you pick 3 cards at the beginning of your turn instead of the usual 2, another could let you shoot other players with cards other than the usual "Bang!" card, another still could let you regain 2 HP instead of 1 upon using a "Beer" card, etc.
I have this feeling I should use inheritance and make each character card its own class, but then how would I ensure that the program applied the special ability regardless of which aspect of play it modifies? Do I just have to have a check at any action? Or is there a more elegant way?

V8 is a magical piece of software

ia601503.us.archive.org/32/items/vmss16/titzer.pdf

>mfw plebes tell me that Javascript is an "interpreted language"

>each character card its own class
That'd be at least 81 classes. I've played the game, you could instead use scripts to load in the stats and abilities and have the abilities be flags that are not dissimilar from the equipment cards. Like "heal_amount = 2" "ignore_range = true" etc.

>81classes with minor differences
>static language problems

>best toolchain
>dat cross compiling ease

Muh dick

So I have a nested loop in .net, and I want to refer to the indexes in the code running in the loop without having to type a long list of x = i, y= j, etc. Ideally I would want to have an array and use i(0) as the first index, i(1) as the next, etc, but it won't let me do that. I could use a dictionary and add all the index variables to it but it seems slow.

Is it just me or has there been a sharp decrease in activity of these threads?

>I want to refer to the indexes in the code running in the loop without having to type a long list of x = i, y= j, etc.

So.. just refer to them using i, j?

I don't see what the issue is here.

How deep is your loop nested? Also why can't you use an array?

She looks like wife material desu

you can only fizzbuzz is so many languages

ur mom

>"For loop control variable already in use by an enclosing For loop"

Because it's a lot of nested loops and having to type out all of the indexes manaully inside makes it look messy as fuck.

>use scripts to load in the stats
Like a scanner to read from a txt file that's organized in a sort of table?

Any java dev here?
Which IDE do you use?

Android Studio, because muh company policy.

>54902122
Can't you just use instance Monad (Categorised c)?

Why not use intelliJ ?

Eclipse because my company makes me use it. I'd use Intellij if it was my decision.

Android Studio is a reskinned IntelliJ. I also use vim if I just want to look up code in another project.

>uses javashit unironically
>calls other plebs
A superoptimized flying turd is still a fucking turd.

>What is the best dialect of C to program in?
C11

>What dialect of C is the Linux kernel programmed in?
GNU89, some GNU99.

>Why does dwm not use the stdint.h library?
Doesn't need exact width types. The C standard library also does not use stdint types for most things.

>Why do some projects not use the stdint.h library?
See above.

>Isn't int16_t much better than just int because it is more specific?
No. If you don't need an integer to be exactly a specific size, don't use fixed width types. They aren't even defined on all platforms (in particular, the ones that use 9-bit bytes). As a general rule of thumb, you should firstly always use the type of any function you are using that you haven't written. Most C functions use int to return status codes, and that's perfectly fine. The size_t and ssize_t types are often used with regards to strings/arrays, because the maximum sizes for these often vary based on the platform. I'd rather not use an int64_t to store my string length if I'm on a 32-bit platform, and I'd rather not be gimped by the restrictions of a 32-bit platform on a 64-bit platform, so when storing the lengths of these structures, and often when making indices to offset them, a size_t or ssize_t is preferred.

>Because it's a lot of nested loops

Time to refactor.

>in particular, the ones that use 9-bit bytes

1. Which platforms?
2. Does anyone care about them?

1. Unisys/Univac machines. Some are still in use today. Also, some old IBM and DEC machines.
2. Not really, although I honestly think when writing C code, it is best to make the least amount of assumptions possible about the target platform. If you know something needs to be 32 bits, then by all means, use uint32_t or int32_t. Otherwise, int is fine... unless it NEEDS to be at least 32 bits, in which case int_least32_t is your best bet. And yes, I happen to have multiple devices in my room where int is 16 bits, rather than 32.

So, i have this dictionary
dic = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123465789

i want to generate all password combinations with 6 letters for example: 5h7e54, DTE2ar, cujsas, 123asc, etc

how can i do this in C or python?

thanks

>want to use a library
>I have to get it via all this git wizardry

Is there any point trying to muddle through on Windows or should I install Gentoo?

Development on Linux is "fun" and "easy".

You should have had Gentoo installed already, nobody gets into this thread without it

bump

In python you can use itertools

import itertools

dic = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123465789"

passwords = itertools.combinations(dic, 6)

Literally just generate 6 random integers, bring it into your dictionary's index range by modulo dividing it by the size and finally concatenate the rwsults.

Fuck, I didn't read that thoroughly enough.

this doesn't work

import itertools

dic = "abcdef"

passwords = itertools.combinations(dic, 6)

print list(passwords)


output
[('a', 'b', 'c', 'd', 'e', 'f')]

well there is only one combination of 6 letters, using 6. try with more letters

/fit/ is so fucking retarded they're even more dimwitted and underage than Sup Forums

no i was supposed to output all combinations with 6 letters:

aaaaaa
aaaaab
aaaaac
aaaaad
....
defcba
acbfed
...

I wrote a script to list all packages on my Gentoo system in @selected with no other packages that depend on them.

For example firefox is in @selected because I specifically installed it, but there is nothing that depends on firefox.

However I fucked up my system and have garbage like "random-library-used-by-nothing" that is also in @selected because I specifically installed it, but it's not needed because there's nothing that depends on it.

#!/bin/bash

while read pkg ; do
equery d "$pkg" > temp
if [[ ! -s temp ]] ; then
echo "$pkg" >> nodeps
fi
done < pkgs # A list of all packages installed

>#!/bin/bash

use #!/bin/env/bash

ah i see, itertools.product does that

import itertools

dic = "abcdef"
passwords = itertools.product(dic, repeat=6)
for password in passwords:
print("".join(password))

>We all love JavaScript
>ctrl+w

>use #!/bin/env/bash

You mean #!/usr/bin/env bash, or #!/bin/env bash?

kek

i meant
#!/usr/bin/env bash

Just another day of programming discussions on #rust

what's unsigned code?

+1

(c) kys

code not signed with a digital signature

please use 'humans' instead of guys

Eclipse
best IDE

im out of inspiration
gimme something to program

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA).

A programming language implementations benchmark.

What irc client is that ?

There 56,800,235,584 combinations. kek.

Naive version

import math
import string

dic = string.ascii_letters + string.digits

# only 4,611,686,018,427,387,840 iterations Σ(°□°)⊃
for i in range(0b111111, (1

Is this what turtle genitalia look like?

combinations != permutations ffs

sir please, this is a family friendly image board

do you wear girl clothes when you program?

>those boobs on the table

saved

you don't ?

What's the best course for C?
Paid or free, I don't mind, but free will be appreciated.

mmm... sauce?

Books.

c primer plus

They made a fucking anime out of this?

quora.com/Which-are-the-best-books-to-learn-C

learn-c.org/

Encapsulation: useful mechanism to increase robustness or shooting yourself and others in the leg?

Discuss

by script I really just meant the files themselves. Organized using YAML or XML or something. A bit ambiguous meaning I used. But yes, reading organized data.

>he doesn't put an f after decimal values

If people are making an engine, consider looking at this (possible) code from Kero Blaster

gist.github.com/Wunkolo/039f8c727edfa6cdddec#file-pxpack

>gif
>3.23 MB
>not webm
hey, this is the technology board here so we expect some use of the said technology.

both

>he doesn't want his videos of laughing anime whores to autoloop

it's funny how the webm has less quality in it

>the filename
>laughing anime whores
>anime whores
>whores

A lot of anime reaction webms were converted from gifs by lazy people so they still retain the shittiness of the gif.

actually most of webms are coming from gifs uploaded to imgur.

Hiding complexity is actually best thing you can do to avoid fuckups. Stupid, unskilled and mediocre pogrammers (including yourself) don't have to tackle all shit that's behind the functionality, so chance that they screw something up decreases. Also saves time for everyone.

Eclipse because we're using it at work, but I have preference for Intellij

webms autoloop tho?

Not for me, what browser do you use?

unskilled coders will make bugs, with or without encapsulation
and there is nothing more pointless than making accesors and mutators if all that they do is returning or setting private variable
prove me wrong

Chrome.

>having a bunch of getters and setters

You're doing OOP wrong.

Not the guy you're responding to, but OOP's approach to complexity management is fine. It's modularization, i.e. correctly handling the complexity and preventing future maintainers from having to deal with that complexity unless necessary.

>modularisation doesn't happen in any other paradigm

That's right. OOP is the GOATest.

>and there is nothing more pointless than making accesors and mutators
Say you have a class called Price, and it contains an i64, would you make that i64 publicly accessible?

But yours has worst quality than the gif, that's what I meant, the gif has more details from a glance.

>>having a bunch of getters and setters

>You're doing OOP wrong.
i do not write simple getters and setters most of the time
just make the fucking variables public, it's not a nuclear weapon ffs

Does anyone here have an opinion on bioinformatics? It seems like just text parsing to me, but the algorithms can be pretty interesting; especially about how to make them more efficient. I was thinking about studying a bioinformatics class on coursera, not sure if that is a waste of time though.

Why not?