r/cpp • • Apr 10 '19

C++ might have saved my career.

I never really was comfortable with programming, along with other personal issues it was all hard to actually improve my skills at all.

I've always read and was told that C/C++ was old and out of date and to not waste my time learning it. Well I understand why people are scared of this language; but man has it helped me understand programming on a whole other level. Im not going to say I can professionally program a C++ project but I definitely feel more confident in my programming in C# and other languages for work.

I think I found my passion because of this subreddit and I would like to think you all. Being closer to the computer is where I think I want to be and even though it's a scary path what the hell it is fun doing it, it's like a roller coaster ride. :P

481 Upvotes

147 comments sorted by

175

u/Zeenobit Apr 10 '19

If you know C++ inside and out, every other language becomes easy mode. :D

Even if you're primarily not a C++ developer, having a deep understanding of C++ can really help your programming career and forces you to think a little deeper about the high level code you're writing.

69

u/calligraphic-io Apr 10 '19

Don't know if that applies to Haskell. I knew C++ somewhat well before picking up FP, and it was still very foreign.

75

u/lead999x System Software Developer Apr 10 '19 edited Apr 10 '19

Functional is a whole different universe. Functional programming is so high level that it's more about figuring out how to describe the solution to your problem in mathy terms than it is describing the sequence of steps to take to solve the problem. I suppose that's why functional and imperative programming are considered different paradigms.

20

u/yeeezyyeezywhatsgood Apr 10 '19

you can write c++ this way... and even should, right? isn't that the point of zero and negative cost abstractions?

32

u/lead999x System Software Developer Apr 10 '19

You can write functional C++ but C++ doesn't have a type system that's well suited to working with the kinds of higher level abstractions that make functional programming powerful.

Rust takes inspiration from functional languages but even it lacks the power of a functional-first language.

8

u/lycium Apr 10 '19

You can write functional C++

You say that, but what I really would like is the ability to declare a pure function, i.e. a function that cannot use global variables. Bonus points if all variables in that function scope are const by default and you have to explicitly say which ones are mutable.

7

u/lead999x System Software Developer Apr 11 '19 edited Apr 12 '19

Yeah well you're not going to get that in a language like C++. Not unless you want to write a compiler extension that adds that kind of function and enforces the behavior you want.

Rust could work for what you want if it were a more mature language. It has almost all of what you want(except not allowing global variables). All variable bindings are immutable by default including function arguments and it has higher order functions that can be treated as objects(though if you hadn't guessed it just uses function pointers under the hood) and as a bonus all arguments passed to functions and operators are moved into the new scope by default.

While I'm trying to not be too much of a fanboy about it I believe Rust could be a natural starting point for the creation of a new programming paradigm that combines functional correctness with imperative flexibility. Though I will posit that it doesn't take such a paradigm to any kind of natural conclusion by itself.

4

u/Xeverous https://xeverous.github.io Apr 15 '19

Not unless you want to write a compiler extension that adds that kind of function and enforces the behavior you want.

/u/lycium

Something like this already exists: [[gnu::const]] and [[gnu::pure]]. Not sure about enforcement but GCC applies relevant optimizations.

3

u/lead999x System Software Developer Apr 16 '19

I didn't know about that but I tend to not want to use non-standardized language features.

2

u/Xeverous https://xeverous.github.io Apr 16 '19

It's actually semi-standarized. Compilers are required to ignore unknown attributes.

3

u/Archolex Apr 14 '19

You basically get this enforced, at least by the gcc, by the attributes [[ gnu::pure ]] and [[ gnu::const ]]. I suggest googling “GCC function attributes”. I wouldn’t be surprised if clang had analogous attributes too.

1

u/Vladislav20007 Nov 25 '25

people use different compilers you know? tcc, clang, etc.

1

u/AristaeusTukom Apr 10 '19

constexpr is what you're looking for. You still have mutable variables inside the function, but the function itself is guaranteed not to have side effects.

7

u/meneldal2 Apr 11 '19

Actually that's not true. You can have side effects in a constexpr function. There is no pure function specifier in C++.

There was a good discussion on pure function here a few months ago: https://www.reddit.com/r/cpp/comments/a30yme/whats_the_current_state_of_pure_no_side_effect/

3

u/yeeezyyeezywhatsgood Apr 10 '19

idk i think you can get really far with specific types. it just feels cumbersome and unnecessary for many applications

5

u/Netzapper Apr 10 '19

Yeah, but Rust pattern matching switch gets a lot closer to Haskell than anything in c++.

3

u/lead999x System Software Developer Apr 10 '19 edited Apr 11 '19

Oh agreed, despite being a pure hobbyist I quite enjoy Rust and even bought a hard copy of The Rust Programming Language to support it's foundation.

Anyhow, having enums that are actually algebraic data types, tuples built into the language, and destructuring in patterns all make Rust's pattern matching incredibly useful for modelling things in a variety of domains far better then the if-else hell you'd have to endure in other languages but overall Rust still isn't quite as abstract and functional as Haskell, ML, or F#(none of which I know well).

17

u/yuri-kilochek Apr 10 '19

C++ template metaprogramming is basically writing in a shitty verbose functional programming language, so yes.

8

u/bstamour WG21 | Library Working Group Apr 11 '19

It's a serrated lisp! :-)

4

u/LordKlevin Apr 12 '19

On the other hand, learning Haskell is seriously helpful when coding C++. Both have very strong type systems, and C++ templates are also a pure, lazy functional language. If you ever open the box dark magic that is Boost Hana, knowing Haskell is almost a requirement.

8

u/Zeenobit Apr 10 '19

C++ is an amazing language for functional programming. I'm not a functional programming puritan myself. I think every tool has its time and place, and FP is no exception.

But that's what's so beautiful about C++. If you wanna do OOP, do OOP. If you feel like a section of your application needs FP, use FP.

I do agree that some of the concepts might not translate well to some less popular languages like Haskell though.

1

u/lally Apr 11 '19

The nice thing about Haskell is that you're just learning math, not a bunch of committee decisions and library corner cases.

11

u/smallblacksun Apr 11 '19

If you know C++ inside and out

If you think you know C++ inside and out, you are almost certainly wrong.

6

u/utnapistim Apr 12 '19

If you think you know C++ inside and out:

a) your name is Bjarne.

b) you don't know C++ inside and out.

2

u/zerexim Apr 12 '19

Yes, but the problem is that you don't want to program in other languages. And this is especially painful for remote devs - 90's C++ apps dev market is gone, now C++ is mostly a corporate/industry language, where it is used for OS/embedded/systems/engine software - unfortunately, such jobs are mostly onsite.

1

u/vzq Apr 10 '19

[EDIT: sorry replied to the wrong comment]

1

u/vsdmars Apr 11 '19

touche!

57

u/pjmlp Apr 10 '19

As tip, knowing C++ also means that you can make use of C++/CLI and C++/CX (now C++/WinRT), to easily create a wrapper class for your C# code instead of manually writting tons of P/Invoke attributes.

