[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: 28
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old Thread: >>54514945

What are you working on /g/?
>>
>>54520933
I dunno anon, seems to be a ton of faggotry here
>>
>>54520944
this lol

why is it animeposters don't think they are mentally diseased?
>>
I'm going to make a CLI program that runs on Arch Linux and Windows 10 with the specific purpose of
-calculating production costs and profits for registered ships, ammunition, and modules in EVE Online
-Forecasting profit margins
-Scheduling shipping and production flows to various stations I plan on staging out of
-Scheduling and tracking Planetary Interaction output, and possible profitable applications for the output in production.

I'm going to write it in D.
>>
File: K&R watashi kininarimasu.jpg (475 KB, 852x973) Image search: [Google]
K&R watashi kininarimasu.jpg
475 KB, 852x973
Why aren't you using the C programming language to develop all your applications?
>>
>>54520957
>writing a script in a compiled static language
Disgusting.
>>
>>54520957
how exactly are you going to accomplish this?
I tried this in GTA V and it was hell, due to not having direct access to the pointers and being unable to simulate the network activity from the game programmatically (had to fake mouse movements in the end)
>>
>>54521007
functional languages are better
>>
>>54521007
I typically do. I sometimes write some simple shit in Bash though.
>>
File: 81b.jpg (33 KB, 500x500) Image search: [Google]
81b.jpg
33 KB, 500x500
>>54520933
>When I find out SDl 2.0 is zlib
>>
>>54521015
I'm not hacking the game or anything, I'm literally just tracking data and putting it through formulas. I may refactor it to use API data from EVE central but that sounds hard. Right now I'm just going to manually imput prices by storing them in a text file or something.
>>54521013
This is my first time using D so I figured it would be a good learning experience. Is there a language that would be better? I thought about trying Python, I've only used C#.
>>
eyed3 or mutagen?
>>
>>54521050
>FSF approved
>OSI approved
>GPL compatible
What's wrong with that?
>>
>>54520957
>>54521057
Sounds like it's basically just a calculator.
Why not save yourself a shitload of time and just write it in python or something?
>>
>>54521013
There's an awesome dynamically typed object library for C with only one type you really need, the type is called "PyObject *"
>>
>>54521072
>reccomending the meme snake
Don't do that shit, even in jest. That's just too far.
>>
>>54521072
Yeah I'm thinking thats a better choice. I also should learn Python so its also a learning experience.
>>
>>54521057
like least squares regressions?
the real problem is it only shows you obvious things, really. unless it's fully automated it's not worth inputting shit because it's so obvious the trends
>>
>>54521013
dynamic languages are officially a meme now
>>
>>54520957
Sounds like R would be the language of choice for something like that.
>>
>>54521086
ironic shitposting is still shitposting, anon.

>>54521090
python's easy as fuck, this should be the only real "learning" experience you need for it.

Shit's practically english
>>
>>54521109
>ironic
I'm not being ironic. Python is shit.
>>
how does python not even have match patterns
>>
>>54521060
>What's wrong with that?
Nothing, exactly the opposite. I'm currently sweating profusely over being able to do whatever the fuck I want with my SDL projects, including changing the SDL part itself, without having to worry about getting cucked by the FSF, and release the final product under whatever license I want.
>>
>>54521094
I'm not tracking market trends. I want to be able to set up my own very specific scripts for production outputs for shit thats basically only relevant to me. For example I have X minerals in this staging production station.

Using X I want to be able to find out how many of these specific fits I can produce (ship, ammunition, modules, ect) up to a maximum of 10 in each station I'm selling at on a lowsec boarder system, how many NPC meta 4 modules I have to buy and ship, the prospected profits of doing so, and then the left over minerals afterwords.
>>
>>54521129
you mean like regex?

>>54521165
oh I see yeah that's definitely doable
>>
>>54521192
it's like a switch statement on steroids
>>
>>54521129
>>54521192
python has regex tho
>>
Posted in wrong bread :
Rust is complaining that a variable does not live long enough. That variable is declared in main() it wants it to live after the program exits. We skynet now.
>>
>>54521245
not talking about regex
>>
>>54521273

I would suggest looking up exactly how lifetimes work in Rust before trying to do anything complex in the language. It's a bit more on your face about this shit than C++.
>>
File: w2bg5DU.gif (1 MB, 916x398) Image search: [Google]
w2bg5DU.gif
1 MB, 916x398
i learned c# and wpf while in school over the past 2 or so months by making an anime downloader with some file managing / series tracking features, it essentially just looks for the torrent off nyaa and downloads it into the directories but it's still helpful to me atleast
>>
>>54520933
What is wrong with this code? I will post the errors and the header files below.

 
// Fig. 11.9: fig11_09.cpp
// Testing class BasePlusCommissionEmployee.
#include <iostream>
#include <iomanip>
#include "BasePlusCommissionEmployee.h" // class definition
using namespace std;

int main()
{
// instantiate BasePlusCommissionEmployee object
BasePlusCommissionEmployee employee( "Bob", "Lewis", "333-33-3333", 5000, .04, 300 );

// set floating-point output formatting
cout << fixed << setprecision( 2 );

// get commission employee data
cout << "Employee information obtained by get functions: \n"
<< "\nFirst name is " << employee.getFirstName()
<< "\nLast name is " << employee.getLastName()
<< "\nSocial security number is "
<< employee.getSocialSecurityNumber()
<< "\nGross sales is " << employee.getGrossSales()
<< "\nCommission rate is " << employee.getCommissionRate()
<< "\nBase salary is " << employee.getBaseSalary() << endl;

employee.setBaseSalary( 1000 ); // set base salary

cout << "\nUpdated employee information output by print function: \n"
<< endl;
employee.print(); // display the new employee information

// display the employee's earnings
cout << "\n\nEmployee's earnings: $" << employee.earnings() << endl;
} // end main

// TODO - Add an object of CommissionEmployee
// Run the print method of CommissionEmployee
>>
>>54521415
||=== Build: Debug in Module 8 Quesiton 1 (compiler: GNU GCC Compiler) ===|
obj\Debug\prog30.o||In function `main':|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|11|undefined reference to `BasePlusCommissionEmployee::BasePlusCommissionEmployee(std::string const&, std::string const&, std::string const&, double, double, double)'|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|24|undefined reference to `BasePlusCommissionEmployee::getBaseSalary() const'|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|23|undefined reference to `CommissionEmployee::getCommissionRate() const'|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|22|undefined reference to `CommissionEmployee::getGrossSales() const'|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|21|undefined reference to `CommissionEmployee::getSocialSecurityNumber() const'|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|19|undefined reference to `CommissionEmployee::getLastName() const'|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|18|undefined reference to `CommissionEmployee::getFirstName() const'|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|26|undefined reference to `BasePlusCommissionEmployee::setBaseSalary(double)'|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|30|undefined reference to `BasePlusCommissionEmployee::print() const'|
C:\Users\Anon\Documents\CodeBlocksProjects\Module 8 Quesiton 1\prog30.cpp|33|undefined reference to `BasePlusCommissionEmployee::earnings() const'|
||error: ld returned 1 exit status|
||=== Build failed: 11 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
>>
>>54521415
#ifndef BASEPLUS_H
#define BASEPLUS_H

#include <string> // C++ standard string class
#include "CommissionEmployee.h" // CommissionEmployee class declaration

class BasePlusCommissionEmployee : public CommissionEmployee
{
public:
BasePlusCommissionEmployee( const std::string &, const std::string &,
const std::string &, double = 0.0, double = 0.0, double = 0.0 );

void setBaseSalary( double ); // set base salary
double getBaseSalary() const; // return base salary

double earnings() const; // calculate earnings
void print() const; // print BasePlusCommissionEmployee object
private:
double baseSalary; // base salary
}; // end class BasePlusCommissionEmployee

#endif

>>
>>54521415
You wrote it in C++.
>BasePlusCommissionEmployee
>.getSocialSecurityNumber etc.
Jesus christ. You really shouldn't drink the OOP coolaid.
>>
>>54521398
shit like this is the reason programming should be taught as part of the standardized school curriculum.

Everyone can find a use for programming even if its just making a shopping list application or a schoolwork tracker.
>>
>>54521450
#ifndef COMMISSION_H
#define COMMISSION_H

#include <string> // C++ standard string class

class CommissionEmployee
{
public:
CommissionEmployee( const std::string &, const std::string &,
const std::string &, double = 0.0, double = 0.0 );

void setFirstName( const std::string & ); // set first name
std::string getFirstName() const; // return first name

void setLastName( const std::string & ); // set last name
std::string getLastName() const; // return last name

void setSocialSecurityNumber( const std::string & ); // set SSN
std::string getSocialSecurityNumber() const; // return SSN

void setGrossSales( double ); // set gross sales amount
double getGrossSales() const; // return gross sales amount

void setCommissionRate( double ); // set commission rate (percentage)
double getCommissionRate() const; // return commission rate

double earnings() const; // calculate earnings
void print() const; // print CommissionEmployee object
protected:
std::string firstName;
std::string lastName;
std::string socialSecurityNumber;
double grossSales; // gross weekly sales

double commissionRate; // commission percentage
}; // end class CommissionEmployee

#endif
>>
>>54521451
>le OOP is bad meme

Java runs on like 4 billion devices.
>>
>>54521398
I made something similar. Mine is just a console application that checks RSS feeds and downloads torrents based on a simple regex match. I only made it because uTorrent 2.2.1 RSS downloader is broken.

Mine just downloads to a folder and uses the uTorrent "auto load" feature.
>>
>>54521475
Are you seriously saying that >>54521462, >>54521450 and >>54521415 aren't pure garbage?
>Java runs on like 4 billion devices.
So? Just because something is popular, it doesn't mean that it's good.
>>
>>54521415
>>54521428
>>54521450
Where the hell do you live? Because the semester is over where I live.
>>
>>54521498
I'm doing another semester.
>>
>>54521508
Edit: The semester is over and new one doesn't start until May 26th where I live.
>>
>>54521497

So where do you work Anon? I assume you are a high up at Google or Apple or something. You probably graduated at MIT at the top of your class right? I should totally listen to what you have to say about OOP even though Google and Oracle have built empires on it.

>>54521514

So?
>>
>>54521489
i essentially started off of something like that with a python script, but i also wanted to manage moving around watched files and or tracking stuff about the series as a reference later on (like if i wanted to add it on MAL or whatever), and sometimes i would have a ton of episodes and wanted to easily make a playlist to separate series so i dont watch the same twice, etc. etc. and found that too cumbersome to do through cleanly through a CLI (though that speaks more to my inexperience)
>>
Java is garbage tier language for babbies.

I only program in ANSI C and sometimes I open a lisp terminal and stare at it for a few seconds before closing it.
>>
>>54521563
Sarcastic comments like this are why I come back to /g/.
>>
>>54521525
>appeal to authority
Fuckwit.
Stop being a stupid cargo cult programmer. Don't add complexity that you don't need. Don't use a shitty methodology that doesn't fit your problem.
>>
>>54521583
>Stop being a stupid cargo cult programmer.

You probably use FP.
>>
>>54521583
Since you didn't counter with, "I have a job at X and I graduated from Y" I am going to assume you are an autistic NEET not worth talking to.
>>
>>54521608
I write procedural code that favours pure functions and minimisation of unnecessary state.
>>
>>54521576
I was being partially sarcastic but where I work right now they literally force us to use C89.
>>
Question: Is using os.system('curl [stuff]') bad practice?
>>
>>54521637
>not being an autistic neet

Fuck off normie.
>>
>>54521638

FP, but you don't want to say FP.
>>
>>54521608
Nice red herring tripnigger.

I'm pretty certain he'd say the same about pure FP given how he responded.
>>
>>54521398
Well this finally gave me an idea. Like an app that makes it easy to download anime while trying to keep older downloads alive by distributing seeders.
>>
>>54521648
What the fuck? Why are you using a 25 year old standard? Is your boss too stupid to add -lstd=c99 to the compilation flag list?
>>
>>54521683
not every target system has a mature compiler~
>>
>>54521525
>So?
My point is that it's an odd time for shitter skiddies like you to be posting your homework on /g/ begging for help.
>>
>>54521657
The way I program is a functional style, but is not pure FP.
FP actually has value. pOOP does not.
>>
>>54521737

Essentially, I just called you the fuck out. You OOP-shitter-shitters are literally all the same. Cookie cutter.

Not interesting in the least.
>>
>>54521737
I'm taking an OOP class next semester. It's part of my graduation requirements but it looks like pure garbage.
I looked at some power points and they talked about OOP as the wonderful invention that brought programming out of the stone age.
>>
>>54521753
Essentially, I just called you the fuck out. You OOP-shitters are literally all the same. Cookie cutter.

Not interesting in the least.
>>
>>54521763

I'm not an oop shitter anymore, I'm /RacketRocket/. Still, you were detected.

Try not to be a complete cockend in the future, and it won't be so easy.
>>
>>54521753

Essentially, I just called you the fuck out. You OOP-shitter-shitters-shitters are literally all the same. Cookie cutter.

Not interesting in the least.
>>
Reminder that DRY is the only principle that matters
>>
Oh lord, I've done a thing, now.
>>
i need a skirt wearing trap gf lads..
>>
only good thing that came out of OOP is interfaces, rest is shit
>>
>>54521762
I did an 'OOP paper' in university. Assuming that yours was anything like my one, it will be fucking terrible.
It was going on about """Design Patterns""" and other such atrocities, as well as bullshit like agile and scrum. Basically, it was "How to be a code monkey: the paper".
>>
>>54521789
got u covered senpai
pls be in straya
>>
>>54521802
minsk, belarus
>>
>>54521821
jesus lol
good luck finding a trap gf there
>>
>>54521800
It basically looks like that. They mention waterfall and UML. The only good part is that we'll be implementing Battleship throughout the semester.
The book is also 13 years old, and one project involves making an applet, because applets are relevant in current year.
>>
>>54521835
tfw
>>
>mfw my teacher who is teaching python doesn't really know it herself
>we have been using python 3.x but the quiz is graded using 2.x syntax

NICE
>>
Can anyone give me advice on whether its feasible to land pursue a programming career without a degree?

I'm in college for a medical field and i graduate next year, but i'd much rather be a programmer. I can't stop now its too late. But the past few days ive been doing simple shit in java and its been really enjoyable and I want to learn more.

I'm probably going to pursue it as a hobby at the very least. But can I turn it into a career or does my ass have to get back to school all over again?
>>
>>54522103
>Can anyone give me advice on whether its feasible to land pursue a programming career without a degree?

Sure

Make a bunch of projects that are portfolio-worthy
make a website
apply.
>>
>>54522117
Is the field really that accepting? I'd fucking love to do this shit for a living once I'm more experienced.

What kind of stuff should i focus on first? Sorry if thats a dumbfuck question
>>
Guys is it possible to land a job in software development even if I have a degree in it? I've heard 75% of software companies like Google are now only hiring HS grads without college degrees. If I apply at Google, is it illegal to lie and say I've never earned a degree? Please help.
>>
>>54522165
in companies staffed by young people? Yes, you can get away with no degree if you're competent and have proof (portfolio)
in big and stuffy corporate multinationals with clueless old people? yeah, you need degree, and 5 years experience
>>
File: 1462992993906.jpg (23 KB, 400x267) Image search: [Google]
1462992993906.jpg
23 KB, 400x267
>>54522165
are you making fun of me
>>
>>54522127
Well, projects tend to be a better litmus test that you're competent than a degree with no projects. A degree with projects, would perform better than no degree, but perform worse than someone with work experience.
>>
>>54522165
>I've heard 75% of software companies like Google are now only hiring HS grads without college degrees

where the hell did you hear that from?

I know google will hire people with no degrees but damn son those interviews would be hard as fuck for an 18 year old to deal with.
>>
>>54522194
My question wasn't whether or not i could get in WITHOUT a degree, it's whether I could get in WITH a degree. As in, can I get a job even if I DO have a degree.
>>54522196
I'm making fun of the emphasis some companies have on "HEY GAIZ WERE HIRING PEEPS WIT NO DEGREEZ N SHIET SO COME ON DOWN NIGGA!" to the point where it makes you wonder if you'd be better off claiming to have no degree. It's like applying for a job in disguise as a black guy so they hire you on Affirmative Action.
Also the shiiters who say that college is a complete waste of money when you can learn it for free. Learning it tends to be easier in a structured environment with an instructor for most people and even positions where a degree isn't essential it's still a bonus.
>>54522234
I didn't actually hear it anywhere. It was a shitpos- I mean satire.
>>
Can someone tell me why I cant open a file in my program.
I made some changes to a program and now suddenly it fails to open files. But I swear Ive gone back and reverted everything I was aware of and it still wont open the file.
I dont have the original source but I have the exe created and it works as intended so I dont understand what Im doing wrong.
>>
File: 1402946968443.jpg (6 KB, 250x250) Image search: [Google]
1402946968443.jpg
6 KB, 250x250
Working on some code challenges for another job.

Got a verbal offer for one not sure if I should take it. A variant of Assembly is their entire production code with a smattering of C/C++ and Java.

Their stack has some old stuff, and the average age of their workers is like 40 and their still doing the shit they got hired to do decades ago.

Not sure if I can parlay that into a new job since I have zero interest in the problems they solve. It's all bullshit travel finance stuff.
>>
>>54522350
Are you on Windows? What language was your program written in?
>>
What the fucking fuck is a malloc memory corruption error and how is it distinct from a segfault? I've never seen one before but have been getting them with a bit of code.

I've only seen segfaults, and can't find info about what a malloc memory corruption error is, other than it having a chance to crash my stack unlike what a segfault does.

If it helps it was happening in a part of an object being linked into a .so file that I'm compiling with -fPID. The bit of code causing it was very distant from malloc, or at least I think it was. No idea. -fPID might have changed that.
>>
>>54522457
Now I'm no expert, so I'm pretty much speculating ehre, but since malloc is a method of memory allocation, it's possible that the object was attempting to allocate memory in a similar low-level way as malloc does, and when it fails for whatever reason, the system throws a malloc memory corruption error because it thought you used malloc in the first place.
more deets, please?
>>
>>54522457
You probably overwrote the heap memory table.
You gotta be extra stupid to pull that off.
>>
>What are you working on /g/?
didn't feel like writing too much code today so I'm writing about computer science education (and Scheme :3)
>>
trying to think of an elegant way to parse arm instructions.
foo(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int):
str lr, [sp, #-4]!
add ip, sp, #8
ldmia ip, {ip, lr}
mla r0, lr, ip, r0
mla r2, r1, r2, r0
ldr r0, [sp, #4]
mla r0, r3, r0, r2
ldr pc, [sp], #4
foo():
stmfd sp!, {r4, r5, r6, r7, r8, r9, r10, fp, lr}
nop
ldmfd sp!, {r4, r5, r6, r7, r8, r9, r10, fp, pc}
main:
mov r0, #0
bx lr


should i just consume skip all white spice and consume "tokens" and use a bunch of "find-first-of"s?
There's gotta be someone's project on GIT that does this already
>>
Working on learning C++. I can't even print Hello World. Any tips?
>>
>>54522579
(define you "faggot")
>>
>>54522621
is there a semicolon after your "endl"??

I can't see it because your IDE colors are so shit, and this picture looks pretty potato.
>>
>>54522513
Yes, this is it.

He then tried to perform some operation on the heap and libc detected it/crapped out.
>>
>>54522621
this image is really low quality but it looks like you're missing a ";" there.
And it looks like its not resolving those symbols at all which makes me believe that you're missing the entire standard library in general.
>>
>>54522621
you're missing a couple of semicolons.

every statement ends in a semicolon:
cout << "I'm a fag" = bad,
cout << "I'm a fag"; = good

; does not go after } unless you're defining a class
; does not go after "#include <faggot" type things either
>>
>>54522621
tip: don't "using namespace std." just be verbose. google it for reasons why if you're curious.
>>
>>54522631
>>54522631
Thanks for that.
>>54522635
I believe there is, I'm not on that machine currently but if you're willing to give me some insight I don't mind switching to that machine.
>>
>>54522494
Stared at my code for a bit and thought about what I changed. I was dereferencing a struct exactly 1 offset out of bounds. Normally that causes SEGFAULTS, or at least I thought so?

>>54522513
Moar info about heap memory table please. Particularly how it's structured in PID stuff.
>>
>>54522662
Dereferencing and setting*
>>
Okay I'll switch machines after this adobe install is done. Cause I'd like to get at least 3 languages under my belt before graduating.
>>
in c++ is there a way of switching an ofstream to and ifstream
>>
>>54522662
Moar details:

Now the thing is, fixing that error isn't what stopped the malloc(): memory corruption.

I initialized all the structs in simpler code that didn't buffer overflow by 1 before the buggy initialization code, and that stopped the memory corruption error for some reason.

After I fixed the buggy code, I was able to delete the redundant initialization. Wtf C.
>>
>>54522726
there isn't no. But there is "fstream" which is both an "ofstream"(output file stream) and "ifstream"(input file stream) that lets you both read and write.
>>
>>54522726
>switching an ofstream to and ifstream
If you mean taking an ofstream object and converting it to an ifstream object, I don't think so. You can, however make an fstream object, which can be used for both reading from a file and writing to a file. Or you can read to an ifstream, initialize an ofstream with the variables set by the ifstream, and write with the ofstream.
>>
I am learning to program using old programming practice papers.
> Suppose that any combination of the letters A, B and C makes a valid word. How many anagrams are there of the word ABC (including the word ABC itself)?

I am thinking I want to make a list = ["a","b","c"] and iterate through 0 to 2 in every combination.

ABC
CAB
BCA
Mirrored of above:
CBA
BAC
ACB

How do I make it end the loop when all combinations have been found? My general idea of loops is that the end on a condition being true or false or on hitting a particular value, or reaching the end of a list.

I don't want solutions to this but some pointers for someone learning, I am using Python.
>>
>Get idea, "hey, I should make some console based game in C# for funzies!"
>Remember I have an algorithms assignment due Monday and a compilers assignment due a week from Friday, and any spare time I have should be spent on my research

I guess there's always summer :(
>>
Girls can code.
But only men can program.
>>
File: 1403220299266.gif (835 KB, 474x584) Image search: [Google]
1403220299266.gif
835 KB, 474x584
whats a good way to parse an arm instruction

as in the actual text of it like

>str lr, [sp, #-4]!

theres gotta be some article or blog post somewhere about C-parsing algorithms for tokenizing
>>
>>54523274
>algorithms assignment
explain?
>compilers assignment
sounds really advanced or really stupid depends on what your teacher wants. so care to explain?
>>
>>54523239
there is a mathematical equation for this.
>>
File: 1453366292880.jpg (26 KB, 379x378) Image search: [Google]
1453366292880.jpg
26 KB, 379x378
>>54523239
bruh, just use the combinations formula.
>>
>>54523393

>algorithms assignment
Some FFT shit. Should be able to get it done over the weekend

>compilers assignment
Have symbol table done, now have to set up an AST. Less difficult, but still annoying. Also, YACC is a whore.

>>54523381

Tokenizing/Scanning/Lexing are not the same thing as parsing.
>>
>>54523239
This is touched with a plan of attack in SICP, page 123, Section 2.2.3 Nested Mappings.
>>
>>54523239
Learn math, for this. statistics in general, and chance calculation. it will also improve your programming life if you do.
>>
File: 123.jpg (77 KB, 500x747) Image search: [Google]
123.jpg
77 KB, 500x747
If recv() and send() don't receive/send all of the data should I just keep trying until they do or should I treat it as an error?
Can somebody give an example of why recv would get less than the specified number of bytes that is also not a fatal error such as a network cable being unplugged?
>>
>>54523482
your router said, fuck it, i am not routing that. Or the message ends up lost in cyberspace, which does happen.
Never assume that you connection is flawless. There is even a chance of a byte changing in the process of sending or transporting. On old networks with copper cabling interference is something that you should take into account.
>>
>>54523482

>Can somebody give an example of why recv would get less than the specified number of bytes that is also not a fatal error such as a network cable being unplugged?

When you tell recv you want n bytes, you're telling it, "don't give me more than n bytes," not, "don't stop until you give me n bytes." If you have a buffer of 1024 bytes, and you want to read a message sent over the network like this:

ssize_t received = recv(sd, buf, 1024, 0);


Now say you receive the message "hello", perhaps including a null terminator. At this point, recv has copied all 5 (or 6) bytes out of its buffer. Is it going to wait around for more bytes? Fuck no it isn't. it's going to return that 5 (or 6), and call it a day. Now buf contains the message, and received contains the message length. The function has succeeded, doing exactly what it was supposed to do.
>>
>>54523515
Pretty sure TCP takes care of all of that.
The only thing recv doesn't guarantee is the data being received in one call, in which case you just keep calling recv until you've got all the data.
You only have to worry about that stuff if you're using UDP, and you probably shouldn't be using UDP unless you have a good reason to be.
>>
>>54523515
Doesn't UDP guarantee that data isn't corrupted? Or are sockets more low level than that?
>>
>>54523561
I believe recv() does block by default.
>>
>>54523607

That is correct. However it will block only until it has received at least one byte. Once it gets a message -- of any size, it returns, copying over up to the buffer size's number of bytes.
>>
is there a way to get the state of the mouse wheel from the windows API if you dont have access to the WndProc that handles messages?
>>
>>54523569
>UDP
>guarantee
anon...
>>
>>54524004
My understanding was the packets could be received multiple times, received out of order, or lost in the deepest hells of cyberspace, but if they arrived (no matter how many copies), they wouldn't be corrupted.
>>
>>54524018
that is correct.
>>
Why does my _sleep(int time) statement not work any more. It now produces an error. Did it just get outdated or something?
>>
>>54524060
yes, something
>>
>>54524060
>_sleep
Why aren't you using posix's sleep, usleep, or nanosleep?
>>
Can anyone help me come up with an idea? Basically I have to depth first search a graph in C. That's fine, but not all our test inputs have a single starting node. If there are multiple, we have to 'conceptually' add a node with edges to these 'starting nodes'. Any ideas of a good way to do this?
>>
>>54524159
I don't know. Because it worked so I left it.
Fixed it now though
>>
>>54524060
Why are you using sleep in the first place?
>>
>>54523381
>whats a good way to parse an arm instruction

Reading the manual of the ARM (dis)assembler whose output format you want to support. It will do the exact required parsing.
>>
>>54524248
Because it's for an engine for a game. If the game loops as fast as the computer can, it will play at different speeds based on the computer it's run on. So I'm standardizing it.
>>
>>54524260
christ, you dont use sleep to achieve that m8
>>
>>54524264
Well it works? So what's the problem
>>
>>54524260
>not having your game loop based on the amount of MHz
I suppose that works, but it's not really the way to go for a game loop. The logic shouldn't depend on the speed of the game loop. Look up some examples using a proper loop.
>>
>>54524260
Use nanosleep you nigger.
>>
>>54524287
Sounds complicated
I'll look up more efficient ways once my platformer wants to turn into skyrim
>>
>>54524280
>Well it works?
it most certainly does not
sleep is inaccurate as shit and only guarantees that you will sleep ATLEAST the specified amount, not EXACTLY the specified amount
google delta timed frames and implement it in your program, its not much work at all and will work much much better in the long run
>>
>>54524300
I'll give it a test with a 10 minute run time and time stamp it at either end to see the difference. If it's more than 5 seconds I'll listen to you and look up that shit.
>>
>>54524341
The game is jittery and nasty when you use multi-milisecond precision shit timers. My nanosecond timer 12 lines of code. It's not that fucking hard to stop using _sleep.

You don't need to bother with the delta timed frame shit if you don't drop frames, and using a decent timer/sleeper your frametime will be consistent.
>>
File: 1462813775816.jpg (51 KB, 640x480) Image search: [Google]
1462813775816.jpg
51 KB, 640x480
inb4 >>>/v/

Did someone play Human Resource Machine? Kind of a fun programming puzzle game. There's a torrent of it, 60 MB
>>
File: jeb waste.jpg (139 KB, 500x692) Image search: [Google]
jeb waste.jpg
139 KB, 500x692
>need to do heavy image analysis on Android app
>set it up so that my laptop acts as a WiFi hotspot, then the phone connects to it and streams the images using not-so-valid-HTTP posts
>Python server receives images, applies image analysis algorithm and live plots the data


so far so good


If the damn Android wouldn't run out of memory so fast. Fucking piece of shit Java that won't let me handle the memory management. How do Java babbies justify this again?
>hurr durrr it just werks let the JVM worry m8

It is clearly not up to the task
>>
>>54524408
>run out of memory

All the application does is

>Take one image every 1 second, receive it as a buffer from the camera callback
>Write data in buffer to image file on SD card (this takes less than 1 second)
>Start asynchronous transfer of image, reading from disk this time


The asynchronous transfers might queue up, but they don't need the buffer which clearly lingers despite being of no use after the file has been written.
>>
Why is /g/ so toxic? There's no point even coming to these threads when it's 40% arguments over the same shit, 40% beginners asking vaguely why their program wont compile and 20% FP circlejerking.

Here's a project suggestion. Generate a markov chain of all /dpt/ posts and see if it passes the Turing test. Protip: It will.
>>
>>54524444
Well, why don't you show us your awesome project.
>>
>>54524444
>I'm a retard
>>
>>54524454
*you're

>>54524467
I already knew you were.
>>
>>54524472
>let me prove it even further
>>
>>54524444
>Toxic
Suck on my fat, unwashed dick you baby raping donkey molester. I hope you get beheaded by ISIS and they rape your mother after mistaking her for a goat.
>>
>>54524501
You called your dick unwashed to insult someone else. That says a lot about you.
>>
File: mfww.jpg (95 KB, 746x930) Image search: [Google]
mfww.jpg
95 KB, 746x930
>>54524472
>*you're

you are an awesome project? wat
>>
>>54524512
Eat a bag of boiled baby wipes you cum gargling fudge stuffer.
>>
having the weirdest fucking bug right now
im trying to write a library for injecting dll's into game processes and hooking the some directx9 methods using virtual table detours

for some reason, when i try to create a dummy IDirect3DDevice9 to use for hooking, the CreateDevice method fails with error code D3DERR_INVALIDCALL if i try to call it the first thing i do in my program
but if i wait 100 milliseconds and try to run the exact same code it works flawlessly, reproducable across multiple games

any ideas?
>>
File: 0001[1].png (39 KB, 256x256) Image search: [Google]
0001[1].png
39 KB, 256x256
>http://glslsandbox.com

now, only to learn how to program.
>>
File: kot ghoul.png (2 MB, 1217x879) Image search: [Google]
kot ghoul.png
2 MB, 1217x879
>>54521273
Post the code, I will try to help you.
https://play.rust-lang.org/
Perhaps you don't understand scopes, borrowing and lifetime, which is not something shamefully, cause it is the biggest "innovation" of Rust if you compare with widespread languages and you need to stumble thousands of times over it to understand how it works.
>>
>>54521398
I think this is very cool, I would ask like to ask for this, but I do not know if it is appropriate to ask for things here. Ignore if it is not.
>>
>>54524622
Consider waiting 100 ms to run your code.
>>
>>54524622
Maybe it's doing some async stuff under the hood.
Consider >>54525089
>>
File: plsrespond.png (836 B, 115x30) Image search: [Google]
plsrespond.png
836 B, 115x30
Anyone else at work?

How many of you have jobs?

http://www.strawpoll.me/10199366
>>
what are some good programming books for an absolute beginner
>>
>>54525288
i voted all three and it counts as three separate votes, you can't even tell i'm trolling

fucking webdevs
>>
>>54525291
What language?

Murach's C# is pretty good for learning the language and GUI building in tandem.
>>
>>54525301
That was intentional; some people have a job and also go to school.

Sadly, I cannot make NEET mutually exclusive from the others.
>>
>>54525288
yeah im at work too
>tfw shitposting 4chan 5/8 hours on an average day
its a good feel
>>
>>54525288
>tfw rejecting merge on trivial shit
NEETs will never know that feel.
>>
>>54525312
merge requests*
>>
>>54525305
any language, i just want a good place to start
>>
File: turtle.webm (2 MB, 1280x720) Image search: [Google]
turtle.webm
2 MB, 1280x720
/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA).

>>54521007
because it would be like ignoring +50 years of PLT. C is a programming language for the programming techniques of the past.

>>54523239
if you don't want repetition

for i in range(0b111 + 1):
s = ""

if i & 0b1:
s += "A"

if i & 0b10:
s += "B"

if i & 0b100:
s += "C"

print(s)


https://ideone.com/O1u6Ve

>>54521638
>procedural code that favours pure functions
>procedural
>pure functions
(¬‿¬ )

>>54521475
The java virtual machine runs on billions devices, not java the programming language.
>>
>>54525324
There's two schools of thought here.

Some say you should with C so you 'learn how it works'.

Others say start with something higher-level so you can actually start doing things. For this, I'd recommend C#, Python, or Java, in that order. All of these are fairly straightforward languages that will allow you to immediately get in there and do some cool stuff once you understand the syntax and the concept of a library.
>>
>>54525344
alright, ill start with C#. sounds good. thanks anon
>>
>>54525344
>>54525305
http://www.amazon.com/Programming-Absolute-Beginner-Jerry-Ford/dp/1598633740
>>
>>54525332
>>procedural
>>pure functions
You can write pure functions in imperative languages, idiot.
God damn, you really are the the most retarded poster in this thread.
>>
>>54525407
>a free implementation of BASIC called Just BASIC

Holy shit, no.
>>
File: 7Seaxyz.jpg (94 KB, 1080x1069) Image search: [Google]
7Seaxyz.jpg
94 KB, 1080x1069
>>54525459
>You can write pure functions in imperative languages
Procedural and imperative are two different things.

>>54525459
>God damn, you really are the the most retarded poster in this thread.
Please, don't bully.
>>
>>54525494
>Procedural and imperative are two different things.
Yes, but all procedural code is imperative. I said 'imperative' instead of 'procedural' because it's more general.
>>
http://www.strawpoll.me/10199466

Hey /g/, is programming for you a hobby or something you do as a career?
>>
File: pingu.jpg (33 KB, 267x200) Image search: [Google]
pingu.jpg
33 KB, 267x200
>have win32 problems
>google error
>solutions no where to be found
>find forum post from 2001
>2 posts oh fuck
>some korean dude had my exact problem
>he posts followup with solution
>>
>>54525693
>nvm I fixed it :^)

You got lucky.
>>
>>54520933
I need help with this python script. I want it to have basic signature checking function, like an AV. It's supposed to open all directories, then sub-directories, and then at last open the files to create a MD5 checksum for scanning. I'm pretty much stuck:
import os
import hashlib


database = raw_input('>')

files_to_be_scanned = open("output.txt", "w,r")
# root prints the directories from specified path
# dirs prints the sub-dirs form root
# files prints all files from root and directory
for root, dirs, files in os.walk("./"):
for name in files:
# write all files to output text for later scanning
files_to_be_scanned.write(os.path.join(root, name))
# write new line after each file
files_to_be_scanned.write("\n")
with open(os.path.join(dirs, name), "r") as checkfile:
# reading the contents of the file
data = checkfile.read()
# pipe contents of file for checksum generation
md5_returned = hashlib.md5(data).hexdigest()
# if the files checsum matches any of those in cvd
# the message infected! is displayed, otherwise clean. is displayed
if aline == md5_returned:
print "Infected!"
else:
print "Clean."


I appreciate any help in advance.
>>
>discuss dicks
>whips out *this*
function YrGH_54_iSCf_287($a)
{
if($a == '0') { return '0'; }
else if($a == '0') { return '0'; }
else if($a == '1') { return '1'; }
else if($a == '2') { return '2'; }
else if($a == '3') { return '3'; }
else if($a == '4') { return '4'; }
else if($a == '5') { return '5'; }
else if($a == '6') { return '6'; }
else if($a == '7') { return '7'; }
else if($a == '8') { return '8'; }
else if($a == '9') { return '9'; }
else if($a == 'A') { return '10'; }
else if($a == 'B') { return '11'; }
else if($a == 'C') { return '12'; }
else if($a == 'D') { return '13'; }
else if($a == 'E') { return '14'; }
else if($a == 'F') { return '15'; }
else if($a == 'H') { return '16'; }
else if($a == 'J') { return '17'; }
else if($a == 'K') { return '18'; }
else if($a == 'L') { return '19'; }
else if($a == 'M') { return '20'; }
else if($a == 'N') { return '21'; }
else if($a == 'P') { return '22'; }
else if($a == 'R') { return '23'; }
else if($a == 'S') { return '24'; }
else if($a == 'T') { return '25'; }
else if($a == 'U') { return '26'; }
else if($a == 'V') { return '27'; }
else if($a == 'W') { return '28'; }
else if($a == 'X') { return '29'; }
else if($a == 'Y') { return '30'; }
else { return false; }
}
>>
>>54525288
At work now. Get an hour lunch on friday, and leaving an hour early because I did some overtime work at home Tuesday and would rather use them to leave early than get paid for them.
>>
>>54525332
Jesus if one person in this world would off themselves, I wish you'd be that person.
>>
>>54526158
You don't normally get an hour for lunch?

What's your work week like?
>>
File: babby.png (22 KB, 500x375) Image search: [Google]
babby.png
22 KB, 500x375
>>54520933
Babby's first 3d engine. It's stupid, but I'm trying to understand how 3d works. However, this can only render images, there's no real time output. Anybody know what's the most primitive way of doing that? I'm doing everything in C 100% from scratch (apart from stdio and stdlib; no worries, I derive pleasure from this).
>>
>>54526186
Monday to Thursday we get half an hour lunch. I usually just eat at my desk and keep working. Friday we get an hour, where I do the same.
>>
>>54526189
use opengl
>>
>>54526268
>I usually just eat at my desk and keep working
Why? You have to take a break, unless you want to get a burn out.
>>
File: 1462232635612.png (17 KB, 186x210) Image search: [Google]
1462232635612.png
17 KB, 186x210
I'd appreciate a helping hand coming from the folks who are interested in Qt5(I'm using pyqt but converting c++ to python is easy)

