/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: doubts.jpg (1024x1024, 350K)

Other urls found in this thread:

guide.elm-lang.org/install.html
blog.regehr.org/archives/1292
0.30000000000000004.com/
twitter.com/NSFWRedditImage

Can someone explain what a "side effect" is to a brainlet?

nth for are you hanging in their lads?

im making my own personal website, any tips for somebody new to the language Jow Forums?

A result from a function not intended.
or Anything that's not the expected output of a function.
You add two numbers and then update a global variable from inside the function for whatever dumb reason. Updating the global is a side-effect because it has nothing to do with the returned number.

the most common side-effect is writing to IO.

try elm, it's great for small sites like yours.
guide.elm-lang.org/install.html
And you'll get a very gentle and nice introduction to FP, as the compiler is VERY helpful with error messages.

When a function has any visible effect apart from the return value, that's a side effect. The return value can be considered the "main" effect.

I already did my site, how do I put it on the Internet?

Some of the C UB is bullshit.
blog.regehr.org/archives/1292
>In C you are not allowed to compute — much less use or dereference — a pointer that isn’t inside an object or one element past its end.

>SQLite’s vdbe struct has a member called aMem that uses 1-based array indexing. To avoid wasting an element, this array is initialized like this:

p->aMem = allocSpace(...);
p->aMem--;


That's bullshit. Why can't I do this if I don't dereference it invalidly?

Just write static html+css. Look at CSS zen garden.
Ghetto way: 000webhost + cloudflare + freenom domain
Proper way: Cheap VPS + nginx + regular domain

I wonder how it's possible to write a completely legal malloc implementation with all this UB.

>C uses make fun of Rust for unsafe blocks
>in reality most C code would be in UB blocks

Is Go not worth learning if you're not programming on a team?

what's the best language to program in?

can we all just agree both are shit and move past this bullshit shitshow

only when you install Haskell

holy hell css zen garden is amazing, thanks

personally I really enjoyed haskell but I can't find anything to use it on now... I thought about making a JS library to mimic everything from hasklel

Define best.

Haskell

>unironically thinking of buying an expensive webcam to record every second I'm in my studio (so it can record everything in my life - work, rest, cooking/eating, wanking, chores, shitting, etc.), wear one of those fitness tracker thingys, and at the same time log everything I'm doing on the computer - so I can track pretty much everything, with the hope of getting some useful data with time (no idea what that would be, at least porn habits would be possible I guess)

is this autism?

Attached: 1531505549526.png (1024x576, 8K)

>elm
>didn't even get : and :: right