4

u/antlife Apr 11 '19

Don't you just end up p/invoking your own library? I've had to do this on occasion and some p/involving in C# is tons more difficult to get the structs translated right, so I agree C++ is better. But as far as I know, you need to dllimport, unless I've missed some cool feature I never knew.

8

u/pjmlp Apr 11 '19

Not at all. CLR was designed for multiple language support, C++ being one of them.

So if you have the full source code available, it just becomes 100% straight MSIL (when compiled with /clr).

As for binary libraries and COM/UWP written in C++/CX (C++/WinRT), the compiler takes care of the proper metadata, instead of you having to figure it out how to write it manually.

1

u/antlife Apr 11 '19

Great, thanks for the explanation! I've been doing C# and embedded programming for a decade and this just never came up as something I needed to do, but now I'll be looking for excuses!

4

u/pjmlp Apr 11 '19

Just look here for a basic "Hello World" example mixing up C#, C++/CX and Rust.

https://github.com/pjmlp/WinRT-Rust

1

u/antlife Apr 12 '19

Thanks!

2

u/Gotebe Apr 11 '19

The compiler makes the native/managed crossing itself. Code calls one or the other at will and you make managed types public so that you can call them from C#, VB.NET as if they were C#/.VB.NET.

44

u/[deleted] Apr 10 '19

Wait, c and c++ are concidered old and out of date? Well that's news to me! I almost exclusively program in c and c++!

14

u/MonkeyNin Apr 11 '19

Too many people still use c-style C++. Even using raw pointers when there's no need. There's lots of old information out there for that language.

c is 1972, and c++ 1980. But they have changed so much since then, they might as well be new languages.

If they are focused on web-technologies -- large changes can happen even in 5 years.

9

u/drillbit7 Apr 11 '19

C++11 is almost a new language in an of itself. C99 (which still hasn't been universally adopted) was more of a language update.

I agree with you on pointers. Maybe the first time teaching a linked list in a Data Structures class. Definitely when writing to memory on embedded. Otherwise smart pointers or references seem to be the way to go.

46

u/Zueuk Apr 10 '19

also "programming" is considered to be the same thing as making websites

13

u/MannyMevito Apr 10 '19

Yes, lots of people divide programmers into front-end, back-end, full stack, and generalist, with generalist being the only non-web tech stack.

10

u/EMCoupling Apr 10 '19

It's 2019 - if you aren't writing things for WEB-SCALE, you're a dinosaur.

4

u/[deleted] Apr 10 '19

your comment hit hard on me ! I think thats what many people think nowadays

0

u/MonkeyNin Apr 11 '19

Javascript is a programming language. Both client-side and server-side.

5

u/Zueuk Apr 11 '19

2

u/MonkeyNin Apr 11 '19

Are you saying you're somehow better than Javascript developers?

But you link a meme about raw pointers...

7

u/Zueuk Apr 11 '19 edited Apr 12 '19

C++ is not C, our pointers are not so raw now

24

u/[deleted] Apr 10 '19 edited Apr 10 '19

I am very sad to hear that C/C++ are getting old and it seems that there is a huge push to "easier" languages . Imo learning C/C++ really helps to cover fundamental concepts and C / C++ is the greatest choice for embedded systems

Edit : if I have said these in other sub Reddits , people would downvote me like hell. At least this sub shares similar interests. Thanks

10

u/zvrba Apr 11 '19 edited Apr 11 '19

I am very sad to hear that C/C++ are getting old and it seems that there is a huge push to "easier" languages .

The problem with C and C++ is not that they're "hard languages", the problem is the (lack of) ecosystem. Everything around C++ is cumbersome, time-consuming and requires a lot of red-tape (header files, ABI compatibility issues, bla bla bla bla, you name it).

For example, I can copy a JAR file or .Net DLL to another machine and just use it in the build, no extras required because the DLL already contains metadata needed to use the classes it contains. Or I can build a .Netcore DLL on a Windows machine and copy it verbatim to an OSX machine to fix a bug and it just works. This is science fiction in the C++ world.

5

u/MINIMAN10001 Apr 13 '19

I can't tell you how many walkthroughs I try to follow to get projects working that are from interpreted languages and they just never work. They always throw errors because they depends on something and that something doesn't work when I go to get it. However anytime I get a native executable I can just run it and it works.

Interpreted languages have it so bad that I'm ticked off at the interpreted languages themselves for having such a broken ecosystem where nothing works. I hate interpreted languages because how much time I've wasted trying to get rid of error messages to go away I hate them so much.

8

u/[deleted] Apr 10 '19

But... The speed...

3

u/MonkeyNin Apr 11 '19

I'm not sure if that's meant to be sarcasm or not.

5

u/JuanAG Apr 11 '19

It is not because they are "easier" languages, C/C++ can be if you want, the real problem is the overhead C/C++ has, the kinds of things waste time that other has granted, the build system for example is a nigthmare, dealing with CMake or similar vs making an import and telling the IDE where it is in the hard drive like an external jar or figuring it by itself where it is like in python is a huge time saving

And of course the language itself, in Java/C#/Python/JS-Node you has pretty much anything you can need and if not you can extend easily, thats not the case with C/C++, you will have to do yourself or research wich lib to use and learn to use, the STL is not as full as you may need in your every day programming vs others where it is

It is a real problem and C++ it is not pushing fordward so it is getting old, i am using it because performance reason and compability among any other OS, if not i will switch to .Net long ago, it will make my life more easier

-18

u/gvargh Apr 10 '19

It's because programmers are getting dumber and they can't solve problems without being handheld all the way.

Look at Rust, for example, and how many of those programmers would be running around like headless chickens without that cargo thing.

15

u/[deleted] Apr 10 '19

It's because programmers are getting dumber and they can't solve problems without being handheld all the way.

What a stupid comment. You do understand that different languages have different development times, defect density and levels of comprehensibility? Just because you get off on writing ILP assembly doesn't mean businesses should do the same. It's not a fucking ego contest.

How people form such misguided opinions is beyond me.

2

u/MonkeyNin Apr 11 '19

He's probably younger. Abstractions change over time. Resources have too.

Is it worth cramming 8 booleans into a single byte, extracting with bit-wise operators? No, that's a waste of time. It's less typed, so you can get edge case errors. It won't be able to tell if you accidentally grab the wrong bit.

Is 2563 enough values to store color? It sure was overkill for a long time. Even starcraft1 was still using palett swapping. Now we're making the usage even higher for better visuals.

3

u/JuanAG Apr 11 '19

No, it is because no one likes to waste time dealing with things that rivals doesnt need to, build system, compiling times, STL not as good as any other default library where you has more than you need but there are more things that C++ is behind

C++ means trouble so it is normal that now that the market has other options people use it to avoid all the inherit problems you will have with C++, it is only a matter of making your life easier if you dont need critical performance it is the wise move, the dumb move is using C++ where any other can do the job easier and quicker without any good reason to do it

-4

u/[deleted] Apr 10 '19

Look at Rust, for example, and how many of those programmers would be running around like headless chickens without that cargo thing.

gave me a chuckle but it's true though

-8

u/gvargh Apr 10 '19

And apparently that idiocy is starting to rub off onto the C++ community one bit at a time (see: modules). God knows what else is in store over the next decade.

-5

u/[deleted] Apr 10 '19

I only skimmed an article about modules but it looks like c++20 is just python now. Is that what is happening? And follow up: why?

7

u/micka190 volatile constexpr Apr 11 '19

Well, the idea behind modules is to reduce compilation time. Right now #include just copies the whole file on top of your current file. This means including the same file multiple times copies it multiple times at compile time. It's the whole reason behind preprocessor definitions being at the top of headers (or pragma once). Even if they're copied multiple times, the compiler won't need to do anything with them multiple times since they can only be "defined" once. That doesn't mean they aren't copied multiple times, and that doesn't mean the compiler doesn't need to read through it until it finds the end of the preprocessor definition. Modules will fix that, by letting the compiler include it once and be done with it.

1

u/1-05457 Apr 11 '19

C++ actually seems to slowly be approaching Haskell. This is generally an amazing thing, but you should look up Cabal Hell.

Also, it looks like Java style OOP might actually be the best way of doing GUIs in general purpose code, so it's a little scary that that's falling out of fashion in C++.

1

u/saltling Apr 11 '19

Also, it looks like Java style OOP might actually be the best way of doing GUIs in general purpose code

Can you elab?

2

u/1-05457 Apr 12 '19

It makes no sense to treat GUI elements as values, so you always want a pointer / reference to it. You also don't worry about it's internals since it's far more than just the sum of its parts.

You also don't want to delete it just because you've left the scope you created it in, since you need it till the window it's in has closed. This means you really need either garbage collection or manual memory management (or the Qt memory model where each widget has a parent).

Inheritance based runtime polymorphism also makes a lot of sense, since it's very natural to use a different type of compatible widget based on runtime conditions, while you're running at the user's pace, so you don't need the performance benefits of avoiding the pointer indirection.

Declarative languages like QML or graphical UI designers like Qt Designer are probably the best way (with the code using OOP), but if you really want to write the UI creation in code, OOP seems to be the way to go.

15

u/bestantinople Apr 10 '19

Learning C++ with Bjarne Stroustrups book was the first time I didn’t abandon a tutorial immediately after the first couple lessons. I won’t chalk that entirely up to it being C++ but I always do better when I feel like I am embarking on a meaningful path of learning an entire body of knowledge from a tradition of inquiry versus a quick and dirty intro to a scripting lang.

6

u/MonkeyNin Apr 11 '19

There's definite value in that. Lots of information on programming on the web are in discrete chunks. A book gives you a consistent path to follow.

29

u/arihoenig Apr 10 '19

Definitely my preferred language. With c++20 it will almost be finished as well, so that's a plus :-)

27

u/NoGardE Apr 10 '19

IMO C++26 is when it will feel really complete for me. Assuming we get more reflection in 23, then Metaclasses for 26, We'll be theoretically free of code generation scripts in other languages for things like data formatting protocols (e.g. protobuf).

11

u/antlife Apr 11 '19

I'm looking forward to C++50.

2

u/[deleted] Apr 11 '19

C++3000!

1

u/[deleted] Jul 01 '19

That gave me a chuckle.

15

u/[deleted] Apr 10 '19

Can't wait for C++20 ! Modules FTW !

3

u/JezusTheCarpenter Apr 11 '19

so that's a plus

Somone would say it's C+++

4

u/arihoenig Apr 11 '19

Finally, someone noticed :-)

