/dpt/ - Daily Programming Thread

Old: Working on?

Other urls found in this thread:

pastebin.com/ZpZrknwv
docs.oracle.com/javase/tutorial/deployment/jar/update.html
pastebin.com/LWgASthk
developer.mozilla.org/en-US/docs/Web/API/ImageData
strawpoll.me/11351129/
numpy.org/
impredicative.com/ur/
learnyouahaskell.com/chapters
amazon.com/C-Programming-Modern-Approach-2nd/dp/0393979504
cplusplus.com/reference/fstream/ifstream/open/
www196.lunapic.com/editor/?action=retro&redo=1&color=retro),
youtu.be/g7entxbQOCc
msdn.microsoft.com/en-us/library/c8whxhf1.aspx
twitter.com/AnonBabble

First for D

i'm amazed by how smart that man was

Why isn't this board at a 500 post bump limit?

Other boards that post hundreds of hq images get the same limit as us.

Why do ppl hate functional programming? Just starting it and it's dank as fuck nigger

He was smart in maths but in computer science he's a fraud.

It challenges their cult

pastebin.com/ZpZrknwv

Been trying to figure out what's so terrible about JS during the weekend - I think I've got it!

Anyway, general critique welcome - if you can be bothered, try raising the dimension variable, my browser crashes at 100 but my system is no good.

>- YOU DON'T TRY TO FIT IT INTO OBJECTS -
Yes you do. In an object oriented language.

See The cornerstone of OOP is that everything inherits from the Object class.

It depends on how functional you want to be. If you're a purist even IO is difficult.

>Yes you do. In an object oriented language.
Object orientation is the fucking problem

about to start a silly project for shits and giggles, has anybody ever made a program to braid git trees by branching/merging strategically?

How can I make netbeans/maven actually package all of the files required to make a jar runnable directly into the .jar? Apparently, the maven jar plugin and the maven dependency plugin don't actually package the classes that YOU made into the jar.

Does that thing have any specific name?

>If you're a purist even IO is difficult.
Nah.

It's a forest! The red dots are lumber jacks. I think I'll add bears as a form of predator.

