News for hackers. Stuff that matters.
Re:G.E.R.T: Golang Embedded Run-Time by Numberwang on Tuesday October 31, 2017 @06:40AM (#15592165)
Why would you not use it for things like web services? That's one of the main goals of the language.
Re:G.E.R.T: Golang Embedded Run-Time by bsaul on Tuesday October 31, 2017 @07:11AM (#15592326)
User-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).

Re:G.E.R.T: Golang Embedded Run-Time by oelmekki on Tuesday October 31, 2017 @08:20AM (#15592651)
Actually, not having inheritance is what I love the most about go. When I write ruby code, I keep wondering "where does this method come from?" and have to grep my codebase.

"Composition over inheritance" is not a new trend, that was actually mentioned in first chapter of Gang of four's Design Patterns in 1995 [1]. In that regard, I feel like we mostly failed to ever use OOP properly (although, "fail" is probably too strong a word).

I'm actually annoyed that embedded types exist in go because it re-introduces the same problem (but I have an easy fix for that: I don't use them).

But really, what you're describing is a data structure problem. This can be solved without OOP, and structs are especially good at it.

[1] https://en.wikipedia.org/wiki/Design_Patterns#Introduction.2...

Re:G.E.R.T: Golang Embedded Run-Time by criddell on Tuesday October 31, 2017 @09:00AM (#15592865)
> When I write ruby code, I keep wondering "where does this method come from?" and have to grep my codebase.

Sounds like a shortcoming of your tools. I spend a lot of time in Visual Studio working on native C++ and even there I can ctrl-click on something and jump to the declaration or definition. I bet there's something even better for Ruby.

Re:G.E.R.T: Golang Embedded Run-Time by oelmekki on Tuesday October 31, 2017 @09:12AM (#15592941)
Yeah probably, I don't use any IDE feature for ruby code. It's still a problem that all methods available in current scope are not immediately obvious, though. And if you try to inspect available methods on an object in a REPL console using `#methods`, there usually are hundredth of them, especially when using rails (although to be fair, it's not all due to inheritance, there are also a lot coming for mixins). I suppose ruby IDEs have the same problem.

When I write go code, I have a lot of static analysis tools, but I'm still glad it's easy for me to know what I can call without stopping for inspection.

Re:G.E.R.T: Golang Embedded Run-Time by pcr0 on Tuesday October 31, 2017 @10:49AM (#15593617)
Unfortunately jumping to definitions in Ruby is often hit-or-miss since the language is very dynamic and idiomatic Ruby code often uses a fair amount of metaprogramming.
Re:G.E.R.T: Golang Embedded Run-Time by jrimbault on Tuesday October 31, 2017 @09:06AM (#15592899)
Even Sublime text can jump to definition for most languages, and it's no IDE.
Re:G.E.R.T: Golang Embedded Run-Time by jbarciauskas on Tuesday October 31, 2017 @08:53AM (#15592817)
Pattern matching interfaces also makes finding exactly what underlying object is being used in a given context difficult as well. With explicitly declared interfaces, you can easily find all implementations. With pattern matching it's a bit more complicated.
Re:G.E.R.T: Golang Embedded Run-Time by oelmekki on Tuesday October 31, 2017 @09:05AM (#15592897)
Yeah indeed, there's that too, although I'm glad we can't define methods on interfaces (using the interface as method receiver), so it quite reduces the complexity to just having to figure out the actual type, most often found just by inspecting the caller.
Re:G.E.R.T: Golang Embedded Run-Time by noselasd on Tuesday October 31, 2017 @07:21AM (#15592369)
Note 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.
Re:G.E.R.T: Golang Embedded Run-Time by bsaul on Tuesday October 31, 2017 @07:31AM (#15592418)
You 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.

Re:G.E.R.T: Golang Embedded Run-Time by jerf on Tuesday October 31, 2017 @09:06AM (#15592901)
"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.

Re:G.E.R.T: Golang Embedded Run-Time by bsaul on Tuesday October 31, 2017 @12:02PM (#15594223)
One 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.

Re:G.E.R.T: Golang Embedded Run-Time by lucian1900 on Tuesday October 31, 2017 @08:07AM (#15592588)
Table inheritance is merely an optimisation and rarely used.
Re:G.E.R.T: Golang Embedded Run-Time by bsaul on Tuesday October 31, 2017 @09:58AM (#15593244)
It'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).
Re:G.E.R.T: Golang Embedded Run-Time by pjmlp on Tuesday October 31, 2017 @10:02AM (#15593271)
All major RDMS offer OOP at table level.
Re:G.E.R.T: Golang Embedded Run-Time by red75prime on Tuesday October 31, 2017 @09:31AM (#15593066)
> An Electric Car, is a kind of Car, which is a kind of Vehicle

And then you have a hybrid car with a drilling attachment.

Re:G.E.R.T: Golang Embedded Run-Time by divan on Tuesday October 31, 2017 @08:08AM (#15592593)
Yes, Go is unsuitable for writing this: https://twitter.com/philwinkle/status/688441014160355328/pho...

But it perfectly allows you to model complex real-life processes, and in a way much better than traditional class-based OOP approach.

Re:G.E.R.T: Golang Embedded Run-Time by relyio on Tuesday October 31, 2017 @06:57AM (#15592254)
I'm confused as well. I believe OP meant front-end/templating.
Re:G.E.R.T: Golang Embedded Run-Time by dx034 on Tuesday October 31, 2017 @07:03AM (#15592281)
Even 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.