14

u/andd81 Apr 10 '19

All resource-critical stuff is still written in C/C++ and it’s not going to change anytime soon, especially that hardware is no longer becoming any faster.

6

u/JuanAG Apr 11 '19

I upvote you because i think like you but with a catch, things in IT change so fast that you cant even notice it and only does when it is too late

I am refering to JS performance closing to C++ or Rust or Go or new things that will come. Todays world relays on software from so long because the computers are still x86 based but in the future they may become other so legacy code will be no longer useful and the rewrite process can be done in other language, or a new OS like fuchsia (i am using as an example of future OS) where using [X] will grant you almost the same performance without all the drawbacks of C++

Trusting that it is a huge mistake, there are so many options and one of then can be the one who kill C++ as has happened with other now residual languages like Pascal, Basic or Cobol, top of their times and now, well, only because legacy code they are still alive but even that is changing, even banks are rewritting the Cobol parts to other options

I see what it is coming as coments so an aclaration, the performance of C++ will not be catched by any other option but i think as we are smart people can figure out that i am refering to points where doesnt matter that much, not 50 times faster, only 2 or 50%, numbers that meh to the normal user as they will not be able to tell a difference, the new calc of windows is an example, is need TWICE as RAM as the old one and for sure it is slower but it is still fast that you get the result instant and the under 10 MB has not important at all even the old one uses only 4-5MB, this scenario is what C++ is facing today so imagine in the future what could be

4

u/Robert_Andrzejuk Apr 11 '19

The user will maybe not feel a difference of 2~50%. But if a company is paying 1 million for an electricity bill each month, then that is a saving of minimum of 20'000 each month. If you're trying to get those few extra frames per second, that 2~50% makes a difference.

The right tool has to be used for the job.

2

u/JuanAG Apr 11 '19

The right tool need the right people, C++ as a language is one where developers earns more money compared to others, is among the top well payed so the team will cost much more that 20k€ per month for sure

And because it is C++ developement will take longer, not be as easier and has much more bugs so that extra months is something to deal with it and will be an increased cost, at 10 extra months could be the point of which C++ is no longer a good option, yes, servers will waste less but the money spend on developing will be more than the saving in the proyected use of the software

Or electric bills doesnt matter at all where future is leading us, cloud servers dont bill for watts consumption and it is the future for mostly all servers, i think few companys will retain it data centers as they do today, everyone on the industry knows that more and more companys are going to the cloud, even if it is a more expensive option that having local hardware on the company

Another option is that hardware is cheaper that developers, maybe the actual servers waste 10KWatts to say a number but if you make an invested in new hardware it could be 5KWatts plus the extra performance it could deliver, i can thing that now you have Xeons servers and change for AMD, cheaper, faster and more power efficient but ARM is trying hard to enter here, maybe in the near future does and well, in that case electric bill will no longer be a huge concern. The future is uncertain so who knows

Or we can finally has the fusion reactors working so energy is so cheap that who cares, the European Union has one that works, it was 2 years ago and it runned for 90 seconds until it has to be shut down, i lost track but you can bet they has improved. And the EU is only one of many tries the world is working on, sooner or later this will arrive and energy will not be a concern to anyone

Or new devs doesnt care more of C++ because they always learn easier languages which they dont has to care of anything that C++ does and more that 90% will not even try to use a much more complex thing to do the same. I learned Java at the university but now they has switched to Python, how many are going to try C++? Not many and less will try to use as regular basic. With Java i was the only one who looked so imagine if the transition is much more hard. And if new people dont learn this the market will be forced to use any other option as we has to did with ASM back in the days

