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

It's been 3 years since I've started programming mostly

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 206
Thread images: 14

File: cpp-logo.png (5KB, 577x325px) Image search: [Google]
cpp-logo.png
5KB, 577x325px
It's been 3 years since I've started programming mostly in C++ (11, mind you), and I fucking love it.

Why does it still get so much hate? C++11 is fantastic.
>>
because you're using y and i use x
>>
>>56439217
Cum pile times
>>
File: 1400217501664.jpg (116KB, 691x1000px) Image search: [Google]
1400217501664.jpg
116KB, 691x1000px
>>56439443

>not putting your IDE on an SSD that's run through PCI
>not having an 17-6950X with 126gb RAM at 3000mHz
>>
>>56439511
Yeah, I really am a pleb for not having that compile server farm.
/thread
>>
>>56439511
>17-6950X
>17
>>
Java is better because nothing is better than getting faster and faster computers that run 10x slower code in virtual machines.
>>
Tell me about the learning process
>>
>>56439511
>3000mHz
3Hz?
>>
>>56439217
It's aight. Main complaint is preprocessor (not really C++'s fault) and syntax is getting progressively grosser as more features are added.
>>
C++ is a great language, but I still find the hardest task to be solving the BS surrounding it.

Like figuring out why cmake doesn't link correctly or what you missed to set up the environment.
>>
>>56441217
I agree. Most of the bullshit with c++ is the c++ environment. Linking libraries, garbage standard library, etc..
>>
>>56439217
Some discover that they like to eat shit. It's not because they like to eat shit that shit is good. I'm glad you enjoy shit and eat it anon.
>>
>>56441316
what is wrong with the standard library?
>>
>>56441316
>I've only used C++ to make a hello world in class and I currently have no job
>>
>>56439511
still slow as fuck to compile
>>
>>56439443
wait, then what alternative to C++ do you suggest if compile times are the main drawback for you? please dont say rust
>>
>>56441316
Bullshit.
It's annoying, sure.
But once everything is set up and works
it's fine.
You don't have to touch often.

However, the langauage itself and the standard library are a constant struggle.
>>
>>56439217
there are people love it and there are people hate it. people who love it are idiots.
>>
>>56441639
Yes.
>>
>>56441656
No,
>>
everytime i start to learn c++ i find myself asking "why not python?" i then cease learning c++ and go back to work
>>
because this is a board full of pajeet javafags, hipster webdevs, and elitist Cfags
>>
>>56439217
>C++11 is fantastic.
Only if you don't look carefully.
>>
>>56439217
Because it's very easy to fingerprint different styles and so it's very easy to catch CS majors cheating by copy-pasting. Therefore everyone hates it and prefers autistic languages that force one style like java and python.
>>
>>56441804
That's true for literally any language.
>>
>>56441804
>that force one style like java and python
That's just formatting.
It's really the least distinguishing thing about your coding style.
>>
People shouldn't like what I don't like
>>
C++ is an insult every practice built by computer scientists over generations.
>>
>>56441627
> problems stop being annoying once they are solved

wew
>>
>>56439745
Java is never near 10x slower... Maybe 3x BEFORE jvm warmup
>>
>>56441909
java is 100x slower than c
>>
>>56441924
Not even remotely true
>>
>>56441878
The point is you setup your build system ONCE.
You have to deal with C++ bullshit ALL THE TIME.
>>
>>56439217
because this is /g/ and everyone hates the language they don't use and loves the one they do.
>>
>>56441936
it depends on the vm and code that is running. if it's pure algorithmic code without io, and if jvm is a standard stack machine implementation (dalvik on android is register based), it would be 100x slower than optimized C code.
>>
File: wronghole.jpg (325KB, 1024x778px) Image search: [Google]
wronghole.jpg
325KB, 1024x778px
>you will never decide which language to learn because of intimidating flame wars

It hurts
>>
>>56442026
Pick any. It really doesn't matter.
They're all shit one way or the other.
>>
>>56442026
if in doubt learn C. first programming language is the most important one because it shapes your brain, the way you think, if it's basic, you can never be a good programmer again, as master dijkstra states.
>>
>>56442013
No it's not, that's a totally baseless claim. No benchmark has ever shown Java being remotely close to 100x slower than optimized C. Even most benchmarks don't bother with the warmup phase which compiles the code to native.
>>
>>56442026
C/C++/java are all a good place to start. Not everything about them is initially intuitive which is why I think it's a good place to start. If you can hack it in these languages, you can pretty much hack it in anything until you start getting into things like assembly.

