/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

...

thanks for not using a fag image

((or + -) 1 2 3)

; => 6


That's so fucking cool

>weak typing
RRREEEEEE

he cut his penis

>he
shitty meme desu m80

You think that's bad?
((and = 1 1) +) 1 2 3)

; => 6


I don't see what the issue with weak typing is, I wouldn't actually write a program that did this, but why have a constraint in your fucking syntax that limits the ways you can handle data, just have a uniform function set and let that eat the damn nails when it has to

strong typing only exists to keep someone who doesn't know what they're doing from shooting themselves in the foot

I fucked up, should be ((and (= 1 1) +) 1 2 3)

That way madness lies.

Any decent LISP* has strong typing.

*or decent language, for that matter

>t. unemployable

Okay, but in all honesty as a novice programmer what's the problem with weak typing?

Strong typing is also better for documentation and optimization.

>strong typing only exists to keep someone who doesn't know what they're doing from shooting themselves in the foot
Use something untyped like assembly then, Master.

for anything non-trivial you will want sanity checks to ensure correctness. with strong typing, all you have to do is specify the type and it saves you and everyone else a lot of extra effort.

>in all honesty as a novice programmer what's the problem with weak typing?
This is: >why have a constraint in your fucking syntax
It has nothing to do with syntax.

>just have a uniform function set and let that eat the damn nails when it has to
I have no idea what this means. Do you?

never said I knew what I was doing

My manager wants us to start using Scala, how can I convince him that we should stick with Java?

Also consider that even people who know what they're doing don't want to waste cognitive effort on something that the computer can do just fine. Machines should work, people should think.

You don't. Scala is the better choice and there's a reason you're not the manager.

Without that open that wouldn't have run, strong typing wouldn't have helped that

I heard Scala is a terrible language.

java is the tried and tested choice of the industry, it's by far more popular and more widely supported

scala is shit

>or special form returns the first non-nil/#f argument
>and special form returns the last argument if everything before is non-nil/#f

I didn't say Scala is good. I said it's better than Java.

At least it's not Rust.

>muh trivial OOP shit
Every fucking thread, don't disappoint me now Sup Forums

it's not better than java you insufferable autist. at best it's a matter of opinion.

Those quotes are acurate, the or/and functions seem retarded even to my brain damaged ass, but I STILL don't see how strong typing would help

Expecting implicit type coercion makes reasoning about types more complex and more error-prone.

What about the second and third points?

Hey guys how do I average two ints?

it is, actually but you're the only one going Gran Autismo here. Keep the reeeeing down to a minimum please.
Thanks.

>muh smug FP shit
kys

Hey this is trivial FUNCTIONAL shit you dweebo
Nothing was wrong with those last two, or I would have mentioned them

you're pathetic dude, you're not special for programming in haskell/idris, any programmer could do it if they wanted to, but any actually competent programmer realizes how shit those languages are

But the third point was a question...

mul x, x
bnz $0

Nice run-on sentence, Javesh.

I get a compiler error do I need to do this on Windows maybe? I have a MacBook

Why are they shit, then?

I never said I use haskell. You sound insecure as fuck though.

Still working on akari-bbs!

I added dynamic page titles, but it cuts off unicode characters halfway through.
How do I tell if I'm in the middle of a UTF-8 byte sequence?

I think we can all agree that using Dvorak makes you a better programmer.

>bnz
ARM?

I used Dvorak for a while. It was verrah nice.

how to compute the average from an array?
example:
values from array: 1, 2, 3, 4, 5, 6

output
3.5

Hey /dpt/ long time listener first time caller
Is there anyone who knows C++ that can help me?

It's homework but I'm not understanding the tutorials enough to get it to work.

Essentially I'm using void functions to open a file and then I want to be able to read the file from the main.
I can elaborate if need be but I'm trying to do this without posting my code and then going "whats wrong with it?"

Please help

Reminder that having the same input give the same output across the program is about as restrictive as you ever need to be. This admits side effects but they either must be modelled in the inputs (or outputs, like with IO in Haskell) or they must not be observable again from the program.

Rarely, you might need to model a bit more than that, like imposing time and space restrictions for hard real time software.

pavgw xmm0, xmm1

You even get 8 results at once.

What about random algorithms.

POST MORE DETAILS

C'MON

YOU CAN DO THIS

Pass around the state of the random generator somehow.

Sounds like homework

Tell him there are better meme JVM languages like Frege, Clojure and Kotlin

>Frege
Immature

>Clojure
Garbage

>Kotlin
You might as well stick with Java

Use stdio

pass a reference to the function?

