/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

pastebin.com/RftUMYgN
pastebin.com/tJJBAHAB
linux.die.net/man/2/access
pastebin.com/aDtvXEMw
youtube.com/watch?v=2xyZeovFqCA
twitter.com/AnonBabble

and you don't seem to understand

Second for Lisp is the most powerful programming language

I want to make my own CPU, but don't have money for the electrical components (or the patience to fuck with them, desu) to make a physical one.

What's the best circuit simulator program for this kind of task? I want to go up from logic gates.
(bonus points if it runs on Linux)

Lain's juicy thighs!

get an fpga, you can design everything on your pc and still have something physical you can attach peripherals to or whatever
Bonus points if you get one with a free as in freedom toolchain

Is there a nice clean way to make those digits fuck off?

VHDL

Logisim is decent, albeit a little buggy sometimes.

Alternatively, you can use FPGA design and simulation software like altera's quartus and modelsim, and program your circuits in verilog, but that's another whole level of difficulty.

round(num * 1000) / 1000

search for "from nand to tetris" on google

Some fpga IDEs also let you draw circuits, but I think if you want to do more complex stuff like initialize some memory from a file or write tests for modules you'll need verilog. Besides I'd rather write my CPU up in an actual programming language instead of having to draw everything.

i'm 100% sure that a location in memory of a program i'm reverse enginering is argc, but it's always 2, regardless of if i include an argument. what's going wrong with this? it doesn't really matter to me because i set $eip manually to access that section but i still want to know why

You're probably not looking at argc then

and weirdly enough when i have 2 extra params, it reads as 0

I was researching FPGA boards a few months ago, came to the conclusion that they are not much better than a software simulation. And I'm on a really tight budget at the moment.

I'm currently using Logisim, but it's not much of a pleasure to work with.
If I was serious about making an actual CPU, then of course I would write it in Verilog or something. But this is a toy project, so having it look like an actual circuit is a big plus.

Have heard of it, not interested.

why do you use three fucking lines for your own reply you fucking faggot

well you don't need to actually have an fpga to use fpga development tools.
In school we used xilinx, and you could write your modules and simulate them without needing an fpga. I'm not sure if the xilinx IDE lets you draw curcuits, but you could always just have it convert your verilog into a circuit diagram to have a look at it
I think we also used some altera IDE, where you could draw circuits directly and I assume they could also simulate it

No performance cost

Rust most definitely puts emphasis on safety and forces safer programming. However if you want to do something unsafe, you have to do unsafe Rust, which should be a no-brainer but for some reason late-bloomers fail to understand that.

However, the points I mentioned and has a little to do with safety. C++ is archaic, and ready to die. Rust simply has a better design from the get-go. Better tooling, like RLS (vs clangd, unfinished), cargo (vs make/cmake/qmake/ninja), better project management (cargo vs conan), cutting edge language features (Traits vs Concepts, unimplemented). Modules vs includes, Ranges, no promise of C source level compatibility and the list goes on.

The only excuse C++ has is so called "backwards compatibility" which C++ breaks in each major release.

You can see how much C++ is broken by the mere fact that istreams go on an infinite loop if wrong data is provided. Hell, even using >> and std::getline() together will cause you problem. There are thousands of issues in C++ - it's a broken language.

I fuck your mom

Rust is too complex to thrive.

Which C standard is best to use when developing a library? I usually go for c99 but c11 has some stuff I might want to use. Most of the stuff I've written previously could probably work in c89 though.

--std=gnu11

It's a different paradigm, but not too complex. Rust is not like Haskell or idris or anything like that.

Lainchan

I'd like my code to be compatible thanks.

The borrow checker is alien to most programmers. Programmers don't like change and companies don't want to invest time in learning a different paradigm. This is why Go is such a great success. Rust will never achieve that.

Go and Rust don't compete, they have different use cases.

Go Java C#
Rust C++ C

The fuck kind of compiler are you targetting?
The only relevant C compilers are:
GCC

Idris or Agda?

ATS YOU FOOL

...

logisim is so comfy

>There's people in this thread right now that just argue about which languages they think are better.

Jesus, why is the comp sci field full of egotistical autist fighting over who knows more?