Afterwards. Go directly to python. It's easy to pick up and you can learn more advanced things and make some neat stuff.
>>
>>56442013
Look at this: https://benchmarksgame.alioth.debian.org/u64q/java.html

These are all pure CPU algorithms compared between languages. Worst case Java is 3.5x slower, other times it's almost equal. I don't even think they warmed up the JVM before doing these benchmarks anyway so it's almost totally irrelevant.
>>
>>56439511
>ide
>>
My company doesn't use a compiler that is fully C++11.
>>
>>56441623
C, D, Pascal, Ada, Zig. Also, Rust, because unlike with C++ their compile time issues aren't because of a flawed design but a flawed implementation.
>>
>>56439217
I like it. I feel like I get the pros of Java and C with C++.
>>
args*

* <- WTF is this?

hwnd ?

C/C++ it's incomprehensible

i prefer python and java
>>
>>56443616
>I'm retarded and can't grasp how computers work, so I prefer to use languages designed for retards
>>
>>56442044
fake, I learned haskell and now am learning c
c goes about a different way and is more barebones. causing me to shift my thinking
>>
>>56443616
int main(int argc, char* argv[])
{
return 0;
}

int argc is how many arguments are provided
char* argv[] is a char pointer array of the arguments provided

are you disabled?
>>
>>56443616
>>56443717
>>56443785
ARG
>>
File: pizza2.jpg (74KB, 500x666px) Image search: [Google]
pizza2.jpg
74KB, 500x666px
>>56443616
cliché
é <-- WTF is this?
hwnd ?
Writing it's incomprehensible
i prefer looking at picture books
>>56443717
>I assume everyone needs to learn C/C++, so I prefer to strawman arguments so I feel better about myself for learning a REALLY HARD language
>>
>>56443616
>I'm too dumb for pointers
kys, you deserve python
>>
>>56439217
C++ is great for something like an in memory dbms working on futuristic shit like non-volatile memory.

C++ is a nightmare for large distributed systems and networking like what google was doing for 10 years before they invented Go for that work.
>>
>>56443807
It wasn't a strawman, you are literally that retarded.
also if you think C/C++ is "really hard" maybe you're not cut out for CS
>>
I don't hate it, I dislike it. It's neat to make something on Linux and run it on Windows, for ex. in Java or Python.

Portability is not a meme.
>>
>>56443616
Watch this: https://www.youtube.com/watch?v=ASVB8KAFypk

And no, he's not pajeet
>>
>>56439217
c is love c is life
>>
The problem C++ was trying to solve was noble. the execution was a disaster. The language is too big. There are 1,000 different ways to do the same thing. People tried to overcome this with "patterns".
But, if you want to develop a large project that executes quickly. You don't have much of a choice but to use C++.
>>
>>56443717
Why don't you learn Asm then?
>>
>>56444156
for you
>>
>>56442044
>First programming language is the most important
I started with Game Maker Language for fuck sake, he can learn C/C++ later
>>
>>56439217
The one thing that annoys me most about C++ is that references can't be null. Also namespace access syntax and C backwards compatibility.
>>
>>56444626
I already know various assembly languages.
>>
>>56442026
I started with java then c then c++. I learn a new language from dummies guide to. Then more complicated books, it really doesn't matter.
>>
>>56444156
there's still go
>>
>>56447392
>GC
>>
>>56441676
>python
I'll never understand why someone would truly like that language
>>
>>56439511
How the fuck did nobody comment on the "126gb" of ram comment? /g/ you have let me down.
>>
>>56445432
>The one thing that annoys me most about C++ is that references can't be null

I'll give a pro to C# in allowing me to check references for null
>>
>>56442044
fake and gay
The only thing your first programming language needs to do, is do nothing that deviates excessively from the norm.

If you spent the first year or so learning some asinine shit like fucking Piet, you would probably pick up a bunch of stupid fucking habits that would take years to unlearn.

