/dpt/ Daily Programming thread

This is /dpt/, the best subreddit of Sup Forums

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

/!\ ** Read this before asking questions ** /!\

mattgemmell.com/what-have-you-tried/
catb.org/~esr/faqs/smart-questions.html


What are you working on?

Other urls found in this thread:

github.com/kennyalive/DigitalWhip
github.com/cs01/gdbgui
cppx.godbolt.org/
github.com/godotengine/godot/pull/10013
doc.rust-lang.org/std/primitive.slice.html#method.get_unchecked
benchmarksgame.alioth.debian.org/u64q/compare.php?lang=rust&lang2=gcc
itch.io/blog/12866/announcing-the-github-game-off-on-itchio
itch.io/jam/game-off-2017
basic-converter.org/
twitter.com/SFWRedditVideos

fuck opengl, though

Rewriting coreutils' csplit in Rust.
I've embraced the meme fully by now.

>r/programming
>r/compsci
>r/ReverseEngineering
>r/softwaredevelopment
you need to leave

Threadly reminder that there are "people" here who can't grasp the differences between proper interfaces and abstract classes.

b-but C++20 will have metaclasses that do it!

...

>university uses github classroom to give out weekly assignments
>finish assignment on the first day that it's out, commit, done and dusted
>deadline passes
>the automated marking test suite runs
>0 marks
>I forgot to push after committing
I want to fucking die. I mean it's not going to affect my degree or anything but I generally get close to 100% in every solo programming assignment, so I was aiming for around 95% final grade on this module, and this is like 10% instantly knocked off that.

is your bash script starting fork bomb in the background or wtf?
dumb ugly color scheme using poster

>matt gemmel
you need to leave, hiv+ drug addict

C++23 if anything.

Ok that still doesn't exactly explain what the benchmark doing and if the code is equivalently polished in each language.

How can we take a benchmark seriously when there is a possibility of one version being a highly optimized implementation and the other being less optimized or not optimized?

Just benchmarked C++, D and Go. Go is more than 7 times slower than D/C++

It's garbage collected after all.

>Le interface{}

Why can't I make constructors in the abstract class that will be used by the derived class?

Just benchmarked rust and it is in fact 10 times faster than any other language in every relevant test that can be tested algorithmically

Same here.

Go Go: 33.553163084 seconds time elapsed
Go gccgo: 17.438276362 seconds time elapsed

D DMD: 9.432905226 seconds time elapsed
D GDC: 25.970303586 seconds time elapsed
D LDC: 6.347934615 seconds time elapsed

C++ clang++: 5.518077517 seconds time elapsed
C++ G++: 4.659448453 seconds time elapsed

>It's garbage collected after all.
So is D, D is 1.something times slower
github.com/kennyalive/DigitalWhip


The author of the build/run script is a complete retard and should give up programming as soon as possible.

D has RAII. The GC is (in theory) optional.
D also has templates.

If Haskell is polymorphic lambda calculus as a programming language, I want to make the first Haskell of polymorphic process calculus. Just think - a language where calculating x + y, running a shader on a GPU, and using a web service are equal citizens.

>language where calculating x + y, running a shader on a GPU
Chapel can do this. You shouldn't just do that for 2 variables, just transfering the data gpu has overhead.

>I can't read

github.com/cs01/gdbgui

Soon, Atom and VS Code will have a new gdb front-end. Amazing how it's always the webshitters that end up creating meaningful programs :^)

Well typically the game dev threads on vg show people getting more work done than the average /dpt/

I wonder what that shows?

You're joking, but shills repeat this unironically so it needs to be weeded out. Here's the truth: Rust's safety checks make it significantly slower than C in any real-world scenario where performance actually matters. Remember, there's no such thing as a free lunch. You can have code that's safe and high level, or code that runs fast, but never both at the same time. Programming close to the metal isn't safe and that's just a fact of life.

MODULE MORE_BUTTS
IMPLICIT NONE
CONTAINS
SUBROUTINE BENIS(DUM_INTEGER)
IMPLICIT NONE
INTEGER, INTENT(IN) :: DUM_INTEGER
WRITE(*,*) DUM_INTEGER + 5
ENDSUBROUTINE

ENDMODULE


PROGRAM BUTTS
USE MORE_BUTTS
IMPLICIT NONE
INTEGER, PARAMETER :: TINY_INT = SELECTED_INT_KIND(1)
INTEGER(KIND=TINY_INT) :: THE_ACTUAL_INTEGER

THE_ACTUAL_INTEGER = 5
CALL BENIS(THE_ACTUAL_INTEGER)
ENDPROGRAM