I had made an animation with 120 frames and then a version of it with sections inverted and then a new animation utilizing the previous two over 240 frames that was a simple cartoon-like circle wipe (I took each frame of each sequence and layered one on top of the other, erasing a circle in the middle showing the other animation frame underneath it and I gradually increased the brush size of the eraser so over 120 frames the top layer is erased and the following 120 frames the 2nd layer is erased showing the first animation underneath that.

What I’ve been doing in SpriteKit is to try to accomplish the same effect using programming. I’ve already reduced the amount of frames I need from 120 to 10 (per animation making a total of 20). So the code tree is a simple scene with a pixel by 1 pixel sprite in the center called axis and three sprite nodes as it’s children that display each 10 frame animation. I’m trying to figure out how to use SKCropNode to cut out a hole from the top node as it plays its animation and has the node beneath it plays its animation at the same time.

import SpriteKit

import UIKit


class AnimScene: SKScene {


var tAnimation = [SKTexture]()

var uAnimation = [SKTexture]()



override func didMove(to view: SKView) {

self.initAnimScene()

}
func initAnimScene(){


let tAtlas = SKTextureAtlas(named: "oorb1-10")

let uAtlas = SKTextureAtlas(named: "norb1-10")



for index in 1...tAtlas.textureNames.count{

let imgName = String(format: "oorb%03d", index)

tAnimation += [tAtlas.textureNamed(imgName)]

}

for index in 1...uAtlas.textureNames.count{

let imgName = String(format: "norb%03d", index)

uAnimation += [uAtlas.textureNamed(imgName)]

}


}

override func touchesBegan(_ touches: Set, with event: UIEvent?) {
let axis0 = self.childNode(withName: "axis0")


let spriteNode0 = axis0!.childNode(withName: "spriteNode1")

spriteNode0!.zPosition = 3

let spriteNode1 = axis0!.childNode(withName: "spriteNode1")

spriteNode1!.zPosition = 2


let spriteNode2 = axis0!.childNode(withName: "spriteNode2")

spriteNode2!.zPosition = 1

fuck off hasklet, there's no reason why you need an extra one.

let mask = SKSpriteNode(color: .white, size: self.size)
mask.position = CGPoint.zero
mask.zPosition = 4
mask.alpha = 1

let circle = SKShapeNode(circleOfRadius: 385)
circle.fillColor = .white
circle.lineWidth = 0
circle.alpha = 1


circle.blendMode = .subtract
mask.addChild(circle)


let crop = SKCropNode()
crop.maskNode = mask

crop.addChild(spriteNode0)

self.addChild(crop)


let anim = SKAction.animate(with: tAnimation, timePerFrame: 0.04166666)

let anim8 = SKAction.animate(with: uAnimation, timePerFrame: 0.04166666)

let rot0 = SKAction.rotate(byAngle: CGFloat(((Double.pi) / 6)), duration: 0.00000000000000000000000000000000000000000000000000000001)

let wait499 = SKAction.wait(forDuration: 4.9999)

let gruw = SKAction.scale(to: 1.0, duration:4.9999)

let shrnk = SKAction.scale(to: 0.001, duration:0.0001)

let gro0 = SKAction.sequence([shrnk, gruw, wait499, shrnk])

let gro1 = SKAction.sequence([shrnk, wait499, gruw, shrnk])

let aniSeq0 = SKAction.sequence([anim, rot0])

let aniSeq1 = SKAction.sequence([anim8, rot0])

let aniSeq4evr0 = SKAction.repeatForever(aniSeq0)

let aniSeq4evr1 = SKAction.repeatForever(aniSeq1)

let wipeSeqInf0 = SKAction.repeatForever(gro0)

let wipeSeqInf1 = SKAction.repeatForever(gro1) //meant for the second circle wipe to erase spriteNode1 and show 2 beneath it


let rot1 = SKAction.rotate(byAngle: CGFloat(Double.pi) * (-2), duration: 5.0) //use with axis1
let roti = SKAction.repeatForever(rot1)
axis0?.run(roti)


spriteNode0?.run(aniSeq4evr0)

spriteNode1?.run(aniSeq4evr1)

spriteNode2?.run(aniSeq4evr0)

circle.run(wipeSeqInf0)

}

}

Is it possible to develop regular Android apps with the Replicant SDK

Can anyone tell me what I’m doing wrong or what a better way of going about doing this would be?

I thought about buying cameras to monitor my outer door / hallway. but that's probably a bit tinfoil-y

I dont understand why you would want record yourself..

TO THE FUCKING NIGGER COPY-N-PASTING HIS PAJSHIT CODE VERBATIM (without code blocks) INTO THE THREAD:

FUCKING KILL YOURSELF AND YOUR ENTIRE FAMILY.
EVER HEARD OF PASTEBIN

Attached: 1531495241379.gif (500x346, 471K)

>record self masturbating to porn
>masturbate to what you just recorded

Go

it's perfect

Benchmarking my memory pool implementation. Why is C++ so gay?

Attached: cppgay.png (686x332, 58K)

>Making an automatic resource release stack in C so all tracked resources can be released with a single function call
>Have no use because all of my program following a strict destructor and memory management rule

What compiler you're using?

>I dont understand why you would want record yourself..
For science. I'm not Bezos, so, instead of a million drooling morons who pay me to spy on them, I'll have to do

same result on clang and gcc

Why not use C?

too much of a pain in the ass in a gamedev context.

>gamedev

There is no bad programming language. There are only bad programmers

Is MemoryPool trivially move-constructible or move-assignable? Maybe the optimiser thinks that your move operation is really clunky?

The same user, who's learning python and making overly complex list programs.

Picture related, how does this even work like this.

Attached: how does this even work.png (243x44, 1K)

% is not division. it's the modulo operator. 0.3 is the correct answer.

0.30000000000000004.com/

Looks like it's not trivially move-constructible but is trivially move-assignable. This is a bit of a gap in my C++ knowledge desu. The type is pretty simple:

class MemoryPool {
...
size_t maxSize;
size_t chunkIdx;
void *block;
void *back;
};

It isn't division.
0.3 and 0.3000000000000007 are not the same value.

If you're an OO programmer then kindly get the fuck out of /dpt/. You are not welcome here. or Stackoverflow or Quora may be more appropriate to your limited intellect and pointless questions such as "how do I put an ArrayList into a JTable?". This thread is reserved for nontrivial and interesting problems and insights.

>void pointers
I don't know if this is a hobby project or a professional project but that needs to be removed immediately.

OO what's this

post your fizzbuzz user

>babby's first IEEE-754

Are you one of those functional programmers I keep hearing about?

Attached: 5e7d2681f41320c669f59325845d3b7b64556d26_full.jpg (184x184, 7K)

Sure am! I've never been a dysfunctional programmer.

Haha! Good one.

megumin

take a floating point class

MemoryPool needs to be able to allocate different types of objects. I don't really think void pointers are that evil in this context.

If a language can't implement traverse_ type-safely then what's the point of the language existing?

Have you ever heard of templates?

>inb4 They're messy
Yeah, if you overuse and abuse them.

You're using C++. Use templates!

Rate my fizzbuzz

foreach my $i (1..100){
if ($i % 15 == 0){
print("Fizzbuzz\n");
}
elsif ($i % 3 == 0){
print("Fizz\n");
}
elsif ($i % 5 == 0){
print("Buzz\n");
}
else{
print("$i\n");
}
}

who's saying a memory pool can only hold homogenous objects?
This is a valid use case for void pointers.

the absolute state of modern dpt during euro hours lads

>foreach my
>elsif
What is this language even doing?

A quite important question: What library do I use to make DOS UIs in python, like the one in picture related?

Attached: cnct.png (480x400, 12K)

Void pointers are inherently unsafe and are a sign if bad design in code. I'm sure there is a safer way, but if it works, hey who am I to get in the way?

I am using templates. Basically I preallocate some memory upfront at the start of my program and then pop out some T's from that memory when I need them. Why just assign some arbitrary type to that preallocated memory when I can just use a void pointer?
Exactly

(n)curses?

It's the future of programming.

In that case the future sucks

This is what happens when you take things for granted

is CS50 any good?

I bet you throw a tantrum if you see goto in C code too.

>inherently unsafe
C is inherently unsafe. period.

void pointers are just useful

The present sucks too.

I took it for granted that things would get better, not worse.

>C is inherently unsafe. period.
I know that but since he was using C++ I thought he would use safer alternative.

>goto
Goto creates spaghetti code and its used is discouraged.

Are you the C++ shill from yesterday?

Goto is the correct way to do error handling and cleanup in C.

is that C?

I wasn't here yesterday.

Then the answer is no.

No. C is less ugly than whatever that is

Jeez, that must suck.

no it looks to be some bloated pseudo-syntax from user's langdev.

Probably. I mean, "elsif" is the worst of all worlds.

It's fine. The only problem is Java programmers coming and deciding to rewrite functions into deeply nested chains of if-statements because they were once told that goto is generally bad.

I'm sure a goto is a lot better than an abyss of if statements.

If you want to construct several different objects from one preallocated chunk of memory I don't think there really is a safer way than this sort of shit. What's important is creating a safe interface to unsafe code, however.

Any recommended sites for programming exercises, specifically C#?

I feel like i've been trapped somewhere between beginner and intermediate levels for ages now and i don't know what to do other than keep practicing. I'm fine with making classes and working with enumerables and etc but stuff like linq and lambda functions still fuck me up

The useful parts of programming.

I thought so too, but apparently not. Apparently goto is always bad in every situation no matter how much cleaner it is than the alternatives.

What exactly is elseif? Isn't it just else?

codeacademy.

Can you replace an expression with the result of evaluating it without changing the meaning of your program? No? Then it has at least one side effect.