Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In C++ the over-abstraction starts in your first lessons. I know and understand all the arguments, but I will never type this:

    std::cout << "You have " << itemCount << " items of type " << itemType << "." << std::endl;
When I could do this:

    printf("You have %d items of type %s.\n", itemCount, itemType.c_str());


I will never type this:

    printf("You have %d items of type %s.\n", itemCount, itemType.c_str());
When I could do this:

    std::println("You have {} items of type {}.", itemCount, itemType); 

    https://en.cppreference.com/w/cpp/io/print


That's perfect -- as easy to write and to read as printf. I feel like an idiot for not using it all these years.

Edit: Oh, it's in C++23 standard. Only took them 38 years! ;-)


Agreed with you on both counts - cout was an abomination and that std::println looks great (I'd never seen it before, either)


I doubt it's yet implemented in any standard library. But it has been in the fmt namespace for close to a decade: https://fmt.dev/ . I do use it in a C++11-only codebase.


C++, OOP, and whatever crazy async shit is going on in JS ruined the conceptual model of “code” for going on 2 generations of programmers.

We do students a disservice teaching them how to “code” first. And not instead how to solve problems with code


Yeah, that async stuff is brutal.


Great for solving the typical problems encountered in a web browser.

But a real fucked up mental model to bake into an entire industry’s worth of developers


To me this seems overexaggerated. Most people I went to university with already struggled to understand async code, without having done web development before. And for those with web development background it was pretty easy to adjust.

I also don't know any school, college or university that starts their programming courses in a webbrowser. Typical languages in Germany for a first semester algorithms/data structures class are either Java or C++.


By entire industry I mean web developers, which is a cohort that usually has more non-traditional educations and tends to think in a async mental model.

What you explained happens in Germany is pretty par for the course in the US as well for CS degrees. But even then, why the hell are we throwing a book of data structures at students? You don’t give an apprentice framer a nail gun and say “go at it!”. They’ll destroy everything. You give them a hammer and educate them when they start to complain of smashed thumbs


Where do we use it where it isn’t needed? async/await syntax is much nicer than callbacks or promises. Maybe you’re talking about the old ways.


I would go a step further and teach them how to read code before teaching them how to write it


Many languages have string interpolation, which looks more similar to C++'s << than to printf

  puts "You have #{itemCount} items of type #{itemType}."

  print(f"You have {itemCount} items of type {itemType}.")

  console.log(`You have ${itemCount} items of type ${itemType}.`)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: