/dpt/ - Daily Programming Thread

t-teach me C++ edition

Old thread: What are you working on Sup Forums?

Other urls found in this thread:

make.girls.moe/technical_report.pdf
clang.llvm.org/cxx_status.html
painlessprogramming.blogspot.hr/
gen.lib.rus.ec/search.php?&req=lippman primer&open=0&res=25&view=simple&phrase=1&column=def
clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
twitter.com/NSFWRedditVideo

first for C

First for Golang is amazing

Part of me don't want to become overly dependent on netbeans/qt creator IDE but I don't want to read a 220 page manual only to learn Make

lol

getting people to learn Haskell so that FP can take over the world

Reading through a book

Go is trash

Excellent choices in languages.

First for undereducated and unobsolete languages like C

Currently reading "The Go Programming Language" by Alan Donovan and Brian Kernighan. Very comfy language indeed.

Didn't exist back then.

If you want to learn C++ because of an anime and your loli fetish.

Forget it. Your motivation will fade with your boner.

Haven't decided what to work on today. Still consider myself very new to programming so I'm just looking into doing simple things.
Reading "C++ Primer" and looking into sockets a bit, also messing about with ncurses. I might have a go at my own mail client or something

The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt.
–Rob Pike

This was created one post too early, just FYI.

>teach me C++
Why do you want to learn C++?

Good, there is no reason to to on an autism spree and change your project over to clang now

>loli fetish
>boner
what the fuck dude, you're not supposed to lewd the lolis they're for cute only

Everything else looks easy after C++.

It all started with some pro gcc person saying clang sucks because it can't compile a heavy non c-compliant project like linux.

No actually it started with someone posting misleading information regarding clangs performance.

...

>ywn go to hitotsubashi to learn programming.

>hitotsubashi
is there something special about it?

???
do they even teach programming?

>more up to date with standards
They're both pretty much entirely compatible except for the gcc-specific preprocessor magic, also I'm pretty sure clang would be more "up to date with the standards" as it's more recent an was made to be compliant with gcc standards. The point was to make code easily transferrable from gcc to clang.

>produces faster binaries
any recent sources on that?

make.girls.moe/technical_report.pdf

>Create anime characters with A.I.

Clang isn't compatible with C++17 standard yet

I don't care about the performance that much. Clang is so much more convenient to work with that it doesn't matter.
Empowering me, the programmer, probably makes me produce better code anyway. And I'm more happy. That's more important.

for the most part it is but fair enough clang.llvm.org/cxx_status.html

>being this new
w e w

it's a law school.

>wew

>being this reprehensible

if you understand what flags are being passed to the compiler, you'll be fine either way. (include paths, lib paths, src files, object files, when to use -E, when to use -c, linkage etc)

>tfw have an interview with google today for SE role
>tfw i read over interview material and I just ask myself why do I even bother showing up

I'm fucking useless. Dijkstra, Prim, Kruskal, Pre-order, merge sort, quick sort, dynamic programming, divide and conquer, trees, minimum spanning trees, I don't fucking know anything. I just want to die. I can't pass any interviews I should become a night guard or kms

If you really want to do something, you'll find a way. If you don't, you'll find an excuse.

>t-teach me
You really want to learn computing?
As soon as you fully understand how computing works and how it could work instead you will view it as garbage built on more garbage.

>going through project euler threads
>everyone's solutions are complete unreadable convulted trash

how do these people get by once it starts getting hard

best place to learn programming:
painlessprogramming.blogspot.hr/

why do you think so?

What are some "brilliant languages"?
Lisp, Haskell, OCaml? Smalltalk perhaps?

How good is C++ Primer?

it's just a book to find the prime numbers in C++

If I want to make program that is build with using multiple languages, can it be native? I'm afraid that loading shared libraries and having to spawn multiple runtimes where some of them have GC would not work correctly.
JVM/CLR doesn't have this problem but the language options are shit.

"The most powerful programming language is x86. If you don't know x86 (or its variant, ARM), you don't know what it means for a programming language to be powerful and elegant."

>JVM/CLR doesn't have this problem but the language options are shit.

t. programmer connoisseur

You can, just use their FFI/C compability ABI interface.

>where some of them have GC
That's always a problem, as well as different type systems.
Unless you use a common virtual machine/intermediate representation there is no way to solve that. And even then it might be impossible, because with the JVM/CLR it's only possible because they enforce a strict set of semantics, unlike LLVM IR.

Arguably best beginner book.

Which edition is the best?

The one you can find online is fine.

You replaced Lisp and Scheme with x86 and ARM, didn't you?

Do you have a link? 'filetype:pdf "c++ primer"' doesn't yield any relevant results.

No, I quoted Stallman word for word

I find ARM assembly pleasing to read and write, x86 a shit though.

gen.lib.rus.ec/search.php?&req=lippman primer&open=0&res=25&view=simple&phrase=1&column=def

Learn CMake

Thank you.

Good c++ books for modern c++?

I stopped procrastinating going through SICP and did more chapter 3 exercises. I think the basics in the book have been passed. I will still go through it but I don't expect immediately useful things.

How do I ACTUALLY do something with programming in the real world like create a 2D game or something? I always feel like I'm at least 2 tutorials from the ability to do anything.

