/dpt/ - Daily Programming Thread

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

Attached: 1543464564800.jpg (1006x706, 163K)

Other urls found in this thread:

en.wikipedia.org/wiki/Top_type
radare.org/
rada.re/r/
beginners.re
twitter.com/SFWRedditVideos

Lisp is the most powerful programming language.

Golang

Please do not use an anime image next time. Thank you.

can I have a main function in my dll library so I can test its code

nth for nim!

I have a typdef struct in my C code and it contains int fields and char/int array fields
do I have to allocate space for struct or does it do it automatically when I do name var; in my code?

Saying C is statically typed is like saying Javascript comments makes it statically typed too.

i can't pass typeless args to c functions, so technically it's statically typed.

but they do

thank you for using an anime image this time

void * func (void *arg)

What now?

void is a type in C, try again.

If I want to convert the argument to my C program in an array of bits... am i doing this wrong?

#include
#include

int main(int argc, char *argv[]) {
if (argc > 2) {
fprintf(stderr, "Please use only one argument");
return 0;
}

char *word = argv[1];
int len = strlen(word);
short bits[len * 8];

for (int i = 0; i < len; i++) {
printf("%c: ", word[i]);
for (int j = 0; j < 8; j++) {
char bit = (word[i] & (1

first for python!

second for Lisp!

I just added this to my .pythonstartup
def ls():
pp(sorted(globals().keys()))

I was tired of typing pp(dir()) whenever I went back to an interpreter and needed to see what existed.

third for rust!

Void accepts every type, that's not a "type". that's dynamic typing 101.

void doesn't accept every type.
and void* is a pointer, which accepts memory addresses only

void * accept every other type's pointers and ruins the entire point of type checking. Just admit it that C is dynamically typed, with hints.

make a void function which takes two void args and adds them.
Now watch the C compiler magically not coerce them to ints.

Writing a C compiler for my VM.

>Writing a C compiler for my VM.
can one not run a C compiler that already exists in a VM?

or am i misunderstanding your statement?

I am writing a compiler, which compiles my C code to a self-made architecture, I wrote a VM for.

The VM is written in Rust.

Why don't you just write a new architecture backend to llvm to use with clang?

#include
#include

int main(int argc, char **argv)
{
if (argc != 2)
{
fprintf(stderr, "Usage: %s STRING\n", *argv);
return 0;
}

char *word = argv[1];
int len = strlen(word);

for (int i = 0; i < len; i++)
{
printf("%c: ", word[i]);
for (int j = 7; j >= 0; j--)
{
char bit = (word[i] & (1

when I do I have to malloc every struct?

say what?

Attached: 1472493166371.png (463x492, 179K)

thanks but user i won't have an array of bits at the end. i want to further process the bits later.

also is it better to do char** argv instead of char*argv[]?

education and maybe create a super-geeky game, nobody wants to play.

I already wrote a (dis)assembler for i386 architecture in past and maybe I can create something nice with both of them.

I am really interested in all these lowlevel stuff.

Is this a terry autist?

Help me decide between Haskell and Go

that's because "void *" is just an arbitrary address, which is basically an integer. why would the compiler complain about adding two integers?


void * is a type. it's an agnostic pointer.

I said void, not void *, quit changing your argument.

en.wikipedia.org/wiki/Top_type

I never tested it and I never used TempleOS, because I never saw a practical usage for this OS.

I am more interested in things with practical usage like code protection through virtualization (maybe with polymorphism), an executable to dungeon generator (pic related, I need an emulator for this then ofc. I just worked theoretical on this yet) or just learn more about reverse engineering.

Attached: radare2.png (490x580, 3K)

how make graph like that?

>makes his own VM
>ends up going with x86 style instruction set
disappointed

Attached: dumb crow.png (657x527, 51K)

>I am more interested in things with practical usage like code protection through virtualization
You'd probably be interested in Qubes OS

radare.org/

That's just a screenshot of Radare2.
>rada.re/r/

If you want to write it yourself, you should learn code pattern.
beginners.re described it very nice.


No no no. You understand me wrong.
This are two seperate projects, which I want to mix in future maybe.
I thought about a RISC-style arch, because I never worked with any of them (RISC-V, ARM or MIPS) before.

I already use QubesOS.
I bought a Thinkpad especially for this, because I couldn't install it on my old and new PC (AMD FX and AMD Ryzen. If you want to run Qubes, buy an Intel CPU).

#include
#include
#include

int main(int argc, char **argv)
{
if (argc != 2)
{
fprintf(stderr, "Usage: %s STRING\n", *argv);
return 0;
}

char *word = argv[1];
int len = strlen(word);
char *arr[len];

char *buf;
for (int i = 0; i < len; i++)
{
buf = calloc(9, sizeof(char));
if (!buf)
{
fprintf(stderr, "%s: unable to allocate dynamic memory: ", *argv);
perror("");
exit(EXIT_FAILURE);
}
char *ptr = buf;

for (int j = 7; j >= 0; j--)
*ptr++ = (word[i] & (1

I'm doing a TSP problem for a class. for part of it they don't want an optimal TSP but a fast one. I'm thinking using nearest neighbor and 2 opt.

thanks user i'll take a better look tomorrow morning. am i not supposed to free the memory if i use calloc?

You are. That guy's program is leaking a bunch.

Btw. this screenshot is not my work. It's from radare, but that's how I would create a dungeon generator.

Finding function patterns to create rooms and create doors with "calls" and "jmps/je/jnz/jbe/..." (0xCC would be traps ofc).

Then emulating x86 code to get the the connections of instructions like "call eax", "jmp eax" and thing like that.

- - - -
The VM, which is currently a bit like Dalvik. I want to use it for code protection.

The compiler is for educational purpose and to create and run C programs for and in my VM.


Or to make it short:
Code Virtualization
>disassembler x86 (works)
>converter(?) x86 -> VM code
>VM for VM code (works)

Dungeon generator
>x86 disassembler (works)
>x86 emulator
>a format I can export it to. In best case an open-source RPG

No further usage:
>compiler (but very educating)

if I have, in Java, a class that has an ArrayList as instance variable plus a constructor that initializes this ArrayList why can't I use ArrayList method add() in a different class if I want to add items to the ArrayList of the first class?

FirstClass.java
import java.util.ArrayList;

public class FirstClass {
private ArrayList items;

public FirstClass() {
this.items = new ArrayList();
}

public void add(String item, ArrayList itemList) {
itemList.add(item);
}

public void showItems(ArrayList items) {
for (String item : items) {
System.out.println(item);
}
}
}


SecondClass.java
import java.util.ArrayList;

public class SecondClass {
private String item;
private FirstClass itemList;

public SecondClass(String item) {
this.item = item;
this.itemList = new FirstClass();
}

// here is where the error happens: I can't use "add()" method of
// ArrayList to add items to my itemList object
public void addItems(String item, FirstClass itemList) {
itemList.add(item);
}
}


what's the right way to do it?

Any Apigee devs here?

>public void add(String item, ArrayList itemList)
>itemList.add(item);
Because the type signatures don't match?

>FirstClass.java
>public void add(String item, ArrayList itemList)
it actually is public void add(String item, ArrayList items)

FirstClass.add() expects two arguments. You provide it only one in your SecondClass.

I have no clue. you know how to make it work, user?

you're right but even when I add the second argument it still doesn't work

That's because you just need to add to the items property of your FirstClass, instead of passing any old list in there.

In FirstClass, change:
public void add(String item, ArrayList itemList) {
itemList.add(item);
}
to
public void add(String item) {
items.add(item);
}

Attached: 1526402682434.png (2550x3300, 1.51M)

Back on the ASCII train

Attached: 1507940147251-drlcss (4).webm (772x720, 2.42M)

That kind of looks like you're traveling through the inside of a women's ***** (can't say that word on 4channel) while spinning.

What happens if you say it?

Pls no bully my old-skool tunnel. It's sensitive.

It's nsfw and against the rules of 4channel and would hurt the advertisers who expect a SFW website.

Pussy

I would say it looks more like an anus.

it worked, thx user!

Delete this post.

How dare you disgrace this thread with 3dpd

Attached: &&&&.png (712x871, 679K)

They say not to mix grid() and pack() in tkinter but for the life of me I cannot get grid to place buttons inside a labelframe where I want them.
Pack also puts them in weird places, unlike the predictable NSEW of grid, side="left" will put it in SW

What the fuck am I doing wrong, total nub here. I don't want to leave it at 'fuck it, it works' because Im thinking later on it will cause major problems with layout

Attached: 560924906.jpg (1370x584, 50K)

You can say pussy, twat, and cunt. You just can't depict it.

That's not very nsfw.

If you declare as an array, the array is inside of the struct. If you declare a pointer, it's a pointer and you'll need to point it to an array somewhere.

I don't give a flying ass fuck. It's not against the rules.

Is this allowed?

. ( . Y . )
. ). . .(
. ( . Y . )
. .\ . | . /

fixed it
. ( . Y . )
...).. ...(
. ( . Y . )
. .\ . | . /

>unicode

hot

JavaScript rocks!

Attached: js_rocks.png (1433x779, 473K)

...

wrong thread buddy

will you be posting this next thread as well

Hurry up and tell me the artist fucking retard.

I'm debating is this shit is just a script or something, this dumb ass shit gets posted in every thread

Don't use tkinter if you want to easily create a decent looking UI, it's terrible. Only useful for a bare minimum UI slapped onto a script.

Yeah I think I want to learn something else

What is this suppose to be

client list going to contain a contact like list pulled from an API
Selected will show stats on the selected client
notes will be a text field I can write particular notes on selected.
Almost 100% sure I'm fucking up the basics of columns, rows and the relationship with sticky and grid_column/rowconfigure weights.

stupid question here

say I have a text file with a list of values such as

thing 0
value
thing 1
value
thing 2
value
:
:
thing n
value

how do i use scanf to get the value for each numbered thing?

by doing your own homework.

It depends how thorough and error-resilient you want to be, but the basic version is just going to be you calling scanf twice in a loop.

What are some decent TSP heuristics that are a bit better than nearest neighbor but aren’t terribly hard to implement.

>void * accept every other type's pointers and ruins the entire point of type checking. Just admit it that C is dynamically typed, with hints.
>I said void, not void *, quit changing your argument.

wrong reply chain bro. read the first one in the post of the reply chain.

not sure if you're the same guy, but see >Void accepts every type, that's not a "type". that's dynamic typing 101.
Then he/you conveniently changed to void * which is an entirely different thing.

The post is in reference to where he says to make a "void" function that takes two "void" arguments.

It's not the replies about void *.

Reminder that Nim does not have these problems.

Regardless if you/he meant void *, the point is moot because the original argument was about C being dynamically typed, which it's not because you can't pass typeless args. Circumventing the type system with void* shit isn't dynamic typing, it's just weak typing.

What problems?

Nim has other problems, like autism.

whether or not it's dynamic or static.

wrong.

Nim unfortunately still shares a lot of c problems like no TCO. Which I don't understand, they have a self-hosted compiler but still choose to compile to C for whatever reason.

The only good compilers for C both support TCO. Compiling to C means they reap the benefits of Cs harden and optimized compilers which is why Nim is as fast as C, C++, Rust, etc.