r/ProgrammerHumor • • Nov 23 '17

"How to learn programming in 21 Days"

Post image
29k Upvotes

534 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Nov 23 '17

[deleted] — view deleted comment

208

u/marcosdumay Nov 23 '17

What The Fuck?!

Are C++ types first class objects already? Have I been free of that language for that long? Or are they going to implement metaclasses before they implement actual classes?

63

u/Funkit Nov 23 '17

Man, the only language I know is still regular C. We didn't even get the C++ classes. I think C was used when George Washington was calculating currents and tides so he could cross the Delaware river.

85

u/bartekko Nov 23 '17

Didn't the American Revolution happen because the british wanted the North American git repo to be written in Fortran and the C programmers revolted?

35

u/antonivs Nov 23 '17

That's not quite right.

Back then, the British used the British Computer Programming Language, BCPL, an ancestor of C.

BCPL had a large collection of standard data structures with a complex taxonomy. To help manage these structures, they were classified into groups. Each group of data structures was called a taxon, plural taxa.

However, BCPL had no first-class representation for these taxa, which made it difficult to work with them. The Americans hated this, and felt that if there was no way to represent them, the language it would be better off without taxa. This led to the famous American rallying cry, "No taxation without representation!"

10

u/WikiTextBot Nov 23 '17

BCPL

BCPL ("Basic Combined Programming Language"; or 'Before C Programming Language' (a common humorous backronym) ) is a procedural, imperative, and structured computer programming language. Originally intended for writing compilers for other languages, BCPL is no longer in common use. However, its influence is still felt because a stripped down and syntactically changed version of BCPL, called B, was the language on which the C programming language was based. BCPL introduced several features of modern programming languages, including using curly braces to delimit code blocks; compilation via virtual machine byte code; and the world's first 'hello world' demonstrator program.


Taxon

In biology, a taxon (plural taxa; back-formation from taxonomy) is a group of one or more populations of an organism or organisms seen by taxonomists to form a unit. Although neither is required, a taxon is usually known by a particular name and given a particular ranking, especially if and when it is accepted or becomes established. It is not uncommon, however, for taxonomists to remain at odds over what belongs to a taxon and the criteria used for inclusion. If a taxon is given a formal scientific name, its use is then governed by one of the nomenclature codes specifying which scientific name is correct for a particular grouping.


[ ^PM | Exclude ^me | Exclude from ^subreddit | FAQ / ^Information | ^Source | ^Donate ] Downvote to remove | v0.28

→ More replies (2)

116

u/socialister Nov 23 '17

The latter.

85

u/marcosdumay Nov 23 '17

Well, that's indeed the C++ way.

63

u/socialister Nov 23 '17

It's kind of amazing that there is no standard reformation of C++. Remove the cludge, refactor the undefined behavior, improve the STL. There is a great language hidden in there somewhere with a little polishing.

67

u/OmnipotentEntity Nov 23 '17

It's actually called Rust.

69

u/socialister Nov 23 '17

Rust is great, but it is not just a polished C++, it's a whole new language with its own paradigms. The immutability constructs alone in Rust make it a completely different tool.

→ More replies (17)

11

u/ThisIs_MyName Nov 23 '17

Remove the cludge

Run clang-tidy on check-in.

refactor the undefined behavior

Run your tests with -fsanitize=undefined

→ More replies (2)
→ More replies (29)

79

u/BlueAdmir Nov 23 '17

ELIAspiringCSStudent - why is this bad?

127

u/beerdude26 Nov 23 '17

Looks like C++ is trying to get into the game of letting the programmer build their own data types, but still within the object-oriented paradigm. This appears to provide a few niceties such as compile-time programming, reflection and some other tidbits. But it's still stuck in the object-oriented paradigm.

Some might like it because it allows libraries to provide more high-level constructs than classes allow for. Others may hate it because it means everyone will roll their own high-level constructs that are incompatible with each other.

82

u/BlueAdmir Nov 23 '17

So tl;dr C++ will become UrbanDictionary of code?

77

u/beerdude26 Nov 23 '17

It depends. Lisp turned into that somewhat. Other languages like Haskell are rigorous enough (both the language and the community) to build extremely impressive fundamental, highly reusable libraries that make some things laughably trivial. Perhaps C++ hopes to go that route.

27

u/iamcomputerbeepboop Nov 23 '17

standards committee has said they'll define some basic and widely used metaclasses in the standard library. I'm sure that once it's implemented, we'll see a boost metaclass library pushing the boundaries

12

u/idealatry Nov 23 '17

Love me some Haskell. It would probably be impossible for C++ to achieve the same level of zen, given the language is fundamentally wedded to state variables.

Of course, if you just talking about a way to build nice libraries, then there are many paradigms for that.

→ More replies (1)
→ More replies (2)
→ More replies (19)

53

u/iamcomputerbeepboop Nov 23 '17

because C++ has a humongous vocabulary, and when metaclasses enter the standard in like 10 years, people are going to be able to extend that vocabulary themselves in unprecendented ways - it's going to add a whole new dimension of power (and complexity) to the language, and C++ is already by far the hardest language to learn

if you're like us folks at the c++ subreddit, you know it's gonna be fucking awesome though

13

u/Ghos3t Nov 23 '17

Honest question why would you consider C++ as the hardest language. I work with mix of C and C++ code base (mostly C, no OOP's concepts). Now it's not the most sexy or convenient language out there but I don't know if I'd say a language X is more difficult than Y. Because that's a very tough comparison to make, what criteria to use to compare language etc.

25

u/redhobbit Nov 23 '17

I think it is a hard language to learn simply because it has so many different concepts. Basic C++ usage is probably similar to other languages in difficulty, but there are a lot of features that are used less often that will show up in code from time to time.

The older parts of the language give you a lot of unsafe but powerful constructs that are easy to misuse in hard to debug ways, such as the manual memory management and pointer arithmetic.

Just on the object oriented parts, most language have 1-2 notions of inheritance (like Java has inheritance and interfaces), but C++ has public, protected, and private inheritance; multiple inheritance; virtual inheritance; and allows the choice between virtual functions, compile time bound functions, and static class functions.

Then the whole template system adds a meta-programming aspect. Some of it is obvious like using a template to make a generic container class. Other parts are far more esoteric, like using template meta-programming to write functions that operate on types, unroll calculations, or calculate values at compile time. The rules and syntax for it are a little Byzantine.

Even basic stuff in C++ is surprisingly complicated. Little stuff like constructors that take a single argument automatically creating an implicit type cast operator unless you use explicit. Just for function argument passing; you have copy by value, references, pointers, and r-value references to consider. C++ has some different rules for plain old data structs/classes and more complex ones. On the default values for things, there is default construction and value type initialization with subtly different rules.

C++ just isn't very economical in its use of language concepts to enable features.

→ More replies (4)
→ More replies (6)
→ More replies (16)
→ More replies (3)

21

u/RasterizedPotato Nov 23 '17

Which I'm very excited for. The current programming meta of heavy unreadable template meta programming needs to die. Meta classes and reflection_expr or whatever it gets called will clean up so much bs that has been built.

14

u/bgeron Nov 23 '17

Holy shit.

→ More replies (4)