/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1541532591349.png (821x3109, 559K)

Other urls found in this thread:

gist.github.com/wizpig64/d0ec4e5bb3735ffe47b7c22ba5d2a91c
en.cppreference.com/w/cpp/language/constraints
docs.python.org/3/
oreilly.com/library/view/designing-data-intensive-applications/9781491903063/
postgresqltutorial.com/
gcc.gnu.org/projects/cxx-status.html
twitter.com/SFWRedditVideos

god i wish that were me

You want to be a traumatized little girl?

Design patterns are possibly the single biggest snake oil ever marketed in software development.

im working on finding out where i start learning how 2 code

any tips

if she's got poptarts, sure

Just pick a language and start. Follow some simple tutorials and maybe copy some other people's examples and tweak them until you understand them.

C noob question here.

I'm going through step by step trying to make a function that will do calculations with each element in my array. My array needs to be filled with numbers it gets from a txt file. Before I go through building my function I just wanted to make sure my arrays were filling properly with my end file loop so I wrote the printf statement in my EOF loop.

Why is it that this loop only prints one thing at a time and makes me hit enter in order for it to get the next thing? Did it fill the cells of the array properly or is it only filling the cells everytime i hit enter?
int main()
{
int day, month, id, i=1;
char c;
double hours_used;
int id_array[10];
double charges_array[10];
double cost;
FILE*infile = fopen("usage.txt", "r");
FILE*outfile = fopen("charges.txt", "w");

fscanf(infile, "%d %d", &day, &month);
printf("day: %d month: %d\n", day, month);

while ((c = getchar()) != EOF)
{
fscanf(infile, "%d %lf", &id, &hours_used);
id_array[i] = id;
charges_array[i] = hours_used;

printf("ID: %d hours used: %lf\n", id_array[i], charges_array[i]);

i++;
}

Those cords are dangling all over the kitchen xor that is a fucking powerful toaster

Your while loop is being driven by a getchar, meaning it's only going to run when you enter something on stdin.
while (fscanf(infile, "%d %lf", &id, &hours_used) == 2) {
id_array[i] = id;
// etc
}
is actually what you're looking for.

Do a C++ course on Alison or edx or one of those
It's not a perfect language but it's got a good spread of high and low level features that come in handy when you move on to other languages. Plus it's a good base for learning syntax, whenever I encounter a new language I always find myself comparing/contrasting how it's written with C++.
C++: it's OK, and that's OK

Help me Jow Forums I started learning C++ (my first time into programing), and everything was doing fine, until they start throwing a lot of things that have no use, at least for now.

Any tips/videos for the absolute begginer?

Attached: 1553904528422.gif (245x165, 700K)

>until they start throwing a lot of things that have no use, at least for now.
like what?

Every time you call getchar() it wants to get a char

hitting enter presumably gives it a NULL

too bad, she only has toast

>they start throwing a lot of things that have no use
I don't understand this concept. If you can write it you can use it?

classes/structs

:^)

I wrote some javascript to let credit karma's 1099-B tax form to load a CSV so I didn't have to enter it manually.

gist.github.com/wizpig64/d0ec4e5bb3735ffe47b7c22ba5d2a91c

Just use C++ like C with classes.

Did you have enough transactions to save you some time?

thank you guys

What are some habits you bring from others languages Jow Forums?

>Java classes
I lit make a class for almost everything, i can take that habit out of me.

I implemented linq in a C++ project I was maintaining alone. Too fucking bad I can't has linq expressions or queries though

tfw your code gets cluttered by error handling for scenarios that practically wont happen

Learn C first, then move to C++. C++ has so much goddamn shit in it that stroustrup himself probably doesn't have a complete working knowledge of it anymore. Every tutorial or book will send you careening into some rabbit hole and you'll never understand what the fuck is happening.

*meows*

I understand why C++ Constraints and Concepts is useful but also this language is truly off the rails
en.cppreference.com/w/cpp/language/constraints

Attached: Screenshot from 2019-04-15 20-32-29.png (728x459, 49K)

I probably spent 2 hours on it and could have entered the 60 lines in less than half the time.

But:

1. Hand-entering numbers (and text!) from one spreadsheet into another takes me to a dark place that I don't want to go.
2. I can re-use this next year assuming nothing changes.
3. I can show it to credit karma and demand they hire me.
4. I still submitted before the end of tax day.

now we just have to wait for C++20 to be implemented in compilers

Working on a Python project in college, but I'm stuck. I'm brand new to Python and trying to learn it so I don't fail this class. Any good resources to look at?

Can I get a good book/tutorial/primer on databases? I am doing a quiz program and I need to save user data, and it seems like a good time to delve into this subject. If I need to go really deep, that's fine. I'll probably need to be competent at databases anyway.