yes.f90:20:32:

CALL BENIS(THE_ACTUAL_INTEGER)
1
Error: Type mismatch in argument ‘dum_integer’ at (1); passed INTEGER(1) to INTEGER(4)


how do I make an external subroutine know what integer kind it is being passed?

is there no other way than to move the definitions of my integer kinds to an external module, and include this everywhere?

Is the problem that the subroutine has to be compiled to use a specific kind? What if I know I will only pass it the same integer kind every time, but I do not know which kind until compile time?

I am not sure what the cleanest way to do this is

you can disable the runtime checks

And then you're left with a language that's high level but not safe OR fast. Good job!

>You can have code that's safe and high level, or code that runs fast, but never both at the same time.
What about code that is fast and high-level but proven to be safe 100% statically rather than checked to be safe dynamically?

already achievable now, metaclasses would just make it very easy

it'll make C++20. there are already working implementations
cppx.godbolt.org/

Not him but why the fuck would you use C anyway. Are you rewriting windows or Linux or something?
C lives because of its legacy codebase and nothing else

>not linking to the previous /dpt/
Bad form, OP. Bad form.

you can disable array bounds checking?

Erwin Coumans (developer of bullet physics) just left a comment on Godot's git.

github.com/godotengine/godot/pull/10013

Thoughts?

you can avoid that by using get_unchecked_mut()

In rust, arr[i] is bounds checked and equivalent to c++'s arr.at(i).
If you want unchecked Array access, you can use doc.rust-lang.org/std/primitive.slice.html#method.get_unchecked

>significantly slower than C
benchmarksgame.alioth.debian.org/u64q/compare.php?lang=rust&lang2=gcc

>posting rigged benchmark

>tfw specialized agent isn't learning right
>just going to use a mdp to learn off of some other agent that solved a similar problem

I hate being a cop out

>Doesn't understand the concept of zero-cost based abstractions
>Doesn't understand that Rust safety checks are mostly compile time, not run time
Good shitpost user. Unless you're talking about compile times, Rust is very comparable to C and C++.
Also, user, Rust isn't high level. It has some nice things, but it is far from Python or GO high level standards. (Remember C was considered high-level some years ago)

Pic related: It's you.

how do I stop being such a brainlet

learn lisp

Rust isn't doing anything special at compile time that doesn't already happen in C++. It just takes longer because the compiler is slow because it's written in Rust.

>Godot used Bullet's example character/vehicle controllers as their own character/vehicle controllers
Oh I am laffin

>Rust isn't doing anything special at compile time that doesn't already happen in C++.
Affine type checking and borrow checking are pretty significant additions.

and they keep telling you to use already existing engine even though it's clear they are made by retards

Newbie here having problems with c++.

I'm using a header file to make a stack. So I first enter push(1) push(2) etc. to create my stack and then I'm using a while loop to insert and remove nodes from the stack. Problem is when I'm using pop() to remove nodes. After I remove all nodes from the stack the program just crashes. How can I make the program understand that when all nodes are removed the stack has a value of 0?

How can I make pop template that fixes this problem? Or is the problem something else.

bool stack::pop(){

}

Are you participating in Github GameOff?

itch.io/blog/12866/announcing-the-github-game-off-on-itchio

this new special theme is pretty nice

Official page here:

itch.io/jam/game-off-2017

How does it look like currently?

no, because the SJW there will ban me directly

the glowing orange text is pretty nice but the purple background is :puke:

>Rust isn't doing anything special at compile time that doesn't already happen in C++
Apart from the language defining built-in compile time safety checks, lmao
What's your point? That's all Rust is. It makes sure to eliminate as many headaches as possible in compile time. Of course it's not going to be faster than C compile times, it's doing hell of a lot more than the C compiler! As for C++ compile times, it might be very similar if you use compile time heavy things like templates.

That's the Rust niche, we like performance, we like safety, we like zero-cost abstractions and we fucking hate checking for memory leaks in valgrind

>we

Sorry, I assumed mine would be too broken to bother working with.

template
bool Stack::pop(){
if(head){
Link *newpop = head->next; //Link ='struct' Head='Start of stack' next='Link pointer inside of struct'
delete head;
head = newpop;
return true;
} else {
return false;
}
}

I love rust but i don't want to be associated with a frogposter.

You have no understanding of compilers. Stop shitposting. Have you even tried rust? Have you compared speeds? Come back to me with performance analysis, which I guarantee go against your ignorant claims.

Says the fucking weaboo
The absolute state of Sup Forums ahahahahahaha

