/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?


Previous Thread:

Other urls found in this thread:

tour.golang.org
github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
better-dpt-roll.github.io/
pastebin.com/vSW3BGyp
myredditnudes.com/
twitter.com/AnonBabble

Learn Go
tour.golang.org

>Go
No

>No
Oh

Should have been named Stop tbqh

kek

Making my very first web project with Django.

>>>/wdg/
not programming.

>When it comes to code reuse, projects that used an object-oriented approach were able to take more than 70% of their code from previous projects. Subsequently, the projects that used functional design were able to take about 35 percent of their code from previous projects (McGarry, Waligora, and McDermott 1989).

OMG HOW ARE FUNCTIONALTARDS EVER GONNA RECOVER FROM THIS #REKKING?

>1989

I bet they think Lisp is FP

>1989
>Implying that pure functions aren't the only truly reusable bit of code
>Implying that OOP and all of its statefulness is easily reusable

Because when doing OOP you have to write so much boilerplate code.
Then when you make new project you can just reuse the boilerplate code.

Functional doesn't have this problem.

10k line OOP project, 30% new = 3000 new lines to be written and tested

1k line FP project, 65% new = 650 new lines to be written and tested

Oh, right, right, sorry.

I'm writing FizzBuzz in Brainfuck. There you go, now it's programming.

I want to become a god at programming like you guys please teach me how!

It took me forever to understand and implement my own algorithms how did you guys get so good at it?

Get a CS degree.
Learn C.

learn Haskell

Don't do this.

Is there good alternative to C? Something that has same kind of "stable" ABI as C which is easy to call from other languages?
>inb4 sepples
looking for good alternative.

Java

what are you talking about? why is there nothing on the left hand side?

Just tried this in the python console, and it works:

what's the purpose of this -> sign?

def test(str) -> None:
return str

Why do you even care? There's a bunch of retards who are trying to use a non mainstream language as their social identity. No one will use Haskell in production for large scale frameworks except of some specific cases.

>Something that has same kind of "stable" ABI as C which is easy to call from other languages?
No, not really.

OOP isn't even that bad desu

It's a way to show what the return type of a function will be, as far as I can tell.
It doesn't seem to care if the actual return type is different as well.

Neither is leukaemia, apparently.

if "isn't even that bad" is defined as "it's straight up trash" then sure.

>It doesn't seem to care if the actual return type is different as well
Python is such a lauching stock of programming languages.

>Shows what the return type will be
>Doesn't actually care what the return type is
Weak typing is cancer

>Python is such a lauching stock of programming languages.
not an argument.

We were not arguing...

>It doesn't seem to care if the actual return type is different as well.

if it's straight up trash then how come most software companies all use OOP in medium to large scale producation checkmate all of /dpt/

In Python you could say it's snake oil

they're called type hints
you can also for example do
def f(a: str) -> int:
return len(a)

I think they missed the point of why type annotations are better than comments.

interesting.

bu this only works on python 3.x, right?

Typechecking is oppressive

>>> def a() -> list:
return "not a list"

>>> a()
"not a list"

Why is this allowed anywhere?
Why even bother if you're not gonna enforce your own rules?

if the earth goes around the sun then why does everybody in the vatican believe the opposite checkmate galileo

programming challenge

write Fizzbuzz in a purely object oriented way of programming

Daily reminder that anime people are just bronies without the ponies

Newb programmer here
In C++ I used have my setters return a bool, so I could do this
Person obj;

int age;

do {
std::cout > age;
} while (obj.setAge(age));


But I'm currently learning C#, is there a way to do this?

it should be while (!obj.setAge(age)), but wtv

github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

@58918741
Daily reminder that plebbitors (you) aren't (a person) people and should fuck off back to their (your) subreddit.

lmao why tho

To illustrate the absurdity of "enterprise" coding practices.

Should be the same way
public bool setAge(int age);

Anyone has some intermediate projects or exercices to do for Java ?
I have nothing to do these times and I want to get better at it.

Or any small website ideas to do with Java EE ?

So, nothing out of the ordinary?

lol first anime degenerate spotted

>@
go back to twitter

That's why type() exists you moron. Jesus you lazy compiler babbies need to get over yourselves.

Is it okay to do that? Since C# has it's own ways of having setters and getters?