docs.python.org/3/

>If I need to go really deep
In databases, """deeeep""" means multiple instances, maybe in multiple geographies.
They're otherwise entirely uncomplicated and you shouldn't think too hard about it unless your performance is impacted by your shit design.

I'm new myself. After many false starts over the years I finally decided it wasn't gay if I sucked a dick, and I took a class at the community college.

I lucked out and got a great instructor. The first few weeks were really tough, but the learning curve leveled off a bit and I really got into it. Aced the class and now I've almost completed the text book on my own. The pace of the class actually started slowing me down and I'm doing really well on my own. Already started learning C because I get sick of the pedantry of the c++ textbook.

So I'd recommend taking a class. Or the online course the other user suggested. You could even just get a book or textbook. Check the wiki.

Even though I only know a little c++ and even less C, C++ does seem like a good place to start. It is ubiquitous and does anything you want it to. I think?

This is the advice that kept me from actually learning 2 kode for over 10 years. The learning curve is really steep at the beginning. Having some hand-holding through the first phase is really helpful.

Fuck you and your shitty advice.

How would you quantify the skill level of some programmer? It's this thing where you have a feeling of it, but I can't really think up a way to put it as a number or something.

The first reply was right. Your first language is completely irrelevant because both in (category) theory and in practice, all popular languages are converging to the same featuresets.

After you learn how to write the same sets of algorithms and data structures in your third language, they will all start to blend together.

Do you think 7 weeks is enough time to become fairly well-versed in Python? I've taken 2 classes that use Matlab, and am in a third one now, and I still have to look up how to do everything I want to do.

Wait, doesn't hitting enter give it a '\n'?

>What are you working on, Jow Forums?
For school, Python.
For me, OCaml.

Uh, maybe people learn differently? The way I wrote is exactly how I initially learned, by copying examples out of the C++ for Dummies book when I was 13.

Alternatively, maybe you're just retarded.

MATLAB is an abomination of a language that tries to appeal to autistic mathfags (1-based iterators :DDD) but is actually still imperative.
It is little wonder you are still looking things up for a language that explicitly tries to be a special snowflake.
A language designed to be used by actual human beings is easier to understand.

I literally know nothing about them. I've never used one. I know SQL is a database language.

The best I could do with my knowledge is have my program output a text file with the data and retrieve it during a new instance. Should I just go with that? Is that a database?

My main point is that canard of "just pick a language and learn it" is shit and misses the point.

Most online tutorials are sparse and crap. I found it really useful to have a structured approach. A good textbook and even an instructor was really helpful for me.

Also, just picking a language is not really feasible to a complete n00b. You don't know what's what and how to compare. I personally am really glad I started with C++ and not Javascript or even Python.

Well, when it comes to coding, I'm fucking retarded. I'm better than some other people in my classes, but nowhere near the best. Python seems somewhat more intuitive, but if I'm not using print or plot or writing equations, I'm lost.

What are some benefits of using C++ over C when using it to program more C-like code?
Genuinely considering dabbling with it a little.

Are you interested in understanding why databases are designed the way they are, or do you just want to use them?

Well, there you go. You had a BOOK. A BOOK designed for beginners. Which is my point. Just telling someone to pick a language and learn it doesn't intrinsically include the vital aspect there which is GET A BOOK.

You're the one who needed a book for literal Dummies, so maybe the retard is YOU. *burn*

It instantly alienates the much better pool of C programmers from contributing to your program, and leaves you with the shit-eating scraps.

>Well, there you go. You had a BOOK. A BOOK designed for beginners. Which is my point. Just telling someone to pick a language and learn it doesn't intrinsically include the vital aspect there which is GET A BOOK.
>You're the one who needed a book for literal Dummies, so maybe the retard is YOU. *burn*

*responded to my original post accidentallylike. I guess i am the tard.

But anyone can just surround their contribution with extern "C" { ... } if they really needed to, couldn't they?

>the much better pool of C programmers
Is this true, and if so, why?

I'm interested in being relatively competent with databases. I am a n00b to all of this, and I'm finding that it suits me to really learn a subject I'm interested in.

I'm going to be needing them with some of the projects I have in mind, so I might as well know what they're all about.