But if you learned something more towards the norm, be it C/++/#, Java, or literally any FP language and most imperative-like languages, you would be fine.

Granted, learning something like Assembly or VB is going to give you stupid habits like using gotos instead of structuring your code, or calling shit "if loops", but if those oldfags from the 80's could get used to shit changing and unlearn things, so can you.
>>
>>56443785
c makes use of an "end string" char, correct?
>>
>>56439217
Son, you are not allowed to love or hate programming language. Only your employer is allowed to. Don't fool yourself and think this is better and that's not. Programmers are like other forms of slaves. They are slaves to businessmen. They just happen to be smarter. Smart slaves.
>>
>>56443818

pointers r ard.

Incredibly confusing early on. after years of never touching them. They should be used early by having people use C and coming across char* etc so the idea of how they're used sinks in early.

Nothings more confusing than coming across a piece of code that's a ball of single character variables covered in & and *. It's important syntax and functionality that I wish I'd come across years ago instead of having gone down the VB -> python -> java -> c# - >c++ path.
>>
>>56449041
yes, a null terminator, ascii value 0 or '\0'
>>
>>56439443
>Use a unity build in small to medium sized projects
>Still compile faster than using a build system
>>
>>56439217
>Why does it still get so much hate?

Because it's hard and most of /g/ are the equivalent of Python hobbyists even though they think they're not.
>>
>>56439217

The problem is, C++ is a huge language. It's almost like a family of langauges. This is a strength but also a weakness because it's very hard to learn and git gud. It's also an issue when you read someone else's code. You can be totally awesome in C++ standards and then you read code where some dude did "template magic" and you understand nothing at all..


>>56442044

This.

C teaches you a lot about computers, not only the structures and memory allocation, but also stuff like system signals, the stuff you can do with the console and so on..
>>
Why not C++14? I used C++ a few times but with high level frameworks so didn't dive into it that much.

