Live data from Hacker News

Talking to C Programmers about C++ [video]

youtube.com

61–70 of 128 posts

Re: Talking to C Programmers about C++ [video]

#61
post #20

Earlier quoted context omitted.

There is nothing "simple" about Java once you get past the basics. When you get into the EE world it gets extremely complicated.

No. There's everything simple about Java. The semantics of Java are actually pretty simple, at least compared to C++. What's complicated are the monstrosities people build with Java, but those aren't inherent in the language. Saying that Java is complicated because EE exists is like saying that C is complicated because Linux exists: Complexity can be built atop simplicity. And for some reason, Java is a complexity ma…

> The semantics of Java are actually pretty simple, at least compared to C++.

While true, have you ever tried to answer Java Puzzles?

Re: Talking to C Programmers about C++ [video]

#62
post #45
post #13

Earlier quoted context omitted.

The same is true of any language with similar history. Do you believe anyone knows Perl, Python, Ruby, Java, C#, Ada, Haskell, OCaml, VB.NET, F#, ... across all language versions, the whole standard library, and most used third party libraries? One always need to focus on a specific domain.

The obvious comparison is C — where it is common to know 95-100% of the language. (The 5% I'd pick is general disagreement about expectations of UB and "weird" pointers, like pointers to array types.)

People that don't write portable C code think that they know 95-100% of the language.

I don't miss the days in the late 90's, early 2000, writing portable C code across multiple compilers from each OS vendor, across all major UNIX flavours and Windows.

Many that think to master C, actually master C in compiler X targeting OS Y.

Re: Talking to C Programmers about C++ [video]

#63
post #59

Earlier quoted context omitted.

> functional programming (which is not that complicated at all in C++) > I think most C++ programmers have a reasonable command of all of these These gave me a bit of a chuckle. It's true only if you've never done proper functional programming using a genuinely functional language. It's true that you can now pass lambdas around as first-class values easily, store and manipulate them as you might in a functional langu…

A discussion about "proper functional programming" is not particularly relevant, because the topic is functional programming in the context of C++. The constructs that C++ offers for FP are not complicated.

Sorry, but this is just simply not true. If you've never done functional programming before, then I could see why you think doing it in C++ is not complicated. Here is an example of just how large the can of worms gets when attempting to bring functional programming to C++:

https://bartoszmilewski.com/2013/11/13/functional-data-struc...

and:

https://bartoszmilewski.com/2013/11/25/functional-data-struc...

And, I disagree that you can change the definition of a particular programming paradigm when discussing a particular language. Functional programming means something that is not really possible in C++. For starters, the fundamental underlying data structures for functional programming do not exist in C++ and there is no third-party implementation of them worth mentioning; the above experiment is admitted by the author to fall flat when doing anything idiomatic.

As I mentioned before, C++20 might turn the tide on this front a little bit, thanks to the Range library.

Re: Talking to C Programmers about C++ [video]

#64
post #48

Earlier quoted context omitted.

The problem with posts about C++ on Hacker News is that people who aren't experienced C++ programmers (you've been using C++ for a semester? do tell) feel compelled to write posts explaining the problems with C++.

As someone who's had to deal with C++ since the last century, I find that one problem with C++ is that people who aren't experienced C++ programmers can't get shit done, especially in a code base where experienced C++ programmers have demonstrated their erudition and knowledge of C++ arcana in all its glory. In fact, the intersection of people who had the patience to learn enough C++ to get shit done and people who a…

> what the fuck coutI'm not sure where that conversation would go. It prints to stdout. Would the student say the same thing about printf("%d", x)? How far down the rabbit hole did he want to go?

Stream insertion syntax os pretty bad, though, I'll agree with that. Especially when you want to print floating point.

Re: Talking to C Programmers about C++ [video]

#65

Earlier quoted context omitted.

No, not really. Complexity is not about the language: It's about how you use it. It's not necessarily Java's featureset that makes it so complex, it's its idioms. C++'s lifetime rules, on most variables, are this: It's allocated until you say it isn't. Some of the vars might be refcounted or GCed, but with GC you've still got the same problem on your hands as finalizers, and refcounting can't handle cycles. Manual me…

I'd be interested to hear why you say that RAII cannot be idiomatic. With `std::unique_ptr` and `std::shared_ptr` for handling pointers, `std::vector` for handling data arrays, `std::string` for handling char arrays, I would argue that modern C++ is very heavily RAII. At this point, if I have a class that cannot be declared on the stack, with cleanup handled by RAII, I consider it to be a broken class. Good point on…

The main issue with RAII is that you can only do properly if as you say, the classes were designed to be stack allocated.

Also that no one just placed such class in the the heap, and it was missed, because no one is actually doing code reviews or making use of static analysis.

Another issue with best practices and ownership are binary libraries. There isn't any sort of control one can have over them, so they are the place where RAII and ownership just goes out of the window.

In any case this is much worse in C than C++, because at least C++ does offer some language tools to deal with it, however there is no rescue from developers using C with a C++ compiler.

> Oh, absolutely on Lisp. Lisp/Scheme are amazingly simple, and amazingly powerful. The one downside that I've found is that it doesn't correspond to the hardware as much.