/dpt/ collaboration for this?

I'll make the logo!

That's the logo guy settled.

Need about 4-5 more for programming and another 4-5 for graphics.

Don't forget the CoC!

I can take care of finances.

currently learning python via "learn python the hard way"

one sample program shows:

target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")

Then asks you to 'use strings, formats and escapes to print put all lines with just one target.write()'.
Problem is, target.write takes exactly one argument.
I tried doing;
target.write("%s \n %s \n %s \n") % (line1, line2, line3)
but says unsupported operand type. My shortest solution is:
all = line1 + "\n" + line2 + "\n" + line3 + "\n"
target.write(all)
which does work.

Any ideas? I want to do it in one line.

Are you using python3?
If so use "{}\n{}\n{}\n".format(line1, line2, line3)

>not knowing what a jam is

Holy shit.

>First, click here to save a copy of your Scholarship badge
The funny thing is the link is apparently blocked in my country.

FUCK FUCK FUCK FUCK

Why does Go's bitshift operator have higher priority than arithmetic operations?

Because it should be this way.
This is one of the few places where C fucked up.
Consider the following:
static uint32_t readUint32LE(FILE *f) {
/// TODO: fread may fail
uint8_t bytes[4];
fread(bytes, 1, 4, f);
return ((uint32_t) bytes[3]

python 2.7, the maker of the course insists a lot on this.

the maker (Zed Shaw) is retarded
he literally said Python 3 is not turing complete

Tell me another course to follow and I'll do. Instantly. I have no idea.

Wassup

listen you fags since you're so smart, maybe you can explain to me why do I need header files in C why are their made since they don't contain the source code, ins't i easier to simply include the .c files directly into the preprocessing?


Answer this bitches.

>course
Fuck that.
Decide what program you want to make and do it. Refer to documentation when you're stuck.
If you're an absolute beginner just rush through Code Academy shit for absolute basics or something, anything will do.
You learn by producing programs, not by learning courses

Do your own homework retard

Gonna learn a scripting language. Which is better, Python or Perl?

Because you don't want to have the function in your compilation unit?

remind me.
Why I don't want that?

Because you're not a retard

Perl is almost obsolete in terms of jobs, Python is popular in terms of jobs.
If you're learning a language for fun either is fine.

if it's defined in another object file that compile compile against you would have name collision, unless the function was static.

Header files serve as a heads-up for the compiler.

Going for whichever looks best on a resume. Don't wanna be like my friend who was offered 48k starting salary.
So I might end up learning python.

Yes I am.

I don't understand...


But the compiler goes to one .h file then compiles the source code of that header file, and includes it in the file I am compiling at that moment.

So why not directly include the source code as the header file?
Why do I need .h files?

Stop right there. For résumé aesthetics contribute to an open source project. It doesn't matter which, just do it and have proof that you contributed. It shows programming maturity, teamwork skills and much more.

Check for if head is NULL before popping I guess

Header files contain struct definitions and function prototypes. They mainly exist so compilation isn't super long and for modularity reasons. Imagine you have a 40kb header file and 4 40k c files. If you didnt have the h file, you'd need to copy those 40kb into every single one of the c files: 40kb + 4*40kb < 80kb * 4

OK, I'll do that then.
Any suggestion for small projects?

>But the compiler goes to one .h file then compiles the source code of that header file, and includes it in the file I am compiling at that moment.
>So why not directly include the source code as the header file?
>Why do I need .h files?
This is not what happens. The compiler compiles a series of .c files. These compiled objects are then linked together to create the application. The point of header files is to make a promise to the compiler as it is compiling one .c file, that some other .c file will provide an implementation. If you break this promise, you get a link error.

Header files are not even necessary to make this promise, you can define prototypes directly in the .c file just the same, or a .lol file, it doesn't matter. Header files are just convention.

You seem like you have absolutely no direction in life.
Make a CLI calculator or something, I don't care.

Not that user but
Try solving problems online on some place like hackerrank if you can't quite commit to a long term project.

>tfw installing visual studio
>unchecked all components to get the size down as much as possible
>the install size is still 13GB

>"but user that is a lot"
Oh yeah? Before i gutted out the pre-selected stuff the install size was 35GB and that only includes 4 out of the 13 workloads which vs2017 offers

I fucking love VS so much i will put up with this shit but fuck this is riddickulous

Is this true, /dpt/?

If so, what the hell is wrong with you guys?

who cares

I do.

What's wrong with enjoying lewd cartoons?

cute

This isn't BaCon. Try BaCon.
basic-converter.org/

what?