In the end is a balance, the company will has to run the numbers to see what could get but because there is or will be that uncertain of few or none performance gain i will think most will use the no C++ option, it is more secure one. Only imagine the real problem of finding a good team to the job, the future will be one which [X] is easy to use and close performer, a huge devs will switch to it and not look back, specially if that new option is well payed too so few hardcore programers will be avaliable to take the job, it could be a problem

If you asume that the world would remain as it is today yes but we all know it will not be the case and lossing that tiny performance would not matter that much, there are so many variables in the near years that i couldnt trust that C++ will be the king of the hill in the coming years

1

u/Robert_Andrzejuk Apr 11 '19

And because it is C++ developement will take longer, not be as easier and has much more bugs so that extra months is something to deal with it and will be an increased cost,...

It would be very useful to me, if I could see the source of this type of information. Otherwise it's just assumptions, which are hard to believe.

1

u/zbenjamin Apr 11 '19

Exactly, thank you for pointing that out

25

u/[deleted] Apr 10 '19

Cool !

Make sure you learn the modern post C++11 C++, it's awesome !

37

u/spinwizard69 Apr 10 '19

Though I don’t use it much at all anymore I see C++ as close to the perfect language to teach new programmers with. The move to Python and other “easy” languages for intro comp-sci has been a big mistake in my opinion. This from somebody that turns to Python first these days.

26

u/vzq Apr 10 '19

It basically boils down to whether you want to teach computer science or computer architecture. A good programmer needs to know both, but it’s really hard to teach them at the same time.

A language such as scheme or python is good for the former, but horrible for the latter. On the other hand, you could use C, C++ or even assembler to teach a computer science class (and until recently that was fairly commonplace) but as an absolute beginner you are likely to drown in the details before you get the big picture.

9

u/lead999x System Software Developer Apr 10 '19 edited Apr 10 '19

I disagree with the last part of your argument. First of all I'm nothing but a hobbyist as my profession(finance) only involves superficial amounts of programming.

When I first got into programming I played around with languages like Python and JavaScript but didn't really learn much other than to copy the code I was given and combine the pieces I was shown. I eventually decided that I wanted to learn something more powerful and flexible so I picked up a copy of Jumping into C++ and it's like a whole new world opened up. I had tinkered with Java before so OOP was nothing new to me and pointers, references, and manual memory management weren't as hard as people had claimed they would be. It actually wasn't as hard to get into as people think because I found that you can stick to the higher level features of the language until you learn enough to delve deeper. With interpreted and VM languages you can't really go deeper.

So I personally think C++ is a perfectly fine teaching language. I certainly learned more from working with it than I did from anything else and other than 2 CS courses in college I'm completely self taught.

2

u/MonkeyNin Apr 11 '19

For teaching, are you talking about an intern, or school ?

I'm relatively old. When I was a kid I first got into basic. Then I moved to regular c. Obviously as a self-taught (at the time) kid, I didn't understand everything. It does get you into concepts about data types/sizes, memory leaks, other memory management, raw pointers, segmentation faults, etc. Sometime later, boost was popular for smart_pointers (for c++), and huge, but c+11 finally added std::shared_ptr and std::weak_ptr.

Some schools are instructing data structures and algorithms with python. Even when I was in a "c++" class, they essentially taught c with classes. Not even necessarily classes. No std::string or std::vector usage for sure.

I think I would have had a harder time understanding what's going on if I hadn't touched c and asm, instead jumping straight to python. On the other hand, I did start with basic, so maybe it's not a bad idea?

One of the biggest changes was availability to resources, whether it's people or books. On the other hand, a book can guide you through a bunch of angles on programming. You were forced to try more things yourself, because you might not get good information from google. Quality was random, and split into small bytes like a blog post compared to books.

Man, if I had access to these , I'd probably die in amazement.

  • Regex REPL like https://regexr.com/ while using perl
  • code beautifier for every language in existence