>>56442044
I have wanted to learn C for a while, but I can't think of anything interesting to do with it that wouldn't be more practical with a higher level language.
>>
>>56443616
Lmao. (^: I woke up scared from a nightmare just now and this made me feel better.
>>
>>56441676
Speed?
>>
>>56448094
>he fell for the 126gb meme
better?
>>
>>56442026
>Not just picking one and joining the flame wars.
>>
>>56439217
Because it's not c
>>
>>56449070
Well, when technology takes your job away. you'll want to be that kind of slave.
>>
>>56439236
This
>>
>>56439217
The problem I have with c++ is the books/tutorials.
They are "tutorial for beginners" but, as a beginner, I couldn't understand shit.
Microsoft did a great job with that c# step-by-step book.
>>
>>56442124
http://benchmarksgame.alioth.debian.org/sometimes-people-just-make-up-stuff.html#jvm-startup-time
>>
>>56442026
>learn just one

kill yourself.
>>
>>56447968
i love python for trying something out fast or throw away scripts
>>
>>56441909
>your language takes time to do self-optimizations while running
>>
>>56439217
I want to learn C++. Can I ask you what books/sites/other resources are you using? What compiler and IDE?
>>
>>56454813
learncpp.com

visual sudio community 2015 is the best IDE, and its free
>>
>>56443616
>hwnd
>cluttering c++ discussion with Windows Api bullshit
>>
>>56449102
Java has lots of pointers.. why did C teach you and not java (assuming your list is chronological order)
>>
>using C++
>any year after the release of RUST
ISHYGDDT
>>
>>56454939
>Java has pointers
When everything is a pointer, nothing is
>>
>>56454971
Lol I am not trying to say Java does pointers well/efficiently or in a logical way...

I'm just saying, a newb programmer will certainly run into pointer issues while using java, which I think would pretty easily teach you what a pointer is versus an actual variable...
>>
>faggots crying over pointers

jesus christ. they are simple as fuck.

one operator holds the address of the pointed to value.

The other points to the value held in the address.

WHATS HARD ABOUT THAT?
>>
I honestly have never programmed in C++ or C. I've never had a need for it because, frankly, my job never required me to do so.

I'm interested though. What are some of C/C++'s true strengths compared to other languages?
>>
>>56455429
available libraries, compilers, platform support. the wide usage makes getting help easy.
>>
>>56455540

Forgive my ignorance, but as far as I know, Java and Python both have extensive libraries across many API's as well. What kind of libraries does C++ have that Java or Python doesn't? I mean, I'm sure it exists, but I don't know so I'm curious.
>>
>>56455071
Start throwing pointers around in data structures and be amazed at how quickly you realize that you can't figure out when exactly to delete nodes.
>>
>>56455587
http://openmp.org/wp/openmp-compilers/
>>
>>56455635
>http://openmp.org/wp/openmp-compilers/

Ah interesting! Parallel computing. What's different between what you linked and something like https://docs.oracle.com/javase/tutorial/collections/streams/parallelism.html
>>
>>56455429
>What are some of C/C++'s true strengths compared to other languages?

Operating in soft to hard real time operation constraints. Potentially efficient use of memory. Easy to use SSE intrinsics to speed up your code.
>>
>>56455587
true, this argument doesn't apply when comparing to the other languages with massive user base. c++ main advantages are that it can run pretty much every platform there is with top-shelf performance.
>>
>>56442013
>I am clueless and have no idea what I am talking about
http://beautynbits.blogspot.com/2013/01/performance-java-vs-c.html
>>
>>56455717
>>56455744

Thanks for the replies.
>>
>>56455603
You will never "throw pointers around" if your design isn't complete shit.
>>
>>56439217
I think a big part of it is the template metamagic wizardry programming going on some people like to do. Also the average uninformed programmer is going to create 3 million copies by passing everything by value and he is going to skip doing range checks and other things he expects the standard library to do for him.

I'm in the process to refresh my C++ knowledge due to a new job and I have to say C++11 is really nice and added a lot of features a modern language needs. What bums me out that I can't get good code completion in qt creator even with the clang plugin. It really slows me down having to remember every single function and what it does.
>>
>make a thread safe buffer class to use in a producer-consumer test project
>realize I want this class to be generic
>add template<typename T> stuff everywhere
>LINKER ERROR
After troubleshooting the error for a few hours it turns out you can't separate the code body from the definition file when using templates. Using export doesn't work with my compiler, including the cpp file generates namespace compile errors and defining which classes I want to use with the template feels ugly.

I believe that troubleshooting and interpreting everything around the linker and compiler errors is why people hate the language. I have to say it's really annoying when you aren't a C++ expert.
>>
>>56445432
>C++ is that references can't be null
Eh what? Wouldn't that basically mean you are trying to dereference null?
>>
>>56455958
the header/source legacy crap really is a burden to templates
>>
>>56449041
Yes unless you overwrite it by accident :^)
>>
>>56456061
:^)
>>
>>56451075
>Why not C++14?
It's mostly small additions and bugfixes and I believe additions to STL. They are nice but not as important as C++11. I'm looking forward to C++17 etc because there appears to be good additions to the STL bringing it closer to other language's standard library.
>>
>>56454813
>I want to learn C++. Can I ask you what books/sites/other resources are you using?
I used http://stroustrup.com/programming.html the latest edition. It's a good start even if you have other programming language knowledge. Also google for STL reference and stackoverflow because there is almost always some other person that encountered your problem before and made a post about it there.

Just pick something you want to and pick a design pattern for it. Google C++ plus that pattern for code samples. Do a project while cheating and looking at how those people did it. Also codereview.com or whatever it's called is great for having people utterly destroy your code and call you a fucktard.

>What compiler and IDE?
I use qt creator and msvc2013 64 bit. Only due to qt being compiled with msvc. I hate the setup and the code completion is non-existent or lags 30 seconds. There must surely be better solutions.
>>
>>56455603
I'm new to C++ and this sounds like some tard thinking C++ is just C with classes. If you pass pointers around you will of course have no fucking idea when it's time to delete that memory.

That's why you have references. You pass your shit by reference. If the function expects a reference it doesn't expect to inherit ownership and the responsibility to delete the memory. And use smart pointers if you really need to pass around pointers.
>>
>>56439217

