/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Old thread:

Attached: 1566183733314.jpg (1600x1200, 207K)

Other urls found in this thread:

sourceware.org/gdb/onlinedocs/gdb/Set-Watchpoints.html
github.com/Zevv/npeg
twitter.com/AnonBabble

>anime
wrong subreddit, retard

>write down tests
>write enough code to make a single test pass, then move onto the next one
did you fall for the TDD meme? It seems good

tests can never fully encompass functionality for a non-trival program

started building isometric game in rust

the actual assets wont be cuck tier

Attached: VIDYA.png (790x590, 19K)

>rust
yikes...

anyone who shits on rust is following the meme and knows nothing

Attached: ep1.png (437x495, 499K)

imagine needing the borrow checker to hold your hand so you don't make an oopsie and leak memory all over the place

imagine getting cum in your eye from correctly using raw pointers in a 1M line codebase

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Demo
{
public static void main (String[] args)
{
System.out.println("Hello World");
Scanner in = new Scanner(System.in);
int i = (int) Math.random()*100;
System.out.println("Guessing game. Try to guess my number (0-99).");
int j = in.nextInt();
System.out.println("Enter your guess:");
while (i!=j){
System.out.println("Wrong!");
String s =(i>j)?"Too low.":"Too high.";
System.out.println(s);
System.out.println("Enter your guess:");
j = in.nextInt();
}
}
}

What's wrong with my code? It won't compile. Does it have to do with the compiler app?

