/dpt/ - Daily Programming Thread - Please fall for memes edition

What are you working on?
Previous:

Attached: 1467666803256.png (873x1079, 929K)

Other urls found in this thread:

youtube.com/watch?v=ajccZ7LdvoQ
math.mit.edu/~dspivak/CT4S.pdf
docs.julialang.org/en/stable/
julialang.org/benchmarks/
twitter.com/AnonBabble

the real question is what work are you delaying

Attached: 1528699375904.png (537x537, 151K)

It isn't worth learning C++ anymore. It's been deprecated by Rust.

C# is the best language ever made, combined with VS, the best editor ever made, you can do anything.

Yes, exactly. That's the strength of explicit, imperative code. It's not that I don't trust compilers to be smart, it's that it's mathematically impossible for them to be smart enough in many cases.

Rust is only a baby compared to C++ and most of the libraries for Rust aren't even at 1.0.
Please do some research for spewing garbage.

C# is a lowest common denominator language.

>you can do anything
You still need interop to deal with the native world and get extra perf.
corert production ready when?

What are you working on?

Attached: CPU backdoor using an undocumented instruction.jpg (2448x3264, 736K)

My Java assignment only lets me use "System.out" for programming a game and I'm used to using GUIs
How do I produce an acceptable result within these limitations? I know I can print lines, but I don't know how to do stuff like have the text output refresh instead of just adding on more output.

You best not use anything higher level than assembly ever again.

check if whatever terminal you're using has a screen clear character sequence.

no mommy don't make me do research

is this a defcon pic user? Can I get a livestream?

It's Eclipse, I can't find a clear answer for it.

it's from this thread don't know if there is a livestream tho

can someone link me some resources to learn Julia? i've been looking for hours and nothing seems to come out useful

That's stupid. Parameter passing, stack management and register allocation are fine.

from the same guy

youtube.com/watch?v=ajccZ7LdvoQ

>Breaking the x86 Instruction Set

Thanks for using anime picture

Attached: happy.jpg (394x353, 41K)

>tfw actually reading that category theory book that an user linked a couple threads ago

is this the true face of autism?

thanks user

Which one? Some are not that autistic.

I'm trying to find a way to write a struct to a binary file in C.
Normally fwrite would be fine, but the struct contains arrays, and you can't just write a pointer to a file. Here's a description.

struct x {
int i1;
int i2;
int length1;
int length2;
int *arr1;
int *arr2;
};

How exactly would I go about writing the elements in the struct along with the elements in the array?

Eclipse's terminal emulation is pretty terrible. Can you run in a real terminal instead?

This one:
math.mit.edu/~dspivak/CT4S.pdf

Do the arrays have a fixed size? If yes just dump the variables and each element of the arrays. If not then I dunno maybe write the number of elements and the array after that for each array.

>learn Julia
first you'll need some fake benchmarks

best programming language for a ghost to learn??

Laughed hard at this. Just learn C++.

docs.julialang.org/en/stable/
Julia 1.0 doc as stable :)

Boo

thx

wrong
correct

The array is not at a constant size.
I was hoping to avoid that solution you mentioned, because it makes it harder to parse through a file with multiple (maybe hundreds) structs that all have different length arrays.
If I can't find an alternate solution, then this will work.

Does it have to be binary? I know string manipulation and parsing stuff is a pain in C but maybe consider using a library

Fantom

I've seen this talk it was a good one. Too bad it didn't lead to anything, just few bytes that were not documented instructions but did not generate an error and no actual discovery.

Cyclone

Rust is pretty much what C++ would be if it assumed the programmer was retard

>if it assumed the programmer was retard
It doesn't assume that, it asserts.

I would prefer it to be. Thanks for the input though, I think I can manage.

Preparing to upload an sFlow parser library to PyPI
Trying to get that 100% test coverage, but unit testing binary protocols sucks

For each decoder I have a test like this:
def test_unpack_sampled_ethernet(self):
unpack = sflow.unpackers.inmon.flow.unpack_sampled_ethernet

self.assertIn((0, 2), self.unpacker.flow_formats)
self.assertIs(unpack, self.unpacker.flow_formats[(0, 2)])

buf = bytes()
buf += b'\x00\x00\x05\xdc'
buf += b'\x01\x23\x45\x67\x89\xab\x00\x00'
buf += b'\x02\x46\x8a\xce\x13\x57\x00\x00'
buf += b'\x00\x00\x86\xdd'

self.unpacker.reset(buf)

result = unpack(self.unpacker)

self.assertEqual(result['length'], 1500)
self.assertEqual(result['src_mac'], '01:23:45:67:89:ab')
self.assertEqual(result['dst_mac'], '02:46:8a:ce:13:57')
self.assertEqual(result['type'], 0x86dd)

self.assertIsNone(self.unpacker.done())

It assumed that all programmers are retarded. We should feel ashamed by it.

my bad it was he previous talk, didnt know there is another defcon going on right now
anyway worrh ro watch the old one, the methodology was interesting and well explained

??

seems appropriate, thx

is this a meme? does julia have fake benchmarks?

I'm new to C and command-line arguments/pointers in general. The program I wrote is to print the first n characters of user input with the default being 10. The program works, but it doesn't make sense to me. Why does the value of argv[1] change? Shouldn't it stay -26 and shouldn't argv[2] be the alphabet?

#include
#include

// print first n characters of input: -5 "abcdefghij"
int main(int argc, char *argv[])
{
int LENGTH = 10;

printf("*argv: %s\n", *argv);
printf("argv[1]: %s\n\n", argv[1]);

if (argc > 2 && (*++argv)[0] == '-')
LENGTH = atoi(*argv) * -1;

printf("*argv: %s\n", *argv);
printf("argv[1]: %s\n\n", argv[1]);

while (LENGTH-- > 0)
printf("%c", *argv[1]++);
return 0;
}