Wouldn't that be bad for crypto?

No?

Why do you say that? If anything it's more secure because the state of the random generator isn't just in a static location, it's ephemeral wherever it goes.

But, wouldn't that be bad for crypto?

>You might as well stick with Java
this

what scala and kotlin are doing with java is like if you take a carefully engineered ferrari and then you give it a hellaflush and put a homemade exhaust on it. anyone who actually knows their shit realizes how ridiculous this is

/dpt/ is amateur hour 24 hours a day

Comedy gold.

How do you know the rng state that gets passed in is safe?

this

amateur detected

No?

What do you mean by safe?

FUCK okay
The program I'm trying to make is supposed to be a menu program that reads a different file depending on what you choose (ie you have 5 choices, choose 1-5 to make choice) once the user makes the choice the program is supposed to clear screen (I'm using system("cls"); for this) and display a read file opened from a void function.
Problem is I set my void function to open the file like so:
void DisplayWinter()
{
inputFile.open("Winter-Summer.txt");
}
and I go back to the main to input text from the file before printing like so:
while (choice == 2)

DisplayWinter();
{
inputFile >> line;
cout line;
cout line;
cout line;
cout

stdio

Why'd you stop?

I'm on Dvorak now, it's the fucking best

can you post the whole program?

???????????????????????????????????????

XML needs to DIAF

I got a job involving much typing on many different computers I have no control over :(

The client shouldn't know the rng state.

No dice, still comes up blank

You asked for it
#include
#include
#include
#include
#include
using namespace std;
//**********************Function Prototypes******************************
//5 function prototypes (all void); one for each menu option
void DisplayFall();
void DisplayWinter();
void DisplaySummer();
void DisplaySpring();
void DisplayQuit();
//****************Program Setup (Declarations)***************************
string Heading = "buttfuck College";
string subHeading = "Computer Science Course Offering";
string line;
ifstream inputFile;
int choice;
char word[255];
//**********************************************************************

int main()
{
cout

What if the program requires true random number generation?

hey, you lads like asp.net?

i'm pretty sure i will use it when the time comes

>comment banners

if it were up to me I wouldn't use them. Instructor's orders

Just because you're passing it around doesn't mean it's open. It could also just be a capability to access a pointer to static memory. It could even be a handle to send a RCP to some server to do it.

what do you mean by client? in a client-server scenario, the state would be stored on the server of course

Kill him. It's your right as an American citizen.

How do I fix?

Then you use a linear marker type modelling the world for the input, or equivalently something like IO in Haskell. While this doesn't actually change the operation of the program, it acts as a hint to the compiler so that optimization doesn't fuck it up. The more you put in types, the easier it is to optimize.

It compiles just fine with javac on the terminal but not in Eclipse.

>The more you put in types, the easier it is to optimize.
Holy fuck somebody on Sup Forums finally gets it.

Typing, no side effects, etc is autistic and dumb.
Programming should be as free and flexible as natural language the computer should figure it all out by itself.
You spergs would probably try and write math proof all in formal logic (lol).

don't use function prototypes
put the functions above the main function instead and you don't need a prototype

and don't use global variables
make them local and then pass them as arguments to whatever functions need them if necessary

now your code is better and you don't need comment banners

kys

>You spergs would probably try and write math proof all in formal logic (lol).

But.. formal logic systems are fun.

for loop looping < array size, add every value into a holder variable then divide by array size?

>the computer should figure it all out by itself
Well, computers can't (yet).

pass the ifstream (inputfile) to the void function as a reference, so void DisplayWinter(ofstream&) for the prototype and calling it like DisplayWinter(inputfile) so whatever you do in void carries back to main?

bow down
#include
#include

template
constexpr std::size_t countof(const T(&)[N]) noexcept
{
return N;
}

template
std::size_t countof(const T& container)
{
return container.size();
}

template
T average(const Iterable& iterable)
{
return std::accumulate(
std::begin(iterable), std::end(iterable), T()
) / countof(iterable);
}

int main()
{
auto numbers = { 1, 2, 3, 4, 5, 6 };
std::cout

The way I see it, one of the goals of functional programming and powerful type systems is so that the compiler does more work for the programmer without having to think for itself (e.g. in optimizations). Computers are great at checking solutions that humans come up with, type-theoretically.

Not a Java user but change your eclipse errors preferences. Maybe the current settings don't allow you to override standard library methods or some shit.

Function prototypes are a must if you intend to have more than 1 compilation unit.
What do you think headers are for?

obviously doesn't apply to this code snippet otherwise they'd already be in a header file