/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

Other urls found in this thread:

github.com/PonderingGrower/rbackup
craftinginterpreters.com/
en.wikipedia.org/wiki/Descent_(video_game)
github.com/videogamepreservation/descent
github.com/dxx-rebirth/dxx-rebirth/tree/master/d1x-rebirth
rise4fun.com/SpecSharp/BinarySearch
twitter.com/SFWRedditGifs

my determination

Linear types will save systems programming

Slowly creeping towards 100% coverage on my small backup utiity. 0 to 58% in a few hours.

github.com/PonderingGrower/rbackup

Not stable yet, but will be in a few days.

reading this: craftinginterpreters.com/ and writing my own code for it in rust because i can't stand java (and it's a decent excuse to learn rust, otherwise i'd be writing c++17)

Just in the brainstorming stages here, but I want to make an animated background for my computer consisting of a virtual aquarium with procedural vegetation and autonomous AI fish. :D

whats wrong with java?

Good question.

because java a shit, can't fucking stand it or its bloated environment

my day job is c++17 so if i wasn't playing around with rust, i'd be using that

If I'm not doing low level shit, is it possible to avoid doing memory management in Rust altogether?

You'll still be using things like Box, Arc, etc. but you're guaranteed no undefined behaviour.

Daily reminder that daily reminder should be daily,
and I already claim today's daily reminder

I know a guy who got hired for a large, reputable software company as a software engineer. Dude had a shit GPA, no internship experience, empty github, and wasn't even that great of a programmer (from what I could gather in several classes I had with him).
He knew somebody on the inside didn't he?

Either that or he had great charisma.

this memory editor in c++

It's called cheat engine

no i think cheat engine is a GUI

a simpler to use (ofc i'm biased because i wrote it) cheat engine with some extra functionality

Is there any modern cooperative OS that kills/suspends a process if it goes too long (say, a few seconds) without yielding?

and it can be used as a one liner if you know the mem addr of something you want to change

sudo ./v pid -w address value

will write value to address in pid

what kind of shit do I need to know to write something like this? I am decent at c++ and I know some MIPS asm

there are system calls for most OS's that make it really easy to write. if you're on linux, look into process_vm_readv and process_vm_writev

how memory works

this also helps

I know what the stack and heap is, kind of (mostly about the heap, how the activation records for functions a built). What else should I know?

Rewrite Descent into Dlang

What's Descent

lol i'm surprised to see that name in here

game

get used to pointer arithmetic

Trying to work out a structure for, essentially, a hexagonal map that functions as get-anywhere-from-anywhere with as few nodes as possible.

What I basically have right now is a (obviously somewhat redundant) triply linked list, since any of the other 3 directions can be reached using two links.

The trouble is iterating over a list of this structure without infinite recursion in an efficient way.

I guess I could flag the hexes we're moving out from as visited and make that a condition of whether or not to check its links.

I know this is imptactical and probably pointless, but still.

ok thanks

LOL nice test suite you have there. Too bad it'll never find 99% of the bugs you will encounter.

It's a very old 5-axis FPS

Blast from the past, ladies and gentleman!

en.wikipedia.org/wiki/Descent_(video_game)

Sounds neat, is the source code floating around?

Actually, yes.
github.com/videogamepreservation/descent

github.com/dxx-rebirth/dxx-rebirth/tree/master/d1x-rebirth

I want to use a camera to see if a car park is occupied or not. I'm thinking of aruco marker down and then seeing if it is being covered or not.
is there a better way?

Haskell was a mistake.

Another victim is claimed.

Working on a "clone" (of sorts) of Advance Wars in Python + tkinter. I'm mainly doing it as a programming/OOP exercise since my programming knowledge is mostly limited to scientific computing (e.g. Matlab). The GUI stuff is pretty simplistic, but the main effort is 1) adding features beyond vanilla AW/removing things I thought were dumb and 2) doing it "right" (I could hack something together but I'm really trying to take full advantage of OOP design principles to make the code maintainable, readable, and upgradeable). I usually put in a few hours on weekends and I've already learned a shit ton, definitely more than college for sure (though to be fair I majored in mechanical engineering and not CS).

I'm an engineer but I wanted to be a musician or a painter

...

Nice, you've gotten more done here than most the people here that constantly bash OOP.

That being said, I think it's unhealthy to fixate on programming paradigms so much as finding an effective analogy for the task at hand. After using OOP for some time, I just got tired of cramming everything I wanted to get done into some OOP concept.

Now imagine if Haskell required you to annotate every function, and didn't allow you to type snippets in the repl to find out what their types are.

>now imagine if Haskell wasn't Haskell

Imagine just writing AST directly...
oh wait, that's basically lisp

