Live data from Hacker News

I learnt C++ in 2018 and have no regrets

vishnubharathi.codes

181–190 of 259 posts

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

#181
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. Note that `this` is just syntactic sugar; a call to `obj.method(arg)` is, underneath, essentially a call to `method(obj, arg)`, with the first argument always being hidden, and the only one that's a subject of a method dispatch (polymorphism).

Common Lisp gets rid of implicit `this` by making all arguments explicit, and by not restricting polymorphism to the first parameter - in fact, you can do a method dispatch on any of the method parameters, or any combination of them. See https://news.ycombinator.com/item?id=18848384 for an example.

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

#182

Earlier quoted context omitted.

More of a meta-comment, but the underscores you used to presumably get markdown italics should actually be asterisks on HN. Normally it doesn't make a readability difference but trying to parse the book names from your post was a tad mentally painful. Took me a little while to realize the asterisk v. underscore thing so I thought I'd pass it on. Note: I do wish HN would adopt standard markdown

Oops. Sorry. I had completely forgotten HN markdown. I usually use the underscores around book titles with cleartext in mind. I'll remember asterisk in the future.

> I'll remember asterisk in the future.

Aaand you've just learned all the formatting HN has :). That, and URLs automatically turn into clickable everywhere except the body of a self-submission (i.e. submitting a text instead of a link). Any other formatting here is just convention.

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

#184
post #120

Earlier quoted context omitted.

Usually this kind of refactor is something done as the very first task following the last release in a minor series and as the first step in a major new release. Going from version 7.4.32 to 8.0.0? Refactor that source tree, reformat all the code, and start over on the build toolchain! Best of all, make sure some junior dev does the actual checkin for the reformat. In all seriousness, I think this is the only way. Ye…

Some of these codebases have 10s of millions of lines if not more. Such a refactoring could take years.

The benefit of using widely supported tooling is even greater for large codebases. Automated reformatting is easy, and moving code around isn't that hard if it's going hand in hand with a build system that supports it.

Staying in the cooking pot of ever larger proprietary and exotic hacks is how organizations grind to a halt.

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

#185
post #97

Earlier quoted context omitted.

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

Well, it is. Every f*up you can have in C, you can also have in C++.

Only if you write unidiomatic (Read crap) C++.

In modern C++ it is very much possible to write fast and safe code, but the tradeoff is now put into the amount of stuff the developer needs to know to be productive (Which in my experience isn't as bad as people like to go on about on here/reddit, even if it still pretty shoddy)

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

#186
post #71

Earlier quoted context omitted.

I ran into this trying to get into it about 3 weeks ago. I'm so used to things like npm, ruby gems, go packages, pip that it felt like a huge task just to get something built or settle on a way for me to build mine. Even grabbing libraries from github, I was unsure if I should grab just the headers and DLLs, or import the entire tree and mashup my build scripts with theirs. I wish I had stayed with it since college b…

Making Rust work nicely with win32 is probably less effort (and more valuable) than getting enough momentum behind a good dependency manager for C++.

> work nicely with win32 is probably less effort

Gonna be very hard to do. For the last 15+ years COM is essential part of WinAPI, and too many things in Rust conflict with COM: ownership, OOP, virtual tables, inheritance, they all too different.

Not just in Rust, in all languages, actually. You only have 2 good choices for complex platform-dependent windows development: either C++, or a microsoft's language with COM support embedded deep in the runtime, like VB6 or VBScript or .NET.

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

#188
post #129

Earlier quoted context omitted.

> Someone has made a bunch of decisions for you that down the road you have no idea whether or not it will actually be good for you Opinionated also means that these decisions will be the same in other places/projects I may join. In the medium and long term, that advantage may easily offset the value of custom decisions.

Some subset of those decision are also things which just don't matter, like which side of the road to drive on— the value is in a critical mass of people all doing the same thing more than it is in the merits of either approach. A lot of stylistic stuff like filesystem layout falls into this bucket.

Bless standard formatters (gofmt, etc) becoming the norm.

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

#189
post #117

Perhaps this is an appopriate place to ask: What is the best C++ IDE on the Mac? In particular, fully project-aware autocomplete is a baseline feature. Does emacs or Vim offer an autocomplete plugin that matches the power of IntelliJ, or even Xcode? Is CLion worth the money? Other paid alternatives?

If you're comfortable with emacs, irony + rtags does pretty much all the IDE-type things I need it to. You can autoconfigure rtags based on your build system (supports basically all of them). you get variable type hints, function arg hints, contextual autocomplete (including template stuff), jump to definition, find references, you can fuzzy find and jump to methods/identifiers/symbols across your project, compiler warnings highlighted inline, it's a pretty good setup. I use the doom-emacs distribution which has it all configured and ready to go, im sure spacemacs also has a good setup

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

#190
post #86

Earlier quoted context omitted.

I think that statement would have to be classified as inaccurate. using C++ teaches you mostly about general purpose programming and it's pretty easy to go from C++ to python to Java to bash, etc.

Nonsense. C++'s template system behaves unlike any other language (things like SFINAE and the techniques that use it do not transfer), C++-style RAII is relatively unusual, I don't think any other language requires the programmer to think about virtual versus non-virtual inheritance, the C-derived sequence point rules are obscure and much looser than most languages' evaluation rules, the exception-safety rules are un…

All the complications you list derive from the peculiar C++ language design principle of ensuring high performance despite sophisticated abstractions; popular languages are simpler because they stop at basic abstractions (e.g. C and Forth) or because they trade performance for elegance (e.g. C# and to a higher degree Python and Smalltalk).

C++ does more at a higher cost, and in recent standard updates the cost has been steadily decreasing.

Post reply on HN