[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - daily programming thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 19
File: Intro+to+Algorithms.png (264 KB, 560x629) Image search: [Google]
Intro+to+Algorithms.png
264 KB, 560x629
Does anyone have the instructor's manual to the 3rd edition of Intro to Algorithms?

old:
>>55395402
>>
>>55402595
1st for Go > *
>>
>>55402595
ftp://ftp.installgentoo.com/EBOOKS/Programming/
a:install
pw:parakeet
>>
>>55402637
1st for Go fuck yourself.
>>
>>55402652
lemme guess: you are a C++ dev.
>>
>>55402595
I've actually read the first 50 pages of that book it is pretty good at explaining the common patterns and algorithms in programming of sorting searching swapping and whatever else there is
>>
>>55402680
I use all the Cs (c, c++, c#), because C is for cancer and I don't want to live on this planet anymore.
>>
>>55402595
Nice mem
>>
>Cheese pizza RPG
>Chip8 emulator in rust
>Lack of understanding of programming
>Should I learn Python

Did I cover everything? Can we move onto something more productive like insulting one another?
>>
Can anyone save me.
Ive been trying all day but I cant figure out how to use the glfw callbacks properly.
Particularly
>glfwSetWindowSizeCallback
I want a member function of a class to run if the window is resized. But I cant figure out how to use this callback.
>>
>>55402641
Very cool. Thanks. The solutions are for 2nd edition though.
>>
>>55402803
http://bookzz.org/book/502892/6ad216
http://bookzz.org/book/951032/1b3cf1
>>
>>55402785
you forgot the constant hate on Java for 0 logical reasoning
>>
>>55402803
Nobody cares, fuck off, do your homework without cheating, suck a dick
>>
>>55402845
That's because Java is shit, Pajeet
>>
>>55402785
I've been learning Swift.
>>
>>55402864
No it's not you are giving 0 reasons and no real explanations to why it is.
>>
>>55402845
>0 reasoning
Have fun programming in Blub.
>>
>>55402852
>respecting homework
Not him but I'm confident that simply not learning algorithms and starting to write code for real projects would teach you more than learning algorithms. And that's all assuming the course is good. It's very rare to get good courses at university.

I think people should just have a small booklet which describes a large amount of algorithms and their complexity. Is there anyone who needs anything else?
>>
>>55402885
>Blub
>implying Paul Graham didn't invent that meme to take dumb autists like you out of the workforce
>>
>>55402785

>Showing the irrational aggression that truly stops these threads from ever being productive.
>>
>>55402882
Pajeet, you can't even express functors in Java, because it doesn't support abstracting over higher-kinder types.
>>
>>55402895
A programmer who learns algorithms and has no real projects learns less than a programmer who does real projects and doesn't learn algorithms. They both learn less than a programmer who learns algorithms and does real projects.
>>
>>55402895
Oh, I'm sure not learning any fundamentals or theory and instead jumping into writing code will let you make a fine mess of things.
>>
>>55402915
>Undervaluing yourself by working for others.
Paul Graham's advice isn't for people who look for jobs in programming.
>>
>>55402926
>functors
>>
>>55402957
Functors are useful things.
>>
>>55402930
>>55402944
a little yin, a little yang, boys. yin and yang.
>>
>>55402969
no
>>reddit
>>
>>55402930
Maybe read my post?
Learning algorithms is a waste if they're not really used.

Like linked lists, not to start that conversation again. But they're pointless, you should never have to learn them. I'm not saying people shouldn't know about them. I'm just saying that the kind of shit you're taught is a huge waste of time. Like most of you (i imagine) I've had to teach it, it's garbage. And it's difficult to ease the pain of the students.
>>55402944
It's true. Every newbie programmer is shit. We should teach people programming architecture in a nice way. And not the 'write UML diagrams for everything' kind of architecture. Something useful. It's hard to find that stuff. Most just have an intuition for programming well. That should be codified some way. It'd be nice to have a set of rules different programmers follow somewhere.

But all of that has very little to do with algorithms really.
>>
>>55402984
Do you even know what a functor is?
>>
>>55402990
As a computer science student who has taken algorithms, architecture, and programming. I still can't build anything useful. I learned more on my own googling stuff
>>
>>55402990
Yup, I'm basically restating what you said for retards to understand. I also only skimmed your post, but I don't see harm in restating it.
>>
>>55402990
I oppose any kind of coding rules because all the ones I've seen have been pointlessly obstructive in order to cater to the egos of lazy programmers who don't want to learn.
>>
Working on implementing a quadtree for collision detection, then a boid system for flocking AI. What have you done recently anon?
>>
>>55403001
Why not try building something useful. If leftpad can do it, so can you.
>>
>>55402990
>Most just have an intuition for programming well
i don't have an intuition. i read many books on theory, and learned it.

it's a skill, but at some point along the way it just becomes so ingrained that others misattribute it as some gay intrinsic factor
>>
>>55403015
shitpost endlessly on /dpt/
>>
>>55403015
I wrote an emulator in javascript.
>>
>>55403016
It's either way too hard or I need a team of 5 other guys
>>
>>55402852
I'm not in school. When I was, the end of chapter problems are how I learned. How am I going to know if I'm right and learned if I don't have the solutions?
>>
>>55403035
I wrote an emulator over a weekend. There should be something you can make.
>>
>>55402832
The manual is 2nd edition. Thanks though.
>>
Post yfw the coding standard you have to follow bans gotos
>>
>>55403015
made a simulator of my irl bf

 
int main() {
return 0;
}
>>
>>55403006
There's nuance though.
As your post was a reply to mine there's usually some extra input. And 'learning both' to me in that context would imply that there's formal learning of algorithms and code projects going on.
While I'm advocating you just know about algorithms on a very shallow level and then learn about them as you (think you) need them. Preferably you should know enough to determine.

>>55403010
Well. It's 'rules'. I'm sure you have them. I can't imagine coding without the 'rules'. It's about code structure and the exploratory part of programming that most programmers are missing.
>>55403001
I recommend watching maybe episode 1-27 of handmadehero.org
Skip where you feel appropriate (you don't need to see someone groan about winapi).
It's intended to teach how to program, not 'how to program this specific thing'.

I wish I had that when I was new. And even so I learned some things from it.
>>55403017
I'd call that intuition. There's nothing intrinsic about intuition. Intuition is learned.
Call it skill if you want. But skill is more about the ability to preform rather than the knowledge, to my mind. Doesn't matter. I think we're talking about the same thing.
>>55403061
Jesus fucking Christ anon SEARCH.
>>
>>55403079
>>
>>55403100
>he gives nothing in return
Aww ;3 poor anon.
>>
>>55403104
I have my own tastes in code structure and layout, which many people do not share. I do not want to be forced to conform to the coding style of the majority.
>>
>>55403153
Newbies would gain a lot from seeing stuff like that though. Usually they don't. They just see 'here's how you do OOP' and that's the first glance of a structure they get, and generally people like to have a structure I've noticed.

I'm not advocating some global standard. That'd be retarded and would obviously never work. We can't even agree on simpler things.
>>
>>55402595

Is this it?
http://panther.vos.cz/novaknihovna/new/books/Introduction_to_Algorithms_Cormen.pdf
>>
>>55403153

Then you're in the wrong field. There is almost always going to be a set of standard practices on whatever project you're working on. At least, outside of hobbyist and self started projects.
>>
>>55403190
My previous workplace gave me complete freedom in how I structured my code, as long as I could explain it.
>>
>>55403176
It would help if we stopped showing them OOP.
>>
>>55403079

Goto only really makes sense in C, and only in two areas -- error handling and escaping nested loops. The only time I have ever wished I had goto was when I was using a language custom built for teaching kernel development, which neither had goto nor anything resembling smart pointers to make error handling easier after encountering some sort of problem halfway through acquiring resources.
>>
>>55403245
Yeah but they need something else. So I suggested a catalog of programmers where they describe their styles.

Since it's such a political topic.
>>
>>55403055
no idea how to make an emulator

>>55403104
each video is an hour and a half long no thanks
>>
People use OOP to the T? I don't even do a lot of the design specifications half the time cause it's tedious to come up with all the seperation of concepts. I dont try to micromanage things into their own classes. I divide them by their core "graphics, audio, player" and thats usually enough for me. I use a hybrid of OOp and functional.
>>
>>55403123
it was more in the vein of him not existing
>>
>>55403259
>no thanks
>can't spend ~40 hours learning something important.
Well here's probably the most important takeaway:
https://hero.handmade.network/episode/game-architecture/day026
And maybe the following video (but that's more game specific).
>>
>>55403259
It's an example, you don't have to make one. There were a lot of resources that helped out when I searched "How to make an emulator".
What do you want to make that takes so long? Or is it under NDA? :^)
>>
>>55403283
//tfw no gf

More like that maybe.
>>
>>55403284
This is only helpful for learning how to make a video game for programming lol
>>
>>55403259

If you don't want to spend time and research you will never learn or improve. Literally all skills are a result of prolonged effort.

If you can't even spend a couple days watching videos / researching on how to do the things you don't currently have the knowledge for your patience and dedication is pitiful.
>>
>>55403306
I haven't seen it, but I assume it'd also be helpful for starting a programming project from scratch.
>>
>>55403306
No. I addressed that specifically. But it's very general information that's presented. And if you strip away the game specifics it's plainly obvious how you can translate these videos into non-games.

For instance there's videos on translating code into SIMD and what SIMD is. How to do a job system etc.
https://hero.handmade.network/episodes
Just search this and see.

Also it's interesting because games are very general projects in many ways. They're arbitrarily complex, they can cover everything (though it's unlikely they do). So it's not a complete loss to watch all of it.

Most programming can teach you about other cases. Because it's all about telling computers to do what you want.

>>55403364
Well once he's done with the basic prototype platform layer (day 25) it's really not about a from scratch project anymore. You could pick up GLFW and effectively have skipped that stuff.
>>
>>55403176
>>55403245
The previous generation of memers said it would help if we stopped showing them PL/I, Algol, Pascal, Ada, Fortran, etc. and how they do things.

They were trying to push their "functional programming" garbage down students' throats back then too.

If the replacement is so great, why do you have to hide alternative ideas from your students?

Why should I have any respect for someone who thinks denying their students information is an acceptable way to educate?

Before I started learning about CS history, I thought this kind of thing only happened with political topics in oppressive third-world countries.
>>
>>55403409
I'm saying there's no alternatives offered right now. And it's bad to show a paradigm like OOP to students first. They should learn procedural programming more imo because all else is special rules on top of that.
>I thought this only happened in politics
Why?
>>
>>55403409

Oppressive third-world countries -> Literally America, members of the UN, and others all do this... Is it perhaps a sign that the whole world is progressively become more oppressive?
>>
>>55403315
>>55403364
>>55403393
Teach me to get good the easy way
>>
>>55403464
Through smart and hard work.
>>
I REALLY wanna start learning C, but I am barely learning javascript. I am currently on OBJECTS. Should I wait until I learn python to jump into C? or SHould I yolo and go into C before/after finishing javascript?
>>
>>55403464
Where are you right now?
What is the most complex thing you've done?
What tends to stop you from doing what you want?
Have you tried to do what you want?
If you haven't why wouldn't you?
Do you lack knowledge of the terminology to search your way to answers?
>>
>>55403490
C doesn't really have any prerequisites. It was the first language I learned.
>>
>>55403464

There is no such thing as easy. You just use your brain and work hard.

The only easy way in life is a bullet to the brain or a quick dive off a sky scraper / bridge.
>>
>>55403490
C is simpler to understand than Javascript/python.

The reason C is 'hard' is because it doesn't hold your hand with garbage collection and such. Meaning your fuckups aren't something that solve themselves.

Learning C first isn't a bad idea at all.
>>
>>55403507
So is it okay for me to learn 2 or 3 languages at the same time? I wanna become a GOOD programmer(Software Developer), not a code monkey. Will that be just forcing it?
>>
>>55403524
idk. It might actually help you to realize that a lot of languages are really similar, but you might get confused with the differing syntax. If you want to be a good programmer, then just knowing lots of programs won't help you much. You should also know about different paradigms, algorithms, data structures and the why you do the things you do,
>>
>>55403578
That make sense, knowing lots of programs will just make a code monkey. I gotta THINK like a programmer first, I guess I will just keep practicing. Thanks anon.
>>
>>55403524
Maybe. I'd just focus on one at a time. Because I'd mix it up.
>>
File: 1463518061502.jpg (177 KB, 533x388) Image search: [Google]
1463518061502.jpg
177 KB, 533x388
First for Machine Learning is god-tier research. Anyone who thinks that it is a meme is a brainlet and a NEET.
>>
>>55403615
Just keep asking yourself if you're on the right path and you'll be fine. If you're having trouble figuring out, ask here or in other places. If someone calls you a Pajeet, you might be a monkey.
>>
>>55403659
>being this insecure
You're basically an excel monkey
>>
>>55403796
>ignoring the algorithms developed in this field and for the sake of it
>ignoring all the libraries made in several programming languages
>unironically being this stupid
go back to your memeskell fizzbuzz, faggot
>>
>>55403796
this is what mathlets actually believe
>>>/g/wd
>>
>>55403796
Now I'm curious if anyone has done machine learning or neural nets on Excel. would be pretty meme-y.
>>
>>55403859
>>55403878
>muh perceptrons
>>
>>55403908
>muh one-liners
>>
>>55403925
>muh meme technology
Hey, remember Ruby? Machine learning is the new that.
>>
>>55403853
I don't know much about C++, but I learned this some time ago, guess this is it: http://en.cppreference.com/w/cpp/language/initializer_list
tl;dr: (IIUC): initialize i to i_ (i_ is passed thought the function)
>>
>>55403908

Why is it that people come up with algorithms and give them absurd names?
>>
>>55404036
It was named in 1957.
>>
Can I have a decent life if I learn to program?
I dont study CS or nothing tech related, Im just learning a programing language since two months.
My mind will not collapse for so many hours of coding per day?
Respond to me realistically.
>>
>>55404051

That doesn't really make a difference.
>>
>>55404090
Only if you're enjoying it.
>>
>>55404094
And I don't really see an issue with the name. Can you suggest a better one?
>>
>>55404120
>Can you suggest a better one?

No.
>>
>>55404105
Yeah is fun but I dont know if it will be fun for my brain after working a 8 hrs job for more than a month..
Do I have to work for a corporation sucking the dickS boss like a wage slave or I can become independent in the future?
>>
>>55404213

Sucking corporate dick isn't a programming specific thing.. Truthfully participation in the monetary system isn't a absolutely necessary thing. You always have the option of living as a homeless vagabond or finding a secluded area no one lives and setting up shelter. It can be a enjoyable life.

Then again I may or may not have been recently exposed to hallucinogens.
>>
>>55404250
Wut?
>>
>>55404273

The answer is a firm maybe. If you get lucky you might be able to go solo and get funding for a successful project or hit the jackpot.
>>
>>55403659
>brainlet
Is it just me or is there some kind of group of shitposters who aim to make certain terms a thing?
We've always called people luddites or morons. Why would brainlet suddenly be appropriate? Is this some /r9k/ virgin who wants to hang out with /dpt/ in hopes he'd actually learn something?
It doesn't work like that.
>>
>>55404316
Cool
But.. can I wageslave myself for 2 or 3 years to gain experience and then live working on projects from my badement without a boss?
>>
>>55404386
I mean having a decent pay doing freelance in the future?
>>
>>55404386

You could or you could try it and end up with no money what so ever. It really is up to motivation and chance.

Just make sure you blow the right people when you're a wage slave. Oh, and correcting the dmt deficiency most people suffer from helps also.
>>
I'm having a dunning-kruger induced breakdown at the moment. How does one create a program while taking for granted that their programming environment will work as intended? Like when you use a framework or a library, how do you *not* get distracted by "but how do they do ___" "does this work like I think it does" and when it doesn't work, and it's all broken and awful how do you just figure out how to use the thing the way they intended instead of trying to create your own half-measure that works the way you feel comfortable but doesn't actually work how do you accept abstractions when everything is hopelessly broken all of the time how do I fix my shit if everything has been done already what is the point why do people with computer science degrees think everything is just so easy it's just numbers bro but how does pixel actually get on the screen how do you just take that for granted how can you use something like angular or react without understanding and justifying every line? how come some C++ programs have thousands upon thousands of warning messages when you compile them and the compile time takes forever and these are "real" programs made by "real" programmers from the 90's and sometimes compilation outright fails how is this even possible if everything is just so easy how do computers work how is pixel formmed how keypress make programme it's impossible for one person to have all the answers but yet most programmers seem to work in total isolation I just don't understand anything anymore I hope this is less than 2000 characters
>>
>>55404422
nigga what
>>
>>55404422
woah
9/10
>>
>>55402926
Ocaml functors aren't Haskell functors
Really need better names kek
>>
>>55404422
If you're worried about your programs being portable, JS isn't much of an issue.
>>
>>55404422
the answer to all of your issues is
>read the documentation
>>
>>55404422
C, C++ are notorious for ignoring warning messages from gcc

Program might even break if you fix one of them
>>
>>55402990
I find linked lists good at teaching thinking with pointers in an intro C course, but no more.
>>
>>55404410
I dont want to suck dicks it was just a jocke but..
Can you explain it to me?
I thought that skilled programers could pick a job from their basement doing freelance...
Is it not reduitable enough to pay rent and food? Or live decently?
>>
>>55404508
Any structure that uses pointers is good at that. Linked list is probably the simplest example though.
>>
>>55404508
As long as you use a pointer to a pointer to remove an entry off the list as Linus suggests.
>>
>>55404525
If you're good you can get about $100/hr usd freelancing

you're supposed to get more money freelancing than you would at a "real" job, because your employer also pays for your insurance, sick pay, vacation pay, etc which you don't get as a freelancer
>>
>>55404534
Post it again.
>>
What the fuck do you do in this thread?
Expleain please
>>
>>55404556
You post programming questions, or you post about your current programming project like this is your personal blog.
>>
>>55404556
Talk about programming, ask questions about programming, show what you've been working on, crossdressing.
>>
File: 1466564056907.gif (182 KB, 250x273) Image search: [Google]
1466564056907.gif
182 KB, 250x273
>>55404556
post anime
>>
>>55404563
>your current programming projects
So nobody have a real job here?
>>
>>55404422

This is totally normal, and it's a result of garbage documentation.
>>
>>55404556
you brag about how elite you are
>>
>>55404574
Where do you think you are?
>>
>>55404574
The thing about programming is, it's so great that we choose to do it at work and also at home as a hobby.
Pretty neat, huh?
>>
Are there any resources for learning algorithms or data structures that take a project-oriented method?
>>
>>55404422
Programmers write programs for computers. Not for the language itself.

As for most of those questions it's solved by saying that your OS is the barrier that protects you from all those questions. Your program is correct as long as you rely on the OS to work as documented. You don't need to know all about how pixels are operated on. You just need to put an array of color values in the right place.
>>
>>55404556

Average two (2) integers.
>>
>>55404591
Really?
But what the fuck do you do?
Apps to put then in google play and make money?
Video games?
What?
Do you make some money publishing apps in the google play store?
>>
>>55404599
You mean you'd want to learn about a datastructure by having some arbitrary project assignment they set up for you? Or is this about that discussion that was had earlier in the thread. If the latter then don't. Ask /dpt/ about what datastructures you should know and where to learn about basic characteristics of them and when to use them. Then go write something, anything you want and ask yourself if you should be using some other datastructure right now. If you can't answer ask /dpt/.

Also replace /dpt/ with some good programming source. Maybe a forum or someone you respect.
>>
>>55404626
>You mean you'd want to learn about a datastructure by having some arbitrary project assignment they set up for you?
Yes.
Simply reading about basic ones and how they work isn't interesting, nor is watching/listening to someone speak about how they work.
>>
>>55404556
*in C

we also talk about murrican politics, and show how ignorant we are about politics in general.
>>
>>55404655
What % of /dpt/ posters work and have a decent life programming?
>>
>>55404623
>But what the fuck do you do?
we expand our knowledge by reading some material and then trying out the new information for ourselves
sometimes this means trying a new language or paradigm (like the language haskell and the functional paradigm)
sometimes it means trying out a new algorithm
sometimes it means learning about 3d rendering
and so on

>Apps to put then in google play and make money?
>Do you make some money publishing apps in the google play store?
no, you go to work if you want to make money
this is hobby programming
>>
>>55404679
i work as a webdev
it drains your soul, but the pay is good and workmates are fun so it aint too bad
>>
>>55404623
>Do you make some money publishing apps in the google play store?
Nobody makes money that way. Not where living expenses is above 1000$ a month anyhow (see "first world countries").
>but what do you do
Personally I tutor people for free because I care about programming. I also help a small independent videogame studio. They're really just two guys who know jack shit

>>55404637
Maybe this is good enough for you, il give you an assignment. Do the following assignment using a binary tree structure.
http://aleph0.clarku.edu/~djoyce/cs170/concordanceasmt.html

Basically most programming books have this sort of stuff.
See:
https://people.cs.vt.edu/shaffer/Book/C++3e20100119.pdf
On page 159 (not the PDF numbering, the actual page 159) they start explaning binary trees and all their properties. At 206 they have exercises, either the theoretical kind (5.1) or the practical kind (5.6).

I'm not entirely sure what you want still. It's very unlikely for you to learn how to write a binary tree without having it explained to you in some way. Maybe you'd rather just read an implementation?
>>
>>55404679
if I had to guess, I'd say around 30% of the people here program for work
>>
>>55404706
Point to posts of people who you think work.
>>
>>55404696
I suppose something like opening with a problem statement, then going on to design a data structure to handle said problem, an analysis of the data structure, and finishing with an implementation would be something close to what I want.
>>
>>55404711
>>55404568
>>
>>55404711
when I said "here" I meant
>people who frequent this general
not
>people in this specific thread
>>
>>55404712
That would be really sweet. Generally that's not how these are made though. And really any attempt at doing that would be rather disingenuous. It'd be a person pretending to figure it out. I don't think you're gonna find that honestly.
>>55404721
Actually think so too. I think this person and maybe 1 other person actually works in non-/wdg/ programming.
>>55404730
Do you think there's anyone currently posting who works?
>9AM europe
Probably not.
>>
>>55404740
Surely making simple projects for students to do/learn from would not be considered disingenuous.
>>
This thread really needs a nice dosage of dmt. It's proven to outright kill depression (0.05 mg/kg or so daily.. Large dosages == Going to space)

Anyway, any recommendations for good libraries to check out for rust?
>>
>>55404740
>Do you think there's anyone currently posting who works?
Yeah, because I do.
Freelance, so I work whenever I want as long as I put in the hours.
I find night time is the best time to work because everyone else is sleeping and there are no distractions
>>
>>55404696
>>55404693
Why it is soul crushing?
>>55404690
B-but guys, I dont have time to learn a hobby.

Maybe in the future I hope to have time for a hobby but now I have to decide if I will spend time learning to program to gain money to survive in the future.
I kind of like it but Im not really sure yet because the money part..
If you know to program why dont you pick a freelance project to earn money?
Are you all richfags or what?
>>
>>55404750
My point is that if you were to make up a realistic problem, pretend to do exploratory programming (here's where it's gonna be hard to do) and conclude by having invented the datastructure.

That's really difficult to do well. It's 'disingenuous' because the entire exploration process is really just planned essentially.
>>
>>55404761
Can you live freelancing or it is just a shitty pay?
>>
>>55404773
Very few introductory level books contain "realistic" problems though.
And certainly if these data structures are worth learning, they ought to have some merit or measure of worth in realistic applications.
>>
>>55403153
t.code artisan
>>
>>55404730
>>55404711
Im not that guy
>>
>>55404785
it's up to you to sell yourself
you can try to compete with the russians and indians online for $3/hr
or you can sell yourself as a professional for $80-100 an hour
or anywhere in between that you feel is fair
>>
I'm trying to learn to properly work with C++ fstreams, again. I don't understand what its problem is, or the fundamental misunderstanding I've got here.

I managed to make a uint8_t array of 8 elements and read 8 bytes into it. Now I want to read 4 bytes into a 4 byte integer, but can't. an_fstream.read(var, 4) fails, blah blah blah can't convert from char*. So why? Why is it so hard to take bytes from disk and put them into a serial cluster of sectors of memory, that the compiler then interprets in accordance with the type you've declared it as? Everything it needs to know is already there, it would seem on the surface, so fucking do it.

Oh, and I can't get anything to work with std::array at all.
>>
>>55404772
>Why it is soul crushing?
My mom doesn't find it soul crushing. She works for a company GE recently acquired and the most displeased (I'm quite sure) she was was when she was project lead because there was just so incredibly much to do.
She goes to work happy every day and yesterday she built a network tap to debug an issue (hubs are hard to come by and she didn't want to mess with the system).

>>55404791
That's sort of the point I made earlier. It's very rare to have datastructures that are actually useful. A dynamic array implementation that is a block of memory that ends with a pointer to the next block is probably the most useful I can think of, that's technically a linked list.
Hashmaps are kinda OK. But they're for rather specific cases.

Anything else like a binary tree or any easy to search structure doesn't matter until you have rather major amounts of elements. And in that case there's likely very specialized data-structures to use.

Similar for sorting algorithms except you obviously have to pick one.
>>55404827
Are you forced to use this crap?
>>
Does anybody here like programming enough to just do it all day every day in your free time and be completely consumed by it?

Because I'm not finding that passion for programming and I don't know if I should be worried or not. I enjoy the results that programming can reap, I enjoy the rewarding feeling of solving a problem, and some days I find myself forgetting to eat because I'm so focused on a project, yet, the majority of my free days I just procrastinate instead of ever actually starting. It's strange, one half second I want to start programming and the other half of the second it feels like starting would be the most painful thing ever, and this continues for every second of the day for the whole day. I end up just wasting my whole day on 4chan.
>>
>>55404819

You forgot to mention the low $ / hour work is necessary to start building credibility. A good git hub page with varied *difficult* problems solved / contributions to oss helps also.

Oh and be ready a lot of the free lance work is web dev.
>>
>>55404819
>you can try to compete with the russians and indians online for $3/hr
Do i have to compete with them for the job?
Why seems like everyone in /g/ hate russians and indians who work for nothing?
>or you can sell yourself as a professional for $80-100 an hour
So it is more about marketing skills too?
So if i have say... 2 years of programing skills but I am not a "profesional with a degree" i can sell myself to do freelance?
>>
>>55404858
All of that sounds normal.
>>
>>55404847
>Are you forced to use this crap?
No. I figured it was the standard way to access files in C++, so it could have some redeeming features from at least some perspective. This naivety is beginning to fade.

I've rather write some shit to bitshift / bitwise AND everything into place than fuck around with this much more. I have very simple things that need to be done, and it should be simple to do them by now.
>>
>>55404858
It's fairly similar. It tends to help to have a lot of smaller goals.

But I can get pretty consumed by it. I get analysis paralysis sometimes though. That's generally what kills it for me.
>>
>>55404876
I don't think most people would blame you to just use the C standard library for reading files.
>>
>>55404894
This, don't use the overengineered shit ostreams are.
>>
>>55404863
That isn't true. I got a gig on my first day on elance (now merged with upwork) for $40/hour
yes, it's low for a programmer, but it's not that bad
>>55404866
>Do i have to compete with them for the job?
well they will always be there applying for the same jobs you are. If you want to compete at their pricepoint that's up to you.
>Why seems like everyone in /g/ hate russians and indians who work for nothing?
I don't. My clients wouldn't hire them so they don't impact me at all
>So it is more about marketing skills too?
yes, marketing has a lot to do with it. If you seem like shit, then clients will think you're not worth more than shit.
>So if i have say... 2 years of programing skills but I am not a "profesional with a degree" i can sell myself to do freelance?
none of that matters. If you want to sell yourself as a professional at $80/hr, then you can do that
if you want to sell yourself as an entry level programmer at $40/hr, you can do that too
>>
>>55404894
I just want to understand. This seems borderline unusuable for arbitrary access.
>>
>>55404922
Also people are like "data is data, I don't know what your problem is."

Yes, fucking obviously. I don't know what the problem with reading 4 bytes into a uint32_t is if "data is data".
>>
>>55404922
istream::read takes a char* as its buffer parameter, while you're trying to pass it an int.
>>
>>55404918
How many years of programing do you have?
Since the first time you started learning
>inb4 I have a phd in programing CS tech related enginnering
>>
>>55404949
with C++ you have to cast the data properly

the compiler is trying to help you, it just happens to be getting in the way
>>
>>55404967
started at age 11 writing macros for video games
now I'm 27
I did get a bachelors in comp sci, but I really didn't learn much "computer science" that I didn't already know
what I learned was 3 years worth of math that I've since forgotten
>>
>>55404330
I've seen brainlet used a lot in /sci/
>>
>>55404918
What kind of job or projects a freelancer do?
Explain as if I were a retard
What kind of task?
>>
literally crying right now because vs2015 is being a piece of shit and not wanting to compile main 4/5 times. Propably just gonna readd the source 1 file at a time but its bs.
>>
>>55404922
Don't try to understand it. The people who designed this stuff are insane. And not in the positive insane way. They live to masturbate over how complex they can make things.

Look at this
https://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C
At 0:29:25 he moves onto a slide that you might want to hear the conversation about. For context all he's doing here is that he's given a type, he doesn't know if it's the ham or the spam (in this case if it's an error message or if it's the expected value).
Just look at how they all react to the incredibly stupid code which has very unexpected behavior.

And on top of all this it's just to cram this construct into being an exception.

If you're not sitting at home fuming at this display you're not deep enough into C++ to have any need to understand it.

But if you want help go to some C++ specific forum. That's where these loons live.
>>55405003
/sci/ is /sci/ though. They're just there to have an narcissistic outlet.
>>
>>55405006
just go on to a freelance site like upwork and look around
everything you could imagine.
lots of website scraping type stuff
lots of mobile app jobs
lots and lots of webdev/database things

there's plenty of non-programming stuff too, like accounting, voice over work, editing, ghost writing, etc
>>
>>55405014
What's the error?
I've had something similar. I had a linker error appear randomly and IIRC it was because I had set my project to be an MT and not MTd (multithreaded, not multithreaded debug)
>>
>>55404988
So I will need to program for 10 years+ in order to gain money to live?
Im starting to get discoraged
How many years of work for a noobie to gain experience in order to do freelance?
Or at leat being employable in a job?
>>
>>55402722
this feeling resonates within me.

especially the 9 months last year I was maintaining a C project from the late 80s early 90s.
>>
>>55404966
>>55404972
This is the only functioning read I've managed thus far.

uint8_t test[8];
file.seekg(0, std::ios::beg);
file.read((char*)test, 8);

Why does this work? In what way does it lack the machinery to deal with how I'm going about it? Why won't it just do what I said and let the program segfault if something is wrong?
>>
>>55404988
>3 years worth of math that I've since forgotten
So math is just "to makes you think" in college and then you dont use it in real life unless you want to work in a bank?
>>
>>55405035
>How many years of work for a noobie to gain experience in order to do freelance?
I'm of the opinion that there are certain people who just can't into logic, and so will never be employable as a programmer no matter how much time they are given to learn.

Then there are those high functioning autist/genius types who could go from 0 to employable in a few weeks, because they have the capacity to figure things out on the spot and will learn on the job.

so only you can answer that question for yourself
>>
>>55405023
For better worse it's in my nature to relentlessly try to understand how something was generated, whether it be madness, degeneracy, or stupidity outright.

I'm watching what you linked. Have to be careful framing things the way I described above though, destructive habit better unlearned.
>>
>>55405036
Not him, but I make about $50/hr on average doing freelance work in my local area and I've been programming for about 4 years... It depends on where you live, if programmers are relatively rare in your city than you can get away with charging more because of supply and demand.
>>
>>55405105
>I'm watching what you linked.
It doesn't teach you anything. It's a guy explaining a system he made up to do error handling in C++ because the language sucks (but he doesn't think so).

The point wasn't for you to watch it. It was to have you understand how stupid it all is.

Focus on something else. Find something more useful to understand if you have to distract yourself from it.
>>
>>55405043
You always use uint8_t/char to read from files, only the size changes.
>>
>>55405111
Was meant for:
>>55405035
My bad <3
>>
>>55405071
no, a computer science degree is not meant to be a degree that prepares you for a job in programming

it's a mistake to think of each class in terms of how it will help you when programming
>>
File: D.jpg (42 KB, 512x512) Image search: [Google]
D.jpg
42 KB, 512x512
>>55405023
>andrei
upvoted
>>
>>55405141
Based Andrei.
>>
Does using...

reload(sys)
sys.setdefaultencoding('utf-8')


...is a bad thing in a Python 2 program?

I want everything working with utf-8 and it works fine, I see no problem using it but some people advise against it. Why?
>>
>>55405086
I think Im between those two :^)
>>
>>55405043
the code you post works
can you post the lines which demonstrate what you're trying to do but doesn't work?
>>
>>55405138
Oh I didnt know that..
>20 to 50 people want the same job than me
My god I have to compite with other people to earn money, it seems stressfull..
>>55405111
The problem is that I live in Argentina so shitty pay is guaranteed here
>>
>>55405122
At this point all the infrastructure for my project is functionally in place. Not being able to handle files is a decent blockade, have to figure if / how I'll rework things not to use fstreams.

>>55405126
Size as in number of bytes?

Also, the example I posted won't work without the (char*), which I don't understand at all. They're just clusters of ones and 0's. They're not signed or unsigned until they're viewed through a type, they're not even numbers. But it only reads them as signed otherwise.

Why not:
uint32_t x;
file.read(x, 4);


How would I work with this otherwise?
>>
File: 1462431345366.jpg (83 KB, 580x440) Image search: [Google]
1462431345366.jpg
83 KB, 580x440
Is there any pussle game or something to help with my "mental gymnastic" in order to develope logic to program?
Or it is only gained by practicing programing?
>>
>>55405249
>which I don't understand at all.
like I said before, that's just the C++ compiler trying to protect you from making a bad conversion

you have to cast things in C++ if you want to convert from one type to another (most of the time, some types have implicit conversions and don't need an explicit cast)

this is totally normal behavior
>>
>>55405169
The code works, but it's the only thing I've done that works. I don't really want (or know how) to read to some kind of buffer array then cast to another type.

I want to do something to read directly to a larger type, like uint32_t.
>>
File: 1463823113424.png (43 KB, 342x312) Image search: [Google]
1463823113424.png
43 KB, 342x312
>>55402595
Anyone use SAS statistics here?

I''m an SPSS user and looking for some good resources and/or books. Currently doing the SAS online tutorials to get to the grips with the interface and how it manages data.
>>
>>55405249
uint32_t* x;
file.read((uint8_t*)x, 4);
>>
File: 1465697230618.jpg (18 KB, 470x470) Image search: [Google]
1465697230618.jpg
18 KB, 470x470
Im the noobie of the thread and I have the feeling that now EVERY FUCKING BODY is learning to program...
How will this impact me in the near future?
>inb4 supply and demand
So my destiny will be to earn 10$ per hour in 2 years because will be a lot of new programers?
:^(
>>
>>55405272
I mean I don't understand what "(char*)" is doing, and why it allows reading to an unsigned array. Tried to make a reinterpret_cast work, but failed. Will have to read more about casts, all that matters is that it's done at compile time.

Superfluous explicit casts feel ugly though.
>>
>>55405321
Built-in arrays decay to pointers, even without the cast.
>>
>>55405308
Now this really doesn't make sense. uint32_t* isn't a 4 byte integer, it's a pointer meant to hold an address of one, so how / why would I read to it?
>>
>>55405319
would that really be so bad
>>
>>55405321
>test
is a pointer to uint8_t
>(char*)test
means this address is now considered a pointer to char

the first parameter of the read function is expecting a pointer to char
so it works
>>
>>55405319
99% of the newcomers are normalfags who will never actually learn
no sweat
>>
>>55405371
they're all python fags too, they can't actually program
>>
>>55405319
Only if you're a Pajeet-tier who can't rise above the rest
>>
>>55405362
Oh, I see. The addresses are calculated as offsets of the pointer to the start of the array.
>>
>>55405356
Yeah I accidentally copied and didn't remove the *
uint32_t x;
file.read((uint8_t*)x, 4);

Is what we want
Sorry for the confusion.
I don't see what's so hard to understand though.
>>
>>55405358
I dont understand
>>55405371
I hope so..
>>
>>55405319
The "everyone is learning to code" is a sham.
Everyone will know a hello world-type program by heart because they were forced to learn it, but out of 20 people that know that, perhaps one will pursue a career in programming, and even then, that very person probably could do fizzbuzz-tier stuff beforehand.
>>
>>55405399
Face it, there are billions of us fuckers on the planet, you'll either have to get good or accept mediocrity, no matter the playing field.
>>
>>55405389
>Pajeet-tier
Hate this meme, it was invented by Java fags in an attempt to disassociate Java from India
>>
>>55405389
>Pajeet
Kek I read a lot this in /g/ but I dont know what it means
>>
>>55405423
It's an Indian name
It's a joke about Java programmers
>>
File: front and center.jpg (14 KB, 326x237) Image search: [Google]
front and center.jpg
14 KB, 326x237
>>55405423
Indian strawman name.
>>
>>55405409
>Face it
Eassy to say when you already have 67 years of experience programing in 2016
But yeah
>>
>>55405451
>programmers in 1949
Mathematicians don't get employed tho
>>
>>55405397
It doesn't compile in the context I'm trying to use it (passing a variable by reference).

I'm very tired though. Feels like there's something obvious here and I just can't see it.
>>
>>55405469
If you want to read a value into an integer with C++ I/O streams why not just:

std::ifstream f{"file.txt"};
int x;
f >> x;
>>
Well guys thanks for all your help
I will come in two years to ask you what is a variable and how to print hello world, wish me luck
See you soon
>>
>>55405484
Won't this stop on null / newline characters? I vaguely recall reading that it wouldn't just fill a type and stop, and would drop certain characters unless you tell it otherwise.

The test case I'm reading in here is 0,0,8,32. Some files could contain things misinterpreted if it's treated as formatted.
>>
>>55405249
>why not <code snippet>
Because that's how the type system works. Use a dynamic typed language if you want to ignore variable types when using them.
>>
>>55405640
You're responding to my question, but you aren't answering it. I'm not trying to "ignore" anything, I'm trying to get something to work or at least figure out how to cast properly.

eg, doing what I posted with (uint8_t*) doesn't compile, (char*) results in segfault, reinterpret_cast / static_cast won't compile but probably are my own fault.

I'm trying to play along but as yet it isn't working. Probably because there's some fundamental underlying assumption that's wrong or severely incomplete.
>>
File: example.png (12 KB, 470x249) Image search: [Google]
example.png
12 KB, 470x249
>>55405735
>(char*) results in segfault
no it doesn't, char* works
you must not have opened the file correctly

here I open the file a.txt and read 10 characters
I read those characters into an array of unsigned long
and as you can see it works just fine
>>
Hey I'm kind of new here, can somebody break my code and help me improve it.

Taking an introductory course of C++

http://cpp.sh/63oun

The biggest problem i'm having is the input validation for Integers, as well as numbers less than 0.

I appreciate any input
>>
>>55405829
although in the example I just gave it could segfault anyway because the length of the array is only 2
>>
Hey /g/ ,i need something that will teach me git.
Dont give me bullshit 1000 pages books that talk on general stuff like why would you need it,i want practical examples that cover most of the routines .
>>
>>55405867
>github.com
>create account
>they confront you with a Git Tutorial
>teaches almost every command in 10 minutes
>>
>>55405879
you not scamming me,senpai?
>>
>>55405896
no sir
>>
>>55405847
Put the menu into a separate function, and replace the switch statement with simple ifs.

Also don't use
using namespace std;
to prevent global namespace pollution.
>>
Writing a 3D cheese pizza MMORPG for WebGL
Is realistic 3d modelling like in those 3d cp webms going around on /b/ difficult guise? I've been stealing others models until now lel
>>
>>55405930
I love you.
>>
>>55405847
instead of 500 different cout, cins:

create one function called GetInput
the GetInput function should take as its only parameter the question you are asking the user

then the GetInput function outputs the question to the user and waits for input
it then checks the input to make sure it's not less than 0
if it is less than 0, it will loop and ask again for the input

now any place you need to get input from the user you just put GetInput instead
>>
>>55405829
Reading into an array works, yes. That's the only way I've managed to do... anything. I'm trying to read or cast into a 4 byte integer directly, because buffering and copying seems excessive and extremely unnecessary.

I'm getting really tired. I used to be very stubborn and relentless, if I couldn't understand or figure something out, I'd stay awake and obsess for days until I could brute force my way through or was incapable of continuing. I don't really care much anymore though. I'm pleasantly sleep deprived and listening to Halfaxa which is extremely relaxing.

Fuck it. Might just go to sleep. I've got other things to do than reverse engineer some mess that readily makes sense to someone somewhere, but not me. Thanks for all the help to anyone who responded, I'll read some more about casts and probably understand eventually.
>>
>>55405935
*gropes luscious ass* ily2 bae
>>
>>55405930
>been waiting for this post for 5 hours and 40 minutes
Thanks, I can finally go to sleep now.
>>
>2016
>still using C
template <typename T>
T getInput(const std::string& message = "") {
T result;
std::cout << message;
std::cin >> result;
return result;
}


getInput<std::string>("Please enter your name:\t")

getInput<int>("Please enter a number\n")
>>
>>55405971
Don't lock the door, night
>>
File: example.png (6 KB, 460x137) Image search: [Google]
example.png
6 KB, 460x137
>>55405957
that also works just fine
>>
>>55405982
>not perfect forwarding the arguments to string for maximum speed
>>
>>55406001
Perfect forwarding would not benefit in this scenario you fool
>>
>>55405940
That sounds super useful...

Mind sharing what that might look like by formatting?

getInput(double a)
{
cin >> a;
}
>>
>>55406011
see >>55405982
getInput<double>
>>
>>55406023
I'm not that advance yet....

im using namespace std for christs sake
>>
>>55406011
double GetInput(string question) 
{
double value = -1.0f;
while (value < 0.0f)
{
cout << question;
cin >> value;
}
return value;
}


and then you call it like this
GetInput("Enter a value greater than or equal to zero");
>>
>>55406009
Doesn't the parameter call its copy constructor when you call it with an rvalue instead of moving into it?
>>
>>55406043
Not if it's passed by const reference
>>
beautiful.

thanks...
>>
>>55405997
>&myInt
>&
Wow. It works, but is giving the wrong value. Probably something else wrong.

I thought it was already pretty clear that the int exists, has a beginning, has an end, but guess it needs to be made excessively clear. Ugh.

Thanks.
>>
>>55406086
you were segfaulting without the "&" because a char* to 0 is no good a'tall.
what comes after (char*) needs to be an address
&myInt means "address of" myInt

>but is giving the wrong value
you were probably expecting big endian
but ints are little endian
>>
>>55406119
I figured it was implicit, just like uint8_t x = 1 writes 0x01 to the address of x. Didn't think of how the read function worked internally.

The values are stored in the file as little endian. I'm reading 0,0,3,32, but it's coming out as 50331730. Should be 800. Too tired to figure it out.
>>
>>55406040
Thanks for your help, this was me
>>55406051

noticed I didnt give you any credit.
Thread replies: 255
Thread images: 19

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.