...

where did you get all the resources (sprites and stuff)? love that game

I think it's a jab at any language without proper static typing and type inference.

Using Lens in a dynamic language would be hopeless, even if it had HKT's. Using Lens in Idris would be hopeless. Haskell is the only language that makes something like Lens remotely practical.

I just want to be an application developer for an average company with an average salary. Jesus fucking christ is that so much to ask for? Actually, at this point I would even take a sub 40k salary, that's how badly I need to break into the field. How can pajeet get a job but I can't? How can dipshits that can't program and spent most of their free time playing video games get a job but I can't? Nobody is calling me back.

>That being said, I think it's unhealthy to fixate on programming paradigms so much as finding an effective analogy for the task at hand. After using OOP for some time, I just got tired of cramming everything I wanted to get done into some OOP concept.

Oh yeah, for sure. The main thing for me is that I've never really done anything serious with OOP so I'm trying to incorporate it where it makes sense, but if it can be more readily done without OOP then I'm not opposed to that. OOP is really great for this project since most of the constructs in the game (terrain types, unit types, the state machine for carrying out a turn, etc) are readily mappable to OOP concepts like inheritance.

I just googled "advance wars sprite sheets" and found a bunch. They needed some work (splitting into individual tiles, changing the alpha channel, naming, etc) but it was pretty simple all things considered. The hard part was trying to figure out how to get all the sprites to look "correct" based on the adjacent terrain. I ended up developing my own bitmasking approach that worked far better than I could have hoped.

Ye, I find OOP adheres most clearly to ingame object models.

What does Lens do? Seems like such a busy idea, it better have a solid concept behind it.

what's the point of haskell though? I am generally curious.

Are there no good scripting languages? Python makes working with arrays and raw bytes a pain in the ass, as does Ruby. Javascript/node is also not suited because you have to deal with async/callback bullshit even on local scripts.

I have a huge pile of quake 1 .bsp I need to rip the textures from and python and ruby are making it a bitch.

>What does Lens do?
accessors, like in C you'd have

struct.x.y

with the lens library you do

struct^.x.y

x and y are first class values
(x.y) is literally creating a new lens out of x and y, and then ^. is is using it on the struct to get a value out

it's a bit more general than that, e.g. you have isos (alternate representations) and traversals (an accessor to multiple fields), prisms (potential fields)

>Python makes working with arrays a pain in the ass
how so? Do you want Matlab style arrays?

Still not entirely sure. Is that analogous to processing data via a function before using it as a map index?

different modules expect data in either a list or array. pypng and PIL expect an array and aren't happy with a list, others are the reverse.

no it's like a view on data, so you can view a tiny part of a big thing, set that part and return a new version with that bit modified
with an iso - turn it into another representation, modify that representation, turn it back
etc

What's a systems project I could do with Haskell? inb4 functional OS

So it's like a way of providing "copies" of a state by modifying parts of it?

You have this high-level expressive lang, and you're trying to use it to manipulate the memory that it is so good at abstracting away. Why bother?

What are you talking about? Python doesn't have a basic type called array. Do you mean a bytearray? A tuple? The array module from the standard library?

no it's like a struct field or an accessor or a property
literally like the bit after the .
a.x
x would be a lens
a.x.y
x.y is a lens

bash or unix utils

user, you've described the syntax of lenses to me but I have absolutely zero idea what they do.

Good point, I'll re-evaluate what I'm trying to get out of this

Thanks, I'll look into it

Fun fact: C without recursion or side effects is not Turing complete, because infinite loops with no side effects are undefined behaviour according to the standard.

If a tree falls outside of the C standard and nobody hears it, does it make a sound?

It's a notoriously difficult concept to "get". See Personally, I grokked monads after a few hours of playing around with them since I had some category theory background. I've tried to properly understand Lens for more than a week now and I still don't really have a good intuition for all the concepts in the library.

>c isn't turing complete if it isn't c

lenses specifically, two things

a.x
access a field

a.x = y
set a field

(not haskell syntax)

>without recursion or side effects
What a useless statement.

It's funny to see turing completeness of a language subset being affected by whether behaviour is defined or not.

Suddenly I'm really curious about the turing completeness of various Fortran subsets.

Can someone post a real-world example of a lens? What's the idiomatic use case here?

accessing a nested field

person^.name.firstname.initial

updating a nested field

db^.places.at "newPlace" ?~ NewPlaceData

So, it's kind of like abstracting data access? Like getters and setters on steroids?

yes

traversals is like a thing that can access multiple fields at once
prisms can access potential fields, like members of a map

what's your stack look like? I see cov, travis, and pytest. Do you use tox, sphinx, or anything else? I'm trying to find the best python stack for small/medium sized projects so im trying a few of these out.