Actually it can also be an upside, as you see with the adoption of FP patterns in mainstream languages, including C++.

One of the themes at CppCon was exactly hardware heterogeneity and possible C++ abstractions to take advantage of it, while keeping the algorithms high level.

Re: Talking to C Programmers about C++ [video]

#66
post #56

Earlier quoted context omitted.

http://pastebin.com/fgPhGaxz

Personally I think that looks pretty good. There's no templates, no inheritance. Not sure what would make bloat there nor latency. Whatever the faults of the syntax for folding, it's got to be better than VA_ARGS hasn't it?

There are templates: for example

    void print1(auto x){std::cout
is a function template

    template 
    void print1(T x){std::cout
This is not valid C++14 however, so it doesn't compile. If you replace these, you'll probably still get a stack overflow while expanding the templates because there are almost 7000 arguments to a single function call.

Re: Talking to C Programmers about C++ [video]

#67

Earlier quoted context omitted.

I'd be interested to hear why you say that RAII cannot be idiomatic. With `std::unique_ptr` and `std::shared_ptr` for handling pointers, `std::vector` for handling data arrays, `std::string` for handling char arrays, I would argue that modern C++ is very heavily RAII. At this point, if I have a class that cannot be declared on the stack, with cleanup handled by RAII, I consider it to be a broken class. Good point on…

Well then, that's your problem: C++ is trying to be both low-level and high level at the same time . This isn't a good idea, IMHO. What I mean is that while some amount of RAII is a common idiom in C++, It's rare for a program to use RAII fully, as many C++ idioms conflict with it. Mind, I'm not an expert, so I might be wrong, but that was my understanding. AFAICT, if RAII was used all the time, idomatic C++ would lo…

> Well then, that's your problem: C++ is trying to be both low-level and high level at the same time. This isn't a good idea, IMHO.

It is a very good idea and C++ isn't alone there.

Professional Basic dialects, Turbo Pascal, Delphi, Modula-2, Modula-2+, Modula-3, Ada, D, Rust, Mesa/Cedar all share this idea that you can program at both levels, depending on the needs of the use case.

Re: Talking to C Programmers about C++ [video]

#68
post #48

Earlier quoted context omitted.

The problem with posts about C++ on Hacker News is that people who aren't experienced C++ programmers (you've been using C++ for a semester? do tell) feel compelled to write posts explaining the problems with C++.

As someone who's had to deal with C++ since the last century, I find that one problem with C++ is that people who aren't experienced C++ programmers can't get shit done, especially in a code base where experienced C++ programmers have demonstrated their erudition and knowledge of C++ arcana in all its glory. In fact, the intersection of people who had the patience to learn enough C++ to get shit done and people who a…

I agree. To truly learn and appreciate programming, you have to be able to enjoy it, first and foremost, and, unlike, say, Pascal, Python or JavaScript, the languages like Java, C, and especially C++ make that extremely hard for a novice programmer. This is because before you even begin to appreciate the ideas based on which those languages were designed and the languages' sophisticated features, you need to face the problems that these languages are trying to solve, and that takes time and programming experience.

It may sound strange, but I find assembly to be an appropriate language to learn programming. Not only your focus will be on what you are doing rather than on the language itself, you will get a feeling of what is really going on, and you will quickly appreciate - and fully understand - the the reason why C is useful and that it is a good, well designed programming language. (In the same way, with enough experience using C, one comes to appreciate C++.)

Re: Talking to C Programmers about C++ [video]

#69
post #48

Earlier quoted context omitted.

The problem with posts about C++ on Hacker News is that people who aren't experienced C++ programmers (you've been using C++ for a semester? do tell) feel compelled to write posts explaining the problems with C++.

As someone who's had to deal with C++ since the last century, I find that one problem with C++ is that people who aren't experienced C++ programmers can't get shit done, especially in a code base where experienced C++ programmers have demonstrated their erudition and knowledge of C++ arcana in all its glory. In fact, the intersection of people who had the patience to learn enough C++ to get shit done and people who a…

I was part of the C++ teaching group on CS labs on my university back in 1999.

The majority of them surely were able to get shit done in C++ at the end of the semester.

Re: Talking to C Programmers about C++ [video]

#70
post #65

Earlier quoted context omitted.

I'd be interested to hear why you say that RAII cannot be idiomatic. With `std::unique_ptr` and `std::shared_ptr` for handling pointers, `std::vector` for handling data arrays, `std::string` for handling char arrays, I would argue that modern C++ is very heavily RAII. At this point, if I have a class that cannot be declared on the stack, with cleanup handled by RAII, I consider it to be a broken class. Good point on…

The main issue with RAII is that you can only do properly if as you say, the classes were designed to be stack allocated. Also that no one just placed such class in the the heap, and it was missed, because no one is actually doing code reviews or making use of static analysis. Another issue with best practices and ownership are binary libraries. There isn't any sort of control one can have over them, so they are the…

Pretty much exactly the point I was trying to make about RAII. Thanks for explaining better than I did :-).
Post reply on HN