/dpt/ - Daily Programming Thread

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

Attached: 1535695506626.png (1000x800, 427K)

Other urls found in this thread:

strawpoll.me/16604780
github.com/antirez/sds
gnu.org/software/emacs/manual/html_node/elisp/Strings-and-Characters.html
gnu.org/software/emacs/manual/html_node/elisp/Sequence-Functions.html
en.wikipedia.org/wiki/Safety-critical_system
archive.adaic.com/projects/atwork/boeing.html
en.wikipedia.org/wiki/SPARK_(programming_language)
en.wikipedia.org/wiki/Correctness_(computer_science)
en.wikipedia.org/wiki/Design_by_contract
twitter.com/SFWRedditGifs

Akarin will save systems programming

Attached: 1517555515788.png (1277x1190, 2.2M)

where my /riscybois/ at

Attached: IMG_20181008_145455__01.jpg (4608x2304, 2.23M)

My wife.

Bilinear interp.

text editor poll continues:
strawpoll.me/16604780

>can't understand derivatives
I'm not gonna make it

Mikoto a cute!

Safety is a meme
Unsafe programming languages will always be superior

Can I help you?
What do you know, and what is confusing to you?

Why do so many public projects have years of open pull requests? For example, github.com/antirez/sds has 51 open pull requests spanning years. Why allow pull requests if you're going to ignore/cherry pick them?

the concept of derivatives is quite easy to grasp, the actual calculations can be hard sometimes but not THAT hard
you'll make it user

How do you guys deal with large projects? I'm overwhelmed

>be me
>hired as game developer
>they ask me to rewrite an entire portion of their code base
>maybe 20k lines

It's the core of the entire plugin, so I have the ability to basically make the entire thing on my own framework. I'm just so lost when it comes to such a large (solo) undertaking

Mikoto is cute ! CUTE !

Attached: 419d7f600323cdca99ee551e1e56d686.jpg (373x320, 69K)

what portion are you rewriting?

based

Just burn a trail through the code and make everyone else work around your shit

Everything on the backend. Networking, database, core functionality, the I/O system and file management, etc

Just me, only developer they have in the division. Only person I report to is the CIO.

so they hired you to rewrite their whole game with nobody to tell you what to do and you don't have any prior experience? sounds good

sure, bro. could you imagine if planes were programmed with C instead of Ada? think about that next time your airliner lands safely.

Yup
d.deserialize_u8().fold(err => Left(err), one => {
d.deserialize_i16().fold(err => Left(err), two => {
d.deserialize_u32().fold(err => Left(err), three => {
d.deserialize_i64().fold(err => Left(err), four => {
Right((one, two, three, four))
})
})
})
})

How bad is it doc?

Writing small function to help me write latex documents.

How would you compare chars in elisp? I know the double-quotations and single quotations are ways to create strings, but how do I create a character in elisp?

Basically I'm writing something like this:
(defun okay-to-newline (chr index)
(and (or (= chr " ")
(= chr ".")
(= chr ","))
(> index LINE-WIDTH)))


Additionally, any better ways of doing this? In C, I'd write something like:
const char* TARGET_CHARS[ N_CHARS] = " .,";
int result = 0; // false;
for(int i = 0; i < N_CHARS; i++)
if( TARGET_CHARS[ i ] == chr ) result = 1;

return result;

seems like vim is on top again

These polls always make me frustrated. I don't use Vim, but whichever editor I'm using you can be damn sure I'm using vim mode.

Instant sanatorium. Few years at least.

If it was written in C, that would guarantee that it was made by people who actually understand how a computer works. Because that's what C is.

The Linux kernel is written in C and asm, but it's still full of bugs and unknown vulnerabilities

what do you think about rust

C is the favourite language of clueless Jow Forums posters, so something doesn't add up here.

All software is full of bugs and vulnerabilities. It's the price you pay for having software. Using a "safe" language does not buy you anything, it just moves the bugs around like rearranging the deck chairs on the Titanic.

wow i love cpp now!

Attached: wow i love cpp now.png (1169x1347, 931K)

>All software is full of bugs and vulnerabilities
no just most of it
if people dies when code fails that code is made to be secure

It's all so tiresome.

I'm trying to get a userscript in Greasemonkey to fire before midway through a page's loading, because it changes a faggy-ass inline script in the middle of the HTML. Using @run-at document-start is useless because the page document doesn't exist yet, and @run-at document-end is useless because the document has finished loading, and altho assets aren't loaded yet, the inline scripts have already been executed.

