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

As a C++ programmer, the first time I had to write some complex generic code in C# I was annoyed that a common C++ pattern of macros+templates for registration of factory functions wasn't directly expressible in C#. My recollection is fuzzy, but I hit exactly the inability to constraint new that you mention.

Then I found out about the ability to introspect and modify lambda expressions and generate code at startup time, which obviated the need for a template with constrained new, and I was blown away by that power.

I was also very pleasantly surprised that C# had very easy to use multiple dispatch.

So, C# is an extremely powerful, but you can't always port C++ idioms 1:1.

edit: and before you ask, yes, I'm a recovering complexity addict.



Your edit seems to show your awareness but it's a plus for languages not to let developers do literally anything they want.


You are not wrong, but programmers, uh, find a way.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: