6 ms·
> That 'headache' has to be weighed against the needs of some parties to write very fast code and to have as little overhead as possible. ref returns enables a
by flukus 10y ago
> That 'headache' has to be weighed against the needs of some parties to write very fast code and to have as little overhead as possible. ref returns enables a much more pleasant coding experience that enables these sorts of speedups in these specialized scenarios.
I'm worried this could result in a loss of focus, you can't make everyone happy all the time. c# is a fantastic language to develop applications in (web or desktop) but it's never going to be the fastest language around or be a systems level language. For me some of the other features listed here (like immutable records) would be a much better fit for where c# excels already.
- pjmlp 10y agoThe Midori project proved otherwise. One of the reasons we are stuck with C and C++ is because other language vendors, including Microsoft, dropped the ball regarding performance of type safe languages. Do you think C++ would have been kept around if Java and the CLR had been AOT compiled to native code with focus on compiler optimisations since day one? I really appreciate the efforts of the .NET team in adopting the Midori lessons in the standard .NET stack.
- int_19h 10y agoSome things can be rather tricky to AOT-compile, especially when you don't have a fixed "world" (i.e. when code can be dynamically loaded, as is the case with both Java classes and CLR assemblies). Consider virtual generic methods, for example. If your set of types is not statically bound, you can't allocate the appropriate number of vtable slots in advance, because you don't know all the instantiations.
- pjmlp 10y agoC++ has the same problem. I was already using dlls with plugins in Windows 3.1 and C++.
- int_19h 10y agoC++ doesn't have this problem, because it doesn't allow virtual function templates. For that matter, it doesn't allow any templates across ABI boundary, except when you manually instantiate them (extern template) - and then only for those explicit instantiations. So it is effectively impossible to have a generic C++ API using templates that is not statically linked.
- pjmlp 10y agoOf course it does, as I said I was doing that. Borland C++ for Windows 3.x had an initial implementation for templates as they started to be discussed at ANSI and also supported exporting classes across dlls, providing both producer and consumer were Borland C++.
- int_19h 10y agoHow exactly did that implementation work for templates?
- pjmlp 10y agoNo idea, not something I was too deep into. Back on those days I just used them. Here is the link for the Borland C++ compiler documentation, I was actually using the Turbo C++ version for Windows 3.1. https://archive.org/details/bitsavers_borlandborn3.1ProgrammersGuide1992_17439947 https://archive.org/details/bitsavers_borlandborn3.1Programm... The BIDS, Borland International Data Structures were the template based library that replaced the object based one and could be accessible as a DLL as well. To export classes from DLL one would do something like // On the DLL side class _export MyClass {...} // On the consumer side class huge MyClass {...} Described on page 336 of the manual. If you check the the templates documentation, the generated code code could be externalized, page 152, via the -Jgx. I was only a BIDS user across DLLs, but I can easily imagine a combination of _export/huge and -Jgd/-Jgx being what was necessary to make it all work.
- 10y ago
- pbz 10y agoWell maybe you don't care, but there are folks that do (I'm on that list) ;-) I want the speed of C but the safety of C#. There are many pieces of code that you probably use every day that go to great lengths to squeeze as much power as possible. Why not help these folks help us? I'm glad there is more focus on performance because we all benefit. (Hoping to see more on the CLR side.)
- flukus 10y agoWhy c# and not rust or something similar that has a lower level focus?
- pjmlp 10y agoBecause some of us believe in GC enabled systems programming languages, as done already at Xerox PARC (Cedar), DEC (Modula-2+/Modula-3), ETHZ (Oberon, Active Oberon, Component Pascal) and MSR (Sing# / System C#). What is missing is a company like Microsoft to push it down to mainstream developers, at all costs, like it happen to all luddites.
- snaky 10y ago> I want the speed of C but the safety of C# Try OCaml.
- Dayshine 10y ago>I want the power of a Bugatti but the efficiency of a Prius. Use a tractor.
- skoczymroczny 10y ago> I want the speed of C but the safety of C# Rust or D seem like the best bet here