Do you actually use it for serious large scale projects?
>>
File: 8d0.jpg (55KB, 500x500px) Image search: [Google]
8d0.jpg
55KB, 500x500px
>>56441316
>garbage standard library
The STL is probably one of the best standard libraries around.
>>
>>56445432
Why would you ever want a null reference?
>>
>>56447392
>>56454964
MEME LANGUAGES
>>
File: v1qQH2N.png (483KB, 720x830px) Image search: [Google]
v1qQH2N.png
483KB, 720x830px
>>56455603
>t. a retard who can't manage his pointers
>>
>>56439217
>the thing that i exclusively use is good
>>
File: Bait (3).jpg (95KB, 680x989px) Image search: [Google]
Bait (3).jpg
95KB, 680x989px
>>56456342
No
>>
>>56439443
Install clang. And use a build system so that you won't have to rebuild everything.
>>
>>56444015
Use portable libraries? Retard.
>>
>>56443616
>hwnd
That has nothing to do with c++

>intimidated by pointers
You are garbage tier
>>
>>56451075
Mostly because C++11 made C++ almost a new language. Auto keyword, Java-style for loops, thread/async, lambdas...

I wish that newer revisions bring some more idiomatic ways to deal with Collections/Iterables. Typing begin and end endlessly makes the code really ugly, especially after the changes introduced in C++11
>>
>>56439217
the key to C++ is to write as much of it as possible whilst using as little of it as possible
>>
>>56458014
>intimidated
more like can't be fucked

for the quasi totality of new projects in 2016, GC is good enough
>>
>>56456266

But the other guy was right..

Pointers are simple if you don't dpo anything fancy. But as soon as you start to get fancy it can become complex pretty fast.

I.e. data structures like trees or networks.

Let's make a simple "doubly linked list" in C/C++. I'm not saying it's not doable, but I bet will have to spend some minutes thinking about where to delete references and most guys won't get it right at the first try. The same problem in C# or Java is just easier to accomplish.
>>
>>56458164
>Let's make a simple "doubly linked list" in C/C++. I'm not saying it's not doable, but I bet will have to spend some minutes thinking about where to delete references and most guys won't get it right at the first try
Isn't this why one should use Allocators when designing a container class?
>>
>>56439236
No, I'm using x and you are using y, faggot.
>>
>>56455429
Control over memory. When you use a language like Java, you lose the ability to manage your memory allocation and deallocations. This can have tremendous performance implications for latency sensitive applications like vidya and trading systems.
>>
>>56459050
i work in hft. java gc isnt really an issue as we customise the jvm so we dont gc until out of trading. means we build up a lot of shit, something like 2TB/ram/day, but once gc hits (and can take a long fucking time) its down to a few GB

java is actually pretty awesome for hft as it allows for hotpatching which is a fucking nightmare in c++ and requires lots of horrible runtime hooks that are compiler specific. java "just works". same reason things like erlang are so good for telecomms
>>
>>56456539
So you can return null from a method indicating that something was not found.
But you're stuck with either pointers or exceptions. And pointers are fucking shit, and exceptions are out of the question for this use case.
>>
do people who use c++ actually finish anything?
>>
>>56439217
Because deep down inside, most of the people on /g/ are casuals who think interpreted languages are as good as compiled languages.
>>
>>56463222
I finished a pong game in windows console.
shit was cash
>>
>>56439217
Cpp11 is the new Java. Wait, it is even worse than Java. Piece os shit.
>>
>>56463502
>casuals who think interpreted languages are as good as compiled languages

What if my favourite language is Erlang?
>>
>>56439217

The majority of the userbase still consists of gen-x'ers who can't into templates.

At that point, it really is just C with clazzes.
>>
File: smug_stimpy.jpg (40KB, 514x459px) Image search: [Google]
smug_stimpy.jpg
40KB, 514x459px
>>56463530

I once finished a whole tetris game. Even russified the menu.
>>
>>56463569
I tried making an arkanoid clone, but I can't into math and the ball would only hit every other block.