Type hints are entirely meant to be ignored by the Python runtime, and are checked only by 3rd party tools like mypy and Pycharm's integrated checker.

Oh right, it does
I have no idea then, try googling around for it

...

I think I have finish my twisty game. I don't see what to change.

Who is going to stop you? C# method of getters and setters are just syntactic sugar you know.

>write a function that says it returns x type
>it doesn't
>"hurr you're meant to check it yourself you idiot"

Nice m8

>type()
>not isinstance()

Ok, thanks

your png is now optimized.

better-dpt-roll.github.io/

I fail to see how that shows anything except that the programmer needs to add type checking into the program.

The point being that there are ways to see what the type is so that you can adjust accordingly.

rate my word counter
#include

int main (int argc, char *argv[]) {
char *s = argv[1];
int spf = 0;
while(s && *s) if (*(s++) == ' ') spf++;
printf("words: %i\n", spf + 1);
return 0;
}

try with
nigger you failed

Might be able to shorten it with strtok()

>"Hello World " is 3 words

s/\s+/ /g stop being niggers
probs

you're code is shit, you're the nigger

do it better then
no haskell or lisp allowed

rate my string reverser too niggers
#include
#include

int main (int argc, char *argv[]) {
int i = strlen(argv[1]);
char *c = (argv[1] + i) -1;
while(c && *c && c >= argv[1]) putchar(*(c--));
putchar('\n');
return 0;
}

printf("words: %d\n", argc-1);
if the user grouped words with "", they obviously wanted it to count as one

(define (word-count str)
(length (string-split str " ")))

(word-count "hello world! ") ;=> 2

#include
int a,b,c,d,e,f,g;
int main()
{
for (;f=getchar()+1;++a)
d-=(f==11?(f++,(d>e?e=d:d)):-1),
g=(f>33?b+=!g:0);
printf("%d\n", b);
return 0;
}

public class ConsoleMain
{
public static void Main()
{
int line = 7;
int[] numbers = { 12, 21, 4, 9, 7, 8, 4, 13 };
PrintOver(numbers, line);
int sum = SumOver(numbers, line);
Console.WriteLine("The sum of numbers over " + line + " is: " + sum);
Console.ReadKey();
}
public static void PrintOver(int[] numbers, int line)
{

}
public static int SumOver(int[] numbers, int line)
{

}
}


I need to print all the numbers that are higher than 7 and then sum them together (C#). Please write it for me.

Thank you.

superior C++ solution
#include
#include

int main(int argc, char **argv) {
if (argc < 1)
return 1;
std::stringstream ss(argv[1]);
std::string temp;
int i = -1;
do {
temp.clear();
i++;
ss >> temp;
} while (!temp.empty());
std::cout

Are pointers a meme? If so how would you rewrite this without a pointer?
func main() {
goku := &Saiyan{"Goku", 9000}
Super(goku)
fmt.Println(goku.Power)
}
func Super(s *Saiyan) {
s.Power += 10000
}

I want it to print 19000

...

Is there a hidden non-reddit version of this thread?
>Are x a meme?
Fuck off, stupid redditor.

what's c && *c for? are you expecting it to become a null pointer?

might be

reddit reddit reddit reddit reddit reddit reddit reddit redditreddit reddit reddit reddit reddit

>uninitialized global variables

bookmarked

I need help with c++ templates, it's driving me mad.
pastebin.com/vSW3BGyp
I wanted to pass the argument to print by reference rather than by value, but if I make the specialization use A& it calls the generic one instead.
Can anyone tell me if it's possible and if so how?

>uninitialized global variables
No such thing, idiot.
All static and global variables are initialised to zero.

>that reddit image coupled with a new file name
yup, that's a redditor. Back to your subreddit.

it just works bro

you had to say something, didn't you?

reddit reddit reddit reddit reddit reddit reddit reddit redditreddit reddit reddit reddit reddit reddit reddit reddit reddit reddit reddit reddit reddit redditreddit reddit reddit reddit reddit reddit reddit reddit reddit reddit reddit reddit reddit redditreddit reddit reddit reddit reddit

You are like a babby. Watch this.
#word counter
def counter(string):
assert string != str, "This is not a string you faggot."
words = string.split(" ")
count = 0
for i in words:
if i != '':
count += 1
return count

>that reddit image coupled with a new file name
yup, that's a redditor. Back to your subreddit.

see

see

git gud