/dpt/ - Daily Programming Thread

Old thread: →

What are you working on, Sup Forums?

Other urls found in this thread:

cplusplus.com/doc/tutorial/functions/
electron.atom.io/
twitter.com/SFWRedditGifs

anime

Midna a cute.
Will I run into problems if I never use private? I almost always use public for my variables and functions. The books tell me to set things to private so people don't have access to things they shouldn't but if they're already doodling with the code don't they have full access already?

learning web dev.. any one know a good site/board I can go on and beg for answers for my JS questions?

yes you should when you finally make a full real application making them all public will cause lots of problems for your program

No.

no one will hire you, its a security nightmare.

lets say you have a function that allows for transfer or reception of money. Then the variable for the cash is public. See what could go wrong

why is qt so fucking expensive

you're fucking retarded

>set things to private so people don't have access to things
>people don't have access
>people
this is obviously bait.

wow, except private does literally nothing to protect that field. It's like you don't understand what the keywords actually do. Private is just a suggestion, if someone's able to interact with your code in that way they can just get the field by peeking at the object in memory and guessing offsets.

for the following


double bmi (double;

int main

cin height
cin weight
cout bmi
}

double bmi(n);
double n
n = weight / height^2

what am i doing wrong to not be able to call bmis value

obv this is pseudo code of c++

It's for gaylords. Gaylords have a lot of money or are willing to pay a lot of money for things because they are also hipsters.

when you're dealing with a bunch of contributors this is a thing you need to consider.

For now don't worry

>obv this is pseudo code of c++
How about you post the actual code, along with the error you're getting?

I am overloading with 3 constructors, how does that make you feel buddy? eat shit

>muh clean code

Smells like Java

post actual code

Pajeet here ask me anything

dumb question time

if i close my program, is windows smart enough to free up the memory the program used?

#include

using namespace std;