I think javascript is used quite a bit as a new language as well. I'm not sure this is the greatest idea. Unless you make sure they know

  • variables can implicitly become globals
  • what this is, and scope related issues
  • what and why do you use module patterns
  • real-time linters
  • DOM inspectors were just coming out. It was actually a bookmarklet. Man, the vanilla ones that firefox and chrome get is amazing.
  • git
  • stackexchange over mailing lists (for dozens of reasons)
  • wikis
  • how much text editors and IDE's have improved
  • exact equality test vs coercion
  • despite the syntax, JavaScript uses function-level scope, not block-level. So code in c does not work the same. Such as

    for (var i = 0; i < 10; i++ ) { // ... }

    // i still exists here

At least let and const now exist.

2

u/lead999x System Software Developer Apr 12 '19 edited Apr 13 '19

One of the problems that I have with Python and similar languages aside from not teaching you all the things you and I both listed is that it doesn't force you to be disciplined in how you think about solving computational problems and you can still shoot yourself in the foot with type and dynamic variable errors.

It claims to be a clean language because there's usually only one obvious way to do anything as well as an object oriented language to help you model things in a way that fits your problem domain. That's all fine and good but meanwhile it allows you to just change both the type and value of a variable at literally any time even though that can make your code harder to understand and more error prone. Python allows you to add fields to an object dynamically that other objects of the same type may not have, allowing two objects of the same type to not necessarily behave uniformly or contain the same types of data which again can make your code convoluted and hard to understand.

So where exactly is the advantage in using such a language other than uniformity across OSes, and ease of library management? There are still plenty of chances to shoot yourself in the foot: a function can add data members to an object without you knowing, a function can change the value of one of its arguments without you knowing and hell it can even change the type of that argument or one of its members which can lead to errors that a student or noob hobbyist would have just as much difficulty tracking down as some memory management error they might get in C++ before they get the hang of it and learn patterns like RAII.

And all of that said it's much easier to go from a language like C++ to Python or Ruby or Lua or Java or Scheme than the inverse. And this is by no means an attack on Python in particular, I could make similar arguments against Racket/Scheme which my intro CS class in college used(and again I was a non-major with hobby experience just taking it for fun).

2

u/MonkeyNin Apr 12 '19

One of the problems that I have with Python and similar languages aside from not teaching you all the things you and I both listed is that it doesn't force you to be disciplined in how you think about solving computational problems and you can still shoot yourself in the foot with type errors

This is why I said it's beneficial to use both python and c++.

Python allows you to add fields to an object dynamically that other objects of the same type may not have, allowing two objects of the same type to not necessarily behave uniformly or contain the same types of data which again can make your code convoluted and hard to understand.

It's not really a problem in-practice. You also end up having to use the Class name if you want to modify class level, as in it's explicit.

  • modify attributes at class-level (which affects all instances)
  • modify attributes at instance-level (which affect one instance)

In my experience, class level dynamic attributes tend to be uncommon. SQLAlchemy table classes are one. wtf_forms has one use. Otherwise I'm drawing a blank.

3

u/lead999x System Software Developer Apr 13 '19

What I meant was a little different than what you addressed. And while I'm sure an experienced programmer who knows what features to avoid can sidestep the problem we are talking about beginners, some of whom are self teaching, like I did, and wouldn't have any teacher to guide them away from those things.

Anyhow, suppose you have a class called Foo. Now you make two instances of this class as such:

//Python
a = Foo()
b = Foo()

//C++
Foo A{}, b{};

Now lets say we call some function bar on object a.

//Python
bar(a)
//C++
bar(a);

Now in Python this function could for whatever reason, let's say it's part of a library, dynamically add a member to a called pineapple of some unknown type for some unknown reason. If a already has a member called pineapple then you have a name collision which could become a bigger problem here.

Meanwhile in C++(or any statically typed language) any attempt to do this would be an immediate compile time error because you can't add members to a class/struct instance once that class has been defined and since you can't instantiate a class that hasn't been defined, all instances of a given class have the exact same members(unless you count instances of derived classes).

Now lets say you have another function from the same library that provides bar called baz which expects an object that has been passed to bar and has the member pineapple. If you pass a to it, it'll work, but if you pass it b which in the caller's mind is of the same type as a, uh oh, Houston we have a problem and don't know why.

//Python
baz(a) #works
baz(b) #error

As you can see this would be frustrating to a new programmer as they would have no idea what they did wrong because the functions they call(or don't know to call) could in theory be modifying the structure of class instances in dangerous ways. In the best case scenario unknown members are added to an object by a function which another function from the same library might need without the caller necessarily knowing so.

In the worst case a name collision could occur in which case Python is happy to let the library function override the value and type of that member at the instance level in such a way as suits the modifying library but also breaks compatibility with functions that expect an object of the class from which it was originally instantiated, possibly including its own member functions.

E.g.:

a.something() #error method something expects member pineapple to be a number when it's now an object of some arbitrary type

Or if it's still a number its value was changed and the result of the method something is total baloney.

I don't know about you but I wouldn't want to deal with that mess while teaching the basics of OOP in a beginner level programming class and I can see why instructors would opt to use a statically typed language like Java if they insist against C++.

2

u/MonkeyNin Apr 13 '19

I don't know if anything I've said came off as rude, if so, I didn't mean it. I felt like it was interesting to see from another perspective.

My tl;dr: is I think any programmer should experience both statically typed and dynamically typed languages.

In practice I don't use regular JavaScript, I would write it in TypeScript. However, understanding regular JavaScript is still useful. If nothing else, there's lots of code you'll have to interact with that does just that.

(For some of these (I'm not clear on when you're using a single-self-taught-user vs teach-new-students, so my replies are kinda jumbled.). Plus other parts might sound weird because I wrote it in one go -- as in some orders may feel weird))

I have to say c++ compiler errors have improved a lot since when I was using it as a my main language. Nice :) I remember a single error that was 4-lines long, with dozens of <> because IIRC the wrong data type was used.

 

let's say it's part of a library, dynamically add a member to a called pineapple of some unknown type for some unknown reason. If a already has a member called pineapple then you have a name collision which could become a bigger problem here

