r/programming • • Sep 16 '19

Open Sourcing MSVC’s STL

https://devblogs.microsoft.com/cppblog/open-sourcing-msvcs-stl/
283 Upvotes

63 comments sorted by

14

u/masterofmisc Sep 17 '19

So wait..... Who exactly is P.J. Plauger?

Did Microsoft originally buy their STL implementation from him?

23

u/DangerousTea4 Sep 17 '19

I'm not sure you've noticed, but one of the core authors of this STL implementation -- Stephan T. Lavavej -- has exactly the initials of the project he's working on: STL. This means he's perfect for this job :)

19

u/matthieum Sep 17 '19

You'll never guess his reddit username...

9

u/z500 Sep 17 '19

PM_ME_UR_FART_BOX_MY_DUDES?

2

u/thegoldenshepherd Sep 23 '19

This made me laugh out loud, thank you

1

u/Frexxia Sep 17 '19

Nominative determinism

1

u/maxhaton Sep 18 '19

My business teacher's name when I was 14 was Andrew Startup, how's that for nominative determinism

55

u/[deleted] Sep 17 '19

Getting closer... we just need the actual compiler. It’s ludicrous that versus their competitors (Apple, Google, GNU) that the official OS’s build tools still aren’t freely (gratis) available for any purpose, even if they’re proprietary.

32

u/scalablecory Sep 17 '19 edited Sep 17 '19

What are you looking to use the compiler for that the build tools don't allow?

-15

u/[deleted] Sep 17 '19

Not quite those build tools - the compiler itself is under the full VS license agreement. AKA, if you’re under any kind of contract that technically lets your employer claim your work, you can’t use it. At all.

35

u/JonnyRocks Sep 17 '19

This isn't true. Visual studio is used all over the place, in the biggest and most restrictive companies. I almost feel like I am not following you and you are talking about something else.

0

u/[deleted] Sep 17 '19

[deleted]

18

u/dakotahawkins Sep 17 '19

Presumably they mean the free community edition. I'd buy that the terms stipulate you need to use the paid versions for commercial work in corporate settings, but I haven't looked.

4

u/Pazer2 Sep 17 '19

Pretty much. Community can only be used for

  • open source projects

  • commercial projects by a solo developer

  • education

1

u/irqlnotdispatchlevel Sep 18 '19

I'm not sure you've noticed, but one of the core authors of this STL implementation -- Stephan T. Lavavej -- has exactly the initials of the project he's working on: STL. This means he's perfect for this job :)

Isn't that just the IDE? I was under the impression that MS Build Tools (available here, for 2015 https://www.microsoft.com/en-us/download/details.aspx?id=48159&WT.mc_id=rss_alldownloads_devresources ) are free of charge.

2

u/dakotahawkins Sep 18 '19

I honestly don't know. I would have thought that it applied to both, and that binaries built with the community edition of the tools are somehow distinguishable from binaries built with paid versions. I've always had a paid version for work stuff so it's not something I've ever really looked in to.

8

u/scalablecory Sep 17 '19

It wouldn't surprise me -- god knows Microsoft's licensing is not for the feint of heart -- but I don't see that in that license. Presumably there is more text elsewhere that isn't part of the installer's EULA?

22

u/maxhaton Sep 17 '19

So much underscore noise, what a wonderful language C++ isn't in 2019

27

u/STL Sep 17 '19

Macros gonna macro. Complete modularization would make the _Ugliness unnecessary. (Other implementations use __ugly.)

21

u/afiefh Sep 17 '19

Flexible code, high performance code, beautiful code. Pick two.

22

u/gracicot Sep 17 '19

The STL must uglify it's coffee because user macros could clash with any local name. So the standard define any name that starts with a double underscore or an underscore followed by capital letter reserved to the standard at any scope.

Modules gonna save us all, isolating code from macros.

4

u/maxhaton Sep 17 '19

I am aware

3

u/maep Sep 17 '19

