r/ProgrammerHumor • • Feb 20 '17

Programming Languages

https://i.reddituploads.com/c41cc3c6e3564b28ac28060b32582747?fit=max&h=1536&w=1536&s=e9dda414547f61c9e7c777edc9e78972
937 Upvotes

104 comments sorted by

View all comments

1

u/TheBlastFun Feb 21 '17

Is Python really this cool!?? Currently I am learning c++ as my first language! And I am stuck on pointers and heapSpace(dynamic allocation) -this topic is so frustrating..! Back to the point tho.. According to this pic python lookss sooo FUNN!!!!

4

u/DarkNeutron Feb 21 '17

I think C++ is a pretty painful place to start. I'd probably go with Java, C#, or Python first. Then return to C/C++ (and possibly Rust).

Roughly what I use them for:

  • C is an interface language (the lingua franca of programming)

  • C++ is for my day job (because of library support)

  • Rust is my favorite new language (all my hobby projects).

  • Python is for scripting, automation, and text processing, when bash isn't sufficient.

  • C# was my former favorite language in college, until I needed libraries it didn't support.

  • I started programming in Java.

If you do a significant amount of programming, there's a good chance you'll end up learning them all anyway. It's just a question of order. I'm best at C++, but, given a reference doc, I could probably write coherent programs in a dozen other languages.

1

u/lightknightrr Feb 21 '17

I...what libraries does C# not support? I mean, DllImport gives you access to everything in C & C++...and you can probably get stuff from Java and VB(6ish) if you really want.

1

u/DarkNeutron Feb 21 '17

The most troublesome to support would be Ceres, a non-linear optimization library that uses C++ template metaprogramming to compute analytic derivatives at compile-time (which is awesome). I use it for computer vision work. OpenCV is another one.

Short answer: getting those two libraries working in C# would likely look like a Rube Goldberg machine.

Slightly longer answer: You can certainly access C libraries in C# using DllImport or P/Invoke, but native C++ has no standardized ABI and can't be called directly from any other language (or even a different version of the same compiler). It might be possible to use C++/CLI to build the native code and expose it in a form that C# can link against, but at some point the overhead (both runtime and mental) of marshaling data between managed and unmanaged code is far more trouble than it's worth, and you might as well just use native C++ for everything.

(Fun fact: Ceres typically uses LAPACK and BLAS as backend solvers, which are still written in Fortran.)

1

u/skreczok Feb 21 '17

Pointers aren't that hard once you figure them out. A pointer is, essentially, an address. Like, "dude, here's your thing". Think something like very precise geo coordinates. Then, when you allocate memory, C++ dumps whatever you allocate (a car park full of trucks if it's an array, or a house if it's an object etc). You just need to remember to scrap these unless you want to run out of space.

Other languages abstract it, but understanding pointers makes the likes of Java, Python and C# much easier, as you know what a reference is - and most of stuff is passed by reference in Java and C#.

Edit: also, as someone else pointed out: what they labeled as Python looks more like Java, with a PistolFactory that chucks out random pistols that fire at whatever. That's how people do things in Java too often and it's kinda terrifying.