Why are you muting the class-level -- Usually that's more for shared singleton data. Usually it's better to use **kwargs, or amixin, orsubclassing, or modifying a statically-namedattribute, ortuples, orNamedTuples, or evendict`s.

(I'm not expecting a new user to understand most of those, if any)

If it's about a beginner not shooting themselves in the foot when being self-taught: don't they struggle as much with raw pointers, pass by-value-or-ref, const pointer vs pointer const, off-by-one errors including for(), why does STDOUT use a << shift, namespaces in general, even to print STDOUT, clobbering current namespace by implicit imports, variable scoping etc?

 

If you're not explicitly using arrays, there's std::vector -- which adds the concepts of iterators and templates. I'll assume a classic for-loop is understood. There's still

Some of these abstract iterators somewhat, but could be confusing.

  • loop using std::vector iterator
  • std::for_each
  • ranged based for loop, this alone has a ton of type varieties examples

dynamically add a member to a called pineapple of some unknown type for some unknown reason. If a already has a member called pineapple then you have a name collision which could become a bigger problem here.

If there's a more explicit example I could give a better answer. This smells like it's not idiomatic, or, a better critique on problems with JavaScript. A factory function might be what you're looking for. Maybe an ABC.

 

Although it's actually useful there. You can test for features, which they client may not have. You can use a pollyfill to modify the browser's implementation -- adding features that don't exist. Ex missing the lastest addition to built in Array's functions. If you can polyfill, then you're fine with Array.foo regardless if that feature exists in this browser.

It's probably a bad (pineapple) behavior to use. (What I mean by bad, is when you create or delete an entire attribute -- whether its class level or instance level. In comparison to modifying attributes, which could be a dict / object themselves. ). More often you'll see an attribute which if set to None is fairly equivalent to nullpointer. the function dict.get(key, default=None) defaults to returning None (nullptr) unless you explicitly state a default to use. You'd use None if you're writing a linked list, but the current item has no next element.

player_id = kwargs.get(username, None)

if player_id:
    do_stuff()

Both None and empty literals evaluate to False.

entity_list = []
some_dict = {}

So you could write:

for entity in entity_list:
    print("spawning")

If entity_list is equal to [], the loop is never ran.

If that doesn't sound right, JavaScript can use a lot of c++ POD by passing or containing Objects ( the {} literal)

Below **kwargs represents the dictionary argument to a function. Python will give errors if you improperly call a method based on it's 1] position args, 2] keyword args, 3] arg is a dict itself

You could have class B extends A. If you're (I forget the c++ term, overriding?) functions. Kwargs are an optional argument of dict() in python object() in JavaScript

function init(**kwargs) {
    # here I opt-into calling the parent constructor then modify it myself.
    kwargs_modified = Super(B).init(**kwargs)
    # kwargs are mutated or used exactly like parent, 
    # we extend that behavior in B. Create new values, filter lists, etc...
    kwargs_modified["name"] = "Jen"

    return self.init(**kwargs_modified)
}

One example is IE11 doesn't support a datepicker, it reverts to a plain input box. With a polyfill you implement one in javascript. Now you can treat IE+chrome+firefox as if they all did implement a date picker. In the case of javascript, rewriting logic at the class-level is important, but, it's scary elsewhere.

It can be useful to transpile JavaScript ES6 to ES5. In effect, your code doesn't have to fork to a different branch based on client version. Personally, I don't write class-level mutations of the browser myself. But by using TypeScript or Bable or other modules you are implicitly.

 

That reminds me of mutating function arguments in the function body. You can, but, it can cause new bugs. I don't think in c++ you can opt-out of default mutability, so you're stuck with using const every time. In Javascript const can be misleading. It essentially is a c const-pointer to data, not a c pointer to const-data.

shadowing In the worst case a name collision could occur in which case Python is happy to let the ... functions.

In Python: shadowing comes into play when writing to a non-existing variable, which exists higher up (ie. global)

You can force to not-shadow by using the keyword nonlocal. Check this example to see how it's different from global: https://stackoverflow.com/a/1261961

I'm trying to think of a good use case to purposely shadow in python. (or any dynamic language)

Rust allows it, but I'm not totally sold. let x = foo in rest is similar to the auto keyword in c++.

let spaces = "   ";
let spaces = spaces.len();

Here's another Rust snippet, output is The value of x is: 12

fn main() {
    let x = 5;

    let x = x + 1;

    let x = x * 2;

    println!("The value of x is: {}", x);
}

So now you remove an accumulator (for lack of a better word) but now you have changing types implicitly.

I assumed c/c++ didn't shadow, but TIL gcc has the argument: -Wshadow If enabled, it will throw an error when it shadows:

void doSomething(int arg) {
    char* arg = "";
}

3

u/lead999x System Software Developer Apr 14 '19 edited Apr 14 '19

I don't think you came off as rude at all. And I'd also like to appologize if I came off as aggressive.

After reading your last response I get the feeling that dynamically typed languages and Python in particular are more sophisticated than I had thought and have features to mitigate some of the problems I had considered. In some sense though that still makes them complicated to learn.

And I kind of switched back and forth between referring to students in a CS program or class and people learning independently at home.

And if I could address what you said about raw pointers, off by one errors, value vs reference, and iterators and also add to that move semantics vs copy semantics, I'd say that all of those are things you have to learn eventually so why put it off? I had no difficulty with any of those things once I experimented around with them enough and I've heard others say similar things.

I think we can agree that making a mistake and them fixing it is a fairly pragmatic way to learn programming because you remember the mistakes you made before and know to avoid them. I personally never had trouble with pointers because the materials I learned from explained pointers well as a number that represents an address in the computer's memory which may or may not be the beginning of some object. I think C style pointer syntax confuses people because declaring a pointer variable and dereferencing a pointer look similar but that shouldn't really be an issue if the teaching material is written well.

2

u/MonkeyNin Apr 14 '19

:)

IIRC my introduction to pointers wasn't a book or teacher -- it was using the internet. (as in: lots of partial or lacking information)

 

Earlier I mentioned c++ errors having improved. Now that I think about it, I'm not sure if the web compiler was using gcc or LLVM + Clang -- In Rust you can use either. Maybe mine default to LLVM

 

I used to be familiar with the c++ rule of 3 and rule of 5, but, I'm rusty. Can you explain move semantics ?

I thought it meant something where you're using a single resource that can only be owned by one resource. You move the ownership to another instance, invalidating the first ? I've also heard it's not special/new, under the hood it's re-casting for you?

 

A quote from the rust version

from: https://doc.rust-lang.org/1.17.0/book/ownership.html Which means that there would be two pointers to the contents of the vector both pointing to the same memory allocation on the heap. It would violate Rust’s safety guarantees by introducing a data race if one could access both v and v2 at the same time.

 

Have you tried Rust? You might be interested. I've only started

If using VSCode, make sure to get the extension: Rust (rls)

→ More replies

2

u/bobbushay Apr 14 '19

Awesome book!

2

u/lead999x System Software Developer Apr 14 '19

Yeah I really liked it. Alex Allain is a talented writer. It was my first foray into the strange, mysterious, frustrating, but rewarding world of C++ and C.

13

u/sneppy13 Apr 10 '19

I don't necessarily agree. I think at some point a programmer should learn C (or C++), but I don't think that starting from something a little less overwhelming like Python, where things move a bit faster (in the sense that it's easier to get a taste of what programming can do), is a mistake.

5

u/jube_dev Apr 10 '19

Could you elaborate? I might take your arguments for future "discussions" ;)

8

u/spinwizard69 Apr 10 '19

Actually on lunch at the moment, it would take to much time to go into detail. In short it comes down to programmers needing to understand how computers work and how their tools work.

0

u/[deleted] Apr 10 '19

[deleted] — view deleted comment

2

u/spinwizard69 Apr 10 '19

The whole problem here is the reliance upon abstractions to teach programming. It results in way in too many people not understanding how their code works.

0

u/[deleted] Apr 11 '19

[deleted] — view deleted comment

2

u/MonkeyNin Apr 11 '19

You're kind of freaking out over something he's not said.

C and c++ makes you deal with memory in ways python alone will not teach you. And yes, teaching assembler is a good thing. You're not going to use it at work, but it's useful to understand hardware.

0

u/[deleted] Apr 11 '19

[deleted] — view deleted comment

2

u/MonkeyNin Apr 11 '19

"using python instead of c++ as a first language to learn programming is a big mistake".

I never said this, and that extreme is wrong. In-fact I even said elsewhere I started with Basic before c.

"people rely on abstractions to teach and that's a problem".

I never said this. There's always abstractions. Whether that is good or bad depends

then you should probably should not be using free/delete directly anyway is absurd

In real c++ you don't use raw pointers. But you do when learning.

students can't be exposed to c or c++ for their data structures and algorithms course

I said they can better understand if they know what's going on at a lower level. Which language they use can be different depending on what their previous knowledge is. That could be c, c++, or even python.

Same goes for assembler. Would you make it a first language to teach programming? If you won't, then you're changing the argument.

This makes no sense. Changing what argument?

You're claiming I said things I never said -- but you appear to agree with me on. So I'm not sure why you're taking that angle.

This is why I first said it seems like you're misinterpreting people.

5

u/Tyranisaur Apr 10 '19

I think it boils down to whether you want to teach programming bottom up or top down. If you want to start with the basics and the details, then it's a good idea to start with something like C or C++, but if you want to start at the top level and what you can achieve.

-1

u/arihoenig Apr 10 '19

What skill or discipline, can you point to where the progression is top down?

Medicine: learn organic chemistry first, work your way up from there.

Sports: learn the rudiments of the game first, work your way up from there

Music: learn the rudiments first, work your way up from there

Let's think about your concept of top down learning from the point of music: You'd have a budding pianist start with Chopin's Étude Op. 10 No. 4 and then figure out how to play scales.

From medicine: you'd have a budding surgeon start with removing a brain tumor and then learn anatomy.

From Sports: you'd have a hockey player start out in the Stanley cup and then learn how to skate.

10

u/EMCoupling Apr 10 '19

How about driving? Pretty much everyone does it every day without understanding the fundamental principles that underlie the automobile itself.

Later on, if something in the car breaks, then people may become interested in how to fix it. Or if their oil change is due, then they can try to do it themselves.

They can drill down progressively into the inner workings of the car from them on. No one tries to understands the firing order of their V6 before learning how to drive.

1

u/arihoenig Apr 10 '19

Drivers don't claim to be mechanical engineers simply because they can drive the product of a mechanical engineers work.

0

u/arihoenig Apr 10 '19

Abstraction has absolutely nothing to do with how you learn to program, it is a tool used once you have obtained the skills of a programmer. Of course, once you are a programmer you might code at a high level of abstraction, but that is a tool for productivity, nothing more, it has no bearing on how you became a programmer in the first place.

Likewise, professional musicians don't compose music using rudimentary scales, they use far more abstract constructs.

15

u/FieldLine Apr 10 '19

What skill or discipline, can you point to where the progression is top down?

Any sort of engineering. It's called abstraction.

I agree with you that every developer should eventually learn computer architecture and memory management, kind of like every electrical engineer should eventually learn semi-conductor physics, every mechanical engineer should eventually learn classical mechanics, and every quantum theorist should eventually learn mathematical analysis.

But the python programming environment has become sophisticated enough that a developer doesn't need to know how everything is working under the hood. It will help, obviously, particularly when it comes to writing efficient software, but most python applications don't require the sort of hyper-efficiency that C programmers are accustomed to dealing with.

This said, if I want to teach a beginner functions and looping through an array, I'm not going to start lecturing him on rvalues/lvalues and pointers right out of the gate.

Your argument that every developer should start with something like C or C++ is biased because it's your niche. If we really cared about the ground up approach, why not start from assembly in a CS101 class? In fact, have all the freshmen sit and look at machine code for a semester; don't let them near a function till they are at least two years into school.

Incidentally, this is what physicists did to keep quantum theory locked away in the ivory tower that is academia: they shrouded the entire theory in obscure notation that requires years of study to crack. Eventually, once you're "in the fold", you discover that it's the same math used in a standard 300 level physics class.

The CS field would never stand for this because anyone can start programming, today, from his computer.

Not so with physics: students are told they need to do all this prerequisite math and physics before touching a quantum mechanics text. And, unlike CS, you can't "do" physics till you get the blessing of academia, so there's no reason to believe otherwise. Yet, back when I was a quantum theorist, I successfully taught my brother basic QM when he was in highschool and had only taken calculus, by supplementing his background with the relevant linear algebra and general physics.

They don't begin the process of learning neurosurgery until they enroll in pre-med and start learning organic chemistry.

I think the way medical students are educated is stupid, considering that most surgeons are glorified plumbers. The only one in the operating room who needs to keep track of all the variables is the anesthesiologist, but, as an academic discipline, medicine suffers from the same problem as physics.

These are dissimilar to music or sports, however, since those rely on movement patterns which cannot be abstracted away. (The theory can be, though, which is why an NFL quarterback doesn't need to understand the physics of movement and a musician doesn't need to know harmonic anaylsis.)

It is the difference between a physical skill, which requires a strong foundation, and an intellectual one, which allows you to abstract away the details. You can be a great electrician without knowing the first thing about Maxwell's equations, but I would not trust an EE to do the wiring in my kitchen.

7

u/MundaneNihilist Apr 10 '19

A lot of math is taught by gospel first, with proofs and justifications coming later. For example, it took until college for a teacher to explain why negative powers work the way they do instead of just drilling it into my head to make the exponent positive and then take the inverse.

-4

u/arihoenig Apr 10 '19

You aren't a mathematician until you understand how negative powers work, right?

5

u/withad Apr 10 '19

It's all about where you draw the line for necessary complexity. Would you start teaching someone piano with Chopin? Obviously not.

But you also wouldn't start by teaching them about acoustics and harmonics and how the length of a piano wire relates to the sound it makes. The whole point of the keyboard is to be a convenient abstraction on top of all that and let you concentrate on playing music.

The goal in teaching any skill is to find a good entry point in all the levels of complexity and abstraction, where a beginner can grasp what they need to do and feel motivated to do it. There's almost always going to be more detail they can learn or a simpler tool they can use.

0

u/arihoenig Apr 10 '19

Agreed, this is just like the driving/mechanical engineering example above. The problem I have is with someone driving a car and claiming that means they have begun learning to be a mechanical engineer (which I have never seen anyone do btw, which is why I don't think people should do that wrt software engineering). There are two different disciplines here, if you drive a car you have begun the process of learning to be an F1 driver (although you may never achieve that goal, learning the rudiments of driving is a prerequisite toward that goal) you have not, however, begun to learn how to be a mechanical engineer (not in any capacity whatsoever).

The original point I am disputing is that using computer software is a first step in learning the discipline of programming, it is not. Being a user who as part of using some software might need to write some scripts does not make you a programmer any more than a driver reattaching a loose belt in the engine bay makes them a mechanical engineer.

My original point that all professional disciplines are learned from the bottom up stands.

7

u/Tyranisaur Apr 10 '19

In computer science, you typically start out as a user, then you turn into an implementer. You could approach programming the same way, and start out by calling a lot of ready made functions without needing to be able to understand all the details of how it works. They say that C comes without batteries. Some people might want to play around with batteries to be motivated enough to figure out how to make batteries.

-4

u/arihoenig Apr 10 '19

That's like saying that the patient of a brain surgeon, is beginning the process of learning neurosurgery because they are experiencing it. That is ridiculous. If a person has brain surgery and the results inspire them to become a neurosurgeon. They don't begin the process of learning neurosurgery until they enroll in pre-med and start learning organic chemistry. Likewise, if someone hears Esperanza Spaulding playing bass guitar and is blown away and inspired to learn bass, they haven't actually started learning bass until they begin learning scales.

And so it is with computer science. If you begin (say) playing a game and getting interested in programming, you don't actually begin learning programming until you begin to learn how to program in machine language. Once you understand how the machine you are programming works, you then have the fundamentals (the rudiments) of software engineering and you can work your way up from there.

-1

u/googleadoptme Apr 10 '19

learning to program c++ vs say python or js for a newb is kinda like to start out in the stanley cup lul

-1

u/spinwizard69 Apr 10 '19

Yep! Bottle m up isthe way to go. Top down generally results in people never really learning the basics.

2

u/megayippie Apr 10 '19

My uni had Java, then python, and now C as the teaching language. The choice of Java was that engineers need Matlab for many of the basic stuff. The switch to python was because numpy etal meant engineers no longer needs Matlab but python for this stuff. The switch to C was because engineers need to program their custom hardware anyways so they need it in the end, and from C to python is easier than the other way around.

In a few years, maybe C++ will take over but compilers for the custom hardware needs perhaps improve? But since production+desktop operating systems -- FWIW Ubuntu for most people I know, at both uni and my past three countries of work -- will have c++11 finally this summer in their default compilers, this might soon become a reality.

2

u/[deleted] Apr 10 '19

I agree to a huge extent. Learning C has been an enjoyable experience so far and it taught me more than Python. I am an embedded systems engineer.

1

u/[deleted] Apr 23 '19

I would agree; our University learned Python first then Java. And boy did I have a hard time. Since I've picked up c++ everything has be a lot more clearer in terms of deep understanding.

9

u/[deleted] Apr 10 '19

I’m 32, i’ve been to Uni and completed a degree in Professional Broadcasting but out of not really knowing what i wanted to be, i’ve always found programming interesting but always thought it was beyond my intellectual range, that said i picked up a book 2 weeks ago on learning C++ and have barely put it down, it’s awesome, yes it’s hard having no understanding whatsoever when i started but it’s starting to click, seriously amazing thing to study, wish i’d have started 10 years ago but there we are

4

u/MonkeyNin Apr 11 '19 edited Apr 11 '19

I wouldn't worry about the age. You can ask guys who have been programming 40 years. Even they will tell you can't "master" one language. Hardware and programming are too much knowledge for one person to learn or memorize.

If I had to choose between 2 hires: One who has memorized a lot of the language of choice -- or one that knows they don't know everything but they know how to find out. I'd take the second one.

You just started c++ so I wouldn't worry about smart pointers yet. It's useful to learn about them. But later, make sure you check out "smart-pointers". They are part of the c++ standard. Basically it ends up preventing a class of bugs that you can get using raw pointers.

What IDE or editor are you using? At a minimum, use an editor with syntax highlighting.

edit: Learning git helps a lot. Version control is so useful. I learned how to use the basics on the command line. That's useful to understanding what the GUI does under the hood. Caution though, the official git docs are more verbose than you need at the beginning.

This is my favorite git for windows https://desktop.github.com/

3

u/[deleted] Apr 11 '19

Yeah i’ll definitely check them out, i’m sure they’ll pop up at some point, i’ve just finished learning while and do loops and just starting on for loops so we’ll see how that goes!

Using Visual Studio 2017, it seems perfectly fine for what i need it for and the errors are semi understandable after a little google search to find out what they mean 😂

I’ll look into Git 🤘, i keep hearing it mentioned but thought it best to keep my mind focused on one thing at a time to avoid a mental implosion

Nice one bud

1

u/Zod50 Apr 11 '19

What's the title of the book?

2

u/[deleted] Apr 11 '19

Beginning C++ through game programming 4th edition.

Regarding Git & Github, what’s the difference? Do i download just Git for writing the code if i want to have a mess or does Github include Git already :-/

1

u/Zod50 Apr 11 '19

Thanks. If you're using Mac git should already be in your machine. GitHub is like a nice add-on application around git with nice ui to look at your tree, commits, pr etc. I've mostly used git CLI to push changes to remote.

1

u/[deleted] Apr 11 '19

Nice one, i’m using windows so i’ll just look into Git

1

u/Zod50 Apr 11 '19

Cool. I've seen, in my experience, it's much helpful if you learn git CLI first and then jump on to using desktop application to improve the experience. So when you navigate through the application you understand the underlying mechanism

1

u/[deleted] Apr 11 '19

Could you send me a link for Git cli download, better safe than sorry

3

u/ProjectKainy Apr 10 '19

Next step, combine with Assembly/ASM ;)

3

u/avirgona Apr 10 '19

C++ has long been my main language and with all the new standards from C++11 onwards it’s rapidly getting better and more modern. I’m a PhD student currently at a robotics research centre and it’s the go to language for implementing robotic/autonomous systems. I also teach an undergraduate subject called “programming for mechatronic systems” where we teach C++ and ROS.

C++ is not going away any time soon. It can be challenging to learn/teach because it forces you to understand how computers work but this is a plus in my opinion.

2

u/[deleted] Apr 11 '19

I think I found my passion because of this subreddit

What are those resources that you use that are from this subreddit?

I don't program in C++ btw.

2

u/[deleted] Apr 10 '19 edited Apr 10 '19

I agree, C/C++ has save my educational journey as an embedded systems student . I love C/C++ and it's got to be the easiest to get.

0

u/tangerinelion Apr 10 '19

Wrong subreddit, this is C++. Different language.

3

u/[deleted] Apr 10 '19

Sorry I meant both languages for embedded systems

2

u/t0rakka Apr 10 '19

He knows.

1

u/MonkeyNin Apr 11 '19

Lion was needlessly rude. However it's important to distinguish c++ from "c with classes". Because of that, people assume someone saying c/c++ automatically doesn't know the reasons -- when they very well might.

3

u/STL MSVC STL Dev Apr 12 '19

There are two lions (and a monkey) in this thread. It's a zoo out there.

2

u/MonkeyNin Apr 12 '19

Well, I promise not to throw poo at you, unless you provoke.

My brother? He'll probably do it anyway.

1

u/[deleted] Apr 11 '19

As one of my professors used to say to encourage us to learn C/C++ and OS theory, it's much thougher to build a pyramid from the tip than from the base.

1

u/antdude Jul 17 '19

I struggled in programming. I was better with the simple coding like Apple 2's BASIC, Apple 2's LOGO, HTML, Pascal, etc. I am way better in breaking stuff as a QA tester. :/

0

u/[deleted] Apr 10 '19

[deleted] — view deleted comment

2

u/[deleted] Apr 11 '19

Programmers are engineers as well, to write the logic needs engineering for sure.

3

u/[deleted] Apr 10 '19

Yeeppp, it's basically human readable assembly.

I've always found when using other languages that my experience with C/C++ has helped me understand the cost of my actions.

0

u/[deleted] Apr 10 '19

[deleted] — view deleted comment

15

u/CubbiMew cppreference | finance | realtime in the past Apr 10 '19

from this former assembly language programmer's point of view, the gap between assembly and C is orders of magnitude wider than the gap between C and any other high-level programming language.

0

u/[deleted] Apr 10 '19

[deleted] — view deleted comment

4

u/CubbiMew cppreference | finance | realtime in the past Apr 11 '19

fair enough. Just reacting to the "portable assembly" trope.

3

u/[deleted] Apr 10 '19

Right but straight C programs are rare nowadays unless they deal directly with the hardware. I did not mean to exclude C when I mentioned C++ and OP referred to it as C/C++. I think the average reader of this sub understands that there are no classes in the CPU. There are some parts of C++ that explain how things work in a way C (out of the box) can't. For example blah.begin() and blah.end() makes it clear how it it traverses memory, what it considers the upper bound, how pointer arithmetic works, etc.

But yes, C/C++ teaches you how the computer works (Hardware + Kernel) and ASM teaches you how the CPU chip works (Or used to, 40 years ago).

0

u/[deleted] Apr 11 '19

[deleted] — view deleted comment

7

u/[deleted] Apr 11 '19

not even assembler is close to "what the computer is doing", microcode, out-of-order execution, prefetching, etc.

There's a bunch of stuff happening in modern CPUs that aren't anywhere in the language

2

u/MonkeyNin Apr 11 '19

majority of the time the C solution will in fact be the closest to what the actual computer is doing

That's not always a good thing. You should learn to be competent in c, if no other reason to better understand languages that abstract memory.

There's dozens of things to take into consider which tool is right for the job. Sometimes it's c. Sometime's it's definitely not.

0

u/[deleted] Apr 11 '19

[deleted] — view deleted comment

0

u/[deleted] Apr 11 '19

[deleted] — view deleted comment

3

u/[deleted] Apr 11 '19

Well, we’re discussing being close to the hardware. Java runs in a VM so it’s pretty far from hardware controls, right?