Like every other block was impossible to hit for some fucking reason lol
>>
>>56463543
First up against the wall when the revolution comes for being a smarty-pants.
>>
>>56441664
maybe
>>
File: georgeFrustated.jpg (13KB, 188x194px) Image search: [Google]
georgeFrustated.jpg
13KB, 188x194px
is there a REPL like environment for C? I come from haskell and I usually prototype and check types in ghci. On C I ca kind of fake it with gdb at correct addresses, but I would like some real repl.
>>
Which resource should I use to learn how to make a GUI with Qt?
>>
>>56439236
>x
>y
>not using z
>>
>>56463742
Fucking z pleb
>>
>>56461831
>So you can return null from a method indicating that something was not found.
You use iterators. You return the element one beyond the last element (end()). It's how STL does it.
>>
>>56458164
Yep.
Try a multithreaded CLH queue lock with reusable nodes. The actual locking part is easy. Cleaning up after yourself when unlocking is hard.
>>
I never found an use for C++. If I want performance, C is unbeatable and forces you to adopt strong software architecture. If I want to pump out reasonably performant code quickly, Java is the tool for the job. If I just need to throw some bullshit together, Python has me covered.
>>
>>56442026
>waah people disagree with me online
pussy
>>
We've seen this same thread 8 times now.

I'm scared
>>
I worked in C++ (and C) for close to 15 years. (I am in my 40s, yeah an oldfag) until I had the opportunity to switch to Java 3 years ago and took it just because I wanted a change. Now I never write in C or C++ if I can help it. It is way too much work these days. We don't live in a world where every cpu cycle matters anyway. We have phones with 3+GB RAM and multicore CPUs. Shit is insane compared to what I had to use in the 90s.

Java gives me around 80-90% of C++ speed with about 30-50% of the mental effort. It has stable built in networking, UI and threading features. Really the only downside is needing the JVM installed but that is trivial to solve these days.

Now Java isn't perfect but you need to ask yourself if you really need the small performance benefit of C++ for all the extra complexity it brings. After being a developer for 20 years I much rather use something that makes life easier than harder.
>>
>>56466643

Some of you Python developers are allright.

Don't go to the code retreat tomorrow.
>>
File: c_plus_plus.jpg (10KB, 435x139px) Image search: [Google]
c_plus_plus.jpg
10KB, 435x139px
>>56466933

This.

C++ will always have it's place when it comes to OS or graphical stuff.

But for the "everyday work" it's just too bothersome.
>>
>>56439217
C++ is really syntactically complicated, mostly because people wanted it to have backwards compatibility with C.

I'd take it over Java any day though.
>>
>>56463742
There's a reason no one uses z; enjoy your scripting language.
>>
>>56467022
yeah if i am writing a driver i will obviously use c(++) but the need to do that is very small. almost everything i do is get input from the user/network/db, do something to that data (often many, many times) then write the result someplace. for that it makes zero sense to use c(++). the jvm does an amazing job of making the repetitive tasks fast. the biggest latency is due to i/o not processing power. even on mobile hitting the network is orders of magnitude slower than cpu with the exception of some edge case stuff like codecs and 3d graphics. so if you are writing a video codec or 3d render pipeline then yeah by all means you want c(++) but for your average program with a normal UI that transfers data over the network java is more than good enough. plus all of the cool things in java like much better debugging and hotpatching makes it a non-brainer.

also even with a messy codebase thanks to foreign out sourcing java makes it much easier to manage and refactor than C++. InteliJ IDEA is a fucking god send as it allows me to be so much more productive than any other tool I have used. it catches so much bad code and even *gives you a better solution* with the click of a button. it is almost like it writes the code for you. seriously i have loaded up horrible older java 5 shit written in the 3rd world and it has converted it into easy to maintain and test java 8 with hardly any mental work from me. i just have to click ok to a bunch of refactor suggestions.

back when I finished my masters (1997) i was all about writing my own solutions but then i started to realise far smarter people than myself had fixed these problems in much better ways. rather than fixing the problem for just my specific scenario they fixed it for pretty much everything. using the built in features of the language means it is thread safe etc which wasnt true for my own stuff all the time as i wrote to fix MY problem not fix THE problem.
>>
>>56439217
Use Dlang. Thank me later.
>>
>>56467604
continued... programming today is a lot like building with lego. you have all the parts you need available to you but knowing how to put them all together in a way that works and is stable is what requires the real skill. before this lego programming stuff you had to use meccano which is similar but took longer and required you to fiddle with little nuts and bolts to often built something that might do the same job but was also more clunky. its about using the right tool for the job. somethings it makes sense to go and build a special piece to make things work better but more often than not you can just figure out how to do it without needing to reinvent the wheel.

