4 ms·
Why would you not use it for things like web services? That's one of the main goals of the language.
by Numberwang 9y ago
Why would you not use it for things like web services? That's one of the main goals of the language.
- relyio 9y agoI'm confused as well. I believe OP meant front-end/templating.
- dx034 9y agoEven for templating it doesn't have to be a bad choice. I use it for templating and while it's certainly not the most powerful tool out there, it allows to quickly create site engines that perform very well (in case existing tools don't fit the use case). Not a fan of the built-in template syntax but there are luckily good (and faster) alternatives.
- bsaul 9y agoUser-facing applications or web services often deal with business logic. That is, logic that models real-life processes and entities, such as "Customer" or "Purchase". In order to model those kind of processes you often need powerful modelling abilities (such as subclassing, or generic programming), which go really lacks. I don't have a proof of that just my personal experience, but i'd say Object Oriented Programming is the de-facto standard in "enterprise" software for that reason. The reason go fits the "technical layer" best, is that technical layer deals with things closer to the machine, so the number of different types you need to manipulate is much lower, and is for the most part of the language (it doesn't go further than numbers and strings). All of this is just my personal opinion of course. EDIT: i know composition (which go provides) and subclassing provide the same possibilities in term of modeling, in theory. However in practice, not beeing able to say things like "An Electric Car, is a kind of Car, which is a kind of Vehicle" may make things cumbersome. So is not being able to simply create a function such as "sortByMileage" that applies to all kinds of Vehicle (and just that), but remain type safe. To sum-up : relying on interfaces and composition only is IMHO not as powerful as having interface, composition, inheritance and generics (which most "enterprise" language have).
- noselasd 9y agoNote that you can certainly express "An Electric Car, is a kind of Car, which is a kind of Vehicle" in Go by using interfaces - albeit such kinds of relations are rarely needed in business logic in my experience.
- bsaul 9y agoYou can indeed, but it makes you duplicate every implementation with its associated interface. As for this kind of relationship, i'd say it's fairly widespread. One proof is that even relationnal DB such as postgresql added table inheritance.
- lucian1900 9y agoTable inheritance is merely an optimisation and rarely used.
- bsaul 9y agoIt's an optimisation against the OOP vs relational mismatch, but the fact that it's here proves that OOP subclassing is being used quite often (otherwise there wouldn't be any need to optimise for it, at least not by adding core features to pg).
- jerf 9y ago"You can indeed, but it makes you duplicate every implementation with its associated interface." Only if A: composition can't do the job somehow and B: you can't use perfectly normal factoring tools to do the work. While I will tell you before anybody else complains that there is a non-zero percentage of the time that will happen, I will also tell you the average person who has never tried Go yet complains about its lack of generics anyhow will overestimate the amount of time that happens by a good order of magnitude or two.
- bsaul 9y agoOne remark (that may seem like a nitpick, but is in fact crucial) : composition doesn't say it "is a kind of", but rather "it has". It's the two most fundamental concept of any language : to be vs to have. Now it may or may not be just a philosophical difference and bring no practical consequences to a computer program, but at the minimum one can say it expresses two different concepts.