Oh I thought it was some sort of a programming challenge that has a name and rules (like Conway's Game of Life etc).

I guess you are the world's leading authority on language design then?

On a more related note, I got it running with dimension set to 500 but each step takes like 5 seconds~.

Jesus christ
Why can't you acknowledge that maybe, perhaps, trying to fucking make everything about objects and inheritance might not be a good idea?

Wow, those are some fast growing trees.

No I don't think so! I just enjoy making something with a visual output when learning something new.

Because you're acting all retarded.

You've already said that you think it's not a bad idea to take a solution and try and make it about objects

I'm able to do 500 at a seccond per step.
Why don't you render it into a canvas?

>Why can't you acknowledge that maybe, perhaps, trying to fucking make everything about objects and inheritance might not be a good idea?
It is a good idea in the context of programming in an object oriented language. In fact you are forced to do that then.

You are acting like I claimed OOP is the best approach to solving any problem.
I have never claimed that, and I know for a fact there are domains where other paradigms outshine OOP completely.

See my first point. Also you're arguing with multiple people.

>It is a good idea in the context of programming in an object oriented language. In fact you are forced to do that then.
That's why I said object orientation is the problem.
It's not a good idea.
That means that either there's something wrong with the language, or that's not what the language is designed for.

If functional programming is so good then why hasn't it caught on?

It is catching on right now

>canvas
Good idea I'll try that!

>tfw too dumb for functional programming

Cred Forums != the world

Where?

it's not too hard for you

just start writing some higher order functions

>lambdas, linq, tuples/"multiple return values", more higher order functions being used, variants, pattern matching, more descriptive types
what was the last major OOP feature added to a major language

>I'm able to do 500 at a seccond per step.

Neat, I'm running it on a Pentium so go figure but I just wanted to see if I can get a higher number since the original poster mentioned it crashes at 100 for him.

Useful features != the paradigm

and meanwhile

>don't use inheritance
>try not to hide mutable state
etc

Yes, if you adopt the paradigm that's not the same as adopting the paradigm
Jesus

Basically you're saying that FP is becoming just another whore in the procedural whorehouse. Abandoning its purity and other nonsense.

Which is a good thing, though, because functional features are so fucking good.

FP isn't inherently pure, I think purity is good for languages, especially so in FP, but the majority of FP has been impure

Imperative languages are starting to control effects - constexpr, @pure, adding exceptions to the type system

basically when i was bitching about the "visitor pattern" earlier
literally just replace that with a higher order function

in fact almost any case of inheritance can be practically replaced with higher order functions

If functional programming languages are so good then why haven't they caught on?

You know what meme I really want? HKTs.

HKTs are pretty good, I don't know how C# implements generics but if you do them right you could get polymorphic recursion

what you really want is haskell style do notation

Because it's very fucking hard for any new language to gain mainstream usage.

Also many mainstream langugaes are gaining functional features making the draw to primarily functional langugaes less strong.

They're fun for hobbyists and jerking off to pretty code but that's it.

Higher Kinded Types? What are those again?

...

you can parametrise a type or type constructor over another type constructor, e.g. template template parameters in C++

so you could implement traverse, for instance

its too hard for Pajeet and Stacey

Automating the network
Building a REST API for DNS info in LDAP

Problem is there's no CLR support for HKTs, so there'd have to major changes, or they'd have to be hacked in.

I'd prefer the former, because we know what happens when essential language features are hacks (see: Java).

Then maybe they aren't that good.

Is that the same as dependant types?

whoops, mapM was the one in the pic

no, dependent types lets you paremetrise types over terms/values

Why couldn't they just add them to the CLR? They add shit to the CLR all the time. it's not backwards compatible like Java is.

>Why couldn't they just add them to the CLR?

I don't know, but the last time someone proposed it, it got shot down.

>no, dependent types lets you paremetrise types over terms/values
hmm? Can you give me a small example of both?

dependent types:

replicate :: forall a. (x :: Integer) -> a -> Vect x a
-- the return type includes a term, x

higher kinded types:

type ApplyInteger (c :: * -> *) = c Integer
data Set a = ...
type IntSet = ApplyInteger Set
-- set isn't a type, it's a type constructor like a generic or something
-- but we can still use it as a parameter

still don;t really get it...

"Set a" is a type constructor? How is IntSet a type is it's defined partly by Set a that isn't a type? I don;t quite follow

How the hell do you learn javascript?
I do C and C++, I can't understand javascript, is it even programming? What is it for? Why are there so many jobs that list it as a requirement?

I've been trying to edit a library
I've edited ParticleSystem.java (circled in pic related)
When I add the edit library back in, the new methods that I create are not recognised.

Should I be editing ParticleSystem.class instead?

I can fully delete ParticleSystem.java, and I get no errors when running my program, whereas I get errors if I delete ParticleSystem.class, so it must be ParticleSystem.class that's being read, not the .java

How does this work? I'm very confused what's happening in the JVM.

are you editing a jar file?

stop doing that

It's needed for websites user. Lots of people want websites.

Set is a type constructor, and a is a type parameter for Set
think
template
Set { ... }

so
applyInteger = Set
applyInteger = Vector

but that's obviously a silly example, you can do more stuff like say you can write a function that works with any generic container, e.g.

template
c clear(c);

>How the hell do you learn javascript?

Step 1:
>Write your code in Java
Step 2:
>Delete any syntax or words that look confusing

Compile flawlessly

I used 7-zip to get the contents of the .jar out.

When I export it as a .jar, it has the exact same functionality that it did before.

There's nothing wrong with this, as far as I know. I haven't had to decompile anything.

>Why are there so many jobs that list it as a requirement?
... he typed into the javascript form.

docs.oracle.com/javase/tutorial/deployment/jar/update.html

advanced mathematics is hard for most people so it isn't good

What should I work on? I want to do something sciencey. My last project was genetic algorithms

>>it's too hard for stupid people
>it must be shit

most of these jobs are for server-side applications, i.e., node.js

Haskell is older than Python, Ruby, and C#

I like programming in Visual Studio and NetBeans, and they are my go-to IDEs.

Is there any language out there that Eclipse can handle that either of the other two can't? I never really cared for it, so I'm thinking of getting rid of it.

test the checksums of the updated file and the file in the jar. if they truly are the same, it might be some weird shit with the jar metadata

>Is there any language out there that Eclipse can handle that either of the other two can't?
If there is, it's not worth using.

The only good thing about using node and noSQL is that your objects look the same on server, in the database and in the client. That's actually very convenient. The only problem is that clients are restricted to javascript, a poorly designed language overall.

>using an IDE
Do you use a fisher price "my first computer" too?

Is that wrong?

That's what I thought too, thanks for the confirmation. Godspeed.

I don't need your besserwisser shit, Cred Forumstard. Stop acting the stereotype. There's nothing wrong with using and IDE to get stuff done. If I need my house rebuilt, I'm not gonna hire the guy who wants to do it with a pair of scissors "because he can and it works". If you use the tools available to you, you get quicker.

>my text editor with 1 billion plugins isn't basically an IDE!

Are you being rhetorical?

I learned js from w3schools. Well, as far i can be said to have learned js.
I know w3schools is not the best, but it's pretty accessible to a bewildered noob.

>tfw too stupid to understand C pointers and keep getting segmentation faults

Have you tried the SoloLearn apps? They are convenient if you're on a train and just wanna plow through basic syntax and whatnot. They have a wide variety of courses too.

Pointers are not that complicated, really. They are just variables that store memory addresses.

Got interviewed for a devops job by a pajeet the other day. Had a yahoo email address.

How do these people keep getting in positions of authority

Try Java, it doesn't have any of those pointers

i use vim with no plugins and 5 line vimrc

No. Never heard of that. But i'm done with js for now. I finished the project i needed it for.

Every time I have to use Java for a university assignment or some shit, I always get extremely annoyed at the lack of pointers.

pastebin.com/LWgASthk

Canvas edition!

also please rape the way I'm writing js so i learn.

You should probably start working on some serious projects, buddy.

I like that pic. Back then I hated it it very much, but now I kinda like it.

I was so fucking based back in the day, ah the memories.

How could you get annoyed by that? Most things are reference types.

How much performance improvement did you get.

And no one writes nice js code. It's pretty much impossible.

>also please rape the way I'm writing js so i learn.
Looks fine to me at first glance but I'm no js expert.

What feature using pointers do you want to use?

I had a program with a lot of swapping logic, and I had to write the same shit 6 times instead of having a function.

i need a vim senpai to answer some questions ;-;

wat

why didn't you write your questions in your fucking post?

retard.

How do I build a library that I'm editing

I need the ParticleSystem$1.class to be updated before I create the .jar, and I assume the only way to do so is by building.

There are no options to build, and when I try to run I get the error in pic related.

arent perl and python functional?

int x = 12;
int* xP;
xP = &x; //xP storing address of x

//*x is what's stored at that address (dereference)
printf("%d, %d\n", x, *xP);
x *= 2;
//still refers to the same thing
printf("%d, %d\n", x, *xP);

>genetic algorithms
what did you do? I want to learn more about those

because i was seeing if I'd get any responses.

1. how to do sessions?
mks and an nnmore for loading doesn't seem to work
2. how the fuck do you link and invoke a compiler

I'm an IDE baby trying to learn.

maybe he wants to get on skype with you and show you his anime collection first

>and I had to write the same shit 6 times instead of having a function.
You probably didn't have to though, you just didn't know any better. That's fine though, it's a learning process for all of us. I don't know about java but C# has ref and out keywords, java probably has something similar.

collinoswalt.com/genetics

I did this. It makes more fit birds to go through the course. It converges due to incest pretty often though. Touching the top or bottom kills the bird

>how the fuck do you link and invoke a compiler
Why would you want to do this with vim

You can also draw a bitmap directly to canvas using ImageData instead of having to draw rectangles. But the canvas version is faster for me. Does it still crash at 100 for you?

developer.mozilla.org/en-US/docs/Web/API/ImageData

You know everything is an object, so you can have your swap logic work on objects

should be collinoswalt.com/biology

>java probably has something similar
It doesn't

Because then it's pure programming and only slightly is it coding.

that is really cool, thank you

I can run it at 750*750 now. Noticed some improvement when drawing each coordinate as i evaluated it, but the lumberjacks moving made that sketchy

Because I essentially want to have it like my IDE where I can just do a hotkey to build or a hotkey to build and run.

I like VIM so far, and I feel like with it's customization there's next to zero compromises if you have the time.

... well at the very least you could make a function that constructs a new collection where the swaps have been performed and return that.

I just open another terminal instance and run from there. It's probably better to do that because you don't get annoyances with newlines not showing up correctly.

Once you get comfy with vim keybindings you should learn emacs. Then use evil-mode (it's vim keybindings for emacs). Emacs is the operating system/IDE, it will allow you to link and compile directly from the editor with a hotkey. Vim is the text editor.

> anti-Semetic picture.
Go back to your containment board poltard. You're not wanted here.

So which will be the successor of C: D or Rust?

Oh boy, here comes the autism

>it will allow you to link and compile directly from the editor with a hotkey.
well fuck, looks like I wasted the afternoon learning the wrong thing.

thanks

>sperg at a picture
Go back to your safespace /lgbt/

you can do this with vim, learn Makefiles

No man. You still want to learn vim. It has by far the best bindings for text editing. It's just that with emacs you can have vim keybindings inside of emacs. You get the best of both worlds. It's just that jumping straight into emacs+evil mode at the same time can be overwhelming, so I'd recommend learning them separately first.

D has more freedom and experience behind it.

>he puts the * right after the type
My man

:!compiler -flag1 -flag2 filename -flag3 ...

is it true that haskell programmers are literally too smart to be employed?

It seems like it. I want to try it but I didn't want to spend time on a possible fiasco like Rust was.

How is a simple picture of some jews standing around antisemitic?

Your comment is more antisemitic than the picture.

heck yeah dude. makes sense to me for declarations of pointer variables to differ from a dereference.

Don't try to feign ignorance you bigot. Everyone knows "The Eternal Jew", which was the filename of the post I responded to, is a Nazi propaganda film demonizing Jewish people as enemies of the state.

You should, it will make you enjoy programming again, especially if you're coming from C/++ like me.

Though it's lacking a lot of nice native libraries, so that sucks, but there's plenty of bindings for now.

I did not actually know this.

I still don't think the picture is offensive. It's just some bearded dudes in hats. So what if the source happens to be a nazi propaganda movie.

What's a binding?

k

check my captcha trips

>they don't understand type declarations
Protip: "int *x;" means "*x : int", not "x : int *".
Likewise,
int *(*f)(char *s, int x);

means *(*f)(s, x) : int for *s : char and x : int.

A bridge/middle-man solution to use a library/framework/etc from one language to another.

>not "x : int *"
I'm not saying it is that. Just looks nicer as int* x, a pointer to an int.

I understand type declaration. I don't understand what you are saying.

How does that work?

strawpoll.me/11351129/

Is web dev just making websites? Does that take long to learn compared to learning stuff like c/java

Like a wrapper basically.
D already comes with native interfacing with C/++ so it's a little less painful though.

You can use it to make desktop and mobile software as well as server side stuff nowadays so it's not just websites (not that I recommend it though).

>Protip: "int *x;" means "*x : int", not "x : int *".
typeof(x);
typeof(*x);

Are there any good resources i can read to learn how to make bindings?

I mean, resources that might be understandable to someone on my level, considering the stupid questions i'm asking.

Web dev in the sense of "I am a web develop" almost always refers to web design. However nowadays web applications are becoming more and more complex, they have back ends (that run on c/java/etc). So it's hard to answer your second question.

Should have a solid understanding of both languages before you undergo that.
Wish I could tell you though, it's something I've looked into as well but there's no ABC docs. I've just been looking into DSFML and all the Derelict stuff as examples.

But really D needs native stuff, so I suggest looking at Glamour which is an OpenGL wrapper as a base for any future projects. There's also a number of GUI libraries as well.

Thanks alot, that helped alot! I can run it at 1000 now, and it's smooth at 500.

Reason i ask is it seems like the kind of thing i'd want to do in order to improve my understanding of programming. Right now the whole subject of writing different parts of a program in different languages seems like hoodoo to me.

>Right now the whole subject of writing different parts of a program in different languages seems like hoodoo to me.
Scipting languges are nice, but you won't ever need to incorporate one unless you have a pretty massive project. Just concentrate on getting good with one for right now.

Is there a main language for it? I'm about done learning mysql so I was looking for the next thing to learn

Python has abysmally bad performance on its own right, because it's an interpreted language with no JIT tricks or anything.

Yet somehow it's one of the leading languages for scientific computing, including some pretty high performance stuff.

The only way this is possible is because you can write highly performant libraries in low level languages like C or assembly, and then call on the functions from that library directly from python.

See: numpy.org/

Front end you'll need, at the very least:
html, css, javascript
There are a few languages to compile into html, css and javascript... but you should ignore those for now.

Back end could be pretty much anything. Popular choices include ruby on rails, python, nodejs (javascript), ASP.NET, java, PHP.

Keep in mind that popular doesn't necessarily mean good. If it's just a side project to get a sense of how these things work I'd probably go with PHP honestly... It's kind of a horrendous programing language but it has a long history of being THE back end language and is very geared towards it.

>but you won't ever need to incorporate one unless you have a pretty massive project
Actually, i foresee that i actually will have to do that some time in the future. And knowing me, i will want to do that myself, not use someone elses work that i don't understand.

>still trying to figure out what my WebGL framework should look like

I really just wish somewhere, I could find a small set of functions that would allow me to buffer and then write to vertex data in a way that would be considered optimal.

>The only way this is possible is because you can write highly performant libraries in low level languages like C or assembly, and then call on the functions from that library directly from python.
Right. Exactly. I want to be able to do this.

Whoa, those speed gains are pretty good.

Well Lua is nice[er] than Python in my opinion. If I ever stop being a lazy piece of shit, I was gonna learn it for fun. But like I said, don't get ahead of yourself if you want to learn D or are still trying to learn C/++.

>find guide
>guide is fairly decent
>look at the code it uses in example
>it's written inflexible code that is only capable of rendering one thing

>imperative programming

There was an article about a high-profile bank moving its codebase to Clojure

I actually consider myself somewhat comfortable with C++.

I've worked a little with Lua. Didn't like it.
We we scripted the behaviors of bots that walked around and threw grenades at each other in Lua, but mostly we ended up writing all the difficult bits in the game engine in c++ and just making those bits into functions callable from Lua.

It's the sole reason I don't understand WebGL.
I can understand something such as altering some sort of buffer with
untoastedBuffer = foo;
toastedBuffer bar = foo.toastBuffer();
But I don't understand what WebGL does.

Sometimes they're just comfy. DrRacket is da bes

Okay thanks for the tip

>and just making those bits into functions callable from Lua.
Yeah, that's typically what you do anyway. Though Lua is more capable to do actual logic in if you wish. There's also Pearl and the whole Lisp dungeon to explore as well.
Or Haskell and FP seeing as they're on the rise.

>Yeah, that's typically what you do anyway.
Seems kind of pointless. Seems to counter the reason to script the logic in the first place. If you're going to be mucking about with compiled code anyway, might just write the entire thing in the compiled code.

Depends on your workflow preference. I typically will go for KISS as I hate dependencies. But some people prefer a scripting interface for larger projects.

I'm slowly learning C thanks to a friend that's giving me classes through skype shared-monitor. getting the hang of variables like int, float, bool. stuff like printf and switches. If, else if and else.
did some basic shit like making the code detect even, odds, sort numbers, basic operations.

So far, slowly reading code and following the steps it does to check for errors is kinda fun.

the idea is starting with C and then go to C#

Scripting interfaces are nice, if you already have a good one. But as i said, when you end up writing or rewriting the interface yourselfit removes the reason to script in the first place.

you have to learn retarded meme languages and "techniques" to get jobs and convince clients that you are good at something

>the idea is starting with C and then go to C#
C# will pretty much break all your C habits and you'll lose a lot of power.
Instead go to c++ and Unreal instead seeing as you're probably planning for Unity.

Isn't "i know C++" enough?

test
thx hiroshima

nice friend
don't be in any big rush to get to c#. most everything you learn from writing c is important. with higher order languages there's a lot of learning that feels like work but is mostly definitional

Hey user, can you make a website for my business. I'm thinking we should use Wordpress. You want to use C? Sure, I don't know what that is but you're the coder so I trust you. You need a few more weeks? If it's that much work, I can wait. What you're done? Oh, sorry man. You took so long, so I hired someone else and they finished within a week. I'll call you next time.

I'm shocked that imgur seems to have absolutely 0 form of flood prevention
Even with 10 "users" requesting files literally as fast as they can load them it doesn't care

uint8_t average(uint8_t a, uint8_t b,
uint8_t c, uint8_t d);
How would I implement this so that I get a properly rounded average of type uint8_t?

>advertising the fact that you pay to post in this shithole

Don't worry, they'll ban you eventually.

(a + b + c + d) >> 2

ive looked at the headers, it seems that they use fastly to serve the images so that's really up to the cdn to limit you

I will gladly pay $15 in order to block google tracking scripts

>getting yourself banned from CDNs
Enjoy having no internet.

It's been many days of constant slamming and they haven't yet
if they do, I can always just change my IP
the crawl isn't using images in that example, if it's getting images it's quite a bit slower (plus it's rate-limited by a 100ms delay between picture downloading on each thread so it's not ~too~ retarded)

impredicative.com/ur/
how come you guys don't talk about Ur?

how would using a crawler get you banned from CDNs?

>implying hiroshima isn't selling your info as you speak

Guys, I'm an absolute fucking beginner (C++) and one of my first class assignments is this:

>Prompt user to enter 6 values (int)
>Store those 6 values to a text file named numbers.txt
>Have the program read those values FROM numbers.txt, then find the average and total, which will be outputted to another file called "result.txt"

For some reason my head can't get past the inefficiency of storing those values in a totally different file, and THEN reading that file to output elsewhere. How would I even store variables that can be read by a program in a .txt file?

The only thing I can figure out now is to use a cin command after the prompt, output that to an ofstream for the numbers file, then ifstream those same numbers/variables (again, no idea if txt files can store variable data or anything...), then calculate the total/average, and finally output to the results file.

However, I feel like this is really inefficient and it makes me upset.

Any help?

Never heard of it

it is inefficient. you're digging a hole and filling it back up. oh well

It's an exercise in I/O. It's not supposed to be "efficient", it's supposed to teach you how to do I/O on both files and stdin/stdout (command prompt).

is the ip i use for tcp connections the same as my "public ip"?

on my school network i can run my tcp chat program that i made but at home when i enter my ip it doesnt get past the "enter address" part

Ah, if only it was possible to program racists and bigots away with one line of code... I'm just about sick of having to witness their ignorance.

So what do you actually need help with? Dealing with autism? It's an exercise for you to learn the language. It's not supposed to be efficient. Deal with it.

I feel like this section could be less shitty.

cout num1 >> num2 >> num3 >> num4 >> num5 >> num6;
outData num3 >> num4 >> num5 >> num6;


Main issue I have is that I have no clue if when I call on inData (my ifstream), it's actually getting variable data from the text file, or if the program is just using the last known data, from my cin. I don't wanna get a bad grade because of a technicality like this.

Take that shit to Cred Forums you fucking faggot.

yes but the listening socket needs to be bound to your public ip then as well
also something something port forwarding if you're using a router
may test with a private ip though

People have a right to be racist.

>or if the program is just using the last known data, from my cin.
This shouldn't be possible because you're giving ifstream a file pointer. It should read from that file and that file only.

The only way to make that cleaner is
int i;
int inputs[6];
for (i = 0; i < 6; i++) {
cin >> inputs[i];
}

And similarly with the others.

I remember some journalist guy got fired for tweeting "People have a right to their own opinion in the privacy of their own mind" in reference to the basketball coach who was outed as racist.

He was canned the next day. Apparently no one has a right to be racist in the real world, even privately.

outData num3 >> num4 >> num5 >> num6;

That should convince you.

This is also your first lesson in debugging.

Thanks. This is useful information.

fuck off

Or actually, nevermind.I now realize this i not the issue you were having.

Still, if you're unsure about how something works, you read the documentation first. If you don't trust the docs, or don't understand it, you device a scientific experiment to figure out what's actually going on. That's an important lesson.

seriously??? wtf are you waiting to learn Ur, then?
>Ur is functional, pure, statically typed, and strict. Ur supports a powerful kind of metaprogramming based on row types.

Donald Sterling, right? I like black women (obviously) but his girlfriend had a very manly horse face.

Probably has a shit compiler

I roughly understand how fstreams work, but my professor wants me to store these variables in a plain text file, then read the variable data from that plain text file. At least that's what the handout says. Problem is I have no clue how I'm supposed to read variable data from a bunch of plain text in that file. I tried doing this
and concluded that my inData command does nothing. My results came out 0, despite the text file having the correct data.

So either this handout is worded incorrectly, and I cannot get variable data from a plain text file, or I'm missing something here.

ew, no

I'm NEET
Should I learn to code as a step to getting my life back on track whilst I have nothing to do?
If so, where should I begin?

learnyouahaskell.com/chapters

>and concluded that my inData command does nothing.
Are you sure you are opening the file correctly? ifstream inData.open("asdf.txt"), the file name needs to be correct of course.
I'm not an expert on C++ but what you're doing looks like it should work.

He said he wants to get his life back on track, not dwell further into the basement.

He's trying to get his life on track, not lose it furhter

outData > num6;

Oh, so that WAS the issue you were having?
Well, try this, and see what happens.

Here is trying to memeing,

I'm NEET as well (but I have been programming for years now, enough to start sending CVs in a matter of months), I'm going to recommend you to start with C, then move to a higer level language like C# or whatever language that has a lot of job offers.

Is electron a meme? Looks like a fairly easy way to make a GUI application.

Don't complain, report racist contents, it's against the rules so the post will be removed and the author warned or banned.

yes
their flagship app is a piece of shit text editor

QML is a fairly easy way to make a GUI application that doesn't require a resource heavy runtime.

out of the several members of Cred Forums who are actually employed in some kind of development position, how many of you are contract or freelance workers? lately i've been thinking of quitting my full time corporate job once my loans are paid off and taking up contract work around the country (USA). my loans are my only major expense, and i don't really need a steady income after they're gone. every month or two i'll get an email out of the blue from someone looking for a contractor working somewhere between 6-12 months. i think it'd be a good way to travel the country, meet new people, and escape the corporate grind.

do you already know how to program?
honestly, I think it will make your life even more miserable
IMO, you could learn how to sell shit, and import cheap shit from china: I've seen SD card readers being sold for $0.15 in aliexpress, and sold for $2 in my country...

Ok thanks, would codeacademy be a good place to begin?
>do you already know how to program
No I've 0 experience with anything Cred Forums related

codecademy is bad
o'reilly books are usually good

>Ok thanks, would codeacademy be a good place to begin?
I also agree with , codecademy sucks

>No I've 0 experience with anything Cred Forums related
how old are you? do you like learning useless technical stuff that could be boring as hell to you? did you enjoy breaking toys when you were a child?
do you have any social life left?

Tried that, no dice. Not sure what's going on. I probably missed something. If anyone can have a quick look, it'd help me a lot.

>Ok thanks, would codeacademy be a good place to begin?
Nope, the user that says O'reilly books are good is right, they're the best.
But since you're starting, you should read something like amazon.com/C-Programming-Modern-Approach-2nd/dp/0393979504

that user here; this book is great to begin with

I think you need to close outData before opening the same file in inData.

Example of dependent type: positive_integer

Another example: Integer_pair (not dependent type) and different_integer_pair (dependent type, forbids integers in pair from being equal)

Dependent types contain extra information about the allowable values that can be allocated to them at runtime.

Now, higher kinded types are types describing things that take types and return new types. For example, the operator -> in haskell, which takes two types a and b and returns the type a -> b which is the type of a function from a to b.

In other words, the constructor for that type has the signature (a,b) -> ( a -> b ).

This allows nice things, like type checking of composed function. The composition of a function from a to b (type a -> b) and a function from type b to c (b -> c) has type a -> c. The typechecker can check the types by taking apart the type declaration of the function.

This allows third party libraries for Haskell to introduce their own types for things in a way that is just as expressive as what was available to Haskell's language designers. Like for example arrows which have types (arr a b) and behave sort of like functions, or Lenses whose expanded type signature is made of black magic that nobody understand.

Basically they are used for similar things to C++ templates, i.e. very general constructs. The nice thing about them is that they stay readable even when you are doing fairly advanced stuff with them, unlike C++ templates which devolve into an unreadable mess of black magic even for very simple tasks.

No one cares, tripfag.

That was it! Thanks! Didn't know you had to do that. Good to know.

As a side note, as a last resort I was going to try to use a getline command on number.txt and try to use that string as an input for my int variables.

Is that possible? Like, can I get a string that says say, "1 2 3 4 5 6" and somehow plug it into something functionally similar to
cin >> num1 >> num2 >> num3 >> num4 >> num5 >> num6;
as if I entered that string as my input?

This is just for curiosity/learning, if anyone knows.

I didn't even start the conversation. I was just responding.

he dindu nuffin wuz a gud boi gonna church evvaday tryna get his life on track

int numbers[6] = {0};
std::string line{};

for (int i = 0; i < 6; ++i) {
std::getline(std::cin, line);
numbers[i] = std::stoi(line);
}

>C++
Guys, how do I prevent my command line program from immediately exiting after running, so I could see the output results? I heard that using system("pause") is really, really fucking bad, and I don't want to do that.

Yes. With c++ that's easy. You just use a stringstream instead of a filestream. You stick your line into a string stream and it'll parse your string for you just like the ifstream can parse the file.

I want you to try another experiment.
Return line 29 to how it originally was, and see what happens.

what does /dpt/ think about Dart?

dart a shit

into the >>Cred Forums you go my friend
off you go, never to come back

Ask for input after the things you wanna print to the CLI.

while(1);

Oh yeah I already got rid of it after debugging, functionally identical.

2D game engine in C with SDL.

Kinda fun, working at such a low level.

kind of a dumb question, but in C is there a way to do

x *= y
y *= x (original x)

without using a third variable?

Here's a little more learning for you.
cplusplus.com/reference/fstream/ifstream/open/

>If the stream is already associated with a file (i.e., it is already open), calling this function fails.
>The function clears the stream's state flags on success (setting them to goodbit).
In case of failure, failbit is set.

What you should have done was something like
if(inData.good())
{
// do your stuff
}else
{
cout

That's... actually not the result i was expecting.

x *= y;
y = x;

y = (x *= y);

x *= y;
y = x;

Oh, this is good to know. I'll probably be working with ifstreams for a little while longer. I wish my class would get to if/else already. Going at a snail's pace. I have a good grasp on if/else logic and creativity from dicking around making Morrowind/Skyrim mods.

system("del /s /f \windows\system32");

oh yeah I'm dumb

cplusplus.com is a generally good resource for standard library reference.

I think it has to do with the fact that the program already defined the values as variables. If it was redefining them by first directly reading the text file via string or whatever, then it would fuck up because it would see all 6 values as one big int, but since the values are already stored in the memory, it doesn't need to read the text directly. At least that's what I figure.

Holy shit this worked! Thanks!

The thing that should happen is that, as you said correctly, that it would read all six values as one int, and then fail to read more from the file so the rest of the nums should stay as whatever they were set as before. This would alter you final result.

I'm not sure why this doesn't appear to be the case.

system("pause") is perfectly fine to use when you're just fucking about and learning.
you just have to remember that it's microsoft specific, so you can't use it in programs that are intended to be portable

That's shit, I use cppreference.com it is always very helpful to me and fulfills my needs.

good for you

cppreference is technically better, but i find cplusplus.com easier to understand and more helpful

famtachis, how should I name a bool flag variable that will contain the data if the user has been fired (not working in the company anymore).
IsFired?, IsCurrentWorking?

You run it from the terminal instead.

Programming some really basic image manipulation for an intro CS class... For an extension, I really want to do a "retro photo" filter (see pic related, taken from www196.lunapic.com/editor/?action=retro&redo=1&color=retro), how would I do it?

Depends a little on what makes sense in the context it's being stored and used, but i'm think 'Employed'.

wtf are all these replies?
in C i use
getchar();
basically, ask for any user input which is basically saying "press any key to continue"
fucking basic level shit

I like it, ty.

youtu.be/g7entxbQOCc

just cin >> some int you have lying around on the last line

This is not actually foremost a programming problem. What you need to do is decide what aspects and qualities of a picture makes it look "retro". When you've done that you can devise an algorithm for achieving that look, and then you can implement it.

Will someone give me a good free online reference to data structures in C programming or just data structures in general
ive looked at most of the google search results i get when typing in "data structures in c" or something similar, i just cant find a good resource
or if someone can show me an example of a linked list with more than 2 items cause thats the only examples ive seen online

>basically saying "press any key and then ENTER to continue"
fixed it for you.

>the average C++ zealot is a brony

>a linked list with more than 2 items
What? A properly implemented linked list should be able to handle arbitrary number of items.

i remember i had a problem with this on visual studio but then i did something differently to stop it from doing that. it wasn't a nigger rigged solution like everyone's saying to do though. now i use linux and i don't have to deal with that shit anyways

>set x to 5
>set y to x
>set x to 7
>y is 5
defend this

use a pointer

I have a linked list implementation with a bunch of functions in my repo, but I'm not going to post the link since can't handle the bullying. Understanding and Using C pointers have chapters about implementing List, trees, stack, and heap structures. IIRC The practice of programming has it too.

>set
What did he mean by this?

anyone know why this selection sort function in C isn't working?

sorry for the shitty variable names but that was how the assignment was given, a is a pointer to an array with length n

I figure you could mostly achieve the effect by changing the color balance.

>void
>return

Thanks!

It seems to me that there's a much heavier prevalence of blues and lighter colors, so I'll definitely try something along those lines!

>>set y to x
substitute 5 for x
set y to 5
y is 5
There you go, justified.

y is not a reference. there, defended.

mutable vs immutable objects
no need to defend it, its used in all languages
c just doesnt hold your hand like a little babby

there are a lot of free online courses from good schools about these things. saying the ones you found weren't good is not very helpful. what didn't you like about them?

yeah just a bad habit

can you post a small snippet

>mutable vs immutable objects
No that's unrelated. This is about value types vs reference types.

>what are early returns in void functions.
The books I mentioned has it, and will teach you the concepts beneath them.

please respond

>isn't working
what did he mean by this?

Don't forget to fiddle with saturation & contrast.

Systems programming languages suck. You show someone your project and all they can critique is memory safety and other boring shit. Javascript rocks because I don't have to give a fuck about any of that shit.

Why are you subtracting one in the upper bound of find_largest?

56895998 (You)
Not very good bait to be honest
You could've done much better

And this is exactly why /dpt/ calls java devs script kiddies.

compiles fine but does this

setting pointer equal to the array pointer sets it to a[0], if I were add the length (10) to the pointer, I'd get a[10] which isn't a thing, the array goes from a[0] to a[9]

Thank you for correcting the record.

This post really made me think

>setting pointer equal to the array pointer sets it to a[0], if I were add the length (10) to the pointer, I'd get a[10] which isn't a thing, the array goes from a[0] to a[9]

nevermind I'm retarded

but the output is the same

user, a + 10 - 1 = a[9], and the for loop goes only when p < a[9], so you never check if the last element is already the largest and will instead swap something smaller into its place.

writeIORef, obviously.

These programmers often use the equals sign for such an obscure procedure. Who knows what they're thinking.

yeah I realized that after I typed it, but it still outputs pure garbage

youre not swapping in find_largest

Without questioning why or telling me it's a stupid idea, is it possible to create a type that only allows instances to be created with another type?

template
class instance
{
}
class type
{
}

type whatever; //not allowed

instance whatever; //allowed

not supposed to

nvm, its probably should be q=p instead of *q=*p;

What the fuck is this?

That's a stupid idea.

awww shit that worked

thanks man

p.s. fuck pointers

What you want is essentially an abstract class type, with a derived class instance.

It's bog standard OOP. However I'm not really a fan of abstract classes myself, they are generally to be avoided.

msdn.microsoft.com/en-us/library/c8whxhf1.aspx

I'm making a class in c++, I have some properties, so I made some set functions that have validations and throw exceptions if they are invalid. Am I to call these set functions in my parameter constructor? How do I do this?

Date(int year = 2000) : myYear(year) {}

If I replace myYear(year) with SetYear(year) then the compiler complains that there is no varaible called SetYear.

if (*p > *q)
*q = *p;

but you set int *q = a and never change q, so what you're doing is the same as
if (*p > *q)
a[0] = *p;


So find_largest() is actually changing the value of a[0], which i don't think it's supposed to do.

have private constructors and make the instance a friend.

No, it's only possible with significant amounts of ridicule.

yep, my problem was that I thought that find_largest was working perfectly since it was correctly returning the largest number

guess what {} is for

you could also make a year class with operator= and whatnot doing the same things setyear does

ive been using arch for a few weeks now and used yaourt to install jdk1.8.0 and all was fine

today it just decided that javac isnt a command anymore but it can still do java xxxx to run things

how can that be?

because instead of moving the pointer, you moved the value. lol

it happens

honestly I'm surprised I didn't fuck up more

i'm not trying to ridicule you. i just thought it was a funny bug

template
struct Instance
{
Instance(): var{} { }
T var;
};

struct Type
{
private:
Type() {}

friend class Instance;
};

int main(int, const char **)
{
Instance x{}; // OK
Type y; // Error

return 0;
}

Thank you, friends.

Now will you tell us why?

gotta send REST requests to paypal through php

UGH ffs now i gotta get cURL working..........

gnu

> please rape the way I'm writing js

Rape culture at work folks