C and C++ is nice for simple command line tools but for anything with GUI I would avoid.
>>
>>56439572
no, you're a pleb for calling /thread on your own post.
>>
>>56461831
>>56464317
or throw an exception
>>
>>56466933
So why does a windows phone with 2 generations older processors run everything smoothly without lag while a flagship android device can't provide a smooth user experience? Your performance may not matter on a desktop but on a mobile device it's still very relevant.

Is the jvm on Android such a poorly coded piece of shit that you can't eliminate lag without scrapping the entire jvm? Or is it a java feature because it appears microsoft can interpret code way faster on mobile.
>>
>>56467703
for simple programs with GUI, C# ist just as nice as Java.
>>
I hate C++ so fucking much.

I wish I didn't, I wish it was the C 2.0 everyone needed, but it just isn't there.
>>
>>56467976
It's nicer. Java is purge garbage and I don't understand why anyone would want to use it. Didn't microsoft port everything .NET to linux already?
>>
>>56467992
Not Windows Forms, only simple command lije stuff, I think
>>
>>56439217
C++ makes me feel fucking stupid, especially when reading other people's code
>>
>>56467917
i can confirm this post, im still using a lumia 520 since 2012 because it just works for me.
it runs smooth without lag, but it has loading screen.
>>
Can we talk about how fucking stupid inheritance is?
>>
>>56468122
Yeah it's pretty shit but sometimes you can't avoid it. Coming from C# I try to make virtual/abstract classes to emulate interfaces.
>>
>>56468205
Interfaces are even worse.
>>
>>56468231
How so? They describe a contract a class is expected to fill. It's very useful. It makes writing decoupled code easier. I use it to swap different kind of producers depending on which hardware it runs on.
>>
>>56468347
The only need for interfaces/virtual base classes if you're using polymorphism, and even then a switch statement does a better job.

Why would anyone write a blueprint for a class?
Just write the class.
>>
>>56468396
>Why would anyone write a blueprint for a class?
Plugin system? Being able to make future extensions by "just writing the class" without having to make changes to existing code. In my example I have a server process that reads a configuration at start, dynamically loads the libraries in a folder to be able to read from certain hardware interface depending on hardware.

To run the software on new hardware interfaces for data acquisition I just write a new plugin without having to change any other code that is already tested. Granted you don't really need polymorphism for a plugin system. I find interfaces makes it easier to write decoupled code.
>>
>>56468073
(You)
>>
What is the point of private and protected variables?
>>
>>56468614

Reducing likelihood of errors. Only exposing methods and properties to outside the class space that are supposed to be manipulated outside.
>>
>>56468941
But what's the difference between changing data inside the class versus outside?

If I want the data, I have to use a function from the class, which can still access the private data but then other functions can't access it so I have to make more functions within the initial class.
>>
>>56469261
abstracting...

You are isolating your solution of a problem to a small space/scope that is reusable to other parts of a code.
>>
>>56469301
But it's hidden. It's not reusable.

I just want the variable.
But people keep yelling at me not to use global variables, to make everything private.

Now I have to keep track of what's private, what's public, what inherits from what, whether it inherits private data or public data.
>>
>>56469365
Read up on design patterns. You reuse the objects.

Let's say you have a member variable x with valid values in the range 1-25. If you had direct access to the member variable you could assign 789 to that variable. But if it was private you would have to do
bool set_x(const int& xx){
if(xx<1 || xx>25){
return false;
}
x = xx;
return true;
}

It would prevent you from setting x to invalid values. It's just an example of abstraction though,
>>
>>56469365

You are reusing the whole logic of the class/module you write, not the variables hidden within.

You are making your life easier by making guarantees about the integrity of the logic contained within the class, not having to worry about other parts of code modifying your privates constantly.

If you just want to write a program that uses a single linear register of data with no regard to software architecture, reusability, readabality, feel free to do so. Whoever has to read your code will hate you though.

Abstractions are your friend. Computers wouldn't work without them.
>>
>>56469517
That's a lot better.

Now I just have a function to go with any int instead of something declared private within a class.