http://stackoverflow.com/questions/37198582/gifs-shown-inside-a-label-doesnt-update-itself-regulary-in-pyqt5
>>
>>54526268
>I usually just eat at my desk
anon please dont be that guy
go talk shit with your work m8s
>>
>>54526307
Not him, but I do the same thing.

I usually eat at my desk, sometimes I'm productive, sometimes I find horrible ways to spend money in /csg/.

It's not like you can really get burned out doing stuff you enjoy at a comfy desk.
>>
>>54526307
Sometimes I'll go sit by the lake if it's nice out, but might as well keep working. I don't really burn out, I like what I do.

>>54526352
Everyone leaves at lunch.
>>
>>54526189
I made this to handle flow control way back.
class FrameRate
{
//DEPENDANCIES:
//<iostream>
//<glfw3.h>
private:
//DECLARE FRAMERATE VARIABLES
float frametime, framecompare, framespeed, maxtime;

public:
int tFlag;
FrameRate(void)
{
frametime=0.0f;
framecompare=0.0f;
framespeed=0.0f;
maxtime=0.0f;
};
//1. SET FRAMERATE VARIABLES//
float SpeedInit(float speed, float max)
{
framespeed=speed;maxtime=max;
}
//2. FRAME INITIALIZER FUNCTION//
float Start(void)
{
if(glfwInit()==true)
{
if((framespeed==0)||(maxtime==0))
{
std::cout<<"FrameSpeedInit() has not been declared\n";
return 0;
};
if(glfwGetTime()>maxtime)
{
glfwSetTime(0.0f);
framecompare=0.0f;
frametime = 0.0f;
return 2;
};
if(frametime<maxtime)
{
frametime = glfwGetTime();
return 1;
};
}
else
{
std::cout<<"glfw failed to initialize\n";
return 0;
};
}
//3. FRAME LOOP PARAMETER//
float Loop(void)
{
if(glfwInit()==true)
{
if((framespeed==0)||(maxtime==0))
{
std::cout<<"FrameSpeedInit() has not been declared\n";
return 0;
};
if(frametime>(framecompare+framespeed))
{
framecompare=glfwGetTime();
return 1;
}
else
{
return 0;
};
}
else
{
std::cout<<"glfw failed to initialize\n";
return 0;
};
}
//4. HARD RESET WHOLE CLASS//
float Reset(void)
{
frametime=0.0f;
framecompare=0.0f;
glfwSetTime(0.0f);
}
//5. CANCEL CURRENT FRAME//
float Cancel(void)
{
frametime=0.0f;
framecompare=0.0f;
}
};