Attached: c.png (255x131, 4K)

argv is an array of pointers.
Try *argv[0], or **argv

Why is this a problem, I don't understand. Either the data is self-delimiting or you have to delimit the data. If you're not going to try to implement some crazy binary encoding to force self-delimiting data—and why would you just to save data—then the only option is to write the size along with the data.

Of course this does mean that tampered files can lead to all sorts of mischief in your program.

Attached: mischief.gif (750x500, 13K)

There's a few tutorials to learn the basics that are pretty easy to find, and all say largely the same stuff.

Personally I learnt just by using it, and discovering little bits here and there. It's not the ideal way to learn, but it's enough that I'm doing all my work in Julia now.

How many fake benchmarks have you made with it so far?

julialang.org/benchmarks/
Some compiler begin old version.

These micro-benchmark results were obtained on a single core (serial execution) on an Intel(R) Core(TM) i7-3960X 3.30GHz CPU with 64GB.

And benchmark single thread in old processor when several microbenchmake are heavy paralelism.

Using FFI to BLAS in Julia vs Native Matrix multiplication in other languages.

give me something to write in python im bored

Masturbation engine: something that tells you what tags to pound off to.

steganography in tweets, camouflaged as procedurally generated normalfag speak

Reading the Rust 2018 book, currently on ch. 8 collections but rereading ch. 3. On the topic of shadowing, doesn't this allow programmers to write absolutely shitty code anyway? I reckon it's still safer overall but I can imagine the quality of code that poos or my classmates would have written shadowing almost every compiler error they came across.

Hey, this isn't a bad idea at all.

Its benchmarks are... dubious.
And generally they don't look nearly as good when they compare themselves to something like Numba (Python) or Rcpp (R).

I had some crazy idea where I would partition the file somehow and separate the struct variables with the pointer array variables. Doesn't really make much sense thinking it over now.

Good unis teach Haskell. Great unis teach ML.

Fuck sake I feel like such a nub. Does anybody mind if I ask a dumb question?

Is there anyway I can register a class to an array (or vector) , so I don't have to manually add them manually like so:
void
example(std::vector &masters) {
masters.push_back(Bullshit());
masters.push_back(Bullshit2());
}


Pls advise.

I'm learning linked lists right now, post some nice knowledge on the subject. Btw there's any way to make a void add data function and use pointers to pointers 100% of the time? C C C C

You could make it like this if your vector is global and a reference or pointer to whatever
class Whatever;
std::vector master;


class Whatever
{
public:
Whatever() { master.push_back(this); }
};

But it would probably end with the code doing unexcpected things so I wouldn't recommend it

A better way could be to have a constructor take std::vector as an argument. Kind of like this

class Whatever
{
public:
Whatever(std::vector& master)
{
master.push_back(this);
}
};


There are probably some errors there, the downside of being a phoneposter I suppose

Learn the basics then move on. There aren't many reasons to use a linked list in practice.

None, I just got on with my work thanks.

If you're taking Rust seriously you've already lost. It was designed by academics, people who have never written more than two lines of code in their life.

>Is there anyway I can register a class to an array (or vector) , so I don't have to manually add them manually like so:
nigga what
do you just want a vector of some class?

most languages are designed by academics, you moron.

not Jai, the best language for making video games

jai aka "my language is the best but i won't let anyone see for themselves, just trust my words idiots"

Not any of the languages that can get you a job
>inb4 "I'm not learning to program to get a job"
If you don't see it strictly as a way to obtain funds for the purpose of doing capitalism then you're a lost cause

what ok it's not done yet, but you'll see

YOULL ALL SEE

haha Xd

>Striving for all work and no play
Remember every hour not working is a wasted one

what's faster, adding a bajillion things to an empty linked list or adding a bajillion things to an arraylist I initialized with size zero?

if you have to resize the list each time you add an item, that will be slower

static arrays are always faster. prefer them if you can.

Yeah .. so suppose my arraylist implementation resizes to the next powerful of two. Is this still O(n) or are we at some other thingy now?

:thinking:

Are we assuming -O0?

idk lol, I wasn't assuming a language even

Tell me what happens for O0 vs O99 -funroll-loops

Oh and the number of items added is read from something external so the compiler doesn't know

Top kek

r8 my lang selection pls

>haskell
>idris
>agda
>purescript
>f*

Yes now let's see your selection of useful languages

>haskell
>idris
>agda
>purescript
>f*
(and I'm not too sure about haskell tbqh)

F* is not the same as the rest.
I'd say Idris and F* though.

Thanks for the list of your useless languages. Now let's see your selection of useful languages

They're the only useful languages because they take DRY seriously

Languages cannot take anything

you know what I meant

A linked list of statically sized arrays.
If the items you're reading in are stored in a way that aligns them properly, you can allocate an array for a block size, read the block directly into the array, and then copy the pointer to that array to the link in the previous block.

So I am trying to learn C (really all I have done is do some cs50) and I read a article in PoC||GTFO about ELF format and its parsers. I know a parser basically breaks down the program into more "readable" parts for the compiler, but what is ELF?

For context, this is one of the first PoC||GTFO articles and its about making polygots (which the pdfs in PoC||GTFO are usually)

They can take words from other languages.

This fucking guy gets it

my discord bot and exercises from SICP :(

is totality only practical with dependent types?

no, go look at Elm.
It makes webshit 10000x better.
Totality is just ensuring your program can exit safety, and prevents holes in your program that can cause nasty run time errors.

What is your opinion on Rust?

good ides, bad execution.
Rust is a stepping-stone language to me. Someone else is gonna improve upon the BC and linear/unique types