Dude, why are you sperging out? Go back and read my original post where I mention "simple tutorials."
Calm down, have a nice hot cup of tea or something, and work on your reading comprehension.
(And stop writing *burn* and random capitalized words like a pre-teen forum user in 2008, it's a bad look)

Pros:
Some nice features of C++ that really should have been in C11

Cons:
RAII is fucking retarded and nothing will work in any way you expect until you wrap everything with extern "C" because C++ is retarded

Imagine not being able to comprehend the simple elegance of RAII

Well, when you figure out the answer to that question, if you want to understand why people use databases and why databases are designed the way they are, then just read this book
oreilly.com/library/view/designing-data-intensive-applications/9781491903063/

If you want to just use a database, then I'll cut to the chase and tell you to download Postgresql and follow their tutorial. postgresqltutorial.com/

But lastly, SQL is called a declarative language. In declarative languages, you define facts and are effectively just telling the computer to "give me what I asked for." Markup languages like HTML are also declarative languages.

Concise tutorials are exactly the problem. They suck. They're not helpful.

K&R is concise but it's actually really good. It's a joy to read and it pretty much gives you all the information you need to learn the concepts. Most online tutorials are written by actual spergs who have no sense of pedagogy or basic humanity.

>RAII is fucking retarded
std::unique_ptr is good enough for 99% of cases of memory management

>still using old as fuck C++17 in twenty fucking nineteen when C++2a exists
fucking luddites

Interesting. Thank you very much.

GCC already implements half of C++20 and it's not even 2020 yet.
gcc.gnu.org/projects/cxx-status.html

This language is so freaking huge already and it's only getting worse

lmao fucking brainlet.
C++ isn't big enough yet, it still needs a lot more features.

>I personally am really glad I started with C++ and not Javascript or even Python.
Certainly there are benefits to learning from a particular language... learning from Javascript will place you in the hotpot together with bootcamp ``koderz'', compilers, businessmen abusing SEO, retards, and data """scientists"""

But what you're supposed to understand from the statement I made is that once you learn how to do something in another language, because its syntax and quirks forces the entire community to do something different, you will find a similar way of doing things in languages you've learned before.
Maybe those other ways are better. Maybe if you started in Javascript and moved onto C# or Python you would learn how fucking retarded javascript programmers really are. But you wouldn't really be any worse off for it.

What are some good projects written in C++ that represent everything that's good about the language?

C++ is what happens when people who sit in academia theorizing about languages get to design one. Haskell is the same way but at least Haskell is driven by proofs rather than "wouldnt it be neat if"

Perhaps the web browsers

Best way to learn Java? I learned other languages like python just from fucking around, but have to take a Java class in the Fall and want the basics of the language down

Do the needful and learn the java

Attached: 1546322940144.gif (849x458, 150K)

take a vacation to india
bathe in the waters
absorb the essence of java
then you will truly have done the needful.

you don't know what you're talking about

K&R. Used by programmers for generations, never once failed me.
Good basics applicable everywhere.
When you got that down, you could try doing some smaller projects of your own. When you feel like you're ready to go on to the next level, read TAOCP.

Attached: 1539813386350.png (792x1023, 104K)

Shut up faggot

Making it possible to change the z-order of widgets in my operating system, and hooking it all up in the interface builder.
I spent the day chasing down excessive kernel heap traffic so it's nice to be back to some GUI programming.

Attached: zorder.png (1920x1200, 858K)

What's the deal with his shirt?

Attached: 1523965950078.png (873x493, 292K)

When you make pure interfaces in C++, is it bad to not make constructors and destructors? What about empty destructors for normal classes, what is the view on that?

he's in india and temperatures are regularly 90F over there

How else are you going to learn how to create a class with 1100 members?

If you don't get this sweaty then you simply aren't programming hard enough

They don't have air conditioning?

air conditioning and its consequences have been a disaster for the human race

This is the new Linux :)

>indians
>affording things

Attached: 1479956234614.gif (400x225, 1.96M)

>indians
>humans

yes, indians are a subspecies of human

a species of subhumans*

i never thought i'd hear the phrase, "it's nice to be back to some GUI programming"

Is there a better way of printing ascii art rather than going:

1 #include
2 using namespace std;
3
4
5 void pyramid(){
6
7 cout

Attached: 1554598616344.jpg (2448x3264, 1.08M)

>"wouldnt it be neat if"
>implying that isn't the best way to design things

you could remove the "; cout" but it's still dumb

for (int i = 1; i

When you make your own GUI library, you can make it as nice as you like. :)

no you can't

pretty sure he just did

stdout is the best GUI library

void pyramid(){
std::cout

ah fuck i forgot a quote
fuck

This is the kind of shit they have you do in your first programming class to teach you loops. Use loops.

That pyramid is just an example. I want to be able to print ascii art in the most efficient way.

_nnnn_
dGGGGMMb ,"""""""""""""".
@p~qp~~qMb | Linux Rules! |
M|@||@) M| _;..............'
@,----.JM| -'
JS^\__/ qKL
dZP qKRb
dZP qKKb
fZP SMMb
HZM MMMM
FqM MMMM
__| ". |\dS"qML
| `. | `' \Zq
_) \.___.,| .'
\____ )MMMMMM| .'
`-' `--'


for example

nope it probably sucks