Like, I open up a blank test.py or test.js and then what? If it was a game I would have to use someone else's engine and library like some sort of dumb monkey?

"Effective Modern C++"

>you'll find a way
But he just told you he doesn't know Dijkstra.

>How do I ACTUALLY do something with programming in the real world like create a 2D game or something?
Throw away SICP, it has nothing to do with the real world.

If you are want to learn or lrarning cpp curently how did you know that everything else looks easy after cpp?

And that's not necessarily a bad thing.

You're telling me that a programming book that takes 2 chapters out of 5 before it gets to changing variables isn't useful?

If you want to be in absolute bliss, it isn't.
If you want to archive something, it is.

hey
it's ok to use other people libraries, that's why they are there. General rule of thumb is to use already tested and stable libraries, rather than writing them yourself and submit patches upstream if you think something can be improved (of course, this does not apply to huge commercial proprietary engines like unity). Those libraries just do the boring stuff, so you can jump straight to the fun.

Look up pyopengl or something. Library for drawing stuff to screen

I just like abstract things, man. Let me have it.

No idea what he thinks is a brilliant language. But I imagine Rob Pike is the kind of sleezebag that'd complement other languages against his principles just to have his claims seem less controversial.
In essence this quote is devaluing programming as a craft. I don't believe that the people who actually couldn't comprehend other languages (as expressed they could just understand Go) can be productive in producing good software for the long term. Imagine using a library written by people who could only understand Go. I imagine you're not too pleased with that.

I'm fine with Go and lots of other languages for less serious applications. But don't write airplane, car, infrastructure, operating system or other critical software in them.
Sadly you find things like this in the FAQ. It's intended to be just the thing I don't want it to be. A lowest common denominator language for important systems.

Its not that impressive.
You could easily have written a book on C in SSA form and get about as far.

This any good?

yes

Sorry, I did submit my own unreadable, ridiculously complicated code as well when I was first learning to program many years ago. It's probably not even consistently indented.

...

So, I'm feeling pretty stoopid right now.
I haven't programmed in C++ for a year or two now and I decided to implement a Sieve of Eratosthenes to knock the dust off, but it's failed on all fronts.

The way it works is that it uses an Boolean array, where every element represents if a number is prime or not. (ie Sieve[2] represents 3, and is true)
The problem is (I think) that the modulo operation isn't working, so the sieve never actually eliminates any numbers.
The other weird thing is that the very last for loop (which is outside of the "main loop") is supposed to print every prime that the sieve found, but instead it just prints "2" 100 times (or whatever other value I set MaxNum as)

#include
using namespace std;

int MaxNum = 100; //this is the largest number that the sieve will check for being prime
int lastPrime = 1; //tells the sieve that 2 is prime as a freebie

int main(){

bool Sieve[100]; //Initializes the array as all true
for(int i=0; i

Also, yes, I know I should generate the array based off the MaxNum value, but I'm just trying to get this to work

B-but c++ is deprecated, use C if you serious developer, or Rust if you fucking hipster.

Try to write bubble sort first, quick sort, binary search, merge-sort.

undefined behavior line 11, 16, 22, 23, 30, 31, and missed others maybe.

>x86 (or its variant, ARM)
what a fucking retard

is there a compiler option that informs about UB?

I'll probably try that after this, but for now I want to make a sieve.
Also, I'll be damned if I fail and don't learn why it failed.

Pardon my ignorance, but what's undefined about it?

>bool Sieve[100]; //Initializes the array as all true
Does it? surely you need an initializer

I'm trying to learn c++ (and programing in general) and I found something weird.

The program would skip the first function, print out some number and the second function would start and then the program stoped working, just because I added some simple text output and changed a semicolon in a completely different part of the program.
Why?

No, you just get a feel for it.

Have you tried posting code?

Not on gcc.
clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
This doesn't catch everything but it catches a lot of UB.

That's what the next two lines do. Sorry if that's not clear.

It was originally bool Sieve[100] = {true}; But that seemed to be undefined behavior.

Do you know any online exercise websites that could teach OOP aspect of C#? classes, methods etc.

How do I use gtk? I installed msys, made a new folder in ~ and copied the prototype PKGBUILD into it. But how do I know what to fill in? What do i put in 'source' and 'depends' and the functions at the bottom of PKGBUILD? I literally just want to make a desktop app with gtk.

>But don't write airplane, car, infrastructure, operating system or other critical software in them.
Well it it has good enough performance then it should be fine. Don't big companies that do critical stuff usually want dumbed down languages or they force you to dumb yourself down. For example see NASA's C guide.

PHP is safest language

Can you please elaborate?
I'm at a loss.

very good language, lots of haters, so many jealous

Sieve is accessed out of bounds at these lines. Read the meaning of comparison operators. I'm not saying this is the only problem with your program, though.

Also Sieve[x] represents a boolean, that once cast to an it is 1 if true, which means your cout at the end will only ever print "2"

I want to build good software without a huge learning curve, thanks for this.

Brb making a successful startup while you nerds figure out how to get shit to work in hasklel.

>I want to build good software without a huge learning curve, thanks for this.
Just because your language is easy doesn't mean you can write good software easility with it.