double BMI (double);
int main()
{
double height;
double weight;

cout height;
cout

Yes

Public methods, private data.
aka: Make getters and setters and make all variables private and live happy

you only declared 1 argument in the prototype and 2 in the definition, also you didn't include the types for the definition.

Most things can be googled. Try to break down problems until you get stuck at a single thing and then ask for help

this is what Java is all about

pirate udemy nodejs and angularjs courses
i did those and i'd consider myself to be an expert webdev

Most/all operating systems do that automatically.

cplusplus.com/doc/tutorial/functions/

Windows is a lot smarter than you think. At least a lot smarter than you, for asking such a stupid question.

cheers, super easy fix

#include

using namespace std;

double BMI (double, double);
int main()
{
double height;
double weight;

cout height;
cout

now do it in Java

you're not even calling the function anywhere

double BMI (double height, double weight)
{ double n;
n = weight / (height * height);
}

Why isn't the compiler yelling at you for this

I think it's technically valid on most compilers if the statements are within the block and end with a semicolon

holy shit your right, i tried to fix it without having thefunction outside of main and forgot to remove it

#include

using namespace std;

double BMI (double, double);
int main()
{
double height;
double weight;

cout height;
cout

You never gave input to your function and your function doesn't output anything either

lol
you have to return n from bmi not 0

pls rate

#include

void fizzbuzz(int a, int b, int n) {
int i;

for (i = 1; i

smells like shit you mean?

Not using argc and argv
4/10

>Not doing Fizzbuzz in a proper OOP Enterprise edition

It's like you aren't even a real Software Engineer

right

/**< */#include

using namespace std;

double BMI (double, double);
int main()
{
double height;
double weight;
cout height;
cout

what the fuck is this retarded language you're trying to speak? and no, i'm not talking about sepples

what?

nice ty, Nodejs is the backend for JS isnt it?

1. You only run it once, so cin for the two arguments is tedious to use.
In your declaration of main, it should be like this:
int main(int argc, char *argc[]){
...

Then you call call your function with two arguments instead (like you do with other applications).
2. You didn't call the function, you wrote it twice.
3. The function was not properly declared. You need to return the n value.
4. I know this is Sup Forums, but fix your indentation. It is a fucking mess to look at.

lol at "optimizing" this.
I guess what you really need is to write some multithreaded simd code in assembly language so that you can compute 16 BMIs simultaneously.

Im currently working through an android development course online, however Im starting to loose interest in app development. But I still like programming...

Should I just switch to a pure Java or different programming language course or is it worth it to stick it on the android course?

Nodejs is essentially a compiler for JS. It allows you to write an application backend in JS.

apply to fixed pls

developing a weather app is a meme

memeing is totally mispelled

What are non meme Android application projects to learn and do?

fizzbuzz with a GUI

no.

in past times, you'd need javascript for the frontend, some c type language for a backend, and then sql or something comparable else for a databse

nodejs allows you to use javascript for all of those. nodejs is a godsend, you should definitely learn it if you want to webdev. it's really powerful in ways you can't even comprehend. i wasn't joking when i said that i'm an expert webdev, and it's all thanks to nodejs.

well since you need to ask the weather app isnt a meme to you since its necessary for learning shit.

android developement is a meme though. you can make money sure, but you cant make anything useful

what useful applications could you make that would earn you lots of money on Android?

what would that gui do?

interesting, thanks for the info.

Where is the real money in programming these days?

being a CEO in charge of programmers and not a programmer

whats a good win32 book other than the petzold meme

none, especially sinec the mobile market favours ios. a clash of kingdoms or whatever its called clone will make you money.

like i said,

i want to get into electrical engineering and programming robots n shit. oop would be uselesss in this case right? if i know c++ though, would that make it easier

...

myAny :: (a -> Bool) -> [a] -> Bool
myAny f xs =
foldr (\x b -> f x || b) False xs

> myAny even [1..]


what are the values of x and b in the user func

x is an element in the list and b is the state

>tfw every project is a lonely endeavor
>tfw not a single person to share code ideas with
>all people I know are code monkeys who wouldn't understand

i cant believe overwatch wasted money to use starcraft 2 in their game

i'm interested in this too since qt is too expensive

i looked up the book you mentioned but that's from 1998, is there anything more recent? also, what's wrong with just using SDL to write a program even if i only use it to render a gui? at least i somewhat know my way around video game engines.

>tfw no programming sempai

she would probably work shit like kobayashi

I dont get it.

Why?

>sempai
there isn't such a thing

cant you only use case once?

a ~ b isn't a thing you can do
~X is binary NOT
so flips all bits

~ is a unary operator

Oh wait, you are right, I forgot about that.

Thanks.

don't need break statements when you have a return statement btw

Nothings wrong with SDL
I have a specific fetish for doing it with the Win32 API but eventually I'll probably make my own

pls rate again

/* >tfw no pure functions */

#include
#include
#include

#define PROGRAM_NAME "fizzbuzz"
#define REQ_PROG_ARG_CNT 4

/* returns true if str contains only a positive int and returns false otherwise*/
int isstrposint(char *str) {
char *stritr = NULL;

for (stritr = str; *stritr != '\0'; stritr++) {
if (!isdigit(*stritr) || atoi(str)

I too enjoy win32 api. when I first worked with it I got a stiffy for weeks

>I have a specific fetish for doing it with the Win32 API

you sound like me but now I'm wondering what you mean by ideas. I just want someone to share the task of coding with and maybe someone to share the project ideas with.

If you drew that, and this isn't just bait, then I would totally delegate art to you and code off of your ideas as you may have more on the ready than I am willing to look over while coming up with new ways to hold it all together.

No teetering either. Want my twitter? I am not a code monkey. But I'm probably not as good as I think I am.

>>tfw no pure functions
Chuck an __attribute__((pure)) (behind an appropriate compiler test macro) on it.
Also your code is needlessly complicated and your error handling is shitty.

not look over, I mean overlook

>__attribute__((pure))
neat
>Also your code is needlessly complicated
be more specific pls
>your error handling is shitty
that I know

>A function returning a function
Is this practice really necessary? Or is it just pretending to be 1337

Hard to follow in a big file

I'd recommend it. There's a few more advanced ways to put them to use but explaining them might make them sound insignificant. But learning how to use them now might make it easier for you to create little patches here and there without having to make a full blown class file out of nothing.

function is just data, not hard at all to follow

it's useful since you can partially apply shit together

Just remembered that you can do GUI in html now.
Is there any reason not to? I've mostly used xaml and winforms(for quick projects)

isstrposint is completely pointless and implemented very poorly (O(n^2) solution).
You can just covert the argument to an integer, and check if it's negative after that.
Don't use atoi, as there is basically no way to check for bad input. Use strtol instead.

when you don't wanna include v8 in your app

>v8
what's that?

"html" desktop apps include Chromium in the app, that is how they do the gui stuff
electron.atom.io/

How many cylinders are in a car engine.

This is used in Closures. Closure provides data isolation.
package main

import "fmt"

func main() {
counter := newCounter()
fmt.Println(counter())
fmt.Println(counter())
}

func newCounter() func() int {
n := 0
return func() int {
n += 1
return n
}
}

In this example our closure references the variable n even after the newCounter() function has finished running. This means that our closure has access to a variable that keeps track of how many times it has been called, but no other code outside of the newCounter() function has access to this variable. This is one of the many benefits of a closure - we can persist data between function calls while also isolating the data from other code.

Please stop posting those disgusting tumblr GIFs, you faggot.
Those look fucking terrible.

Where else do I get my rare yurus?