[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 320
Thread images: 28

File: dpt_flat.png (102KB, 1000x1071px) Image search: [Google]
dpt_flat.png
102KB, 1000x1071px
Old thread: >>57145590

What are you working on /g/?
>>
>>57149874
First for D
>>
File: 8452926.png (29KB, 633x758px) Image search: [Google]
8452926.png
29KB, 633x758px
>>57149874
>What are you working on /g/?
Finding a gf
>>
>>57149906
you have to set realistic goals, anon
>>
>>57149906
Stop posting forever
>>
Optimizing my dogfed som package.
C code runtime optimization is unironically fun.

>>57149906
I postponed this task indefintely.
>>
File: 507.jpg (42KB, 500x598px) Image search: [Google]
507.jpg
42KB, 500x598px
>>57149906
>>
>>57149906
but that's NP-hard
>>
File: 1476099442362.jpg (5KB, 225x224px) Image search: [Google]
1476099442362.jpg
5KB, 225x224px
>>57149874
trying to lose my virginity before 30 (hookers don't count)
>>
>>57149874

I'm making a prop logic theorem prover. r8m8.


import Data.List

data Prop = Atom String | Not Prop | Imp Prop Prop deriving Eq

instance Show Prop where
show (Atom a) = a
show (Not a) = "(~" ++ show a ++ ")"
show (Imp a b) = "(" ++ show a ++ " -> " ++ show b ++ ")"

type TruthAssignment = [Prop]

addTrueAtom :: TruthAssignment -> Prop -> TruthAssignment
addTrueAtom atomList (Atom x) = (Atom x) : atomList
addtrueAtom atomList _ = atomList

getTruth :: TruthAssignment -> Prop -> Bool
getTruth atomList (Atom x) = (Atom x) `elem` atomList
getTruth atomList (Not x) = not (getTruth atomList x)
getTruth atomList (Imp x y) = (not (getTruth atomList x)) || (getTruth atomList y)

numParantheses :: Prop -> Integer
numParantheses (Atom x) = 0
numParantheses (Not x) = 2 + numParantheses x
numParantheses (Imp x y) = 2 + numParantheses x + numParantheses y

numSymbols :: Prop -> Integer
numSymbols (Atom x) = 1
numSymbols (Not x) = 3 + numSymbols x
numSymbols (Imp x y) = 3 + numSymbols x + numSymbols y

numAtoms :: Prop -> Integer
numAtoms (Atom x) = 1
numAtoms (Not x) = numAtoms x
numAtoms (Imp x y) = numAtoms x + numAtoms y

subFormulas :: Prop -> [Prop]
subFormulas (Atom x) = nub [(Atom x)]
subFormulas (Not x) = nub (subFormulas x ++ [(Not x)])
subFormulas (Imp x y) = nub (subFormulas x ++ subFormulas y ++ [(Imp x y)])

truthTable :: TruthAssignment -> Prop -> [(Prop, Bool)]
truthTable tAssign prop = [(subProp, getTruth tAssign subProp) | subProp <- subFormulas prop]
>>
>>57149874
OP, I like you.

Thank you for posting an anime image.
>>
satisfies :: TruthAssignment -> Prop -> Bool
satisfies tAssign prop = getTruth tAssign prop

satisfieS :: TruthAssignment -> [Prop] -> Bool
satisfieS tAssign [] = True
satisfieS tAssign (prop:propList) = satisfies tAssign prop && (satisfieS tAssign propList)

getAtoms :: Prop -> [Prop]
getAtoms (Atom x) = [(Atom x)]
getAtoms (Not x) = getAtoms x
getAtoms (Imp x y) = getAtoms x ++ getAtoms y

getAtomS :: [Prop] -> [Prop]
getAtomS [] = []
getAtomS (prop:propList) = getAtoms prop ++ getAtomS propList

satisList :: Prop -> [Bool]
satisList prop = map (`satisfies` prop) (subsequences (getAtoms prop))

satisfiable :: Prop -> Bool
satisfiable = (True `elem`) . satisList

satisfiableS :: [Prop] -> Bool
satisfiableS (prop:propList) = satisfiable prop && satisfiableS propList

isTautology :: Prop -> Bool
isTautology = (foldl (&&) True) . satisList

isContradiction :: Prop -> Bool
isContradiction = not . (foldl (||) False) . satisList

getSatisList :: Prop -> [[Prop]]
getSatisList prop = [ x | x <- (subsequences (getAtoms prop)), x `satisfies` prop ]

getSatisListS :: [Prop] -> [[Prop]]
getSatisListS propList = [ x | x <- (subsequences (getAtomS propList)), x `satisfieS` propList]

implies :: [Prop] -> Prop -> Bool
implies propList prop = foldl (&&) True (map (`satisfies` prop) (getSatisListS propList))

implieS :: [Prop] -> [Prop] -> Bool
implieS sigma gamma = foldl (&&) True (map (`satisfieS` gamma) (getSatisListS sigma))
>>
File: image.png (50KB, 400x250px) Image search: [Google]
image.png
50KB, 400x250px
>>57149906
Oh my god.
>>
Do programmers understand gtime johnny?
>>
>>57149995
>>57150017
Until I see the formal proof of correctness for your program and your Haskell implementation, it's useless.
>>
>>57150044

It's not even finished yet.
>>
>>57150020
Where did this image come from? Who's the artist who made it?

p-pls respond
>>
Fuck this, I'm making my own imageboard with instaban for shills and webdevs. I give up, love you guys.
>>
File: maxiumbuthurt.gif (120KB, 600x487px) Image search: [Google]
maxiumbuthurt.gif
120KB, 600x487px
>>57149906
(define (find-gf s)
(if s
(gf)
(find-gf s)))

(find-gf #f)
>>
If i have a pointer to a struct, how do i get the address of a field of the struct?
>>
>>57150224
&str->field

or

&(*str).field
>>
>>57150106
Yeah, great pitch "I'm gonna make an imageboard with higher regulation and less leniency on what constitutes acceptable discussion!" Because if there's one thing we all know the target audience wants it's high regulation
>>
>>57150224


&(pointer -> field)

>>
>>57150224
>If i have a pointer to a struct, how do i get the address of a field of the struct?
what language?
>>
>>57150224
&(s->field)
>>
File: ItsOver.jpg (14KB, 316x202px) Image search: [Google]
ItsOver.jpg
14KB, 316x202px
>>57149874
Just working in some Web Dev shit

>>57149906
>tfw
>>
>>57150241
>>57150250
>>57150276
Fuck. Then i'm doing something else wrong. Most likely not asking the right question.
>>
>>57149874
Cryptopals Set 1 Challenge 1 in Rust
it's pretty painful dealing trying to bitfiddle with this string class
>>
>>57150364
Do you mean the offset from the start of the struct or something?
>>
>>57150244
Well.. I know that. I hate private clubs and whatever social groups.

But when there are more than 10% of the catalog threads shilling MS, what should you do?

/g/ is dead. Time to kill myself I guess
>>
I'm trying to contact aliens so they can realize how cancerous we are and try to give us mercy by purging us.

I'll do this by making a makeshift satellite that will carry pictures of anime and 4chan posts.
>>
>>57150420
Use the other 90%
>>
>>57150475
I'm autistic... Can't... Ignore...
>>
>>57150487
filter then
>>
>>57150494
Good idea
>>
>>57150412
Bitfiddlng strings?
>>
>>57150464
>I'm trying to contact aliens so they can realize how cancerous we are and try to give us mercy by purging us.

i hope you succeed, i often hope for an alien invasion of that nature
>>
>>57150547
well the challenge is to convert a hex string into base64, and in order to do that I have to fiddle with the bits
so I have to do a bunch of conversion
>>
>>57150598
Can't you convert the string to a number, then convert it to a base 64 string?
>>
learning based c has shown me why an integer can be a powerful data structure

>inb4 other languages have that too

if i want slow and convenient ill just use pytohn haskel or java or some other shit
>>
File: CeXE-GTUIAEyh-K.png (520KB, 640x629px) Image search: [Google]
CeXE-GTUIAEyh-K.png
520KB, 640x629px
Quick question
In Java, Methods, Classes, and Variables could all be called ________ ?
I'm writing a parser for an assignment and I'm trying to think of a logical name for a package that contains their definitions
>>
>>57150630
concepts
>>
>>57150618
>Haskell
>Slow
If you're in it for the speed try OCaml
>>
File: 0qbChio.jpg (225KB, 600x505px) Image search: [Google]
0qbChio.jpg
225KB, 600x505px
>>57149906
>tfw I finally got a gf
>tfw she's actually cute but still thinks she isn't good enough for me
>tfw her insecurities might actually make me break up with her if she doesn't work on it at all because she won't even tap me on the shoulder to ask me if I want to watch something while I'm working because she doesn't want to distract me
abstract feel

>>57150643
Thank you anon
I was gonna go with "members" but that's better
>>
>>57150630
Use utf8 names.
>>
>>57150617
I don't see that functionality in the string class, I can only convert it into a byte vector, which I can then bitfiddle with.
>>
>>57150653
>>57150630
I'm retarded. I thought you wanted to literally name all your methods "_____".
>>
Back to the contacting alien bit. I'm poor as shit, I do got a broken ass thing. Some aluminum, two old ass phones with everything intact, two one foot poles, some pictures of myself, a flash drive, a video of weebs cosplaying, and a fork. Any help on contacting aliens? How will I send radio waves?
>>
>>57150653
Oh man anon
if I wanted to do that why would you recommend me a way to do it instead of calling me retarded
>>
>>57150661
"____"
>>
>>57149874
How can I take three 8-bit (so 24-bit total) characters and turn it into four six-bit ones.
Basically I'm trying to convert to base64 in C.
>>
>>57149874
StrongAI... currently writing the part that asks questions when the KnowledgeEngine spots a gap in its knowledge or infers a contradiction.
C++14

You?
>>
>>57150666
Any kinds of electromagnetic pulse would emit a radio signal. Just connect your jack to it and start singing

>>57150676
>>57150684
What
>>
>>57150701
https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64#C.2B.2B

This may help.
You doing Cryptopals too?
>>
>>57150666
you can't really, but you could try aiming for an eventual race that has time machines or some sort of advaced travel mechanism

basically try to contaminate space and time with as much talk about having aliens destroy us as possible

spam the web, write it down, talk about it etc

you could try doing something that will get you in the news, like showing your dick out in the open and shouting your message to the wide public
>>
>>57150660
I just looked up how to do it in rust. Why would anyone use this hideous language?
>>
a tactics RPG

http://pastebin.com/Sm0RVPyq

TODO:
add weapon ranges
add magic
add fight system
add computer AI (no idea how :( )
>>
>>57150464
>Pale chimp... we heard your call to us from your shitty planet filled with idiots.
>What do you want?
>>
>>57150747
Programmers coming from C++ having no idea what a beautiful language is.
>>
>>57150747
Well, it's supposed to be a safe C/C++ essentially.
>>
>>57149874
Learning Haskell and being really bad at it

Can anyone help me figure out the equivalent for iterating over a list. I am trying to make something like this but I am to stupid to figure it out without using loops. I know I can use recursion somehow but the way to go about it is escaping me.
for x in range(1,13):
print("")
for y in range(1,13):
print(x*y, " ", end="")


1  2  3  4  5  6  7  8  9  10  11  12  
2 4 6 8 10 12 14 16 18 20 22 24
3 6 9 12 15 18 21 24 27 30 33 36
4 8 12 16 20 24 28 32 36 40 44 48
5 10 15 20 25 30 35 40 45 50 55 60
6 12 18 24 30 36 42 48 54 60 66 72
7 14 21 28 35 42 49 56 63 70 77 84
8 16 24 32 40 48 56 64 72 80 88 96
9 18 27 36 45 54 63 72 81 90 99 108
10 20 30 40 50 60 70 80 90 100 110 120
11 22 33 44 55 66 77 88 99 110 121 132
12 24 36 48 60 72 84 96 108 120 132 144
>>
>>57150796
>Learning Haskell
stop

it's a waste of time

learn some cs or algorithms or math or work on a project in a real language

that's learning

learning haskel is not learning anything
>>
>>57150818
Filtering "real language"
>>
>>57150770
>priest and wizard menus are the same, yet print statement is duplicated in it's entirety
>not giving non-magic classes "skills" in place of magic
>not just putting magic and skills in the same menu so you don't have to have a bunch of different menus printed
shiggity
>>
>>57150833
haskel is not a programming language

im sorry
>>
>>57150770
What am I supposed to do?
Enter a SquareA2
3 19
None None
Traceback (most recent call last):
File "rpg.py", line 217, in <module>
wl,wn = char_move(wizard,wl,wn,wd)
File "rpg.py", line 56, in char_move
num_diff = abs(old_num-row)
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
>>
File: I want to get off this wildride.png (16KB, 238x454px) Image search: [Google]
I want to get off this wildride.png
16KB, 238x454px
I think I'm about 3/4ths done but last time I thought that I was dead wrong
At least I'll be able to chuck this on github for resume shit
>>
>>57150858
innit turing complete?
>>
>>57150795
Just by looking at it, I can tell it's not thought out.
>>
>>57150858
>X is not Y
>therefor X is bad
w--wait..
>>
>>57150860
read the error, trace the lines wher eits pointing ta and find why you are trying to subtract a None from an int
>>
>>57150796

consider how a list is actually composed. remember any arbitrary part of the list points to the next element in the list

consider doing one thing with the head of the list and another with the rest of it
>>
>>57150719
Yes.
>tfw this was only supposed to take me a couple of minutes
>>
>>57150858
Im learning it mostly because it's a meme language. It's got a lot of concepts I don't really use often.
>>
>>57150890
Nah, I'm just reporting the error to the rpg guy
>>
>>57150796
iterating over a list is done with map. if you're printing within the loop, use mapM_ (since this allows for IO and doesn't return the list back to you)
>>
>>57150860
lol didnt error proof anything yet, use numbers/lowercase

2a
>>
>>57150894
you are right it has nice concepts and interesting implementation, but using it for anything or remembering syntax or the language itself seems just pointless

besides i just wanted to bait the incredibly defensive and thin skinned haskel-fags

these individuals live in a state of constant stress and terror
>>
>>57150886
What particulars are you referring to?
>>
>>57150884
>muh look how my X is big
>>
>>57150893
I believe one of the people who helped make it said the first set took him a week to actually implement so I wouldn't be too put out over it.
I'd assume it gets easier (read: more abstract) once you get past fiddling with bits.
>>
>>57150946
What?
>>
I wish I could be an attractive dpt'ers sex slave ; (
>>
>>57150958
Adding lines of code and files for the sake of inflating your resume is just retarded.

>tfw when it's actually the best way to get hired
>>
>>57150936
let my_u32: u32 = "42".parse::<u32>().unwrap();
>>
>>57150932
You're an idiot.
>>
>>57150969
I'm doing this assignment
the assignment sucks
I can at least take consolation in that it will look good on a resume
I'm not bloating code to bloat anything
>>
File: 1472493166371.png (179KB, 463x492px) Image search: [Google]
1472493166371.png
179KB, 463x492px
Is this safe in C:
struct vec2 {
int x, y;
};

struct vec3 {
int x, y, z;
};


//... somewhere in code with x = some vec3
v2 = (struct vec2) x;
v2.x ...
v2.y ...


or could my compiler screw me over if it does padding/alignment of the struct internally? What is the proper way to do something like this?
>>
>>57151003
Yes
>>
>>57151003
Use pahole(1) to check alignments
>>
>>57150891
Got that part already, it's grabbing it which sucks.
>>57150901
Thank you.
>>
>>57151003
It only works with pointers.
It's actually pretty unclear whether that is undefined behaviour or not, but quite a lot of code uses that (including POSIX C) so it'll probably be fine.
>>
>>57151003
Just do
struct vec2 {
int x, y;
};

struct vec3 {
struct vec2 xy;
int z;
};
>>
>>57151035
No.
pos.xy.x

looks terrible
>>
>>57150977
That line makes perfect sense, apart from the redundant :u32 the programmer added in for no clear reason. What do you take issue with apart from subjective "muh syntax" bikeshedding?
>>
>>57151028

head xs, tail xs?
>>
>>57151035
and down the rabbit hole we go
>>
What's the difference between
int i(42)
and
int i{42}
?
>>
i believe chimps have the capacity to know how to program, but it's impossible to teach them
>>
>>57151035
>>57151046
If only
struct vec3 {
struct vec2 {
int x, y;
};
int z;
};

worked, but for some odd reason, you can't have named anonymous structs.
>>
>>57151003
#include <stdint.h>
struct vec2 {
uint32_t x;
uint32_t xpad;
uint32_t y;
uint32_t ypad;
};

struct vec3 {
uint32_t x;
uint32_t xpad;
uint32_t y;
uint32_t ypad;
uint32_t z;
uint32_t zpad;
};
>>
>>57151078
typically
braces indicate a different scope, parens indicate calling a function or enforcing a particular order of operations
>>
>>57151047
The right side is completely unintelligible if you don't know rust. Very few languages I can make that claim on. C++ isn't even as bad.
>>
>>57151096

Why would you name the inner struct. Just leave it anonymous, plain and simple, and compile with C11.
>>
#include <iostream>

using namespace std;

int main()

{
int y=4, z=4 ;
int sum = y+z ;

cout << "The sum of x and y is = to " << sum << "\n";

return 0;
}
>>
>>57151115
What if I was on a 32-bit system?
>>
>>57151115
Why the hell would you add padding?
Also something like
struct vec2 {
alignas(uint64_t) uint32_t x;
alignas(uint64_t) uint32_t y;
};

would be more appropriate for that situation.
>>
>>57151147
>Just leave it anonymous, plain and simple
Just so you can use vec2 as a type as well, and not have to redefine it.
>>
If I were going to work with bitmaps, is there any reason not to use a 2D array in preference to a flat array with offsets?

Conceptually it is much simpler, but I don't know what sort of penalties might be involved, or if they're even relevant.
>>
>>57151146
You can write horrible unintelligible code in any language.
>>
>>57151220
>"It makes perfect sense"
>>
File: a pic for you.jpg (221KB, 1024x1816px) Image search: [Google]
a pic for you.jpg
221KB, 1024x1816px
I'm learning java and trying to add some functionality to this calculator gui.

Can anyone tell me why the 1 button (bt1) does not display sum as 1 when I press it?

Please look at my events and let me know where I severely fucked up.

pic is me

http://pastebin.com/E1xwZTF4
>>
>>57151203
I assume you're talking about C or a similar language.
In general, 2D arrays are just more of a pain in the ass to deal with, especially if you want their dimensions to be dynamic.
From an efficiency standpoint, they should be the same as a 1D array, as 2D arrays are tightly packed.
>>
>>57151241
I can't see your link, I just gouged my eyes out.
>>
>>57151203
Because duplicating for-loops adds unnecessary bloating.
Also, cache lines.
>>
>>57151231
>everyone in the thread is the same person besides me
>>
>>57151241

woah, you really let yourself go eminem
>>
>>57151241
Denmark?
>>
>>57151269
Can you write a good version
>>
>>57151298
No, because I don't know Rust.
>>
>>57151296
draeb dig selv, han er min
>>
>>57151269
Shit. How did you know
>>
File: 1469843979355.png (231KB, 304x366px) Image search: [Google]
1469843979355.png
231KB, 304x366px
The loops you C weenies have to go through just to do a simple thing that every OOP language has with just a few keystrokes to do.
>>
Can someone explain why Java names are like this?
public class MyJavaFX extends Application
>>
>>57151340
C can do anything OOP langs can do

the reverse is not true
>>
>>57151340
>tfw you will never experience full control of your runtime
>>
>>57151352
Like what?
>>
>>57151316
Jeg er mere til traditionelle maend. Han ligner bare virkeligt meget en dreng fra et bornehjem jeg levede i i en periode. Ville være vildt hvis vi begge voksede op til at være trannies
>>
>>57151365
>>57151354
>what is C++
>>
>>57151340
I'm going to assume you're talking about the standard library, and not the language itself.
>>
>>57151340
OOP in fundamentally flawed, idiot.
>>
File: 1470950158496.jpg (111KB, 1252x1252px) Image search: [Google]
1470950158496.jpg
111KB, 1252x1252px
>want to do OpenGL in Common Lisp
>bindings I found don't always stick to the OpenGL naming scheme for some stuff
>some functions have arguments flipped around
>have to jump through hoops just to pass arrays to opengl that could have been managed by the binding to make it integrate better

these feels
>>
>>57151241
LONDON
O
N
D
O
N
>>
>>57151451

So fix the bindings, then.
>>
>tfw can't think of any real world applications to create that would be portfolio worthy and am stuck in the academic world of using programming as a convoluted calculator
>>
>>57150044
You can just output the proof steps and verify those.
>>
>>57151380
lyver du nu
>>
Test Driven Development - unbelievebly stupid idea or THE way of programming


Discuss
>>
File: $.gif (1002KB, 250x251px) Image search: [Google]
$.gif
1002KB, 250x251px
>>57151651
I don't believe in writing any code that doesn't have a test case beforehand. Each function should ideally have at least one test case.
>>
In c++, what's the easiest way to see if a struct instance is zeroed?
memcmp?
>>
>>57150796
This is the most direct translation to Haskell (of course, its horribly un-idiomatic and ugly-looking)
forM_ [1..13] (\x -> do 
putStrLn ""
forM_ [1..13] (\y -> do
putStr ((show (x * y)) ++ " ")))
[\code]
>>
>>57151606
Nej.
>>
>>57151651

As a general rule I like it.
>>
File: 1437357152500.jpg (54KB, 640x480px) Image search: [Google]
1437357152500.jpg
54KB, 640x480px
>>57151691
>>
>>57151679
How can you be sure how the code that does not exist yet will solve any given problem?

I tried writing tests first but too often my tests turned out to be irrelevant to code that implemented functionality in best way. Starting from tests is pointless.
>>
>>57151003

vec2 Vec3ToVec2( vec3 const *v ) {
vec2 result = { v->x, v->y };
return result;
}

v2 = Vec3ToVec2( &x );
>>
>>57151787
I feel like this post or a variatiom of it is posted too often in this thread. I'm seeing a glitch in the matrix
>>
>>57151787
>How can you be sure how the code that does not exist yet will solve any given problem?

Because you will MAKE it solve that problem.
>>
>>57151243
So it doesn't really make a difference performance wise? I'm not too worried about the array being dynamic at the moment, but I guess I might as well try it both ways, and just see how much more trouble it is, seems like a good enough learning experience.
>>57151261
I don't mind the code being verbose, if it makes it easier to read, or simpler to conceptualize what I'm doing.

What are cache lines?
>>
>>57151689
That's how to do it in C
>>
>>57151809
yes, but in the beginning you rarely know HOW you will make it until you write that code, and than probably rewrite it to make it cleaner and more efficient
>>
How do you guys focus on code? I just cant will myself to do it, my mind rebels, even though I enjoy it the few times I get the groove
>>
>>57151900

What does how matter when all you care about is the result?
>>
File: 1469936823694.png (39KB, 482x556px) Image search: [Google]
1469936823694.png
39KB, 482x556px
>>57151794
Nigga are you seriously returning a stack variable?
>>
File: 1473904174293.jpg (47KB, 600x373px) Image search: [Google]
1473904174293.jpg
47KB, 600x373px
>>57151651
One thing about programming is that it's always easier to find out what needs to be changed than it is to find out what needs to be done.
So, in a work environment it can be good, but only as good as the quality of the tests themselves, and it's pretty rare to find good tests.
Whenever software developers invent new ways of keeping code quality and shit, stupid people just apply it incorrectly and defeat the purpose.
Personally I don't need tests, because 1.) I know what I'm doing and 2.) I'm constantly adding new shit and I don't want to write new tests for each thing I implement.
To sum up, I think tests are a compromise designed to bound software quality from below, so if we had competent programmers who adhered to the language guidelines then we wouldn't need tests, and more importantly companies wouldn't have to hire special people just to write tests, which costs a lot of money since they too have figured out that shitty tests are only a burden, so now we have these people called "TEST ENGINEERS" who basically just put asserts everywhere and get paid anywhere between 80k and 120k.
>>
>>57151930
you can't always test stuff efficiently this way
>>
>>57151921
I usually go pen and paper first and figure everything out, then it's a simple matter of following that to write actual code.

Also I just focus better with pen and paper than on a computer., probably from years of schooling and doing lots of math and shit by hand.
>>
>>57151995

You can't always test efficiently any way. But by keeping tests in mind from the start you have more time to think of corner cases.
>>
>>57151651
It's bad. If you need to handle special case, just use comments.
>>
>>57151809
Why are you memeing with that idiot
>>
>>57152003
Yeah that would do nothing for me, parkinsons makes writing uncomfortable
>>
https://www.rubyrampage.com/

alright ruby is gay but let's do this
>>
>>57152044
Sorry anon, it would suck to be you.
>>
>>57152046
>alright ruby is gay but let's do this
alright ruby is gay so let's do this *
>>
>>57152014
Not him but the idea that you'd have to know exactly the one answer for every problem in a programming environment is ridiculous. That's why they hire sentient beings and not just throw "logic bomb" programs at it.
Someone is just shilling a framework or something here. Just ignore that guy. He's clearly being fed a crock of shit and wants to make sure it doesn't just taste like shit because he's only ever tasted his own. Too bad he doesn't know her estrogen is piled to the ceiling with schmi and schmoo.
>>
>>57151787
>too often my tests turned out to be irrelevant to code that implemented functionality in best way
But tests should be implementation agnostic!
All you need is a functional specification and an interface.
>>
template<const std::array<CoolType, |||This???||| > &Foo >


How do I pass an array as a template parameter while also having access to the size?
>>
Is there honestly any real argument for using C over C++11 now a days?
>>
>>57151354
Like operator overload?
>>
>>57152108
The argument for using C over any flavor of C++ was always that C++ is a feature explosion and incompetents can't be trusted to make good decisions on which features to use.
>>
>>57152108

They're different languages that do different things?
>>
>>57151900

How isn't always important -- you aren't testing implementation because you haven't written it yet. When you're doing TDD, you're starting with black boxes that will provide you the correct result.
>>
Now testing my som... the time steps notation everywhere is confusing.
>>
>>57152119
But how can you trust yourself to do the right thing versus a committee of experts who write the C++ standards and the compiler experts who implement them?
>>
>>57152064
Sucks to gno python so hard. Did she wag her finger at you a lot?
>>
>>57152139
Why would you need to trust yourself when you could just reference the same primers and design manuals that they do? The RFC specifications are literally a few keystrokes and clicks away.
>>
>>57152156
https://www.ietf.org/rfc/rfc2068.txt

Here's one. Notice that it's supposed to be LIGHTWEIGHT.
>>
>>57152119
>and incompetents can't be trusted to make good decisions on which features to use.
And letting the same incompetents near any C code that does anything important is a better idea?
>>
>>57152156
At that point you're just rewriting the wheel, and that's assuming the compiler experts aren't using tricks not otherwise noted in implementation details of RFCs
>>
>>57152143
What did she mean by this
>>
>>57152172
What is it with you and character assassination? I thought Anita Sasuke was done with this side of the world. Would using the word incumbents have made it more clear to you?
>>
What are programming languages with strict rules about how you're supposed to make a program?
>>
>>57152097
Foo.size()
?
>>
>>57152181
Did they start taking down the anti-stormtrooper python threads again?
>>
>>57152195
java
>>
>>57152195
Haskell?
>>
>>57152195
Different!

What's the difference between strongly typed and statically typed?
>>
>>57152202
I have to ensure that the template argument is of type std::array<Dither::ErrorMatrix, (some number) >
>>
>>57152209
>
>>
>>57152222
Then just put the number? If you have arrays of different size, they are different types.
>>
>>57152139
Oh you mean like Stallman who works in C and wouldn't recommend anyone work with anything he himself wouldn't?
>>
>>57152222
are you trying to pass this to a function? or something else...
>>
>>57152261
Stallman is literally a wack job
>>
>>57152261
Don't be daft. Stallman wants everyone to use LISP.
>>
>>57152252
So is it impossible to take an std::array of any size as a template argument.
Something like

template<const std::array<uint32_t, Size > &Foo, size_t Size >

would be ideal
>>
>>57152281
He's the wack job we need for freedom. There is a thin line between insanity and genius.
>>
>>57152315
He's the hero we deserve, but not the one we need right now.
>>
>>57152309
still don't know what you're asking. you can do this

template<size_t N>
void Function( const std::array<Dither::ErrorMatrix, N> &Foo ) {}
>>
>>57152174
Aren't you trying to learn how to program in a programming language? Why would compiler experts, I will assume you mean gnu and stallman, use "tricks" not otherwise noted? The whole premise of a compendium is the writ and note of the specific details to a certain pretense. Not some gobbledeegook trick where we decide, "Ummm this doesn't sound right. We better charter a course of alternate route and detour their intentions".

What you're not understanding is what you learn when you take on the C language. All that extra fluff that comes with the C++ language ( though I do like C++, I hate the noise level ), the way it ties into all the new frameworks ( which are bloated and obfuscated as all hell ) is very much enterprise specific and can only guarantee express by committee because who would hire me to work on Microsoft Servers. If I'm going to be working on this stuff and it's going to be known that I spent some time on this website, I may as well make sure I have what it takes to show that I can use the language to bring to life, I mean manifest, whatever it is you need me to do. I wouldn't let anyone that DIDN'T know C get anywhere near something important. It's just too important.

Besides, I was incompetent once. I still kinda am, but I was too.
>>
>>57152097
Just do
std::array<uint32_t, INT_MAX>

And stop wasting time with the muh performance meme
>>
>>57152281
Stallman just didn't have an overbearing mother. You remind me of my ex-girlfriend. She forced herself too.

I have never heard a professional of quality call any other kind of professional a whack job. Have fun with your memes and your guns.
>>
>>57152295
Stallman says lisp offers more freedom but discounts nothing from the basis of C.
>>
>>57152365
I'm not passing it as an argument. It's a template argument. Why can't I access a templated parameter from within array?
>>
Great! They're gone.

What are you all coding today? I'm trying to go over this Assembly Primer but I hate that the guy talking into the mic seems to be SUPER uncomfortable in his own home. Also the background noise is so fucking annoying, especially the ASMR.

https://www.youtube.com/channel/UCfzJt14kLSHHH-jqFu8pxNw

In case anyone else wants to try and learn. It seems fairly short and he goes through rather casually but still has some more strictly typed lessons on screen.
>>
>>57152365
This looks like it's made for traceroute. Since when does the military need help with this kind of thing?
>>
File: 91fecfbb7a.png (34KB, 1253x656px) Image search: [Google]
91fecfbb7a.png
34KB, 1253x656px
>>57149874
Anyone knows how to create a Server instance in MSMM? Like I did try the 2008 version without possibly doing this, but in the 2016 version, after installing there were two server instances!, so I need to create another for testing purposes.
>>
File: 1476924143938.jpg (170KB, 401x1317px) Image search: [Google]
1476924143938.jpg
170KB, 401x1317px
Just a friendly heads up that true artisans express their wearyness in the comments occasionally
>>
>>57152597
//  no one will ever read this code and none of this matters
>>
>>57150244
What if the regulation eased tensions rather than mitigating the resolve effort? I'm thinking he/she is uncomfortable with the trigger words and bad punctuation. Especially with the tirade of vlad and his consumerist horde.

Besides, to change something doesn't mean subclass a precedent. It could be a lateral distinction. He gets rid of the cop talk, the anime gossip wheel, the shill for commerce of a tangential variety and for a separation of trusts among devotees to technology and the self designed programmers? There's a reason loops are always the same but can be expressed differently.
>>
>>57152591

Are you being paid to learn this crap?
>>
>>57152632
Firstly, talking about reality like it's a program is tired and not cute, secondly you shouldn't be here if you dislike anime
>>
>>57150717
Knowledge can be interpolated. You're simply looking to lock definitions and standardize assembly. Why are you calling it strong?
>>
Let ALLDFA = {<A> | A is a DFA and L(A) = Σ*}
Show ALLDFA is decidable.

What does <A> mean? i don't get what ALLDFA is supposed to be.
>>
>>57152621
Good job anon, now do this in your actual programs with small regularity and you'll channel the powers of the OG script kiddies.
>>
File: smh_tbh_fam.gif (490KB, 500x671px) Image search: [Google]
smh_tbh_fam.gif
490KB, 500x671px
>>57152665
I already told ya that I'm learning this memes since the job I'm gonna apply for needs it.
>>
>>57152194
Wat?
>>
>>57152597
>tfw you program in a dark castle on an e-ink screen lit by candlelight
Productivity magically increases 900%
>>
>>57152683
Your mom is tired and not cute.
>>
>>57152848
Tru. I'm much cuter
>>
>>57150618
Interned symbols are better than integers and are just as fast and provide better debugging information
Wake up to the stockholm-syndrome that is C
>>
>>57150618
Haskell is fast and Java is even faster.
>>
>>57152898
>Stockholm meme
C++ is painful. When will you learn?
>>
>>57152913
>Java faster than C
hmm
>>
General question:
I recently decided to change my major to computer science from Psychology. So obviously my math skills are lacking. I have a good 8 months before heading back to school and am currently learning python and started Intro to Algorithms as suggested by anon. I'm also watching the MIT Open courseware intro to Computer Science and Programming.


My question is, assuming my knowledge of math stops at algebra 1-2 (its been a while lol) what would be the best way to reach enough math proficiency for a comp sci degree? Its my understanding that ill need to learn discreet mathematics and a pre requisite for that would be calculus?

Sorry if the message seemed all jumbled up. Really appreciate y'alls input! (Ba dum tss)
>>
>>57152949
>things I didn't say
Hmm.
>>
>>57152930
Does C have function overloading?
Does C have lambdas?
>>
>>57152963
Less is more.
>>
>>57152963
You do know operator overloading can be done via pre-processor directives or simple function calls, right? You almost had me going there, I googled the problem a bit.

Aaaaallright I always google the problem.
>>
>>57152972
t. dicklet
>>
>>57152972
>no array type
>has caused literally tens of thousands of errors and vulnerabilities in software written by professionals
>"less is more"
Yeah, go fuck yourself.
>>
>>57152957
Calculus is pretty much the opposite of discreet mathematics.

You need to understand limit theory from calculus to understand algorithm complexity analysis, or big O, though.
>>
>>57152998
>being this mad
>>
>>57152998
>no array type
>
>>
>>57152988
>pre-processor directives AND simple function calls
fixed that for you. anyway, Cs pre-processor directive are the tool of satan, and i refuse to touch them for anything more complex than an include guard.

Also, i didn't say operator overloading. I said function overloading.
>>
>>57152998
>checking array bounds is the job of the runtime
>>
>>57152972
Have you heard the gospel of Assembly?
>>
>>57152683
We're talking within the concepts of programming. Besides, this is the first I've spoken to you. How have I been doing that before?

Chemistry is literally happenstance effects in theory of a "program". Does it hurt to think on things logically or something? The imagination is a wonderful tool. It helps those of us that can't afford to break every other thing we run into, fembot. Also, talking about anime is not programming. Discussing qtpie lollerskaters is not a prime subject of programming or /g/ for that matter. That stuff came with the mods. It's like the posters that fill their rooms. Get it?

Anyway, I didn't mean to trigger you by using a metaphor. Subclassing a precedent kind of pertained to the sentience behind the "evolution" of C into the C++ language.

Also programming is a reality. Whether you like to admit or are ven allowed to is a completely different thing. I worked in Graphic Design some time ago and I spoke to the sales department. It became clear after maybe a day or two that they sink themselves into the mind and look to keep a grasp from there. They use fear tactics to sell t-shirts for christ's sake. The only thing you don't seem to grasp in that manner is that it's selling social cues. Also, it is very cute.

>>57152896
Helloooo WOooorll- SKIP! Bud-Wise-Er.
>>
>>57153090
>>dynamic arrays
>>
>>57153127
Do you really think bounds checking is what's slowing down your shitty malloc() ridden O(n!) code?
>>
>>57152998
>professionals

All that's required there is to get paid.

The vulnerabilities, though, came from the kind of teaching you and your squad here have been propogating.
>>
>>57153121
Was this a failed Markov chain?
>>
File: 1474496560896.jpg (85KB, 633x738px) Image search: [Google]
1474496560896.jpg
85KB, 633x738px
foo_int (int a)  
foo_char (char b)
foo_float_int (float c , int d)

#define foo(_1, ...) _Generic((_1), \
int: foo_int, \
char: foo_char, \
float: _Generic((FIRST(__VA_ARGS__,)), \
int: foo_float_int))(_1, __VA_ARGS__)
#define FIRST(A, ...) A



>C function overloading

my god
>>
Is file encapsulation a good idea.
>>
>>57153150
No, one file for everything
>>
>>57153083
Well, I didn't mean to assume you needed both. It could be either or if you consider that the operator overloading happens logically either which way. As a sort of undefined behavior but not that of a bounds error checked exception.

And you're right, you did say function overloading. TWO CHEE.
>>
>>57153149
not even once
>>
>>57153141
Imagine how much comfier C would be if it had tuple types, bounded arrays and interned symbols...
>>
>>57153149
But people will still say it's "elegant"
>>
>>57153142
I hope not. That sounds painful.
>>
>>57153194
Oh, and lambdas. Maybe with closures (unsafe closures eqv. to just passing the stack pointer as an additional word) but not necessarily.
>>
>>57153166
ta
>>
>>57153194
If you want bounded arrays just go ahead and write boilerplate around all your operations to pointers tat you intend to be arrays or make some horrid array struct with functions to deal with it
>>
>>57151691

better version


forM_ [1..12] $ \x -> do
forM_ [1..12] $ putStr . (" "++) . show . (x*)
putStrLn ""



in haskell we don't do that but it's possible
>>
>>57153222
No, that sucks, and bounded array syntax builtin wouldn't suck. Literally every other language but C has bounded arrays built into the language. They could even make bounds checks disable-able for sensitive code, and you'd still be able to convert arrays to pointers if you need to.
>>
>>57153252
Just use Ada at that point 2bh
>>
>>57153194

Then it would be Ada.
>>
>>57153266
>>57153267
Maybe I fucking will
>>
>>57150086
Are you serious?
>>
>>57153252
You could do it like in sepples if you had operator overloading.
>>
>>57153280
I hope you do you, cunt!
>>
>>57153252
It would suck as it breaks the ability to do lots of exploits and hacks that are fairly unique to C.

If you want a sandbox to play with your plastic trucks go back to Java or C#
>>
>>57153266
>>57153267
Spooky
>>
File: Bn0blPdIQAA4c7n.jpg (30KB, 598x448px) Image search: [Google]
Bn0blPdIQAA4c7n.jpg
30KB, 598x448px
>>57153252
*Cough*Linked List*Cough*
>>
>>57153295
Programming is a tool, not a dick measuring contest
>>
Any good JPA tutorials that use Eclipse and MySQL with building a wep app?
>>
>>57153319
If I pee faster than you and it doesn't burn when I pee, is my dick bigger?

How do you infer anything from that, anyway?
>>
>>57153319
You mom is a tool. And a dick measuring context.
>>
>>57153310
wow, this is meme is now on /g/
>>
>>57153326
*web
>>
business idea: a programming language, but everything is lists
>>
>>57153367
omg it's like you want to learn assembly!
>>
>>57153367

You mean like LISt Processing?
>>
>>57153411
Oh man I didn't even know that! I'm a terrible fan of computers and stuff!
>>
Okay, post your programing language ideas.

I'll start: something like Haskell but with the ability to create infinite set of strings with Regex. Or more generally, everything is a set and types are subsets.
>>
>>57153432
Haskell, but fast
>>
>>57153432
Could you elaborate over the "create infinite set of strings with Regex" part? Are you meaning a smart pointer layer over the hardcode?
>>
File: Lanka45.png (22KB, 124x101px) Image search: [Google]
Lanka45.png
22KB, 124x101px
>4 classes on Mon/Wed next semester
Kill me now senpai
>>
>>57153429

Lisp was created in 1959, Anon. It's over half a century old. You were not aware of its existence, or at least of its descendants, such as Scheme, Racket, Clojure, Common Lisp, or Emacs Lisp?
>>
>>57153446
Nein
>>
/dpt/ I have a question. you have 8 colors:

000 = black
001 = red
010 = green
100 = blue
110 = cyan
101 = magenta
011 = yellow
111 = white

is there some mathematic operation $ that can properly combine colors this way

color $ itself = black
color $ black = color
color $ white = black
[r, g, b] $ [g, b, r] = [y, c, m]
[c, m, y] $ [m, y, c] = [g, r, b]
>>
>>57153462
No, yes, that I was. I did not know it was List Processing. That's...just amazing!
>>
>>57153446
Basically, in this language you don't manipulate variables but all the values the variables would take if the program was repeated an infinite amount of time.
>>
>>57153496
Sounds like a lexicon tied to a super computer. Is this because I filtered the Chinese Shit General thread?
>>
>>57153432
It's C++ but with modifier overloading.
 
class MyClass
{};

modifier long : MyClass
{}

int main()
{
MyClass A;
long MyClass B;
}
>>
>>57153485
a & !(b)
>>
>>57153492

There was another language created just a bit earlier. It was called FORmula TRANslator. I'll give you a hint which one that was.
>>
>>57153536
b--but... why?
>>
>>57153544
4chan?
>>
>>57153429
why are you triggered
>>
>>57153530
I don't understand. Is this some obscure insult?
>>
>>57153485
Yeah that's just bitwise XOR.
>>
File: d86e6199e6.png (53KB, 1276x602px) Image search: [Google]
d86e6199e6.png
53KB, 1276x602px
>>57152591
Yay!, after messing three days with this shite, finally I'm able to connect with this old database. I still don't know how to create a local server tho, but I can move on.
>>
>>57153536

We'll call it C++20.
>>
>>57153319
So you're telling me because you are incapable of managing your own pointers and knowing their bounds everyone should be penalized?
>>
>>57153485
Bitwise operators
>>
>>57153539
red & !(green)
001 & !(010)
001 & 101
001

red & !(green) = red

nope

>>57153587
red ^ yellow
001 ^ 011
010
red ^ yellow = green

nah

>>57153604
that's the question. which one?
>>
>>57153266
>>57153267

Adamind
>>
>>57153620
a ^ ((b << 1) & (b >> 2))
>>
>>57153650
wait no
>>
>>57153620
>red ^ yellow
>001 ^ 011
>010
>red ^ yellow = green
>nah

On all of these, XOR will work.

>color $ itself = black
>color $ black = color
>color $ white = black
>[r, g, b] $ [g, b, r] = [y, c, m]

On this it won't.

>[c, m, y] $ [m, y, c] = [g, r, b]
>>
>>57153695
What do you mean by
>[c, m, y] $ [m, y, c] = [g, r, b]
>>
Are C++ objects allocated on the stack?

like if I do something like:
pos = glm::vec3(1f, 1f, 1f);


I don't have to free it?
>>
>>57153594
I'm saying that managing pointers and bounds is busywork that just makes writing programs more difficult when there are myriad techniques that do it for you at negligible or no performance cost. And it would be possible to make unsafe no-checks optional but possible (for EXTREMELY sensitive code), rather than the default.
Also, rarely is code going to be random accessing an array an enormous number of times, such that there are bounds checks (that absolutely CANNOT be optimized out) in a volume that dramatically effects performance. Instead, most array access happen in an iteration over the array, or happen repeatedly on the same few indices.
>>
>>57153721
If it's not a pointer, you don't need to free it.
>>
>>57153721
By default they're on the stack unless you specify otherwise with new.
>>
>>57153539
>>57153587
>>57153604
>>57153650
>>57153695
>>57153705

fuck, you know what? I think it's impossible to do with just bitwise operators. every bit depends on every other bit

001 $ 011 = 000 but 001 $ 010 = 011, so the
>>
>>57153762
This basically comes down to you having poor technique. The fact that you need to rely on a implicit bound check shows you're careless and would just end with your shit program crashing while a smart programmer will catch it or simply avoid it by knowing ahead of time
>>
>>57153149

It's very self contained and doesn't have any side effects.

You get what you write. Admittedly, C will need more generic programming language features before _Generic feels a lot better to use, probably in C2X if it gets in.

For now, yeah, it's nasty to write code like that but it works.
>>
>>57153762
It doesn't matter how hard you explain the decades of vulnerabilities caused by C's paucity of memory management features and how they've been remedied at zero runtime cost ages ago, all you're going to get in response is empty dickwaving by people who think cargo-culting their Unix heros by writing fizzbuzz in unsafe languages makes them expert system programmers.
>>
>>57150464
what if the plan backfires and the aliens love anime and shitposts so they connect to 4chan and act like Australians
>>
>>57149874
I haven't programmed since I've switched to arch a little over a year ago. I used windows before then. I'm getting ahead on classes at my uni and have some more spare time and wanna pick it up again, what are some good (graphical) compilers/developing tools. I used 'bloodshed dev-c++' before.
Please no emacs/vim
>>
>>57150643
no this is fucking terrible
concepts are a term used in generic programming
>>
>>57153820
>C2X

m8 C is done, there will never be another standard
>>
>>57153878
Please do not use dev-c++. It hasn't been supported since like 2004.

The most popular free IDE is Code::Blocks but I don't really like it. There's Geany, Anjuta, and a million other IDEs out there, but you really would be better off to use a terminal and text editor if you want to become a good programmer.

You might feel more comfortable with Atom or Sublime if you do choose to go the text editor (grown up) route
>>
>>57153883

It actually exists though...

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2086.htm
>>
>>57153536
at first I thought this was retarded but the more I think about it, the more it makes sense
>>
>>57153536
I don't understand
>>
>>57153944

Anything good yet?
>>
Is there some rapid way to pull information out of a webpage using javascript and forward it to a perl script, then send it back and have the javascript interact with the webpage?
I'm trying to build a bot for an idle clicker game because it's good search pattern practice but I'm struggling to figure out a way to do it in perl
>>
File: when_someone_insults_my_food.jpg (221KB, 742x1080px) Image search: [Google]
when_someone_insults_my_food.jpg
221KB, 742x1080px
Get the fuck over to this new thread or you mom will die in her sleep tonight

>>57154434
>>57154434
>>57154434
Thread posts: 320
Thread images: 28


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.