I want to take screenshot of youtube stream.
Can youtube-dl do it?

/dpt/ has been language war general since the beginning. Nothing new here.

pure c11 no gnu no posix

You can use youtube-dl to get the video and ffmpeg to extract the frames you're interested in.

Try firefox's new screenshot feature, my dude.

>no posix
retard
>pure c11
glibc doesn't even implement the threading.

youtube-dl downloads video, it can't even play it

What would cause a "Resource temporarily unavailable" (EAGAIN) error when a parent process writes a small amount of data (a few bytes) into a blocking pipe, that a child is reading into after a fork/exec?

I keep reading the mans but they only mention EAGAIN for non-blocking file descriptors.

it is argc. but when I include 1 argument it's 0, and 2 its 1. works correctly outside of gdb though is why i know its argc

>change small thing
>entire program crashes
>panic
>run .exe few more times
>it runs normal like on 5th try
wtf

ok, I used headless chrome. but how to disable sound?

--mute-audio
solv'd

Are there any examples of java programs that allow the user to modify the bytecode of it in runtime?

Yes it's called making if statements

weird it's behaving as expected now. not doing anything different. maybe gdb was being buggy

What the fuck I cant post my code, I keep getting connection error

undefined behavior

Imperative programming, am I right gentleman?

Imagine a /dpt/ where people post and discuss their codes and projects rather than do the pointless entry level "debates" over and over.

FUCK VHDL

a line in a binary has
0x08048592 : call 0x8048420

what does do? is this a well known thing? google's not returning anything for me. it jumps from the plt to another place in memory i can't look at

int clrScr(void) //clrScr, clears screen
{
system("cls");
}

int genRand() //Random number function
{
int intRand;//intRand is the number that will get returned
srand ( time(NULL) ); //Seed rand()

do
{
intRand = rand();
} while (intRand < 1 || intRand >= 20); //While random number is less then 1 OR greater then or equal to 20
return intRand;
}

int main()
{
int intActualNum = genRand(); //Set number CPU is thinking of to a random number generated by genRand()
int intUserGuess;
int intTries = 3;
char charInitialPrompt[0];

printf("Welcome! Would you like to play a game? (y/n)");
scanf("%s", &charInitialPrompt);

while((charInitialPrompt[0] != 'y') && (charInitialPrompt[0] != 'n'))
{
printf("Please only enter y or n\n");
scanf("%s", &charInitialPrompt);
}

if(charInitialPrompt[0] == 'y')
{
clrScr();
printf("Great! Im guessing of a number between 1 and 20...\n");
while(intUserGuess != intActualNum)
{
scanf("%d", &intUserGuess);
if(intActualNum == intUserGuess){break;} //If user guessed correct number, break out of loop
intTries--; //If user did not guess correct number, take away 1 try
if(intTries == 0){goto loose;} //If user has no more tries, go directly to loose
printf("Nope! %d tries left!\n", intTries);
}

printf("You got me! I was guessing %d.\n", intActualNum); //Winner
return 0;

loose:
printf("Oh dear, you lost! I was guessing %d.\n", intActualNum); //Looser
getch();
return 0;

}

else if(charInitialPrompt[0] == 'n')
{
printf("Goodbye then!");
return 0;
}

}

Fuck you.

Well im fucking retarded, can anons scrutinize this code anyway

Configuration file user here. I think I aced it by dropping RSS feed support. JSON/XML/TOML are all too verbose.
This is what it'll look like:
# key reflects the name of the subreddit
programming.enabled=yes
programming.order=hot
programming.filterNot=*Rust*

technology.enabled=yes

mail.enabled=yes
mail.host=smtp.localdomain.com
mail.port=25

Use code formatting faggot

it's the dynamic loader's job.
Basically, some parts in your executable are saying "I need libxxx.so", and the dynamic loader will loads the library in memory. the "access@plt" means a jump to an address stored in a table that will be filled at runtime (executable startup, precisely).

anyone know anything about Scheme/LISP?

I have an assignment for uni thats literally the hardest thing I've ever done. Functional programming is a whole other animal than OOP, man. I'm 3 days away from the deadline and I have to go back and start the scheme book from the start because my mind is full of fuck.

Is there somewhere I can pay someone for this assignment?