That makes more sense. Tanks.
>>
>>56469642
I still don't understand the need to make data private.
If the data can still be accessed via what they call getter and setter functions, what's the difference?
>>
>>56469756
Are you just starting out with programming? If you are I would suggest you read an approved entry level programming book for your selected language. It will bring up classes kind of late because it will only confuse new programmers. With experience most will see the benefits of encapsulating stuff.
>>
>>56469835
I get classes, I just don't get 'classes'.

Classes should just be containers.
You lose out when you couple your functions and your variables together because they could work on anything.
>>
>>56439217
Because D deprecates C++.
>>
>>56469865
That's some massive imperative programming thinking. When making a math lib it certainly makes sense to just put a lot of functions in a namespace.

Consider a car factory. It can produce many models of a car. How would a generic function convert the class to a string when every car can have a different set of features, names, other data etc. Would you
std:string car_model_alpha_to_string();
std:string car_model_beta_to_string();
...

And just keep adding util functions in your car factory util lib for every car you add? Or would you just do a base class car with a virtual function called to_string() that every car model inherits from? In the latter case you know that every car implements a to_string() method that will serialize the class correctly to a string.

It's a poor C++ example but do you get the idea? If not you really need to pick up Design Patterns: Elements of Reusable Object-Oriented Software and read it.
>>
>>56470159
Why not put the string of each model in the class as a variable?
>>
>>56455851
>I'm in the process to refresh my C++ knowledge due to a new job
http://stroustrup.com/Tour.html
>>
>>56470256
What about printing feature lists, options, etc? Just hard coding it in a string doesn't really make sense. As said read the book referenced.
>>
>>56454813
>I want to learn C++
Anon already linked you the single best book for learning programming, PPP2.
>>56456206
Learning to program is done by programming. Using a book is the best way to help you start to actually write programs in a methodical way. This book is the single best one for a beginner bar none. Also, here's the best book list:
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list

>>56456206
>There must surely be better solutions.
Linux, libclang & juCi++.

>>56456266
>That's why you have references
References are still just pointers and can be abused just as easily as 'real' pointers. If you really want to do it correctly use the Owner<T> typedef from the GSL
https://github.com/Microsoft/GSL
and follow closely the advice of the Jedi Council for their proper use.
https://github.com/isocpp/CppCoreGuidelines

Take these two steps and you will never leak resources again.

>>56458031
>I wish that newer revisions bring some more idiomatic ways to deal with Collections/Iterables
Bjarne has been fighting the Committee over the introduction of Concepts for literally decades. I blame them. Also, Ranges will be a great improvement.

>>56466933
>but you need to ask yourself if you really need the small performance benefit of C++
It's a 90/10 thing anon. For solutions where latency is a showstopper, that 10% is critically important. Otherwise try and use Python if you can, not Java.

>>56469806
>If the data can still be accessed via what they call getter and setter functions, what's the difference?
Only a complete pleb would use getters/setters in C++. Don't be a pleb anon.
http://www.yegor256.com/2014/09/16/getters-and-setters-are-evil.html
>>
File: 131947619456.jpg (24KB, 400x400px) Image search: [Google]
131947619456.jpg
24KB, 400x400px
Do people unironically use anything but C# as their main language? I thought that was a meme.
>>
>>56470745
>getters-and-setters-are-evil
Is there anything that isn't evil in a programming language according to someone?
>>
>>56471051
>"Exposing implementation details is an awesome idea!"
said no project lead of a big system ever.
>>
>>56471096
The article linked suggested that the solution to get and set functions is to rename them to something else but keep the same logic. Poor example why something is evil and not very convincing.
>>
>>56470823
Currently learning C++ but will move on to Java soon on my own vocation
>>
>>56471212
>The article linked suggested that the solution to get and set functions is to rename them to something else but keep the same logic
'''. . .'''
As you apparently didn't read the article, I'll forgo any further response anon.
>>
>>56439217
I'm trying to learn C++.

I made a program to fetch and use JSON from a API i created, and now i'm trying to make a pong clone with SFML.

Why should i use C instead of C++ if i can make C++ just werk?
>>
>>56471590
The article is garbage.
>Start thinking like an object and you will immediately rename those methods

Do link something else not written by an idiot that got some kind of revelation after reading a book and is now preaching something he fully doesn't understand.
Thread posts: 206
Thread images: 14


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.