6 ms·
I NEED generics to do any quantitative code. I evaluated Go for a project, and completely ruled it out because of this. You're unable to write an algorithm for
by dangjc 8y ago
I NEED generics to do any quantitative code. I evaluated Go for a project, and completely ruled it out because of this. You're unable to write an algorithm for float 32s and 64s, scalars vs vectors vs matrices, etc.
There might be a bias in the commentary because the membership of the Go community has self selected to just be those for whom the current constraints are feasible.
- giovannibajo1 8y agoYou won't be able to do numeric stuff with these proposals as well. You would still be missing operator overloading and parameter of integer types, which are the basis of any generic numeric code.
- garfij 8y agoTrue about no operator overloading, but that's just syntactical sugar for functions. I believe you can get integer parameter types by using something like the `convertible` contract seen here https://go.googlesource.com/proposal/+/master/design/go2draft-contracts.md#passing-explicit-types-to-a-contract https://go.googlesource.com/proposal/+/master/design/go2draf... (unless I'm mistaking what you are saying)
- sanxiyn 8y agoI believe you are mistaking. C++ allows things like std::array<int, 3>, where 3 is parameter of integer types.
- majewsky 8y agoIf you need a generic algorithm where the possible types are very finite (e.g. just float32 and float64, or just NxM matrices for N,M=1,...,4) you might be able to `go generate` the concrete implementations from a text template.
- jacques_chester 8y agoText generation is fragile, error prone, does not play well with other type-based tooling, is difficult to upgrade, adds unnecessary busywork to the programmer's day. When Java's limited, half-crippled version of generics showed up, sourcecode generation died. Pretty much overnight. Why doesn't anyone do it? Because it's a terrible experience compared to having types.
- foldr 8y agoFortran does ok without generics.
- pjmlp 8y agohttp://www.msg.ucsf.edu/local/programs/IBM_Compilers/Fortran/html/pgs/lr60.htm http://www.msg.ucsf.edu/local/programs/IBM_Compilers/Fortran...
- foldr 8y ago>In Fortran 90, user-defined procedures can be placed in generic interface blocks. This allows the procedures to be referenced using the generic name of the block. I don't know Fortran, but I'm fairly sure that you just googled "fortran generics" and pasted the first result without checking it :)
- pjmlp 8y agoFortran got simplified generics in 2003, I pasted the wrong link by mistake. https://cug.org/5-publications/proceedings_attendee_lists/2005CD/S05_Proceedings/pages/Authors/Long-0517-1100/Long-0517-1100_paper.pdf https://cug.org/5-publications/proceedings_attendee_lists/20... https://software.intel.com/en-us/node/692037 https://software.intel.com/en-us/node/692037
- simias 8y agoSo does C but you don't expect the same things from a language from the 70's. I don't think C or Fortran would be very popular if they were released today.
- kown223 8y agocan't you just use different names, algF32, algF64, really? is this the end of the world? No wander we have npm packages isEven and isOdd, sometimes you need to get yours hands dirty.
- Shorel 8y agoAnd after that evaluation what did you use?