Not a test development person.
Are we talking about covering the input space with some caveats? (i.e every possible input of certain bounds, ignoring what files are transfered)
Or are these written tests?

Why didn't spec# become a big thing?

rise4fun.com/SpecSharp/BinarySearch
^ This binary search implementation compiles if you flip the inequalities.

We could have had provably correct C# code with little effort a decade ago. It would have been absolutely amazing for any algorithmic code where it's easy to screw up in the detailed implementation.

I'm writing a scientific computing application that uses dynamic programming. I want to make it run in parallel. Like really parallel. What's the best way to design it so that I can have 1000 (yes, one zero zero zero) threads efficiently interacting with the same priority queue?

What are you trying to do with it?

You might want to use persistent queues if its really, really parallel, but then the RAM accesses will mess with cache locality which might eat up your speed gains.

Anything which uses a priority queue is probably going to paralellize poorly, desu. Priority queues tend to be useful for algorithms that are inherently sequential.

It's part of an optimization algorithm, but it has no way to give a firm guarantee if each partial solution will be part of the final answer or not, so it needs to store it in the queue just in case, no matter how bad it is. My code itself is extremely efficient, but it needs to call some expensive user provided objective function that will take on the order of 10-100ms to evaluate. So on those time scales, cache issues should be negligible, right?

The algorithm is most efficient when run sequentially, but the penalty for running it in parallel isn't too severe since it needs to exhaust the search space anyway.

How do I learn x86 or ARM assembly?

c++ is the greatest language of all time

Write something simple in C then disassemble it and see how it works. Use google as needed.

literally just use godbolt

I want to refresh myself on C, what do you guys think I should do?

Thinking that creating a ftp client with both passive and active mode will do the job.

Any other suggestions?

I finally got my first iPhone app published. It's a decent free browser that lets you watch WebMs.

All the 12 year olds can now browse /gif/ on their iphone now free of charge! (At least when apple approves my fucking update to fix some bugs)

Why C?

I get that there's a bunch of very right-sounding old folks who say that C is the only language you ever need, and at a time, they were right. There was a time when C++ and Java were being widely adopted and it was actively worse than just using C. This is not then.
We have more options, our computers are faster, and modern C hasn't matured nicely.
If you need speed, C++ is safer, faster, and more elegant than ever if you focus on The Good Parts. Rust is quickly maturing to fill many of those roles, too.
If you don't need speed, a huge range of well-typed functional langs are available, as well as dynamic langs just for getting shit done.
There's a whole world of programming out there, and while I do see C as a valid starting point, it is by no means the only language out there.

download cheat engine, open up a process and start poking around
place some breakpoints, step through some code and watch how it jumps around and modifies registers and the stack
you'll have the basics down in no time
then start writing some simple hooks

C++ is broken. Rust is broken. The answer is not changing the language. It's changing yourself and all the other tools you use. Add modules, but do it by improving the build system. Add safety, but do it by improving the compiler. The language doesn't need to change. It's perfect as it is.

Ever had to do embedded or OS development? C is the best language that can satisfy the requirements for these fields.

C++ is absolute shit in this regard, because for it to match the capabilities of C, you need to avoid using all the features that make C++ more convenient than C.

Obviously, other languages have their place, and no one is going to argue that it's easier to make some shitty RESTful API in Java or C# than it is in C.

no on is going to argue that it's harder*

Why does this happen with Chicken Scheme? I have a working implementation of Pascal's triangle, doing (pascal row col) with this implementation:

(define (pascal row col)
(cond ((= row col) 1)
((= col 0) 1)
(else (+ (pascal (- row 1) (- col 1))
(pascal (- row 1) col)))))


but this one doesn't work, just enters an infinite loop:

(define (pascal row col)
(define sum-above-two
(+ (pascal (- row 1) (- col 1))
(pascal (- row 1) col)))
(cond ((= row col) 1)
((= col 0) 1)
(else sum-above-two)))


I was just trying to make it more readable by giving a label to the part of the procedure that calculates the sum of the above two entries, but no luck. Just goes into an infinite loop. What am I doing wrong?

Because your sum-above-two is being evaluated before you run your conditional.

I have limited and in the past experience with haskell, and loved it but have forgotten it. I want to get into Idris, so is the cabal/stack shit still ridiculous? I stepped away because that was retarded, just like I stepped away from D because of their stdlib retarded schism.

Just tell me what to do. I'm a math BS self-study who liked haskell but hated the library bullshit, who wants to delve into dependent types.
I'm open to learning more haskell or some other language. I'm also open to just making idris full hobby. Apparently idris requires some haskell. ADVISE. THANKS.