Live data from Hacker News

I learnt C++ in 2018 and have no regrets

vishnubharathi.codes

211–220 of 259 posts

Re: I learnt C++ in 2018 and have no regrets

#211
post #70

Earlier quoted context omitted.

Examples? As a maven advocate I've commonly seen this claimed ("we have to have an ant build because we need to do x/y/z custom thing") but I've never seen an example that held up under scrutiny. E.g. there's no reason any project would ever need a custom source directory layout. No project needs to run tests before compile (and if you really need build step x to happen before build step y, you can always separate th…

Back in the days when we used Maven, we had an involved asset building system. It was very hard to shoehorn this into Maven's fixed lifecycle phases (they might be customizable now, I don't know) to the point where we had a Maven plugin so powerful, it eventually made Maven redundant.

> we had an involved asset building system. It was very hard to shoehorn this into Maven's fixed lifecycle phases (they might be customizable now, I don't know)

They're not customizable, by design. I find people with this problem tend to be missing the option of using a multi-module project: if you need to build A, B that depends on A, C that depends on B and so on, the right way to model that in maven is to have those things in separate modules with dependencies between them. That way your dependency graph lives in the normal maven representation that anyone working on it can understand, and the within-module phase ordering continues to be what anyone working on will expect (compile before test before package, etc.)

Re: I learnt C++ in 2018 and have no regrets

#212
post #209

Earlier quoted context omitted.

It seems a bit odd to complain that C++ doesn't support garbage collection. I mean yes, it's true, but... part of the point of C++ is to give you control of memory.

Sure, but certain programming techniques become impractical without garbage collection, and a general purpose programmer would be expected to be familiar with those techniques. E.g. C++ programmers tend to just not learn graph-based models/techniques because they're not a practical way of working in C++.

Graph-based isn't practical in C++? Why not?

I mean, yes, in C++ you have to clean up the memory yourself. That means that you need to know when to do so. That means that, for the graph nodes, you're probably doing some kind of reference counting, and it will be a bit fiddly to get right. If you do it in a base class, though, you'll only have to do it once.

I wouldn't call that "impractical" at all. (I might call that "reason to prefer a garbage-collected language for doing graph-based work", but if I needed to do such work in C++, I wouldn't be particularly daunted by the prospect.)

Re: I learnt C++ in 2018 and have no regrets

#213

"To round up, C++ does not dictate about its tooling, which basically gives lot of choices and flexibility. But at the same time it is making it complex for beginners to come in to projects and start projects with it." This was a big problem for me when I first started using C++. I don't remember it being too bad when I was just working on small projects and things I wanted to do at school. The problems started when…

[deleted]

Re: I learnt C++ in 2018 and have no regrets

#214
post #91

> "I have to pay: First and main concern being that the standard study materials for reading about C++ are not free." I don't think this is more than a minor issue. If you can't afford it, the book is very easy to obtain online for free, either through piracy or a paid / free trial Safari Books Online subscription. If you felt so inclined, you could pay for the book after making money with the C++ it taught you.

The last draft is always available for free from. The standard committee website.

The document is definitely not a good way to learn the language.

Re: I learnt C++ in 2018 and have no regrets

#215
post #19

> My quest for relearning C++ started in November 2018. That’s great! I’ve been using it since 2013 and still haven’t learned it!

What language can one say that they fully master? I've been using Python since 2008-ish on and off for various scripting tasks and small tools, I can't say that I've "learned" it. They keep adding new stuff, some things I forgot, others I never needed. I've been using C++ professionally since ~2006 and for similar reasons I won't say that I master it either. Metaprogramming is a clear weak point for me, but OTOH I fi…

I'm like you! And after I argued with someone on another thread here and they told me to watch CppCon talks I realized there are plenty (and plenty of new C++ features) that are not about template metaprogramming and that are useful... won't learn it at 100% but the experience has made me feel like I could improve my C++ every day.

Re: I learnt C++ in 2018 and have no regrets