Apparently FF has a function called document.beforescriptexecute that does exactly what I need, but no other browser does because the cucks in charge of the HTML5 standard dropped it.

Ideas?

Attached: whr190quut3z.jpg (677x573, 53K)

If you like Unix, you like C. Those two are inseparable.

No.

Attached: 1536112224219.jpg (558x640, 118K)

only neckbeards like unix

i wanna fug mikoto

gnu.org/software/emacs/manual/html_node/elisp/Strings-and-Characters.html

Also see

gnu.org/software/emacs/manual/html_node/elisp/Sequence-Functions.html

JavaScript rocks!

>code written with an unsafe language is inherently unstable
What is this meme

run-at doc-start and monkeypatch the builtins
if you posted progress and what you want to do that would help more

Does that mean if we use wangblows we like C++

The pay is nice.

I do have prior experience, this is just my first large solo project.

How computers work is irrelevant, we are talking about specification, correctness, and verification.

>Using a "safe" language does not buy you anything
Yes, it does. It's much easier to compile an erroneous code with C than with Haskell or Ada. You don't want your central computer to unresponsive for a few milliseconds at the very moment your plane is landing because a division by zero did throw an interruption. Ada allows you to specify constrains on many things that are then verified at compilation. Even today, which C compiler warns you about undefined behaviors? Ada makes sure undefined behavior are out of the picture but not only, a static analyzer is literally enforced in its specification. You are talking like a juvenile programmer.

en.wikipedia.org/wiki/Safety-critical_system
archive.adaic.com/projects/atwork/boeing.html
en.wikipedia.org/wiki/SPARK_(programming_language)
en.wikipedia.org/wiki/Correctness_(computer_science)
en.wikipedia.org/wiki/Design_by_contract

> = for char shit
nigga what
pretty sure every lisp has char= char

#include
#include

int main()
{
unsigned char p1[4] = {255, 255, 255, 255};
uint32_t *p2 = (void *) p1;
uint32_t *p3 = (uint32_t *) p1;
printf("%u, %u, %u, %u\n", p1[0], *p2, p3[0], p3[1]);

return 0;
}
Is any of this UB? I think case 4 is, as the value changes each run, but why doesn't it segfault? What's the different between a cast to void and a cast to the pointer type?

Attached: 1414018116015.jpg (456x628, 606K)

>You don't want your central computer to unresponsive for a few milliseconds at the very moment your plane is landing because a division by zero did throw an interruption.
But this exact thing will happen in Ada or any safe language. It's up to the programmer to check that a program is not dividing by zero. What world are you living in with magical compilers that can solve the halting problem?

Would it be useful to define compose such that if a procedure returns multiple values, then the procedure who's taking as input the output of the previous procedure, would be taking the values as arguments

Attached: 1525891708311.png (229x220, 6K)

Attached: bulli.jpg (1073x993, 232K)

f :: a -> (b, c)
g :: b -> c -> d
h :: a -> d
h = uncurry g . f

???

p3[1] is out of bounds so yes it's UB.

segfaults usually happen when you try to access memory not mapped by your process. In this case that's not happening, the memory is mapped and is somewhere on your stack.

I guess some answers to this program depends on big endian little endian stuff ?

A segfault is an exception thrown by the operating system. You usually have extra stack and heap space where you can go out of bounds of allocated memory and it still runs, only when you drift too far out of your memory sandbox does linux start giving you shit.

why not just receive and return tuples?

>joe isn't on the list
Sad!

Attached: highlighting.png (534x327, 6K)

elvis, vim is bloat

here's a fps engine i cobbled together earlier this year, about to do some major refactoring on it

there's a book you should read called game engine architecture, i think a 3rd edition was recently published. taught me everything i needed to know about those things

Attached: indev2_latest.png (1920x1080, 1.08M)

vid although it's older than the pic

Attached: thing.webm (1024x576, 2.41M)

No worries, I just had to start over from the basics since it seems the way I was thinking about derivatives was fundamentally wrong.

Thanks for the encouragement, I'm watching some Khan Academy videos and slowly starting to understand.

Attached: chibi.jpg (1280x720, 54K)

>But this exact thing will happen in Ada or any safe language.

not at all.

foo : Integer Range 1 .. Integer'Max; -- Can not hold zero or a negative value


now, the compiler will __refuse__ to compile and throw an error if you

- assign an out-of-range constant
- assign an out-of-range value without handling the possible (software) exception.

that bobbing frequency

Ah, good to know. I guess that's how its possible to corrupt your own process at runtime:
p3[1] = 1;

