News for hackers. Stuff that matters.
Re:“C is how the computer works” is a dangerous mindset for ... by amiga_500 on Tuesday March 31, 2020 @01:23PM (#22739910)
C++ should only be used as a last resort. It's complex, development is slower, the tooling is poor, some universities have stopped teaching it. It's very hard to hire good C++ devs, and they are typically not cheap.

I manage a c++ team btw. Our app has to be fast.

Re:“C is how the computer works” is a dangerous mindset for ... by pdimitar on Tuesday March 31, 2020 @01:40PM (#22740138)
As your parent said, this is also an answer I can understand.

Still, have you guys looked at alternatives -- and seriously evaluate them? Rust, Zig, Nim, D, others?

If you tell me "we can't afford to, we have too much work" then that's also a valid answer (for a while at least).

Re:“C is how the computer works” is a dangerous mindset for ... by amiga_500 on Tuesday March 31, 2020 @02:02PM (#22740430)
The bespoke libraries etc have god knows how many man hours invested, it would be possible but gargantuan.
Re:“C is how the computer works” is a dangerous mindset for ... by pjmlp on Wednesday April 01, 2020 @03:07AM (#22746423)
Our alternatives are Java and .NET languages, with native bindings to C++ libraries.

C++ alternatives still need to grow up to this kind of mixed language development, where I can have .NET code with C++ libraries and easily debug across them on the same Visual Studio session.

Same applies to Java and C++ development experience.

Re:“C is how the computer works” is a dangerous mindset for ... by pdimitar on Wednesday April 01, 2020 @01:31PM (#22751300)
Not sure how fair to newcomers (as in languages) this requirement is.

F.ex. when coding in Erlang/Elixir I can use an excellent bridging library between their VM and Rust. There's also an excellent support for working with C libraries. Not sure what else can be expected.

Maybe I am not reading you correctly and I apologise if so. It just kind of sounded like "the newer languages must be compatible with 20+ different ABI standards if they want us the older programmers working in C/C++ to adopt them"?

Back on the original topic, I completely understand if a project has too much baggage and sunk cost so as to make even a partial migration (and hardening via using memory-safe languages and/or professional paid code analysis tools) unrealistic.

Re:“C is how the computer works” is a dangerous mindset for ... by pjmlp on Wednesday April 01, 2020 @01:47PM (#22751471)
Naturally it isn't fair, but one cannot expect teams to drop velocity and diminish their productivity only on basis of adopting a new language that doesn't support existing workflows, IDE tooling and libraries.

It is like telling someone to delivering games in Unity and Unreal that they should use Amethyst instead, without understanding what it means to actually having a team working in those ecosystems.

Naturally Rust will get there, however it took C++ 30 years to be where it is today, and that is what any replacement attempt should take into consideration.

Re:“C is how the computer works” is a dangerous mindset for ... by pdimitar on Wednesday April 01, 2020 @01:52PM (#22751553)
This is probably a much larger and not very relevant to the topic here discussion but I feel a lot of the newer breed of languages don't emphasise IDE tooling very much (not in the sense of Visual Studio / Eclipse and the like at least; VS Code gets a lot of attention though). So I fear if that's an expectation from a certain group of devs that this might already be a generational difference that's impossible to overcome.

That being said, I agree -- existing teams can't be expected to just run away to the new thing, that much is true.

Re:“C is how the computer works” is a dangerous mindset for ... by pjmlp on Wednesday April 01, 2020 @04:22PM (#22753139)
Depends where you look, Swift, Kotlin and TypeScript live from their tooling.
Re:“C is how the computer works” is a dangerous mindset for ... by pdimitar on Wednesday April 01, 2020 @04:29PM (#22753195)
My favourite language -- Elixir -- is the same. I also quite admire Rust's and Golang's tooling.

CLI tooling is the best it ever was in history (from where I stand at least). But IDE tooling isn't a first class citizen for many languages these days, is what I was saying.

Re:“C is how the computer works” is a dangerous mindset for ... by pjmlp on Thursday April 02, 2020 @01:15PM (#22761238)
I beg to differ, I rather enjoy languages that pursue the dream from Xerox PARC than working like when I was in high school during the late 80's.

Just for reference, my first UNIX was Xenix.

Don't see the point why people buy expensive computers to just use them like we did at the university lab with IBM X terminals.

The main difference was that instead of Slack we had xterms dedicated to run talk sessions.

Re:“C is how the computer works” is a dangerous mindset for ... by otabdeveloper2 on Tuesday March 31, 2020 @02:26PM (#22740727)
> C++ has a standard that's too long and hard to understand, so let's use a language without any standard whatsoever instead!

Good lord, if that's the kind of human capital that's involved in making next-generation languages, then I have no doubt what will still be used to write serious software in 2080.

(Hint: not Rust.)

Re:“C is how the computer works” is a dangerous mindset for ... by pdimitar on Wednesday April 01, 2020 @01:34PM (#22751338)
You'd be more helpful if you specified what else would you deem appropriate -- as opposed to resorting to snarky sarcasm that brings nothing interesting to the discussion except supposedly degrade people whose tech choices you disagree with.
Re:“C is how the computer works” is a dangerous mindset for ... by otabdeveloper2 on Friday April 03, 2020 @02:54AM (#22766847)
The phrase 'undefined behavior' only makes sense in the context of an ISO standard.

For any particular combination of compiler, OS and computer architecture there are no 'undefined behaviors'; you only care about the concept if you want portability to a different compiler/OS/architecture.

So the idea that C++ sucks because of 'undefined behavior', so let's use some random language without an ISO standard or any portability guarantees at all is completely and utterly insane.

Re:“C is how the computer works” is a dangerous mindset for ... by saagarjha on Tuesday March 31, 2020 @01:50PM (#22740278)
What are you comparing it to? I think C++ tooling is fairly decent. (By the way, what do you work on?)
Re:“C is how the computer works” is a dangerous mindset for ... by amiga_500 on Tuesday March 31, 2020 @02:15PM (#22740590)
I think java has very good tooling.

Java's main issue is the barrier to entry is lower because it has good tooling, which means really bad, inexperienced programmers can write bad code, and have more tooling to bail them out, allowing them to continue down that path until they have a huge ball of mud.

There ought to be some kind of phrase for this "the tooling curse".

GDB isn't bad, IMHO, but the inability of IDEs to deterministically parse templates / index code without huge problems is problematic.

Re:“C is how the computer works” is a dangerous mindset for ... by saagarjha on Tuesday March 31, 2020 @02:20PM (#22740653)
> the inability of IDEs to deterministically parse templates / index code without huge problems is problematic.

More like the inability of text editors to parse templates; most IDEs rely on a full compiler backend that can usually figure things out.

Re:“C is how the computer works” is a dangerous mindset for ... by amiga_500 on Tuesday March 31, 2020 @02:44PM (#22740967)
But it shouldn't require a full compilation.

The ultimate result, given the slow compile times of c++, is that you cannot know in your editor if your code is correct.

Re:“C is how the computer works” is a dangerous mindset for ... by saagarjha on Tuesday March 31, 2020 @03:11PM (#22741278)
The IDEs I have used, or IDE-ified editors, run compilation ("indexing", or whatever) in the background to make this work.
Re:“C is how the computer works” is a dangerous mindset for ... by still_grokking on Tuesday March 31, 2020 @06:02PM (#22743166)
Maybe you want to share which IDEs you've been using? It sounds like a wonder if there is one that can handle C++ in a way comparable to, say, IntelliJ for Java, or VSCode for TypeScript.

My experience is frankly more that the usual IDEs I know of can't even handle syntax coloring 100% correct when it comes to C++…

Re:“C is how the computer works” is a dangerous mindset for ... by saagarjha on Tuesday March 31, 2020 @07:09PM (#22743753)
Xcode for well-structured (read: Xcode) projects. Sublime Text with clangd for random editing (not an IDE, but it gets good autocompletion and syntax checking from it).
Re:“C is how the computer works” is a dangerous mindset for ... by amiga_500 on Tuesday March 31, 2020 @06:28PM (#22743422)
This is problematic on large code bases. Huge mistakes were made on C++ design.
Re:“C is how the computer works” is a dangerous mindset for ... by shadowgovt on Wednesday April 01, 2020 @09:50AM (#22748437)
I completely forgot about this aspect of C++. I remember being surprised the first time I tried compiling a C++ library on my workstation and found I couldn't do so because my workstation ran out of memory. The library was Panda3D; I can't remember what kind of workstation I was running on at the time.

It turns out if you use enough layers of templates, the compiler has to carry around an awful lot of state to figure out what program it should actually output.

This is another downside to a 1400 page language specification; whether the user can hold most of it in their head or use a reliable, safe subset to avoid sharp edges, the compiler and tools still have to be aware of all of the layers of complexity in both the code a developer is writing and often whatever tricks and quirks developers chose to usein the libraries the developers code is depending on.

Re:“C is how the computer works” is a dangerous mindset for ... by saagarjha on Tuesday March 31, 2020 @07:10PM (#22743768)
How large are we talking about? I've been able to use these tools on codebases such as WebKit and LLVM…
Re:“C is how the computer works” is a dangerous mindset for ... by amiga_500 on Tuesday March 31, 2020 @09:25PM (#22744721)
LLVM has 2.5 million lines of code, but I think it also depends upon the number of templated methods etc, not just LOC.

I'm surprised you haven't seen this point made many times. It would be a full-time job on the internet asking people why they have code completion issues with C++ IDEs.

Re:“C is how the computer works” is a dangerous mindset for ... by saagarjha on Tuesday March 31, 2020 @11:25PM (#22745340)
No, I know what you're talking about; this is an issue in general if you'd not using tooling that's aware of the ins and outs of C++. The point is that the IDEs I have used essentially run the compiler on the file, so they can actually understand what the templates are doing and get through them.
Re:“C is how the computer works” is a dangerous mindset for ... by Too on Wednesday April 01, 2020 @12:55AM (#22745842)
Templates can inherently not be understood. It's duck typing 3 degrees of freedom with 3 unknowns. You need concepts which adds 1 known into the equation, (the final missing degree of freedom is the dreaded ctrl-click-into-an-interface-instead-of-the-concrete-class which is hard to avoid). Tell me one IDE that will give any meaningful information about buzz in the example below:

    template<typename T>
    void foo(T bar) { bar.buzz(); }
Other than that, finding foo<T> is usually easy, i've had good experience with qtcreator or clangd, you just have to be very very sure that your include paths are correct, qtcreator is good in that it uses CMakeLists as project-files so all this is done automaticaly.
Re:“C is how the computer works” is a dangerous mindset for ... by twic on Tuesday March 31, 2020 @02:58PM (#22741135)
Not in my experience. IntelliJ can't even figure out where a make_shared call goes.
Re:“C is how the computer works” is a dangerous mindset for ... by saagarjha on Tuesday March 31, 2020 @03:11PM (#22741270)
Does IntelliJ actually support C++?
Re:“C is how the computer works” is a dangerous mindset for ... by ivankolev on Tuesday March 31, 2020 @03:52PM (#22741740)
Probably talking about CLion, their C/C++ offering.
Re:“C is how the computer works” is a dangerous mindset for ... by twic on Tuesday March 31, 2020 @05:19PM (#22742709)
Yes, CLion, my mistake, sorry.
Re:“C is how the computer works” is a dangerous mindset for ... by saagarjha on Tuesday March 31, 2020 @11:29PM (#22745362)
Hmm, that's a bit disappointing…might I suggest trying out a LibClang-based IDE, if CLion isn't using it already? It can do wonders even to "stupid" applications. For example, my Sublime Text (by itself, with only basic knowledge of C++ keywords and such) with clangd tells me that std::make_shared comes from this code in <memory>:

  template<class _Tp, class ..._Args>
  inline _LIBCPP_INLINE_VISIBILITY
  typename enable_if
  <
      !is_array<_Tp>::value,
      shared_ptr<_Tp>
  >::type
  make_shared(_Args&& ...__args)
  {
      return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)...);
  }
Re:“C is how the computer works” is a dangerous mindset for ... by twic on Wednesday April 01, 2020 @08:08AM (#22747822)
Oh no, what i mean is that it can't help me find the constructor of the thing i'm creating. Resolving a make_shared call to the implementation of make_shared is completely useless; the only thing you ever want to do is find the constructor it's forwarding to.
Re:“C is how the computer works” is a dangerous mindset for ... by jkoudys on Tuesday March 31, 2020 @03:56PM (#22741791)
Lots of languages suffer there -- eg there's no reason you _couldn't_ be a really excellent PHP developer who specializes in WordPress sites, but it's an uphill battle to prove you're a good dev because there so many bad ones in that space.

For that matter, most of the so-so devs resumes that come across my desk will list "HTML and CSS" as skills. Even among experienced devs, being legitimately good with HTML or CSS is extremely rare. I'd give my eye teeth to have a dev on staff who was an actual HTML expert (knows the w3c docs, can write clear, correct, semantic html using the right tags, organizes and expresses their intent, etc.), but since the barrier to entry is barely above basic literacy, so finding one is tough.

Re:“C is how the computer works” is a dangerous mindset for ... by stjohnswarts on Tuesday March 31, 2020 @06:13PM (#22743277)
I find modern c++ tooling to be great compared to even 10 years ago. I love the language. Between it and python I stay very busy with both.
Re:“C is how the computer works” is a dangerous mindset for ... by edwintorok on Tuesday March 31, 2020 @01:51PM (#22740294)
Wouldn't something like Rust meet your performance concerns?
Re:“C is how the computer works” is a dangerous mindset for ... by amiga_500 on Tuesday March 31, 2020 @02:02PM (#22740435)
The sunk cost is huge. My main point was: if you don't have to do it in c++, for the love of god do it in something like java. Yes java is not heaven on earth, but still...