Stupid question but could Rust skip monomorphization during development builds and use dynamic dispatch? I heard generics were often to blame for slow builds.
It could potentially do that, but there are a lot of things that "normal" monomorphized generic code can do (and does routinely) that would be very very difficult to implement dynamically.
There are perhaps other tradeoffs that could be made instead, like doing more implicit boxing in debug builds, but it's not clear to me that those would be any easier to reconcile with all of the low-level details that Rust exposes. E.g. what happens to `mem::size_of` when an object of a polymorphic type has been boxed?
Related to this area is ongoing "polymorphization" work to detect pieces of generic code that actually do not depend on their type parameters, to avoid duplicating it: https://github.com/rust-lang/rust/pull/69749
This could potentially be made into a much finer-grained analysis to reduce the duplication further, though that may or may not actually help compile times depending on how expensive the analysis is.
In some cases maybe, but I don't think it could work in all cases. One of the things that monomorphization does for you, is statically determine the size of your types. For example, if you have a `Vec<u32>` and a `Vec<u64>`, the implementation of `Vec` needs to multiply by the size of the element type (4 bytes vs 8 bytes) to figure out the offset of each element. I don't think regular dynamic dispatch provides size information, so the compiler might need to "invent" a new flavor of dynamic dispatch internally if it wanted to do this?
With dynamic dispatch, they'd all be fat pointer sized. It would move to Vec<Box<dyn SomeTrait>> where SomeTrait is auto-generated and implemented for u32 and u64.
Ah I was thinking about "keep things allocated where they were before, but try to dynamically dispatch implementation code, to avoid compiling it N different times." It sounds like you're talking about "heap allocate everything by default." If everything was implicitly boxed, no type could be `Copy`, right? Is that strategy possible without breaking existing code?
You can Box Copy types, yes, but the result is !Copy. So for example, maybe I have a slice of ints, and I'm calling ptr::copy_nonoverlapping on that slice. (Maybe via safe code, like slice::copy_from_slice.) That no longer works; I need new heap allocations for each int. And my slices of ints no longer have a memory layout that's compatible with C, so all ffi breaks?
Is it a goal of production vs debug build that the data structures that you define in your program are always the same?
I could see some kinds of funny differences in behavior between debug / production builds, if for a debug build a particular thing is boxed, but in production it isn't.
If it's a program-visible kind of box, yes that would be a problem.
But if you're generating polymorphic dispatch code at a lower level than expressible in Rust itself, there is no reason why hidden box types cannot be used to simulate unboxed types. That's just a memory representation difference. A bit like the way V8 creates specialised types for JavaScript objects at run time, but it's invisible to JavaScript except for speed.
The trouble is that the memory representation is fixed and observable in many cases. If you have arrays of primitive or repr(C) types, those are guaranteed to have the same contiguous layout as an array in C would. In particular, you often need to pass pointers to those things to actual C code. Copy types are similar; even if you can't necessarily assume all the details about their layout, you can copy them byte for byte and assume the result is valid. But that doesn't work if the compiler secretly inserts an owning heap pointer that needs to remain unique. The compiler could try to deduce when the memory layout is actually observed in practice, and do whatever it wants in cases where it can prove the difference doesn't matter, but I feel like that would end up making everything more complicated rather than less.
I'm not familiar with Rust, but if compilation speed is a major issue, and there are aspects of the compilation that are avoidable to trade-off for runtime performance, it seems to be a good idea to make those configurable per-build-type. Does Rust not offer this?
I've written an image processing tool in Rust, where running a large image downscaling test with a release build takes 2.0 seconds, and with a debug build it takes 18.7 seconds. So most of the time during development I compiled in release mode, because it was actually faster overall.
For many applications debug builds are fast enough, but their runtime performance is already so slow, that I hope they don't get even slower.
> Do you want your code to run as if it was written by hand (i.e. duplicated by hand)? Then monomorphization is best.
That's not always true because monomorphization where the vast majority of the object code is the same in all actual cases means bloating the text of the program, which means putting pressure on the Icache, which means more cache misses, which... is slow.
> The function of the capital markets is to allocate capital.
I never fully grasped this idea. I have no problem understanding that venture capitalists, angel investors or investors that buy shares at IPO do allocate capital. However, why is trading existing shares considered "allocating capital"?
It's a price mechanism. The logic is that by having a liquid secondary market where investors are free to trade securities whenever they want, you always have an up-to-date price that reflects all information known about future prospects for that business. (If you didn't, then someone with superior information could trade based on that and reap a profit, which increases the amount of capital they have to trade on in the future, which means that eventually all the capital ends up in the hands of the firms with the best information.)
Then whenever a company needs capital for future expansion - whether it be for secondary stock offerings, new factories, or stock options to entice key researchers or executives - they have an accurate price on the stock with which to judge the cost of capital. If their stock price is low and capital expense is high, they may decide that the capital investment won't increase the value of the company enough to be worth it; the market has prevented capital from flowing to inefficient businesses. (Again, if they guess irrationally, they go out of business, and the system remains rational even if management isn't.) Similarly, if the market puts a high price on the stock because there's a belief that what they're doing is important and will reap big rewards in the future (eg. Tesla), they'll find it cheaper to make big capital investments.
The early-stage startup financing market - angels and VCs - is actually both quite illiquid and quite inefficient - prices at that stage are basically just guesses, which is why some companies rapidly increase in value and many others go to zero. It too depends upon the liquid secondary market after IPO to keep actors rational, though - if VCs could not sell their shares later on the public markets, they would have no incentive to invest in startups.
Thanks for the elaborate reply but I was aware of all of this already. I wasn't questioning the utility of the stock market and understand its role as a price discovery mechanism and liquidity provider.
I was however questioning whether this sentence from the article was really accurate: "The function of the capital markets is to allocate capital".
I'd argue that trading existing shares, although it contributes to price discovery and liquidity, is not "capital allocation" (unless we're talking with respect to the buyer's capital like another commenter pointed out).
The Capital Market is more than just the stock market. The Bond market - the place where orders of magnitude more $$ volumes are traded is also a capital market. Both are allocating and reallocating capital to daily, and the price signals are just as important to future capital decisions of all participants.
Trading existing shares is not allocating capital (from a company POV), you are correct. But a company issuing new shares, for example, is an example of such. The markets set a price, and the company can take advantage of this liquidity to raise money
This is one thing that frustrates me about investing in the stock market. The idea of calling trading "investing" feels so inaccurate. I didn't invest in your fortune 500 company, I bet on the idea that other people down the line would bet on the same company but that they'd bet even harder. I wish investing was more like selling small corporate loans. I'll give Amazon $50 today if they pay me $100 in 10 years. Sounds great to me, take my money, do something with it, and pay me back. That's investing.
I've grown much more comfortable investing in real estate as a result of this. When I invest in something I want to see how that investment was used, how it helped, and get returns based on how successful my ideas were. If I renovate a house or invest in my buddy's business, I get exactly that. It may fail, but at least my money mattered and I saw what it did to help. When I invest in the stock market I get none of this.
I don't agree. In a farming village centuries ago, a man bought a second hoe from an estate sale. He would go on to lend it to others who needed a hoe, and charge rent for the use of that hoe. Over the seasons, his hoe brought him good rent, but then it came time to sell it. Because many of the hoes in town had been made by the blacksmith's apprentice, several had broken over the years, and the old master blacksmith's arthritis had prevented him from making new ones. But our hero's was one of the few crafted by the master, so over the intervening time, and with careful maintenance, it had actually appreciated as an asset, in addition to the investment income it generated.
This was unquestionably an investment on his part, in the traditional sense of the word. Our hero bought a productive asset and earned returns from that asset. It was nice that it also appreciated, but that's not necessarily what he bought it for. Or maybe he did. It doesn't fundamentally change the nature of his effort.
Buying a stock is very much like that, with lower transaction costs and risks. Only the productive asset you're buying is not a physical one, but a legal one and social one.
Also, you can buy corporate bonds. They don't pay shit because everyone wants a safe investment like what you're describing, and money is real cheap right now.
You are correct in that there is no net new creation of equity capital in a secondary market trade.
I look at it this way: there is a fixed amount of equity capital floating in the world at any given moment. At any point in time, someone has foregone consumption (decided to forego eating a pizza today), at some point in the past (distant or recent) in order to own a piece of that equity.
Also keep in mind companies issue and retire equity on a more or less ongoing basis through employee stock grants and buybacks. So it really is a question of how much you want cash vs. shares of stock, and how that tradeoff works for others.
>I wish investing was more like selling small corporate loans. I'll give Amazon $50 today if they pay me $100 in 10 years. Sounds great to me, take my money, do something with it, and pay me back.
That’s a bond. Corporations do issue bonds but it’s just one way to invest, and generally you’re just betting they’ll pay their debt to you (and you’ll tend to get less over time but it’s more guaranteed). With a stock you’re betting that the value of the company will increase over time and you get paid as it increases in size and income.
This is basically Warren Buffett's conception of a stock: a bond with a variable interest rate.
It gets easier when you think of a share as a fractional claim on a cashflow (profits - what's "left over"). Bondholders are generally promised a specific amount upfront. Stockholders get what's left over -- the amount of that is anyone's guess.
It gets pretty abstracted when you start talking about firms that don't pay out profits but the basic idea is sound.
Sounds like the bond market is right up your alley; that's how bonds work. (N.B. read first, invest later.)
The thesis above also neglects dividend investing, where you buy a share of Ford Motor Company from someone for ~$9, and as long as Ford can do so, they'll probably give you $0.15 every quarter.
> I didn't invest in your fortune 500 company, I bet on the idea that other people down the line would bet on the same company but that they'd bet even harder.
The stock price does connect to the real world though. If a company is deciding whether to expand, or bring in new management, or exit an industry, their stock price will certainly factor into that. If they're looking to buy another company, or another company is looking to buy them, the stock price is even more relevant.
> I didn't invest in your fortune 500 company, I bet on the idea that other people down the line would bet on the same company but that they'd bet even harder.
You just provided a (simplistic) definition of investing. I don’t see how that supports your claim that it’s not investing. All investing is just buying something that you think will be worth more over time. You buy a share of a company because you think the share will be worth more. You buy a bond because you think the issuer will be able to pay back the debt and interest. I can’t think of another definition of “investing.”
Not necessarily. A more general, yet more precise definition of investing might be, "Trading cashflows in a way that both parties find beneficial".
Those cashflows may be subject to (negotiated) differences in timing, risk of nonpayment, intrinsic uncertainty (most equities fall into this bucket), etc.
But at bottom it's all just cashflow.
This is a useful lesson to generalize about finance, in the larger sense. Don't think about "worth more". Just think of it as timed cashflows. Negative when you buy, positive when you sell or receive a dividend.
It might be helpful to take a look at what Graham called a “Net-Net.” If other investors perpetually undervalue your investment in a company that produces earnings, eventually the cash generated from those earnings could be given to shareholders as a dividend, etc. In an extreme example, imagine a company that the market values at $1B with $1B in assets that produces $1B in earnings. The following year, the company would have an extra billion on its balance sheet even if the share price didn’t change.
Trading is when your speculating day or week to week.
Investing is saying "ok big warehouses for distribution companies like amazon is a growing market therefore I will buy shares in a company that owns warehouses (BBOX) - this is sort of how Warren Buffet works
Eh, that distinction is ambiguous at best. There's a far larger overlap between speculation and investing. It would be more accurate to say that value investing is different from speculation - but even then, speculation is fundamentally inseparable from investing.
Every purchase of a share rewards the previous owner with some cash. Follow that chain of trades backward and eventually you end up rewarding the founder, the early employees, the VCs, etc. It's a long, tenuous chain, but it's there.
I agree with the general point that most trades of mature companies don't seem to have a material effect on the expectations of today's founders, early employees, VCs, etc. Though in theory if liquidity dried up enough or valuations fell, those signals would noisily backpropagate through prices and shift expectations of rewards.
I understand the concept of liquidity and the reward mechanism you describe but it doesn't ultimately answer my question, which why is the process of buying an existing share called "capital allocation"? Let's say I buy a GOOG share from Larry Page. Is it the idea that I "allocated capital" to Larry Page's bank account? It seems to me like the correct thing to say would be that I provided liquidity to Larry, not that I allocated capital. Or is it the idea that I allocated some of my own capital to the stock market?
Two points, one going to your question and one is of general interest.
Buying existing shares is "capital allocation" with respect to the _buyer's capital_. So I might allocate 20% of my capital (ie, gross financial worth) to being in shares of some company. The seller is allocating their capital somewhere other than the share. So you allocate your capital to GOOG, pay Larry and notify Alphabet that you are one of their capitalist overlords. If the price of Alphabet stock goes up, you now have more capital even though if you do a quick count you'll discover you have no new currency/cash. The reason this is important is that the people with a good ability to allocate capital will end up with more capital hence control. Eventually, the people in charge will be the people with a good grasp of what is changing (which I'll claim is desirable with no support).
For general interest, I've no insight into the intricacies of the US system, but in Australia every so often a company creates and sells new shares directly on the market. The upshot of this is a company can access the market directly for capital.
> However, why is trading existing shares considered "allocating capital"?
Because the company is made of capital. It has a plot of land with a factory, equipment for making brake pads, raw materials, a trade name that engenders goodwill with customers etc. When you buy a share, that share of ownership of the capital is allocated to you. You get a vote in how it's used. You could vote to keep making brake pads as ever, or mortgage the factory to expand into brake rotors, or cease operations and sell the individual assets to the highest bidder.
In principle you could be the deciding vote and someone else could have made a different decision than you.
Ah, it makes a bit more sense when interpreted that way. So the capital that is described as being allocated is really the company's capital to the investor, not the investor's cash to the company.
One possible way is if we consider capital allocation in terms of acquisitions, where one company acquires other companies by giving them stock instead of cash (which is what a lot of pre dot-com era telecom companies did to acquire customers + coverage like Verizon or the notorious Worldcom) and the ease of those acquisitions was largely based on the demand of that stock and thus the stock price.
If I buy shares in a company say RDSB (Shell) I am allocating my capital to that company and someone else is selling theirs as they don't want to own that asset any more.
I did this when the share price was low so I was taking a long term view that it would recover and I would capture that value and also have the dividend at an expressed yield on between 6-7%.
A functional capital market provides liquidity and higher valuation to an investment. Without these two you would have less capital going into companies. Trading shares may have little immediate effect, but certainly do for the next share offering.
The bonds pay 5.3% of their $1000 face value in interest every year, or $53.
You can buy this bond for $890, so the effective interest rate is actually 53 / 890 = 5.96% per year.
The fact that the price of the bonds is unchanged indicates that Tesla's earnings report didn't cause any change in market expectations of the company's ability to repay the bonds in full.
The price could drop to, say, 79 cents on the dollar if there's a greater probability that Tesla goes bankrupt and the bonds won't be repaid.
Bond prices also fall when market interest rates increase since that $53 per year isn't as competitive if other investments yield more.
Thanks for your explanation, let me see if I understand.
They promise to give $1,000 in some years, plus $53 per annum until that happens. That promise is currently worth $890. But if people were worried about the repayments, that might fall to $790. So they get less money for taking on the same debt.
Have I understood?
What are the rates at companies like Apple or Exxon?
Apple has bonds that pay 3.85% that mature in 2043.
They're currently trading at about 95 cents on the dollar, for an effective yield of 4.05%.
There's nearly zero risk that Apple will default. Their bonds sell at a discount because market interest rates have increased since the bonds were issued, making them worth less.
Note that Tesla's bonds yield almost a full percentage point more than Apple's bonds, which reflects Tesla's higher probability of default.
But if investors were really worried about default, they'd demand a lot more than an extra 1%.
It's worth noting that a 2043 bond is a very very different beast to a 2025 bond. The further in the future maturity happens, the more risk there is of a change in circumstance which results in default.
> What are the rates at companies like Apple or Exxon?
Anytime they issue a new bond, figures change so difficult to give a straight answer. For Apple, bonds typically range around 3/3.5% yield. And prices of the bond usually stay above 90 cents on the dollar, AFAIK (not an expert)
For 89 cents you can buy a Tesla bond with a face value of $1 which accrues at a rate of 5.3% per annum (so would have a face value of 105.3 cents after one year). Tesla will hopefully pay back the face value but they may not if they go bankrupt.
Some bonds don't but you are correct these bonds do. However it isn't guaranteed that coupons will be paid on time especially if a company is in financial difficulty.
The bond denomination is 1000 and usually brokers have minimum lot size of 10, so it would be $8900. However many brokers have minimum trade size of $10K on bonds as well, so the "ask your broker" is the best advice :-)
You can buy a bond that forces Tesla to repay you $1 in X years, for 89 cents.
Bonds trading below value happen when there is uncertainty whether it can actually be repaid in the future by the company (e.g. maybe it is unsecured debt).
If repaid the yield would have been 5.3% per annum + the 11% difference it trades below value
Yes Tesla's latest unsecured bonds have a coupon rate of 5.3% which they pay biannually. So for a bond with a face value of $1 they will pay you ~2.6 cents every 6 months.
> many programs have, instead of the former, means to satisfy some portion of credit requirements without actually taking classes if you can demonstrate equivalent knowledge gained elsewhere (e.g., credit-by-examination.)
Can you name some of those programs? I keep hearing about those but can't find them.
I asked this question in a number of places a couple years ago and the answer is basically no.
I did, however, find that my undergraduate university had a great program for people with nearly complete degrees who had been away for a few years.
I'll be finishing undergrad this May and am now looking at grad schools. Feel free to contact me if you want to chat about this because it's been surprisingly hard to find info or advice in our situation.
Who can apply to the OMS CS degree program?
Admission into the OMS CS program will require a Bachelor of Science degree in computer science from an accredited institution, or a related Bachelor of Science degree with a possible need to take and pass remedial courses. Georgia Tech will handle the degree admissions process. For more information please visit the Georgia Tech program page.
I'm with you up until "the US tried to save Cuba from itself". Castro was an awful dictator but the US embargo not only didn't save Cuba from itself, it made things worse for ordinary Cuban citizens. I wouldn't be proud of it.
> When you see him and his followers advocating misogyny, racism, xenophobia, homophobia, aggressiveness, and basically all the other -isms and -obias, it becomes much harder to "see the other side" of the debate
The exact same argument could be convincingly used to discriminate against members of the two largest organized religions. Are you also going to ask potential hires who they voted for at the last election too?
Thiel is not simply voting for Trump, he's actively trying to help get him elected (first with an appearance at the RNC and then to the tune of 1.25m). And that's after the "hot mic" tape. Which means that Thiel thinks the propensity for commiting sexual assault should not be a disqualifying feature of a presidential candidate.
As a non American who would probably vote for neither of them, Hillary definitely ranks way higher on my internal psychopath detector. The constant fake smiling, cold and calculated question answering, passive aggressiveness, etc. In short, the traits of a great manipulator. Trump is guilty of some of that too but he is somewhat redeemed by the fact that he seems dumb/naive enough to believe whatever he preaches.
> The constant fake smiling, cold and calculated question answering, passive aggressiveness, etc. In short, the traits of a great manipulator.
Aren't those, pretty much by definition, the traits of a poor manipulator? A great manipulator wouldn't seem so false.
Let me put it this way: How natural do you think you would seem if you were spending hours of every day in front of dozens of cameras, knowing that the slightest misstatement or weird facial expression is going to spread across social media to the entire country and be analyzed and picked apart and turned into memes and used against you by your opponents? I think anyone who seems like a "normal person" in that situation is anything but.
I've been thinking about what bothers me about Clinton and here's an example:
In 2008, Clinton declares she's opposed to gay marriage. Now it's 2016, and the majority of the American people are in favor of gay marriage. And guess what, Clinton is in favor of gay marriage. The battle has been won and now Mrs. Clinton proudly jumps on the barricade.
Now you may say this is just the reality of politics, but at some point you wonder what she really stands for except saying whatever it takes to maximize her vote count.
No she doesn't. The chain of emails you're referring to makes it clear that Hillary still believes her support of DOMA was justified to prevent a constitutional amendment, not that she still believes gay marriage is wrong.
There is no evidence to suggest she opposes it now, and a little evidence to suggest she was lying in 2008.
Well that's a fantastic way of interpreting the email thread and flipping my comments.
During a debate in 2008, she said marriage was between a man and a woman. So no, she wasn't lying in 2008 -- nor did I ever imply such a thing -- that was likely her true sentiment.
At this point, you literally don't know who is putting what into her mouth, or what she will really do once in office. That's an absolutely scary thing.
> Aren't those, pretty much by definition, the traits of a poor manipulator? A great manipulator wouldn't seem so false.
This is a good point and it baffles me to be honest. I said "great" manipulator because it seems to be working so far. Great manipulators don't necessarily need to be great with everyone all the time. Or maybe she intentionally wants us to think she's a poor manipulator so that we trust her more? But that surely fails Occam's razor.
To answer other comments, I didn't get this impression solely by watching her on TV, it is corroborated by her history as a politician and recently leaked emails.
It could be that people support Clinton for reasons unrelated to her personal skills at manipulation.
I mean, even leaving aside all issues of substance, campaigns spend a lot of money hiring people specifically for their manipulation skills; even if it's all about manipulation, the candidate's skill isn't the only weapon in the campaign's arsenal.
Or she's gotten to where she is because she's effective at her job and the people working with her see this. It kinda reminds me of myself; I have zero charisma, but I impress the people I work with and I advance.
Psychopath is one particular slur that I've started ignoring. We've been taught it is equivalent to evil, or something like that, and it's used as a thought-terminating cliche. But, the basic traits of clinical psychopathy aren't really inherently evil.
The characteristics that define clinical psychopathy are many of the same that make effective leaders
Indeed - if all the voters were psychopaths then they would at least elect a candidate that served their interests instead of being totally persuaded by show.
I think most people who gain such a high office are much more psychopathic than average anyway.
There are a lot of good reasons to not vote for Hillary, but this has to be one of the dumbest. She's awkward and uncharismatic, so she must be a psychopath? How many actual psychopaths have you met, to compare her to? Have you ever seen her off camera? Do you not have any friends or family who aren't good at faking enthusiasm? Is disliking campaigning really the sign of a psychopath? Is "cold and calculated" not a good quality in a president? Aren't great manipulators usually extremely charismatic? Even supporters agree that Hillary is not very likeable or charismatic, is that really the sign of a great manipulator? How many years of psychological study have you spent calibrating your "internal psychopath detector"?
I was thinking the same thing, it's hard to judge this article without knowing exactly how much code duplication the author thinks is appropriate and in what circumstances.