$ ./a.out
255, 4294967295, 4294967295, 1
*** stack smashing detected ***: terminated
Aborted

yeah it's a little fucked

Yes, read up on buffer overflows if you're curious.

It's how they work, by writing past the end of a buffer (e.g. your p1) you can overwrite other values on the stack like the return address of a function, which gives an attacker control flow of your process.

one of several ways

what technologies did you use to make this? OpenGL and C++?

because some functions return multiple values, not tuples

What shitlang are you talking about here?

It looks like the error shown here is actually a GCC stack-protection feature, which appears to be enabled by default on my platform. If I compile with -fno-stack-protector, it just segfaults and nothing prints. But I wonder, how is that safer given the program continues executing and even successfully outputs to stdout?

how's you're memeOS coming along, user

>how is that safer?
When a stack overflow is detected, the only sane thing to do is quit.

#include

int main()
{
int is_admin = 0;
int buf[1];

buf[1] = 1;

if (is_admin)
puts("welcome admin");

return 0;
}

Very simple stack overflow, try this program with and without stack protection. Should probably work.

In what world is a divide by zero error detectable at compile time? They almost always occur because of something volatile.

It does, yeah. Interesting that this doesn't print with stack protection enabled, while my original program still executes the printf() before aborting.

A little new to programming. Trying to learn Python. So I've got a class, and in that class I've got an object, and in that object there's a whole bunch of attributes. What's the difference between:

class Player:
PlayerName = ""
PlayerHealth = 100
PlayerAge = 10

And:
class Player:
def __init__(self, PlayerName, PlayerHealth):
self.PlayerName = PlayerName
self.PlayerHealth = PlayerHealth
self.PlayerAge = PlayerAge

Am I right in thinking the init method just assigns base values? What's the difference between init assigning base values in comparison to the first block of code above where I manually define the base values? Sorry if this sounds dumb.

Attached: 1538615284368.png (1536x2048, 3.55M)

Funny you should mention monkeypatching, because that's what I'm trying to do. I want to edit one of the page's to remove the source and instead insert a modified script as a string within in the tag, like function botnet {...}. It's trivial, it's just half a dozen DOM-related native functions, and I have verified it works, I just can't get it to run after the document loads and before the offending script is executed.

I'm afraid your solution doesn't apply here, because that "botnet.js" hasn't been loaded either, like the document itself.

That is not a stack overflow.
That is a buffer overflow.

It's a stack buffer overflow*, and -fstack-protector-strong does detect it.

yep, SDL as well but only for creating the GL context, GLEW for extensions

>what is a pre-/post-condition
>what is formal verification
>what is logic

In the first block, you're setting fields on the Player class itself.

The ones outside of init are common to all instances of the class.
A obvious example of this is if you use a dictionary.
class Test:
shared_dict = {}

def __init__(self):
self.own_dict = {}

test0 = Test()
test1 = Test()

test0.own_dict[0] = 'a'
test0.shared_dict[0] = 'a'

test1.own_dict[0] = 'b'
test1.shared_dict[0] = 'b'

print("{} {}".format(test0.own_dict[0], test0.shared_dict[0]))
print("{} {}".format(test1.own_dict[0], test1.shared_dict[0]))

a b
b b

>stack buffer overflow
Nobody says that.
Get your terminology right.

function (call with some args)
this [is quoted]
reserved {for special forms}

I need to save my data in a JSON format using C++.

Any recommendation in term of library? I need to get the job fast tomorrow, any recommendation?

What's the best web scraper library? Is it still Beautiful Soup? Is there anything as good or better in the Node/Javascript or Go ecosystem?

beautifulsoup has ease of use, but scrapy is the superior implementation
I'm not a go/node fag so I can't answer for that

Not programming related.
t. CS and math student

Were multiple values a mistake?

write it yourself brainlet the JSON spec is tiny

And that's where you're wrong sweaty
strictlypositive.org/diff.pdf
>The Derivative of a Regular Type is its Type of One-Hole Contexts

Sorry but C programmers don't know anything about computers

Superior in which way? Speed? Extensibility?

>write it yourself
That's the consensus I made in my mind, I'll do it before sleeping then. Thanks for the confirmation!

i know C - is js as easy to start up as python? AI is my aim, general script usage, parsing

I'm not sweaty

JS is atrocious
Avoid it unless you need to make websites or mobile apps

thanks user, anything for AI and parsing text files/strings?

That is extremely general, user
What kind of AI are you talking, machine learning for prediction, or an agent that acts in some environment