7 ms·
I was interested and intrigued, but then: // A dynamically sized array, like `std::vector`. var circles: Array(Circle) = ({.r = 1.0}, {.r = 2.0}); Y
by dleslie 4y ago
I was interested and intrigued, but then:
// A dynamically sized array, like `std::vector`.
var circles: Array(Circle) = ({.r = 1.0}, {.r = 2.0});
Yegads, they've put effort into ensuring API and ABI compatibility with C++, but they've gone and decided to change the meaning of nouns for basic types?!
Why, just why would introducing that obvious footgun be appealing? It raises the concern that the language is full of other arbitrary choices hiding dangerous footguns.
Edit:
Strangely, their test suite makes it look like Array is bounds checked and fixed size; there is no test for resizing:
https://github.com/carbon-language/carbon-lang/tree/trunk/explorer/testdata/array https://github.com/carbon-language/carbon-lang/tree/trunk/ex...
- mda 4y agoWhy is it an obvious footgun?
- dleslie 4y agoA developer familiar with C++ may believe it to be a fixed length container (perhaps with automatic bounds checking[0]) and treat it as such in memory/security/performance critical sections. 0: https://en.cppreference.com/w/cpp/container/array/at https://en.cppreference.com/w/cpp/container/array/at
- xigoi 4y agoAnd if they named it “vector”, a developer familiar with mathematics might believe it to be a vector.
- bmacho 4y agoWhich is not a footgun.
- Banana699 4y agoIt actually can be, mathematical vectors gaurantee for example that x+y == y+x for all x,y, but no such gaurantee can be ever made on the user-defined operator+, indeed you can't even gaurantee that it is defined to begin with, let alone in the manner prescribed by linear algebra.
- dleslie 4y agoThe language is designed to replace, by progression, C++ for C++ developers. Mathematicians are probably better suited to using R, Julia, Octave, or Wolfram.
- deleted 4y ago[deleted]
- yakubin 4y agoIt's std::vector that was weirdly named. In plenty of codebases "Vector", particularly gamedev and scientific, will mean the mathematical object with that name. Other languages don't need to replicate this mistake.
- dleslie 4y agoAnd yet it is the name used in C++ code for a variable length container of contiguously stored data.
- marssaxman 4y agoThis is intended to be a different language, is it not?
- dleslie 4y agoNot wholly different; it appears to be intended to interop with, and progressively replace C++ in existing projects.
- deleted 4y ago[deleted]
- cnity 4y agoTrue, though in OP's defense I don't know if I've ever seen a language refer to a growing list of entries as an "array".