#216

> Within C++ is a smaller, simpler, safer language struggling to get out.” - Bjarne Stroustrup Ah, yes. I think they called it "C".

I'm having some difficulty imagining that C is safer than C++.

Stroustrup likes to say it's harder to shoot yourself in the foot with C++, but when you do it tends to blow off the whole leg.

Re: I learnt C++ in 2018 and have no regrets

#217
post #103
post #70

Earlier quoted context omitted.

Examples? As a maven advocate I've commonly seen this claimed ("we have to have an ant build because we need to do x/y/z custom thing") but I've never seen an example that held up under scrutiny. E.g. there's no reason any project would ever need a custom source directory layout. No project needs to run tests before compile (and if you really need build step x to happen before build step y, you can always separate th…

Because legacy. Maybe one can't reorganise the source tree layout because to do so would break our custom tooling / integration systems / interface with proprietary vendor tools. We can't change version numbering schemes because our packages already exist 'in the wild' and can't be changed mid-sequence without causing both technical and user pain. Fundamentally: the codebase has worked perfectly well this way for the…

> Maybe one can't reorganise the source tree layout because to do so would break our custom tooling / integration systems / interface with proprietary vendor tools.

That hardcodes the source layout? I don't buy that a tool that's being sold for money would do that (precisely because there's no standardization in the C++ world; any tool that wants to have more than 1 customer will have to support more than 1 directory layout), and if the tools are internal then by definition you have the ability to make changes to them.

> Fundamentally: the codebase has worked perfectly well this way for the last 20 years; what's the business case for changing it (at potentially significant cost) just to be compatible with XYZ new tool that everyone is rallying behind?

Well, if you make adopting good tooling in C++ harder than switching to a language that already has good tooling, don't be surprised when developers do that.

Re: I learnt C++ in 2018 and have no regrets

#218

"To round up, C++ does not dictate about its tooling, which basically gives lot of choices and flexibility. But at the same time it is making it complex for beginners to come in to projects and start projects with it." This was a big problem for me when I first started using C++. I don't remember it being too bad when I was just working on small projects and things I wanted to do at school. The problems started when…

All C/C++ projects I have ever seen used either cmake or autoconf build system. It's pretty standard.

I suggest you have a look at OpenSSL.

Re: I learnt C++ in 2018 and have no regrets

#219
post #156

Earlier quoted context omitted.

Not really. In fact in Lisp OO is the opposite, the functions are explicitly keeped away from the data. For Alan Kay it was all about messanging but I dont think most people think about that. Structs with some kind of dynamic dispatch based on the type would be the most general discription I think.

Are you saying instead of this: def method(): this.value = this.value + 1 lisp does something like this? def method(object): object.data = object.data + 1

Yes. But while this is single dispatch. The real clue is that you can have multiple dispatch.

So you might have.

define generic inspect-vehicle (v :: , i :: ) => ();

define method inspect-vehicle (v :: , i :: ) => () look-for-rust(v); end;

define method inspect-vehicle (car :: , i :: ) => () next-method(); // perform vehicle inspection check-seat-belts(car); end;

define method inspect-vehicle (truck :: , i :: ) => () next-method(); // perform vehicle inspection check-cargo-attachments(truck); end;

This is Dylan code, but its the same concept, easier to read compared to CL. See: https://opendylan.org/documentation/intro-dylan/multiple-dis...

Once you start thinking about dispatch in a broader sense the advantage is clear.

Re: I learnt C++ in 2018 and have no regrets

#220
post #206

Earlier quoted context omitted.

But you don't hear people make the same sort of comments about languages like Go and Scheme. There's a continuation from complex to less complex and C++ is one one end of that.

No, I hear people complaining about writing boilerplate by hand (Go), not knowing with libraries to use, incompatibilities between libraries or political discussions about what the standard library should be (Scheme).

Well crafted C++ is certainly lower on boilerplate than Go, but the other complaints apply to all languages.
Post reply on HN