oupsie woopsie UwU the booboo chekruff got super angry! (>.

Imagine being such a sloppy coder you write something that has 1M lines of code

>coder
stopped reading right there

Attached: l-RKQTRC_400x400.jpg (400x400, 27K)

It works for me without an error, you should definitely check your compiler setup.
Also it always rolls zero because the cast in line 14 casts the result of Math.random() instead of (Math.random()*100) to int.

Good to know, thanks.

Anyone know why this doesn't throw an error? Particularly the 2nd line, doesn't seem like the types match up but ghci telling me very legal even with -Wall on.

Haskell btw
sublists :: [a] -> [[a]]
sublists [] = []
sublists [x] = [[x], []]
sublists (x:xs) = map (x:) sublist ++ sublist
where sublist = sublists xs

>thread made before bump limit
kill yourself OP

I don't know Haskell but isn't it just a function specialization that an empty list should result in an empty list?

Behaviour is meant to be

*Main> sublists "ABC"
["ABC","AB","AC","A","BC","B","C",""]
*Main> :type []
[] :: [a]
*Main> :type [[]]
[[]] :: [[a]]
*Main> :type sublists
sublists :: [a] -> [[a]]

The types seem to mismatch per the above code. B

niggerlicious

ghci doesn't have information to tell you what [] is. [a] is just a guess.

Every list type is inhabited by the empty list.
[] :: [b] where b = [a] holds true.

Remember, a is a type variable that is scoped to that type declaration. The a in the type signature [] :: [a] can be set to [a] where a is type variable defined in [[]] :: [[a]]

It's implicitly quantified, so [] is actually
forall a. [a]
and [[]] is
forall a. [[a]]
If for the first one we pick a = [b] we get
[[b]]
And since we can do this for any b, we have
forall b. [[b]]
which is the same as
forall a. [[a]]
just using a different bound variable name

whats the usual cause of this texture leak im having?

Attached: opengl_texture_bug.png (1366x704, 629K)

...

either have consts all the way down like void muh_func(const char *const *const *const argv) or don't bother with const

>that I promise
not how C works.
it tells you plainly:
ptr.c: In function ‘main’:
ptr.c:9:11: warning: passing argument 1 of ‘muh_func’ from incompatible pointer type [-Wincompatible-pointer-types]
9 | muh_func(&argv);
| ^~~~~
| |
| char ***
ptr.c:4:35: note: expected ‘const char * const**’ but argument is of type ‘char ***’
4 | void muh_func(const char * const *argv[]) {
| ~~~~~~~~~~~~~~~~~~~~^~~~~~
>or don't bother
a cast is also an option.

kk I got it now thanks friends

this is /dpt/ the anime general on 4channel

Attached: 1561024549140.png (1181x1748, 3.71M)

correct
pic unrelated

Attached: 1564432586246.jpg (2362x2362, 353K)

Do you guys recommend taking estrogen to improve my coding? I already have programming socks but not sure if these help at all. I code in C and think maybe it is too manly, should change to Haskell or C#.

Attached: E9458BB0-188B-46A1-8889-0A4950048310.jpg (564x564, 30K)

the meme is funny because it's as wrong as saying that a lobotomy would improve your math scores. Testosterone is a productivity drug.

anime girls program in the latest standard of C++, so that will be C++20. Just take estrogen and wear short skirts without underwear and sneak up your coworkers
in a month or so you will be a god C++ programmer and you have the benefit of sucking your boyrfriends cock.

wow, who would have thought
you're such a genius user for figuring that out!!!

Attached: 1540795052137.jpg (700x1000, 178K)

>explaining the joke
Fuckin low T betas.

B-baka! I know you are jealous but please don't ruin the thread.

Thanks, this is what I wanted to hear. I love New Game and if Nenecchi can do it I can as well. Going to change to C++ should be okay.

Attached: 08AD290F-50A1-4B28-8931-E4CC15642F9A.jpg (1280x720, 112K)

>anime girls program in the latest standard of C++, so that will be C++20
they're japanese, its probably C++98 or something

why do you think they're so far behind? Windows?
Ruby, Gauche Scheme, Kyoto Common Lisp (ancestor of GCL and ECL), and apparently some prolog stuff is also common from over there.

Hey guys, been trying to flash bios without cpu and the flashlight doesnt blink but just stays on. What to do?

Attached: 20190819_201150.jpg (4032x3024, 2.9M)

put a cpu in the socket

They use Visual Studio in New Gamu. I love Nenecchi and her Okinawan lead. God I wish I was a chocolate brown anime girl instead of 200lbs burly man. Would get a job immediately instead of being a neet.

Attached: 599947FD-5FCE-400C-A843-D82418C2B715.png (399x485, 224K)

also a NEET but not terminally overweight, yikes

I will be a passable coder just need to put in some effort and drink more onions etc and do C++ exercises.

well do some. show us a friend constexpr.

>constexpr
is so fucking irrelevant you standard autist

learn Haskell

>he makes decisions at runtime that could be decided at compiletime
disgusting.

implying it isn't runtime for your compiler

if we're talking about C++, we already don't give a damn about the compiler. The compiler's lucky that C++ doesn't flail it half to death or amputate a limb between compilations.

What an idiotic statement.

who said that? Needing to calculate shit inside the program at compile-time is such a niche feature
I think I must have used it twice in an entire medium-sized game

At some point sepples became more about learning useless trivia than programming.
I fear the same will happen to Rust.

That's already the point of Rust.

a TRUEly idiotic statement

Still same

yeah, and people who've never used static types think that they couldn't possibly be useful because "I rarely have type errors".
When you use static types, you change the way you write programs to encourage type errors because that means getting errors earlier than later.
When you have compile-time evaluation, you change the way you write programs to encourage compile-time evaluation because it's more efficient.

Is the category theory book from bartosz milewski worth reading for Haskell programming? It looks difficult

you don't need to know category theory to learn haskell

>When you have compile-time evaluation, you change the way you write programs to encourage compile-time evaluation because it's more efficient.
are you kidding? You're aware you could pre-calculate data for your program before constexpr even existed right?
I swear you've never actually written a program more complex than compile-time fizzbuzz

I didn't know import by glorified copy paste was manly. I thought most retards were average build or smaller.

>don't know where the variable is used around the program
>delete it
>compiler gives me everything I want to on a silver platter
I call this compiler-driven development.

>newfag seethes about reddit
sweet irony

sourceware.org/gdb/onlinedocs/gdb/Set-Watchpoints.html

There exists a thing called ctrl + f, its very good if you use a decent IDE.

When the name is something common in the big enough codebase it doesn't really help. I need exactly this field. "Find all references" in VS sometimes just misses some occurences or gives false positives.

>you could pre-calculate data
this is the limit of your imagination.
You know you can also generate code at compiletime? How about a nice perfect hash? How about compiling and optimizing regexes? How about checking printf parameters? How about parser generation
>b-b-that also exists
yeah and it sucks. Compare it with github.com/Zevv/npeg
you also just won't generate data in your build system, that you could easily do, because it's more work. How about we align convenience with efficiency instead of with sloth?

>this is the limit of your imaginations
you know you can generate code at runtime?

>generate code at compiletime?
its called templates
>How about a nice perfect hash? How about compiling and optimizing regexes?
what kind of program processes static data instead of data provided at runtime?
>How about parser generation
Why generate parsers instead of writing them yourself it takes like 5 minutes
People like you are the reason C++ is such a shitpile in the first place
You don't actually write code, you just jerk off thinking about it

anime website

So just discovered you can invoke a C function macro with a space between the name and opening paren. This might explain why my C preprocessor is completely broken on complex examples.

if you're using C, cscope is p gud. C++ you probably need something more advanced like cquery/ccls.

user trust me, they're really helpful

Attached: 2019-08-19-131340_700x306_scrot.png (700x306, 37K)

>what kind of program processes static data instead of data provided at runtime?
Jesus Christ. ltrace apache some time.
>Why generate parsers
there are limits to how bitter you should be about your shitty noconstexpr language.

>ltrace apache some time.
Sorry I don't speak webdev
>your shitty noconstexpr language.
I use C++

>I use C++

what?

inheritance needs to die

kys boomer

I'm not going to duplicate my code for every similar object, dumb nigger.

class ProfileImageUploader extends BaseUserUploader {
class BaseUserUploader extends BaseUploder {
class BaseUploader extends BaseServer {
class BaseServer extends HttpServlett {
I want to fucking kill myself

oh
class HttpServelett extends GenericServlet {

JavaScript is the most powerful programming language.

No it's OCaml.

Java

Lambda Calculus

>inheritance is the only way to reuse code
retard

Hey me too, but in Ada!

i want to learn to use vim and want to develop good programming habits while i'm at it

what is unit testing and why do i need to install something to do it?
how do i do it with vim?

Fuck off, rustfaggot.

unit testing is where your thing (e.g. code for a program) is separated into units and you test them individually
you're probably installing a framework that's designed to make testing it easier

>everyone who doesn't like inheritance is a rustlet!
retard

Discuss:
c++2b should have a way to enforce that every function, especially private member functions, is pure

pure uint32_t A::func(T t);


This is currently only vaguely possible in gcc with [[gnu::pure]] but so important it's a shame that it isn't an official part of the standard

When will C++ finally replace non-type templates with an actual mechanism for mixing compile-time computations with runtime computations? Constexpr should be a cv-qualifier!

fuck off retard

what's the difference between pure and just having const arguments?

Why?

>tfw D already has this
How is "the world's best language" behind nearly 60 years on features?

>t. Cnile brainlet

I don't understand, it keeps saying I can't start a statement with else and it expects parentheses and semicolons in some lines. I just wanted to try making a simple program...
static void Main(string[] args)
{
int number;
Console.WriteLine("Please enter a number.");
number = Convert.ToInt32(Console.ReadLine());

{
if (number > 10) ;
{
Console.WriteLine("Number too high. Please keep below 11.");
}
else if (number < 1) ;
{
Console.WriteLine("Number too low. Please keep above 0.");
}
else
{ if (number % 1 == 0) ;
{
{
Console.WriteLine(number + "is a multiple of 1.");
}
else if (number % 2 == 0) ;
{
Console.WriteLine(number + "is a multiple of 2.");
}
else if (number % 3 == 0) ;
{
Console.WriteLine(number + "is a multiple of 3.");
}
else if (number % 4 == 0) ;
{
Console.WriteLine(number + "is a multiple of 4.");
}
else if (number % 5 == 0) ;
{
Console.WriteLine(number + "is a multiple of 5.");
}
}
}
}

Console.ReadLine();
}

Why not make it a free friend function?

Pure functions would disallow the modification of private attributes. Every attribute would have to be passed with the argument list