clib next please?

5

u/STL Sep 18 '19

There are no plans to open source the CRT, sorry. As a part of Windows, it is subject to extreme stability requirements, and it is also not fast-evolving.

1

u/SubmarineWipers Sep 20 '19

One could argue, that opensourcing it is the best thing for stability - it would provide the biggest audience reviewing the code. (by opensourcing I dont necessarily mean accepting pull requests)

Btw, I assume you work for MS - is there any chance of ever opensourcing Visual studio? there is a number of annoyances in it for me personally, that could be easily fixed, but "just arent a priority for MS". I would gladly help, but right now I cannot... :/

2

u/STL Sep 20 '19

I assume you work for MS

Yes, I've worked at MS for 15 years, and on the STL for almost 13.

is there any chance of ever opensourcing Visual studio?

I am unable to answer that question about high-level strategy, sorry.

-85

u/corsicanguppy Sep 17 '19

If the license isn't GPL, then they can go to hell.

23

u/[deleted] Sep 17 '19

I am not a lawyer, but the license should be GPL compatible so you can use it in your GPL'd projects. There's even an explicit section about that in the new license: https://www.llvm.org/foundation/relicensing/LICENSE.txt

In addition, if you combine or link compiled forms of this Software with software that is licensed under the GPLv2 ("Combined Software") and if a court of competent jurisdiction determines that the patent provision (Section 3), the indemnity provision (Section 9) or other Section of the License conflicts with the conditions of the GPLv2, you may retroactively and prospectively choose to deem waived or otherwise exclude such Section(s) of the License, but only in their entirety and only with respect to the Combined Software.

64

u/tanishaj Sep 17 '19

Thank God they chose Apache 2.0 ( as they do almost everywhere else ). Now I am free to do whatever I want with the code ( unlike GPL projects that restrict my freedoms as a developer and / or business ).

-3

u/maxhaton Sep 17 '19

The GPL is designed to help the users not you

3

u/tanishaj Sep 19 '19

The GPL does not help users. It helps copyleft activists.

If you are a user of an Apache 2.0 licensed work, you have every freedom enjoyed by uses of GPL projects and more.

What you do not have is the same level of control over other uses of the same software.

The GPL bakes in the idea that, if I let you have a benefit that I do not share, that I have been harmed in some way.

The Apache license embraces the concepts of Game Theory that express the idea that the greatest benefit is achieved when we all cooperate to achieve the most optimized collaborative outcome. It is the evolution of capitalism as described in The Beautiful Mind.

The GPL is rooted in the older idea that the greatest benefit is achieved by pitting competitors against each and fighting to overcome rivals to achieve dominance.

GPL advocates believe they are champions of the common good when, in reality, they are just out to ensue that nobody benefits more than they do. Us vs Them. Pure competition. Winner take all. You are either on team GPL or you are the enemy.

1

u/Vhin Sep 17 '19

The GPL is so naive. It's never going to kill closed source software.

The vast majority of the time companies use GPL code and release their source, they would've kept their changes open source even if it was released under a more permissive license. Even from a purely selfish position, it's advantageous to do so because it lessens your own maintenance burden if you can get your changes merged upstream.

Any company who wants to make closed source software isn't going to be considering using GPLed code. They'll look for something with a more permissive license or they'll reimplement it from scratch, and the former is massively more advantageous, because it minimizes compatibility issues, reducing the risk of lock-in to their proprietary offerings.

7

u/Pazer2 Sep 17 '19

Exactly this. No company is going to find a GPL library they'd like to use and say "well, guess we need to open source the whole project!". They're just going to find a different library or rewrite it themselves.

1

u/jyper Sep 17 '19

Apache 2 arguably can't be used with GPL 2 licensed software, and since that's one of the most common licenses that's a big problem

They should have used MIT/X11 license

7

u/epicar Sep 17 '19

i'm sorry to hear that you're trapped in the world of gpl

28