Continued..
>>
>>54526356
>>54526361
>I like what I do
That might be the difference. My job is meh, so it's nice to do something else. I only have to eat at my desk on Fridays because there's no lunch on that day.
>>
>>54526400
It's ugly as fuck, it's one of the first programs I made and it's C++ not C. But I use it to create frames.

You just set the framerate with SpeedInit(float speed, float max), so speed would be 1.0/30.0 for 30fps. And max is the amount of time before glfwGetTime resets.

You just run start(); before a loop and Loop() as a parameter. So if(Loop()==1)

Then it will only execute the contents of the if statement should 1/30th of a second have passed.

I guess you could change it to make it not shit and to work in C.

Please no bully.
>>
>>54523239
recursion is pretty nice for this

def combinations(chars, length):
if length == 1:
return chars
return [c + x for c in chars for x in combinations(chars, length - 1)]
>>
>>54526426
So for example
FrameRate cocks;
cocks.SpeedInit(0.0333f,3600.0f);
while(message loop bullshit)
{
cocks.start();
if(cocks.Loop()==1){//execute}
}
>>
File: vomit.jpg (90 KB, 650x650) Image search: [Google]
vomit.jpg
90 KB, 650x650
>>54526400
FrameRate(void)
{
frametime=0.0f;
>>
>>54526483
S-shut up. I-I'm better at programming now and haven't gotten around to making it not shit.

I-It just works.
>>
I have a ton of variables that I need to pass around to different functions, and the type signatures are getting huge. Wat do?

I can't put them in a struct and pass that around, every function requires different params
>>
>>54526502
I'm not pointing out the code, I'm pointing out the indent style.
>>
>>54526516
Yeah, that is also a product of when I made it.
>>
>>54526400
>>54526426
>>54526483
Thanks m8, it's not perfect, but I think I can use that as a start
>>
File: what the fuck comrade.jpg (9 KB, 228x210) Image search: [Google]
what the fuck comrade.jpg
9 KB, 228x210
>>54526005
>mfw
I'm clueless about PHP but... there must be a more efficient way to deal with this.
Something like:
if($a<=9&&$a>=0) { return $a; }
else if (ord($a)<=70&&ord($a)>=65) { return ord($a)-55; }
else if($a == 'H') { return '16'; }
else if (ord($a)<=78&&ord($a)>=74) { return ord($a)-57; }
else if($a == 'P') { return '22'; }
else if (ord($a)<=89&&ord($a)>=82) { return ord($a)-59; }
else { return false; }
>>
is this example pajeet-level?
int i;
//if scanf found 0 ints, return -1
if ( ! scanf ( "%d", &i ) )
return -1;


or could i use the following, if nothing is written to ' &i ' if/when it fails

int i = -1;
scanf ( "%d", &i );
return i;


t. beginner
>>
>>54526626
/me vomits
>>
>>54526689
i could be corrupted by scanf, so use the 1st.
>>
>>54526689
Use fgets + strtol. It's far more reliable than scanf, especially when it comes to error handling.
>>
>>54526626
i dont know how php works really but cant you do
$b = ord($a);

at least so you dont have to call ord() so much?
>>
VESA is just a BIOS extension right? and it uses standard VGA hardware right?
I will need to write my own VGA driver after switching the protected mode (fuck switching back to real mode) and I want to know if I can configure it for high resolutions and high color and have it work on all platforms, provided of course I take into consideration the monitor EDID data.
>>
File: 1439858602827.gif (1 KB, 100x100) Image search: [Google]
1439858602827.gif
1 KB, 100x100
//The integer field sizes can differ in a EBML (MKV) header.
func init() {
image.RegisterFormat("mkv", "\x1A\x45\xDF\xA3???????????????????????????matroska", Decode, DecodeConfig)
image.RegisterFormat("mkv", "\x1A\x45\xDF\xA3????????????????????matroska", Decode, DecodeConfig)
image.RegisterFormat("mkv", "\x1A\x45\xDF\xA3????????????matroska", Decode, DecodeConfig)
image.RegisterFormat("mkv", "\x1A\x45\xDF\xA3????matroska", Decode, DecodeConfig)
}


I'm going to just put every possible offset the matroska tag can be at in here.
>>
>>54526784
cpu mikro code needs to wrap him (the out port)
- mishka
>>
>>54526803
What? I didn't quite understand what you said.
>>
>>54521007
Because I Pajeet I Java Geneeus, Microsoft Incorporated Inc(R)(TM) Technical Support Whyruss Officer(R)(TM) here for your technical assisting of technical kneeds. Please to off serwiss. How be may plezzed to be of serwiss today sir?.
>>
>>54526774
We're both fretting over something we don't understand but yes: that's a sensible suggestion that someone with a brain would make.
>>
>>54526189
You are on your way to enlightenment young jedi. I wish you all the best.
>>
What genre/playlist/artist of music do you guys listen to while coding?
>>
>>54527006
slow rnb
too much hype makes me music-autism trigger and i cant focus
>>
>>54527006
This has nothing to do with programming, fuck off.
>>
>>54527006
Progressive, of course.

Intricate instrumentals to stimulate creativity and brain function.
>>
>>54527006
https://www.youtube.com/watch?v=oiY_iKSpWLM
>>
>>54527027
what am i meant to look for coders on a music board?
music choice plays a large role in how much coding i get done
hence relevant.
>>
>>54527006
Kpop, jcore, black metal w/e I feel like. Listening to this right now: https://www.youtube.com/watch?v=g7E5Et7aO1o
>>
>>54527006
Pretty much exclusively drum & bass.
>>
Can somebody walk me through the perspective matrix glm uses?

I'm making it a point not to use this shit until I can replicate it on graph paper.
>>
>>54527061
Not relevant. You, are not relevant.
"music for programming" on youtube.
Enjoy, get the fuck out.
>>
File: cl.jpg (12 KB, 195x245) Image search: [Google]
cl.jpg
12 KB, 195x245
Going through the first few chapters with pen and paper to get down the basics. Some of the answers aren't listed in the appendix for some reason I think.
>>
>>54527085
it's more relevant than a lot of the things in /dpt/
>>
>>54527006
https://www.youtube.com/watch?v=wH4GwPT5Y00

https://www.youtube.com/watch?v=kILB4JQqp5g
>>
>>54527083
http://www.songho.ca/opengl/gl_projectionmatrix.html
>>
File: 1438437856495.png (31 KB, 606x425) Image search: [Google]
1438437856495.png
31 KB, 606x425
>>54527085
badass! thanks for keeping the thread clean friend!
>>
>>54527085
We were talking about our work day earlier and you didn't sperg on that.

Fuck off, retard.
>>
C programmer here.
I make all my C++ class members public.
Getters and setters are a fucking meme and there is no need at all to hide members from the goddamn programmer, we're not talking about end users here.
Fight me.
>>
.h VS .hpp

WHICH ONE
>>
>>54526512
Try group them into smaller structs of related data. Post some examples of what you're dealing with.
>>
>>54527132
Absolutely disgusting anonymous sempai. If you aren't using something outside of the class you are a Communist for making it public.
>>
>>54526689
>
if ( ! scanf ( "%d", &i ) )

should be
if(scanf("%d", &i) != 1)

since it can return errors and eof.
>>
>>54527118
Hey guys, which cologne do you enjoy wearing while you program? For me I usually just rub some cum behind my ears and on my neck and call it a day. Anyone else care to weigh in?
>>
>>54527136
.h
>>
>>54527132
While this isn't exactly applicable to C++, a good type system obviates the need for encapsulation in the preserving-valid-object-state sense. Encapsulation is still necessary for "hiding" implementation details (so that they don't impact the ABI), but you need to use PIMPL or something equivalent for that anyways, which is possible in C.

>>54526512
This sounds like a symptom of heavy coupling to me. As >>54527144 says, post some examples.
>>
>>54527166
I don't wear any cologne at work, just basic deodorant.
>>
>>54527148
But I am.
I need to access those variables from outside and use them.
I refuse to conform to the cancerous idea that all variables must be private, that is fucking stupid and I am not fucking writing getters and setters for everything.
>>
I'm translating a solution of a project euler problem (https://projecteuler.net/problem=14) from python to C++, but I can't seem to spot what I'm translating wrong. Sorry if the code is particulary ugly, I don't study CS or the likes.
Python version:
http://pastebin.com/s6p8EsH3
C++:
http://pastebin.com/cYPu57ry

Any ideas on what I'm doing wrong? Also, do you have any opinion on how optimized the idea for the algorithm is? I found that this temporary vector approach is the fastest between the ones I thought of, however I have some other ideas that I couldn't manage to implement but that left me with the idea that there could be something faster than this.
>>
>>54527132
I completely agree. Encapsulation is the biggest joke ever. You don't need it.

Especially in your internals, for your public API there are other ways to hide implementations (the C way).
>>
>>54527183
Just make sure that in your dogmatic need to oppose the "norm", you're not rewriting the same code all the time instead of calling a method to work with multiple fields at once.
>>
>>54527195
its meant for a lead programmer to be able to direct pajeets so they dont create a (too shitty) mess
>>
>>54527193
The collantz function isn't returning an integer in some of the cases.
>>
>>54527193
Also, has anybody ever tried to write the DP solution to this?
>>
>>54527212
Of course. The reason why I'm using C++ in the first place is to take advantage of inheritance and some of C++'s standard library, which is actually really useful, unlike encapsulation.

I'm still using printf and puts though. and I'm still including C libraries the C way.
And I'm using C strings.
>>
>>54527308
>to take advantage of inheritance
I hope that by this you only mean implementing "interfaces" and using composition otherwise.
Thread replies: 255
Thread images: 28

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.