At least put it on pastebin if you're really too retarded for []

Yeah im fucking trying whenever i hit delete post i get brought to a white screen

paying for your assignment ? What are you, a pajeet ?
What's the assigment ?

Post pastebin.

i now know it's supposed to check if a user has access to a file now. is this likely written by the author of the program, or is it in an existing library? i'm assuming i'm going to have to reverse engineer that to find a way to trick it into printing a file when i don't have permissions for it

How do I install a program in Go so it would be like other programs?
I mean, is there something like "./configure && make && make install"?

pastebin.com/RftUMYgN

#![feature(specialization)]

use std::fmt::{Debug, Display};
use std::ops::Shl;

struct Cout;
struct Endl;

impl Shl for Cout {
type Output = Cout;

default fn shl(self, rhs: T) -> Cout {
print!("{:?}", rhs);
Cout
}
}

impl Shl for Cout {
fn shl(self, rhs: T) -> Cout {
print!("{}", rhs);
Cout
}
}

impl Shl for Cout {
type Output = Cout;

fn shl(self, _: Endl) -> Cout {
println!();
Cout
}
}

fn main() {
Cout

>spent the past 3 days porting some 17 year old application from fortran 77 to c
giving up, not only is fortran awful, so is the guy's code
double whammy
physicists can't code for shit

I know it sounds extreme but I'm at a loss with func. programming.

Essentially I have to make a simple MIDI music mapper.

pastebin.com/tJJBAHAB

I've been struggling for days and I barely understood how its SUPPOSED to work, let alone actually code it.

This is average go programmer.

As I said, it's in a library. Even better, it's in the standard library: see the man page for the access function.
linux.die.net/man/2/access

eww

Sure, write your own makefile. The Go toolchain doesn't provide a proper build tool like Gradle or Cargo.

lol slow down buddy
access is a syscall/wrapper
you can't get access to files you don't have the correct permissions to
also yeah, read up on runtime linking

fuck off apple

You're using windows only things, you don't need to have a perfectly clear screen for your program nor require the system to pause after the last printf.
Goto is not as evil as people say but it's still pretty bad and you should try to find a way not to use it.

meant to reply to

well how am i supposed to break a C standard library function? this is what i have so far reverse engineering it
pastebin.com/aDtvXEMw
i've already tried giving it really long file names, and files with a lot of text in them (i actually fed it /dev/urandom for a minute and it seemed to take it like a champ). and i tried printf exploits in the file name and the text within the file by %x and it took both properly

think i should just keep reverse engineering it? idk if i'm missing something easy

Dude, what don't you understand ? Are you one of those guys that skip the entire course and just try to do the last assignment ?

>reverse engineer that to find a way to trick it into printing a file when i don't have permissions for it
access() is part of POSIX, cf. man 3 access. But it's possible that the system call emanates from another library and not the program itself.
You could run it in GDB and break on access to extract a backtrace. You could also hook the call using the PLT hook trick.

It's not complex, though. Just different.

youtube.com/watch?v=2xyZeovFqCA

I AM FAT FUCK

Okay, what contest/CTF/hackme are you trying to solve ?

Good look explaining to a veteran programmer why the language needs two string types.

pytard here

do
python2
>> import Go

leviathan from overthewire.org. i'm on the second level trying to get into the third. you can look at what i'm looking at by sshing to [email protected] -p 2223, password ougahZi8Ta

Not really, but now I started recapping everything. My grasp of Scheme is not that good I guess, I have no choice but to start over and do all the exercises and see what I missed, problem is I got until Tuesday night.
You got any tips?

and why are you looking at me with that look of disdain

String is like std::string and &str is like char*.

If a veteran programmer can handle const char*, std::string and soon std::string_view, they can also handle &str and String.

It's pretty frowned upon to share flags like that. If you can't solve a problem, you obviously don't know something you're supposed to.

Threadly reminder that Rust can't handle safely anything beyond immutable trees. It only offers safety to fizzbuzzers like you. Systems programmers might as well stick to whatever they're already using because Rust does not deliver.

Overthewire admin here. Thanks for reporting the rule violation.

Okay, first look: if you write "ls", the executable is in red. Do you know why ?

she's like 12