u/favorited Sep 17 '19

Listen, RMS, I know you're unemployed now but don't take it out on Reddit.

11

u/Borno11050 Sep 17 '19

GPL is pain in the arse actually. Restrictive.

11

u/astrange Sep 17 '19

Apache licensed software can't be used with GPL software without an exception (which they granted). Similarly gcc's GPL standard library can't be used with any other software without an exception, which they grant:

https://www.gnu.org/licenses/gcc-exception-3.1.en.html

so it's all cool actually.

6

u/balenol Sep 17 '19

Based stallman

0

u/[deleted] Sep 17 '19

[deleted]

49

u/barchar Sep 17 '19

We ship both 32, and 64 bit versions of the compiler. Visual studio itself doesn't yet have a 64-bit build, but the compiler does.

Source: I work on the STL @ Microsoft

17

u/Ameisen Sep 17 '19

You maintain /u/STL?

2

u/CaseyCarter Sep 18 '19

No, no - not _that_ STL, the other STL.

1

u/OneWingedShark Sep 17 '19

Who would I talk to about the possibility of a Microsoft implementation of ISO/IEC 8652?

3

u/barchar Sep 17 '19

I think that would be cool, but I don’t think there are any plans for it. (I think we used to have a FORTRAN implementation)

3

u/OneWingedShark Sep 18 '19

Hell, there used to be a Microsoft Pascal and a Microsoft Basic, but an Ada,Cobol,Fortran all integrated into the DOTNET visual studio would be pretty cool:

  • Ada, excellent type-system.

  • Cobol, superb batch-proceccing of records.

  • Fortran, VERY wel-done numeric librararies.

0

u/[deleted] Sep 17 '19

[deleted]

19

u/[deleted] Sep 17 '19

"All the hoops" of... opening a prompt? O_O

0

u/[deleted] Sep 17 '19

[deleted]

17

u/barchar Sep 17 '19

it is included in visual studio, just run the x64 native tools command prompt, or find it at VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64\cl.exe

0

u/[deleted] Sep 17 '19

[deleted]

1

u/Pazer2 Sep 17 '19

It's only used if you are running into OOM issues. Otherwise, the larger pointers mean lower performance.

4

u/londey Sep 17 '19

You can also use the 64bit compiler by setting an environment variable (from memory something like PREFERED TOOLSET=x64) I would assume most C++ shops use this to avoid running out of address space during link time optimisation.

0

u/[deleted] Sep 17 '19

[deleted]

15

u/ygra Sep 17 '19

That's up to the compiler vendors to standardize on an ABI (which is not standardized by C++ anyway). It also has little to do with the standard library.

1

u/dacian88 Sep 17 '19

this is already the case?

4

u/elder_george Sep 17 '19

Only if adhering to the (arguably, inferior) C ABI, and even then there're possible problems, I think, due to different underlying runtime libraries. But, as /u/ygra said, this has little to do with the STL, unfortunately.

1

u/dacian88 Sep 17 '19

i've used clang to compile MSABI code, don't think you're very correct here.

5

u/elder_george Sep 17 '19

You're right, as wikipedia says:

On Microsoft Windows, the Intel compiler and Clang uses the Visual C++ name mangling for compatibility.

And on *NIXes they are compatible with gcc, according to the same article.

1

u/[deleted] Sep 17 '19

That's my point - if we'll have one STL, we can finally pass std::vector<int>& between clang and msvc, as it will have the same fields with the same layout with the same implementation.

Or do win compilers mangle c++ names differently on top of everything?

1

u/elder_george Sep 17 '19

Yes, mangling is specific to a compiler. MSVC and gcc (including Mingw) use different encodings.

Some, e.f., (as /u/dacian88 said), clang and, probably Intel's C++ supports MSVC's encoding (and gcc's too, I believe), but it's not set in stone, unfortunately.

1

u/dacian88 Sep 18 '19

if it wasn't obvious already...you can already do this.