News for hackers. Stuff that matters.
Re:Building Web Apps in Go by echelon on Sunday March 27, 2016 @10:42PM (#11372429)
I'm so conflicted by Go. If I want to write a website quickly, I'd use Python. If I were concerned about performance, I have Java. I write my systems stuff in C++ (Rust now). Is there a compelling reason for me to even learn Go? Is it better than Java in some measurable way? Should I take the time to learn it? Honestly curious.
Re:Building Web Apps in Go by latch on Sunday March 27, 2016 @10:56PM (#11372472)
I wrote The Little Go book [free], my first Go blog post was in 2011, and a few of my Go libraries are used by people other than just me.

But Go's not my goto language. I'm a staunch believer in the productivity of dynamic languages. In my opinion, Go's less than stellar type system and weak reflection capabilities exasperate this gap, even moreso for most websites / apis (which deal with impedance mismatch at two boundaries).

But, to answer your question. Consider first that Go's very simple to pick up. So the investment is small. Second, where I differ from you is on your second point: Java. I dislike it. It's complicated and verbose and gets in my way. Rust and Go are both proof that we know how to build better languages now. So, when I need to share memory across multiple cores and performance is a concern, I switch to Go because it's fast and simple.

Re:Building Web Apps in Go by pron on Monday March 28, 2016 @02:22AM (#11372994)
Rust and Go are so completely different that I don't see how they're similar. OTOH, I write most of my code in Java, and a little bit in Go, and can hardly tell the difference between the two (their goals, design philosophy and levels of abstraction are nearly identical). I use Go for small command-line apps, where it shines, and Java for more serious server-side software, where I can't do without its unparalleled monitoring and tooling and more, uhm, grownup approach towards dependencies and project management (unless you work like Google). I know some people don't like Java, but I'm puzzled when the same people like Go (I can understand how you can like neither, or, like me, both). I agree that the onboarding experience for Go is better and more familiar to people coming over from Python (perhaps to the point that to people coming from Python, Java and Go appear very different), but if you're used to Java, Go feels like Java-lite. You use it when you need something more quick-and-dirty (or for command-line apps; Go is a much better fit than Java for those), but you stick with the "full" version for the serious stuff.
Re:Building Web Apps in Go by geodel on Monday March 28, 2016 @10:39AM (#11374491)
The only reason I will stick with Java is because business applications are in Java and there is no reason to use any other language.

> their goals, design philosophy and levels of abstraction are nearly identical

I think it could not be more different. Java APIs (including libs by Sun/IBM/Oracle) is a manifestation of more is less which is exactly opposite of Go.

> Java for more serious server-side software

The seriousness part is only because serious folks (the one who fund projects) prefer Java. I too think this is very important if not the most important part.

> unparalleled monitoring and tooling and more,

I too would need lot of monitoring and tooling if Oracle/OpenJDK GC keeps crapping out for just 10-20GB heaps which is currently the case for us.

Re:Building Web Apps in Go by pron on Wednesday March 30, 2016 @06:12AM (#11388199)
> Java APIs (including libs by Sun/IBM/Oracle) is a manifestation of more is less which is exactly opposite of Go.

For example?

> The seriousness part is only because serious folks (the one who fund projects) prefer Java.

I disagree. There are plenty of design decisions in Go that make it less optimal for very large projects (e.g. dependencies, error handling, generics), but most of all lack of hackability. Go is one of the least hackable languages I've ever encountered, i.e. the only escape-hatch you have when you realize, 5 years into the project, that you need to circumvent some runtime semantics are either source-code instrumentation or hacking on the runtime itself.

> Oracle/OpenJDK GC keeps crapping out for just 10-20GB heaps which is currently the case for us.

There is no way Go's GC wouldn't crap out on you sooner (except maybe in the circumstances that are now addressed as part of Valhalla).

Having said that, I think Go is great, and is a natural fit for anyone who likes the Java philosophy (which is also the Go philosophy)[1]. Some design decisions and some implementation circumstances just make it less suitable for really big stuff.

[1]: Namely, reading comes before writing, no too-clever tricks, and no cutting-edge PL ideas; a "blue collar" language, as Gosling referred to it.

Re:Building Web Apps in Go by tome on Thursday March 31, 2016 @04:01AM (#11395658)
> I use Go for small command-line apps, where it shines

I'm curious. Is there empirical evidence proving that Go is better than Java for small command-line apps, or did you just use your personal judgement to reach this conclusion?

Re:Building Web Apps in Go by pron on Thursday March 31, 2016 @01:16PM (#11398798)
> Is there empirical evidence proving that Go is better than Java for small command-line apps

Sure. It doesn't require warmup, it's a little easier to deploy as a standalone executable, and performance is comparable to compiled Java code in programs of this size (you can easily confirm all three claims); those are pretty much the relevant requirements from many command line programs. It's not a property of the language but of its implementation choices (AOT compilation, statically linked runtime), which match the requirements of those kinds of applications better.

Re:Building Web Apps in Go by jonesb6 on Sunday March 27, 2016 @11:35PM (#11372585)
I actually think Go's simplicity is a weakness because it will only get you so far. Take web development for example, all the tutorials show json.Unmarshall, but this one stackoverflow post says I should use json.Decode. Oh shoot now I'm having all sorts of problems because I don't really understand json.Decode.

Furthermore I think most people reach for Golang in the beginning because they want performance. However I've found it incredibly easy to write unperformant Go.

I think Golang will ultimately be a very important stepping stone in language development in terms of concurrency, type systems, standard libraries, deployability, and many other categories. I think a lot of important programs will be written in it. And ultimately I look forward to how future languages draw from it.

Re:Building Web Apps in Go by shitgoose on Monday March 28, 2016 @11:05PM (#11379219)
"I actually think Go's simplicity is a weakness because it will only get you so far."

Some may argue that Go's simplicity is a strength. Adding moving parts doesn't always help.

Re:Building Web Apps in Go by masklinn on Monday March 28, 2016 @06:52AM (#11373559)
> I think Golang will ultimately be a very important stepping stone in language development in terms of concurrency, type systems

"stepping stone" usually implies progress and Golang was a regression on both fronts, and while its deployment story is ok that's in no small part because it just opts to statically link everything by default, which the field has been going back and forth on basically since the beginning.

Re:Building Web Apps in Go by jerf on Monday March 28, 2016 @09:01AM (#11373974)
"Take web development for example, all the tutorials show json.Unmarshall, but this one stackoverflow post says I should use json.Decode."

Plenty of JSON libraries in plenty of languages have both a function to decode JSON and an object that allows you to decode JSON with some settings. That's not really a Go-specific issue.

Re:Building Web Apps in Go by wfsfw4w44 on Monday March 28, 2016 @08:48AM (#11373913)
Your issue here (obviously), is going to stack overflow for advice.
Re:Building Web Apps in Go by cel1ne on Monday March 28, 2016 @04:57AM (#11373306)
The days of Java being verbose are over with Lambdas and Method References. I don't know what you mean by "getting in the way".

If you have time to spare read this: http://blog.paralleluniverse.co/2014/05/01/modern-java/

Re:Building Web Apps in Go by shitgoose on Monday March 28, 2016 @11:12PM (#11379244)
he may have meant this:

https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...

One just can't write this shit in Go. The language itself precludes it.

Re:Building Web Apps in Go by pron on Tuesday March 29, 2016 @05:57AM (#11380464)
> The language itself precludes it.

It really doesn't, and you could write the exact same thing. Java code doesn't look like that, either (certainly not modern code).

Re:Building Web Apps in Go by twic on Monday March 28, 2016 @09:18AM (#11374048)
In particular, it's preposterous to call Java verbose in comparison with Go when Go has the error handling that it does.
Re:Building Web Apps in Go by bogomipz on Sunday March 27, 2016 @11:24PM (#11372547)
Hi, could you elaborate on you comment about Go's "less than stellar type system"?
Re:Building Web Apps in Go by latch on Sunday March 27, 2016 @11:55PM (#11372646)
Lack of generics (stick, meet dead horse) is at the forefront.

Lack of very basic functions (map, filter, reduce) against slices.

map[string]interface{} is pain to work with (one of the moderately popular libraries I mentioned helps: https://github.com/karlseguin/typed)

Lack of immutability.

I don't want to get into errors vs exceptions, but I've never heard a pro-errors argument that wasn't hand waving. I think the decision makes sense given Go's genesis (system programming), but given how Go's actually being used, it's a step backwards.

Re:Building Web Apps in Go by staticint on Monday March 28, 2016 @12:12AM (#11372691)
What I struggle to understand is: If that functionality is considered useful or even impeding the development process for those developing in Go, why has nobody forked the language to add them?

Many of the points you mention are fairly low hanging fruit for inclusion if you are willing to accept the tradeoffs that official Go maintainers are not willing to.

Re:Building Web Apps in Go by brandur on Monday March 28, 2016 @12:27AM (#11372734)
I think the trouble there is just that many other modern languages haven't taken the extreme stance on typing that Go has. It's much easier to learn say, Rust or Scala, than it is to fork and maintain a branch of Go, and there's certainly nothing so special or attractive about Go to tip the balance in the latter's favor.
Re:Building Web Apps in Go by staticint on Monday March 28, 2016 @12:47AM (#11372778)
The issue with that is that anyone invested in Rust or Scala have no reason to want a better type system in Go. Fixing Go is as important to them as fixing COBOL, and I don't see HN full of threads on what needs to change in COBOL.

What we have here is people who are already heavily invested in Go to the point where its type system is a real problem for them, yet they do not want to fix the problems, even in light of the relative ease at which at least some the problems can be solved (again, if you are willing to accept the tradeoffs).

Re:Building Web Apps in Go by pjmlp on Monday March 28, 2016 @06:32AM (#11373508)
Check the gonuts archives to see how welcoming the community is to such ideas.
Re:Building Web Apps in Go by brandur on Sunday April 10, 2016 @08:02PM (#11468823)
Yes, exactly.

You could fork Go and add generics support, but you'd be maintaining that fork forever. The Go core team would never allow it to go back upstream.

Re:Building Web Apps in Go by geodel on Monday March 28, 2016 @01:01PM (#11375509)
It is rather surprising if not outright shocking that experienced developer get heavily invested in a language when other mature/ better alternatives are there.
Re:Building Web Apps in Go by airless_bar on Monday March 28, 2016 @05:39AM (#11373390)
> What I struggle to understand is: If that functionality is considered useful or even impeding the development process for those developing in Go, why has nobody forked the language to add them?

The group of people who are able to fork, change and maintain their own Go variant are usually not the people who would ever consider using Go in the first place.

Have a look how long it took PHP to get an AST (instead of the broken mess of reading&executing). Those who are able aren't those who would ever deal with PHP.

Re:Building Web Apps in Go by e12e on Monday March 28, 2016 @03:18AM (#11373113)
I've sometimes wondered a bit about this myself. But consider what you'd end up with if you wanted to keep most of go's benefits, but add on such bits. And consider that you could just use Ada, Nim or OCaml. Or maybe Rust (I really like Rust, I'm not sure how much overlap there is in any subjective list of "Go the good parts" and "Rust the good parts" though).

I think some of the best parts of Go is the central model: "go get", "go fmt" along with the standard library - if you fork, the burden falls on the fork keep all that stuff working in a sensible way too.

Re:Building Web Apps in Go by ngrilly on Monday March 28, 2016 @03:24PM (#11376648)
Go' success is not a mere coincidence:

- OCaml is great but parallelism is still limited by its "Global Interpreter Lock" (like Python or Ruby).

- Rust is great but ownership/borrowing is not for everyone and people sometimes prefer relying on a good garbage collector.

- Nim is great but it's a "small" project compared to Go and most people prefer relying on a large ecosystem like the one offered by Go.

- Ada was a major milestone in the history of programming languages, but it's considered by most as an "old" language, compared to Go/Rust/OCaml/Haskell/Scala/etc.

Re:Building Web Apps in Go by bogomipz on Monday March 28, 2016 @12:06AM (#11372676)
Thanks. Right, generics is a big one. But isn't Go actually being used for system programming? At least that what I think of when I think of Golang. Maybe the scales have tipped and writing api/microservices is the larger use case now?
Re:Building Web Apps in Go by latch on Monday March 28, 2016 @12:18AM (#11372709)
I don't know. All I know is this [possibly dated] quote from Rob Pike:

"Although we expected C++ programmers to see Go as an alternative, instead most Go programmers come from languages like Python and Ruby. Very few come from C++"

Maybe Python and Ruby programmers are adopting Go to do system programming, but that isn't my impression.

Re:Building Web Apps in Go by sgk284 on Monday March 28, 2016 @12:47AM (#11372779)
While this may not be a popular opinion, I find Go's type system to mainly benefit the compiler in optimization and be of minimal benefit to the safety or correctness of the program.

Any non-trivial Go project will have interface{} sprinkled all over [1], which effectively gives you the guarantees of a dynamic language with the syntactic overhead of a typed language. Truly the worst of both worlds. While I realize it's a tired argument, Go desperately needs generics in some form or another. It would remove most criticism from the language while substantially improving the correctness of programs.

[1] Here's an example with an LRU cache. Just search for interface{} : https://github.com/hashicorp/golang-lru/blob/master/simplelr...

Re:Building Web Apps in Go by geodel on Monday March 28, 2016 @10:19AM (#11374363)
> It would remove most criticism from the language while substantially improving the correctness of programs.

You seem to assume that people who do not like generics complexity will not complain then.

Re:Building Web Apps in Go by echlebek on Monday March 28, 2016 @12:25AM (#11372725)
Go has concurrency features that the other languages you mentioned don't have. The select construct is a very nice language feature and allows a surprising amount of power.

Go's compiler is very fast, which saves a lot of time in aggregate.

Go exhibits good design in many areas, including the core language, the compiler toolchain, and the standard library. You can write a complete server-side web application using only the standard library, and it won't be terrible.

Go is generally easier to learn than C++ or Java, and requires fewer concepts and fewer steps to produce a working program. A person who has written programs in Java or C can probably learn Go in about a day. Go's spec can be read in one or two sittings. The way to write "good" code in Go is usually obvious.

I've spoken to some detractors of Go and can understand where they're coming from. Erlang and Elixir users tend to not find Go's concurrency features compelling. Functional programmers will not find that Go provides much in the way of expressive power. Java programmers have expressed concerns about the Go garbage collector, although I think a lot of those concerns are now at rest.

For those that enjoy the set of tradeoffs that Go makes, it's a nice way to engineer software.

edit: typo

Re:Building Web Apps in Go by hordeallergy on Monday March 28, 2016 @08:21AM (#11373801)
A person who has written programs in Java or C can probably learn Go in about a day.

I really wish people would stop saying this. There is more to Go than just the syntax. I'm a Go dev on a team of php and Java devs, and just the opinionated philosophy of Go is hard to get across to them. They bypass the Go interview only to create the mess interviews intend to prevent. They are junior/mid devs again, except that because everyone keeps saying Go can be learnt in a day they think they've already mastered it. Go is easy to get started, but there is somewhat more than a day's worth of learning, I see this daily.

Re:Building Web Apps in Go by wiremine on Monday March 28, 2016 @09:16AM (#11374043)
I don't think a day is reasonable either, but 2 weeks is. You get to a point where you just sort of run out of concepts to learn... it's a weird feeling at first, to be honest with you.
Re:Building Web Apps in Go by logingone on Monday March 28, 2016 @11:21AM (#11374774)
I don't agree. After two weeks people are still unaware of lint, vet, -race, haven't even begun exploring how error values can be managed, ... Interviewees with 6 months of Go are regularly rejected - how is that possible if it's so quick and easy to learn?
Re:Building Web Apps in Go by Rapzid on Monday March 28, 2016 @12:15PM (#11375120)
Most interviewees are rejected anyway.

If they have the fundamentals down and are creating a "mess" that sounds like a failure of the existing project leads. A little code review and direction goes a long way.. It doesn't take long to run lint, vet, -race by someone. Establishing best practices and engineering principles for the project/team can help tremendously with on-boarding too.

Re:Building Web Apps in Go by mangeletti on Monday March 28, 2016 @11:09AM (#11374689)
What about for a Python developer with no experience in static/compiled languages?
Re:Building Web Apps in Go by tkinom on Monday March 28, 2016 @01:22PM (#11375682)
I did a simple port of Python program to go a while back.

The python program is web backend for JQuery+html Single page web app for front end. It built its own database in the backend on top of SQlite.

It is not that hard to part a few features over, ~1-2 weeks including learning time. There are lot of examples on how to do most of typical web programs with REST/AJAX for golang.

The REST/JSON in golang is a lot of verbose than python. Go need to define all JSON fields via marshalling which is none-trivial amount of boiler place template code code. It does very strict type check on all incoming JSON structures. I have full functional regression test coverage from my frontend code to the all the python REST APIs /JSON structures. The more stricter type check in REST/JSON in the Golang requires a lot of work while provide little value for me.

The error handling the go compare to pyhon is an "acquire taste". (I have to acquire that taste yet.)

I was used to the code style of raise/catch exceptions. Python provides extremely good stack trace feedbacks on those error cases. Recover from exceptions in python are trivial.

My python code needs to build/handle 10-25 GBytes database. I spent non-trivial amount of time in the low level API of python/C code to optimized/debug memory related issue at that scale. All the issues in python backend were worked out already. The backend python all used very little memory in building and using 20+GB of DB.

For Golang, I can not get pass that barrier. Building a DB of about 2-4GB cause the golang app to completely slow down. (Most likely GC kick in, memory hogs on system level.) I spent a few more weeks on golang and can't get enough info to fixed that issue and put that porting from python->Golang project on the shelf. In python I can force a GC operations in certain point of my app to see the memory usage clearly drop down. I can't find a way to do that in golang. There were documented API in golang that supposes to do that. But it just doesn't works for me.

That's > 1 years ago.

Re:Building Web Apps in Go by pjmlp on Monday March 28, 2016 @06:08AM (#11373459)
Java programmers also know a thing or two about java.util.concurrent, parallel streams, futures and Quasar.

The only thing Go concurrency has over them is that it is easier to start with, but it isn't easier to use any other pattern, because Go doesn't allow library code to be first class in the type system.

Re:Building Web Apps in Go by NateDad on Monday March 28, 2016 @09:42AM (#11374172)
Well, the thing about Go concurrency is that it has been with the language since the beginning. How much library code is compatible with concurrent or streams or futures or Quasar? If you choose one over the others, are you limiting yourself to only libraries compatible with others that made the same choice as you? How much of the standard library is compatible with each of those?

The same thing goes for value types. In Go, everything uses value types. The standard library is littered with them. Will it be the same for Java? It seems unlikely, given that they have to keep backwards compatibility.

Granted, this is all from the point of view of an outsider who only dabbled in Java, so I may be way off base.

Re:Building Web Apps in Go by pjmlp on Monday March 28, 2016 @12:09PM (#11375081)
The java.util.concurrent was introduced with Java 1.5, so 2004.

And there were alternatives available before for Java 1.4.

Which means most Java libraries had lots of time to adapt to it.

Also threads and concurrent queues are there since the early days.

Java already has a kind of pseudo-value types, but it is JVM specific. Some JIT and AOT compilers do convert final classes with only accessors (think Point) to value types.

But yeah, it is a JDK vendor specific optimization that one cannot control.

Likewise you cannot control if a value type in Go gets stack or heap allocated, if I remember correctly. Hence why the compiler options to debug how the compiler decided to do it.

Java value types will take time to get adopted surely, but in many type of applications it doesn't really matter that much.

The use cases driving value type's adoption are related to HPC and HPT, many of which are trying to move away from C++ into Java, but still find themselves have to make use of com.sun.unsafe for that last mile.

At least as presented by IBM and Azul on their talks about their approaches to value types in Java.

Re:Building Web Apps in Go by brightball on Monday March 28, 2016 @09:15AM (#11374034)
Go also has much lower RAM overhead with that concurrency.
Re:Building Web Apps in Go by pjmlp on Monday March 28, 2016 @09:31AM (#11374119)
Assuming a JIT/AOT compiler that doesn't do escape analysis, which varies across JVM vendors.

Also Go's advantage in using value types will vanish when Java finally gets to have them, although we still need to wait for Java 10 for them, while Go is available now. So Go does have a few more years to gain developer mindshare.

Still Java isn't the only game in town, and there are other alternatives with GC, value types, more expressive type systems and battle tested concurrency frameworks.

Re:Building Web Apps in Go by geodel on Monday March 28, 2016 @10:25AM (#11374394)
> It would remove most criticism from the language while substantially improving the correctness of programs.

How the mighty have fallen. A language with more than decade over Go and billions in investment by top tech companies and literal monopoly over enterprise usage need to even think of user share of a marginal language.

Re:Building Web Apps in Go by pjmlp on Monday March 28, 2016 @10:52AM (#11374578)
Except you are off base giving too much value to Go.

What is driving value types in Java is HPC and HPT companies in places like stock exchanges and biology research that want to move away from C++ into JVM land, but still need to keep some C++ around due to value types or make use of com.sun.unsafe tricks.

Nothing to do with Go.

Re:Building Web Apps in Go by dimgl on Monday March 28, 2016 @01:30PM (#11375733)
Why not just use Elixir if you need concurrency?
Re:Building Web Apps in Go by NateDad on Monday March 28, 2016 @12:18AM (#11372708)
Go uses a lot less memory than Java, according to most comparisons. There's a lot of work going on in the cloud space with Go applications (docker, kubernetes, etc), so there's a lot of new libraries for networked webservers getting written.

But mostly, you may find you just enjoy writing Go more than Java. It writes a lot like python... I switched from mainly writing C# to almost exclusively writing Go, and whoo boy, I'm not going back. No more huge class hierarchies, no more "everything has to be in a class"... no more "anything I call may throw and jump me out of my function in the middle and I have no idea if it will or not".

There's just a lot of niceties of writing Go that don't exist in Java. Sure, there's a ton you can do in Java that you can't do in Go, but once you stop focusing on what Go can't do, you realize, it still can do pretty much whatever you want.

Re:Building Web Apps in Go by vvanders on Monday March 28, 2016 @12:38AM (#11372755)
Java memory usage is not really that high if a bar to beat.

Dropbox just rewrote parts of their Go infra into Rust explicitly because of the memory savings they needed.

Re:Building Web Apps in Go by ngrilly on Monday March 28, 2016 @03:40PM (#11376759)
Yes, but the rewrite would have happened ever sooner if the original code had been written in Java instead of Go. The Dropbox case is really very specific and very low-level.
Re:Building Web Apps in Go by NateDad on Monday March 28, 2016 @09:11AM (#11374026)
Well.. yes, exactly. The question was "why should I learn Go if I know Java?" That's a pretty good reason.
Re:Building Web Apps in Go by golergka on Monday March 28, 2016 @02:53AM (#11373070)
Anything you call in go can panic, what's the difference?
Re:Building Web Apps in Go by danieldk on Monday March 28, 2016 @03:06AM (#11373092)
And nearly anything you can call in any language could theoretically exit(3). The difference is that exceptions are a normal control structure in C#, Java, or even C++, while the use of panic should be exceptional. It's not considered the regular way to report an error.

Of course, if you have checked exceptions (which are for some unfathomable reason considered bad nowadays), nothing just throws an exception. Moreover, you don't know for sure whether a Go library correctly handles errors, because it's so easy to ignore them.

Re:Building Web Apps in Go by NateDad on Monday March 28, 2016 @09:34AM (#11374135)
The problem with checked exceptions is that your code trends towards having every method marked as 'throws Exception' (or whatever your application's top level exception is). Any time a low level method changes to throw a new exception, every method that calls it has to update their exception spec... or they need to have their catch clauses updated to catch the additional exception and either deal with it - unlikely - or wrap it and rethrow it as one of their other expected exceptions.... or they're already catching Exception, which is also bad.

At my last job, very few methods in the application ended up throwing a specific list of exceptions, except the most leaf-ward modules. Anything anywhere near the application logic just threw our top level generic exception, because there was too much below them that could throw a variety of exceptions, and there generally was nothing the middle-tier code could do about it if they failed.

It's really not that easy to ignore errors in Go in practice... and you might as well worry that a library correctly handles the result of string.Split() incorrectly. Either one is a bug. Hopefully your tests would find either one, and there are tools to detect errors you didn't handle.

Re:Building Web Apps in Go by danieldk on Monday March 28, 2016 @10:03AM (#11374299)
Any time a low level method changes to throw a new exception,

You don't do that in API-stable code, period. If you are working with API-unstable code - that's the point of static typing. The code won't compile because the intention is exactly to signal that something has changed.

If you change the return type of a low-level Go function, you will have to modify its callers as well.

Anything anywhere near the application logic just threw our top level generic exception,

Bad codebase = bad. Sure. I never encountered that problem in the Java codebases I worked on at various employers. (And I'd be quite happy to complain about Java, I don't like it.)

It's really not that easy to ignore errors in Go in practice...

It is. The compiler will not emit a warning when you ignore the return value of a function/method. Here:

    fmt.Println("Hello world")
I have just ignored an error. The compiler is happy. There are quite some Go packages in the wild that do not deal with errors when they need to.
Re:Building Web Apps in Go by grey-area on Monday March 28, 2016 @03:15AM (#11373109)
Panics are very rare in go code, particularly in libraries, they are not used for error control but for truly exceptional situations.
Re:Building Web Apps in Go by NateDad on Monday March 28, 2016 @09:17AM (#11374045)
As others have said, it is highly discouraged by the community to use panics as control flow. Generally a panic means there's a serious bug somewhere - not just that unexpected stuff happened, but the programmer actively is doing something wrong.

Any library that panics for reasons other than a programmer bug would never be used by the community. I read a lot of Go code and look at a lot of Go libraries, and I've never seen one that said it purposely panics in my 3.5 years of writing Go.

Compared to Java, C#, Python, C++ etc... where declaring your code panics is a perfectly normal and expected way to report errors.

Re:Building Web Apps in Go by wfsfw4w44 on Monday March 28, 2016 @09:00AM (#11373967)
the most obvious difference is a go-panic and exceptions are used in different scenarios.

it's considered bad practice in go library code to panic(), while it is considered normal error handling to throw an exception in java.

also note that you can catch a panic in go, and use it as some kind of exceptions if you really must.

https://github.com/golang/go/wiki/PanicAndRecover#usage-in-a...

Re:Building Web Apps in Go by brightball on Sunday March 27, 2016 @10:52PM (#11372460)
It's a language that when compared to other languages it's the 2nd best at so many features that it gets the title of the most well balanced language.

For the most part, it seems to have gained traction in the Ruby/Python/PHP world as a backend optimization language. IMHO that's where it currently fits best for most people.

Re:Building Web Apps in Go by TheSwordsman on Sunday March 27, 2016 @10:46PM (#11372439)
I wouldn't personally compare it to Java, having written it for some time. I too am not too fond of writing web apps in Go. It's doable, and you can do things to make it easier, but it can be painful. It took me some time to get in to the groove.

I see it being used for system tools, to some degree, because it requires no runtime at all (static binary). It also seems to be pretty popular for different newer data stores. Again, if it's pure Go it'll run anywhere... so it makes development (and portability) much easier.

I like its concurrency model, to a point. That said, I hope they really improve some things about in Go 2 (like working with channels and goroutines). I'm not sure when that will be.

I use Go for a lot of things, most of which are command line applications. Whether it be interfacing with some sort of REST API, taking actions on the local system, or some sort of network client for devices on my LAN. It works well for quite a few cases.

It seems to fit well with my mental model quite often, so I use it. And it's a simple language, so it was easy to get started with it. At the end of the day, it's a tool like many others. I think it's up to the creator to choose the tool that feels best to them.

Re:Building Web Apps in Go by e12e on Monday March 28, 2016 @03:32AM (#11373135)
> I see it being used for system tools, to some degree, because it requires no runtime at all (static binary).

This is something I haven't seen discussed much recently.

Do people generally think static linking is a good idea for things other than self-contained system-level daemons? (Where that daemon and supporting libraries might be the only thing you deploy to a server/vm/container)?

As I recently read in a (rather poor microbenchmark article) [1]: "The C assembly code I got with the following command is just 40 lines long. (...) The Go assembly code is 161.021 lines long which must be due to the static linking of Go.".

As everyone (should) know(s) any kind of language that lets you write a useful program in a page or two of code, will include a runtime of some sort (or be depressingly machine- and kernel-specific assembly code, and probably slower than anything a modern half-decent compiler produce). But I don't see a lot of discussion on how you make sure all your go daemons get updated with a new TLS/SSL/GZIP/PNG/XML-library when there's new serious bug found.

[1] Just included for reference, I don't really mean to pick on the author, but it's rather standard fare in the "quickly do a microbenchark; prove only that I'm wrong"-vein:

http://karlheinzniebuhr.github.io/en/2015/09/28/C-vs-Go-vs-p...

Re:Building Web Apps in Go by TheSwordsman on Monday March 28, 2016 @04:06AM (#11373208)
>But I don't see a lot of discussion on how you make sure all your go daemons get updated with a new TLS/SSL/GZIP/PNG/XML-library when there's new serious bug found.

Yeah, I think it may be because it's situation dependent. For me, it always consisted of recompile all binaries and deploy them. And even then, I'm not sure people would enjoy a blog post just telling you to recompile all the things. It's not very sexy, honestly.

In my situation, it wasn't that big of a pain to do so. A lot of these libraries are within stdlib, so a security bug would incur a new release of Go. So an update should be pretty easy.

If's an external library (i.e., one picked up from GitHub for example), it's pretty much the same. Get new source, recompile binary with patched library, ship to all the things.

There are tradeoffs, absolutely. The alternative would be to write something in an interpreted language. That means we need to push a runtime environment up to the node, and that may include managing any libraries that are needed (think Rubygems). Managing these kinds of setups can be a pain, especially if a node has multiple projects with different dependencies. I found that shipping a single binary was often easier for me.

But it goes back to it being an item in the toolbox, depends on what you need and how your systems are built.

Re:Building Web Apps in Go by calgoo on Monday March 28, 2016 @08:31AM (#11373833)
Well, i personally really like the Static linking, but that is because of the limitations on our network. To get onto a server, I have to use a VDI session -> Citrix -> SSH Jump host -> ssh jump host -> server.

The servers dont have internet access and to get files onto them i have to do the same story as above (using sftp). So having 1 static binary that i copy over without having to worry about the dependencies is great.

Re:Building Web Apps in Go by wfsfw4w44 on Monday March 28, 2016 @09:07AM (#11373997)
go is somewhat special in what is shipped with its system libs:

"TLS/SSL/GZIP/PNG/XML"

all of these are part of the go standard libs, and gets regularry updated with the language.

tls and ssl: https://golang.org/pkg/crypto/tls/ gzip: https://golang.org/pkg/compress/gzip/ png: https://golang.org/pkg/image/png/ xml: https://golang.org/pkg/encoding/xml/

since golang also has built in support for fuzzing in the toolchain, the standard parts are quite battle tested already.

if you study their sourcecode you will also find Benchmark functions, that you can use to benchmark the implementations (go test -bench ./...)

Re:Building Web Apps in Go by tomphoolery on Sunday March 27, 2016 @11:08PM (#11372509)
It's not better than any of the languages you described, but it's certainly different. Go was created in order to build large-scale distributed systems (like the largest search engine in the world), and the problems that Go makes easier to solve may not be the ones that you have. Unlike Rust, Go wasn't created to replace an existing language...it was created to replace an existing way of going about doing things. Unlike Python, Go wasn't created to make code easier to read in general, it was created to make incredibly complex code less ugly.

So no, you shouldn't learn Go unless Go solves the problems that you need to solve. That said, as others have mentioned it's a pretty simple language and I found it quite easy to pick up and start writing programs in.

Re:Building Web Apps in Go by twic on Monday March 28, 2016 @09:16AM (#11374041)
If you (and your team, if applicable) already know that set of languages, then there's no reason for you to learn Go.

Indeed, if you already know Java, the only reason to learn Go would be if you had a burning need to produce self-contained statically linked binaries. For example, at my company, we have a habit of producing command-line clients for our services, and Go is a good choice for that.

Go has been most useful for people who know a dynamic language like Ruby or Python, but who are encountering problems where they need more performance, better concurrency, or stronger static guarantees. Go improves over dynamic languages in those respects, and it's pretty easy to learn, so it's a great addition to their toolbox.

Re:Building Web Apps in Go by ngrilly on Monday March 28, 2016 @03:38PM (#11376745)
> If you (and your team, if applicable) already know that set of languages, then there's no reason for you to learn Go.

Google is the perfect counter-example to your argument. C++, Java and Python were the 3 main programming languages in use at Google, and despite that, they designed Go and started using it instead of C++/Java/Python in some projects.

Go can be used instead of C++ when you need and can tolerate a garbage collector, and you don't need things like a custom memory allocator.

Go can be used instead of Java when you need a native executable, statically linked (like you wrote), when you need a better control over memory layout (especially to reduce pressure on the garbage collector), and when you need async IO without callbacks/promises/futures.

Re:Building Web Apps in Go by FordPrefectAO on Monday March 28, 2016 @10:44PM (#11379153)
Well one reason [1] Google made go was because of how many junior engineers they had who couldn't be trusted with java/python/etc. Instead of letting them struggle, they created go as a more simple and easy to use language.

[1]http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2014/Fro...

Re:Building Web Apps in Go by ihsw on Sunday March 27, 2016 @10:54PM (#11372466)
Some people think Java is icky and other people think the JVM brings too much baggage for their comfort.

Warranted or not, it usually fills the space where fast microservices are necessary.

Personally I think Go's closest competitor is Scala.

Coming from Python, Ruby, and TypeScript -- Go is a fair bit more verbose, and Java takes that a step further. So Go is a nice go-between from scripted environments to compiled.

Re:Building Web Apps in Go by jpliska on Monday March 28, 2016 @01:42AM (#11372905)
Have you seen kotlin? Its a cross between java, python and scala for the JVM (and JS - with wrinkles)
Re:Building Web Apps in Go by xaduha on Monday March 28, 2016 @03:45AM (#11373156)
Everyone should seriously consider using Kotlin, it's here to stay.
Re:Building Web Apps in Go by minionslave on Monday March 28, 2016 @10:42AM (#11374505)
The only thing I hate it the extra symbols. How to they justify using : val companyName: String = "JetBrains". Instead of string companyName = "Jetbrains" ?
Re:Building Web Apps in Go by stephenboyd on Sunday March 27, 2016 @10:52PM (#11372461)
It's good for when you want to write something quickly and you're also concerned about performance. It's a deliberately simple language, it's designed so the most naive simple choice is often the best choice, and you can learn enough in one day to start developing productively.

I've never tried to make a whole web app with it, but it's great for making microservices.

Re:Building Web Apps in Go by d1ffuz0r on Sunday March 27, 2016 @11:31PM (#11372572)
Most of the time database is the slowest component of any website
Re:Building Web Apps in Go by collyw on Monday March 28, 2016 @11:09AM (#11374684)
Don't know how this got downvoted as it seems to be the case for most applications I have worked on.
Re:Building Web Apps in Go by biomcgary on Sunday March 27, 2016 @10:58PM (#11372477)
Should you take the time to learn it? Yes. It is a very small language, so learning will not take long. Go is a nice tradeoff in development time and performance that is only slightly slower to write than Python (for web servers) but comes with good performance out of the box.
Re:Building Web Apps in Go by viach on Sunday March 27, 2016 @10:54PM (#11372465)
Go is less verbose than Java and more statically typed than Python, here you go.
Re:Building Web Apps in Go by dominotw on Sunday March 27, 2016 @11:04PM (#11372501)
> Is there a compelling reason for me to even learn Go?

Yea if you are doing any devops and want to contribute to or use consul/docker/swarm/kubernetes/terraform....

curious if rust has a hit project like one of those above.

Re:Building Web Apps in Go by tomphoolery on Sunday March 27, 2016 @11:09PM (#11372511)
Servo? :-) https://github.com/servo/servo

I mean, eventually...hopefully...

Re:Building Web Apps in Go by coalescence on Monday March 28, 2016 @09:03AM (#11373983)
That's the browser engine, for webapps, look here - http://arewewebyet.com/
Re:Building Web Apps in Go by steveklabnik on Monday March 28, 2016 @10:42AM (#11374506)
Please use http://www.arewewebyet.org/ , the .com has been abandoned.
Re:Building Web Apps in Go by nkozyra on Sunday March 27, 2016 @10:46PM (#11372435)
At least for the Web, Go will match the conciseness of Python with the performance (almost) of Java. It takes a lot of cajoling to make Python a great backend for the Web.

Since confounding downvotes, a tldr: closer to Python than Java.

Re:Building Web Apps in Go by TheSwordsman on Sunday March 27, 2016 @10:48PM (#11372443)
I'm not sure I fully agree it'll match the conciseness of Python. Go will be more verbose, for sure.

If you start having to Marshal/Unmarshal JSON, it'll get pretty annoying pretty quick depending on the JSON format.

Re:Building Web Apps in Go by nkozyra on Sunday March 27, 2016 @10:50PM (#11372452)
Go's JSON marshaling can be heavy if you tie it to a strict struct versus, say, an interface. You can make it light, but yes, sometimes some reflection is necessary to utilize that data.

For most web applications, JSON in or out is of a known schema, so this generally impacts other servers moreso than web applications.

Re:Building Web Apps in Go by TheSwordsman on Sunday March 27, 2016 @10:55PM (#11372468)
Oh absolutely.

I guess I was trying to call out that, depending on the API you are supporting, it can get hairy. If you are designing it from scratch, when starting the Go project, you can structure your JSON in a way that's easy to work with.

If you're coming in to something that was easy to use in a language like Python, it may not be that easy in Go.

Re:Building Web Apps in Go by nkozyra on Sunday March 27, 2016 @11:02PM (#11372495)
I guess my point is it will be more concise than Java, certainly closer to Python.
Re:Building Web Apps in Go by stephenboyd on Sunday March 27, 2016 @11:05PM (#11372503)
And if you have to marshal/unmarshal XML, it gets worse. Go's XML library is buggy and its documentation recommends using JSON instead.
Re:Building Web Apps in Go by millstone on Sunday March 27, 2016 @11:46PM (#11372618)
Go is not concise, it is more verbose even than C++. Compare Python's list comprehensions to Go's for loops, or Python's sort() vs implementing Go's Sort interface, or Python's ternary operator vs Go's five-line if-else statement, or `if err != nil...`
Re:Building Web Apps in Go by iamgopal on Sunday March 27, 2016 @11:19PM (#11372528)
My strategy is to write very modular web app in python and when performance needed replace a module with go. Not only at that time specifications are mostly final, but most bugs are also covered. That way I get speed up the development of dynamic language and when needs a raise, use running speed of go language.
Re:Building Web Apps in Go by freyr on Monday March 28, 2016 @09:18AM (#11374052)
> Is there a compelling reason for me to even learn Go? ... Should I take the time to learn it?

One thing to consider is that the language is purposefully small, and you can learn the basics very quickly. Spend a day with it, and you'll get a feel for the language syntax and maybe some exposure to the standard library. You'll have a sense then whether you want to pursue it further.

So if you're curious, the compelling reason is that you can satisfy your curiosity without much effort, and that will ultimately be more satisfying than asking strangers to convince you one way or the other.

Re:Building Web Apps in Go by dgacmu on Monday March 28, 2016 @12:59AM (#11372817)
There is - Go is a terribly fun language in the domains that it's good at. Like some other fun languages, if you take the time to get into 'the go way' of doing things, you'll get a new perspective on some kinds of programming that'll help you in general.

Go is drastically less bloated than Java. Stupidly fast compilation and running lets you use it almost (but not quite) like you might Python for some things.

A recent example for me: Writing a quick & dirty server that talked to a device that was spouting a stupid binary serial-over-TCP protocol. Goroutines made handling the bidirectional communication trivial, and go being a bit on the low-level side makes it easy to cope with binary protocols without worrying that your chars and bytes and unicode characters are getting all mixed up. You can do all this in Java - but it's so clean in Go.

My current playbook looks something like:

Network servers: Go. Go go go and more go. Things that talk to lots of other things and involve interesting communication are a natural match. I rewrote my pi searcher in Go a year or so ago, for example - http://da-data.blogspot.com/2013/05/improving-pi-searchers-s... - and this year was able to run the thing through Pi day on only a single (larger) AWS instance. Woot. We use it for research, such as writing Paxos derivates. Great stuff.

Go's also pretty amazing for little utilities if you want them to be faster than Python -- particularly if you want the launch time to be faster than Python. Which can be great for utilities you build to use in loops in shell scripts, etc. The fact that they're purely statically linked makes a lot of otherwise hairy cross-platform nastiness just go away.

The fact that it's statically typed and includes great, easy-to-use parsing support for itself also makes it much better for refactoring than Python is. The tools aren't as mature as those for Java, but the language is well-designed to support it (think "go fix" -- which can automatically port forward much old code to newer versions of the language). The tooling for this kind of thing is great for Java, good for C and Go, and absolutely horrible for Python. As a consequence, Go can more roubustly handle being worked on in very large codebases and teams. What would be a slightly scary regexp replace in Python can be a much more syntactically and semantically safe change in Go (at the cost of a little more writing of the replacement code).

Tensorflow (and most things numeric): Python. Because it was pre-decided. :) But, more seriously, Go's lack of generics hurt it here (you can't express matrix/tensor manipulation natively, and saying A * x is about as right as it gets when you're talking math). The ML community has adopted Python to a pretty strong degree, particularly because of NumPy, and so it fits in really well there. I still get grumpy about it -- I've lost count of the number of times I've messed things up that static checking could have caught, requiring quite a long time for tests/running it to finally do so. But I do like Python, to the point of:

Beginners: Python. I pushed hard to switch CMU's intro course for non-majors to it, and succeeded with a lot of help from others. It's awesome seeing what a bunch of motivated, smart first-years can accomplish in Python in one semester. Damn. And they can 'take it with them' -- scientists/engineers and numpy are a pretty good match, for example.

Fast as hell: C++, light on the ++, heavy on the C. A lot of our research code is very low-level. I'm still finding Rust incredibly annoying, but I may just be a slow learner, and it's on my list to take a really serious look at it after I'm back from Google.

(You'll note that nothing that I do involves a UI. I'm a unix & systems person through and through, which helps explain the utter lack of Java, C#, Swift, etc. in my life.)

Re:Building Web Apps in Go by danieldk on Monday March 28, 2016 @03:16AM (#11373111)
Tensorflow (and most things numeric): Python. Because it was pre-decided. :)

Tensorflow has a minimalistic, but good-enough C API for running graphs. So, once you've built/trained a graph in Python, you can run it from Go without much trouble.

(Source: did that last week.)

still get grumpy about it -- I've lost count of the number of times I've messed things up that static checking could have caught,

For basic numpy-like functionality Armadillo and Eigen also work fine. I agree, I highly dislike numeric Python for the lack of type checking. Combined with the relatively long compile times of e.g. Theano it's a disaster (yes, I know 'fastrun').

I'm still finding Rust incredibly annoying, but I may just be a slow learner,

I'd encourage you to continue. I am also a beginner, but wrote some small crates. Once you get the hang off it, it combines the strengths of most things out there - C++-like memory control and performance, the terseness of Python/Haskell (though map/fold/etc.), and safety. It's a truly fun language to program in. Unfortunately, the library ecosystem is still rough.

Re:Building Web Apps in Go by EugeneOZ on Monday March 28, 2016 @06:53AM (#11373562)
> I'm still finding Rust incredibly annoying, but I may just be a slow learner

You are writing most of your code in Go, so you don't really have practical knowledge of Rust. I recommend you to try start some project (or tool) in Rust, keep patience first month or two and then you'll love Rust. It's how came to Rust, now I'm in the "honeymoon" period with Rust and I love everything I do with it. Before Rust, I started thinking I'm losing joy in programming, by doing stupid and boring things every day.

Re:Building Web Apps in Go by dgacmu on Monday March 28, 2016 @11:44PM (#11379349)
Completely agreed. I'm mostly getting hung up on the ecosystem issues the previous person alluded to -- I gave up at some point this weekend after fighting with getting the GMP bindings working properly on my mac with libraries installed in /opt/local instead of /usr/lib, for example. (The previous "ugh" was with the built-in bigint package). That's not about the core language, per se, just about the library and tooling maturity. As I said - once I have a bit more time to throw at it, I'll give it a real shot.
Re:Building Web Apps in Go by austinz on Monday March 28, 2016 @02:19AM (#11372984)
It's possible to write non-GUI command-line Swift programs that run on Linux (and certain other platforms). In terms of 'close to the metal', Swift is probably much closer to Rust or C++ than C# or Java, and is at least at the same level as Go.
Re:Building Web Apps in Go by fauigerzigerk on Monday March 28, 2016 @07:48AM (#11373699)
Is your 'close to the metal' claim based on any concrete experience with Swift? I like Swift as a language but I found its String/unicode support way too slow for the text processing stuff I do on the server side. I also tried using arrays instead, but in my text parsing micro benchmarks Swift is always four times slower than Go, Java, C++ and even two times slower than JavaScript/V8.

I don't really see a reason why this should be the case, so I hope it will improve over time.

But using mandatory reference counting does limit the sort of tasks for which Swift will ultimately be suitable. I wouldn't put it in the same category as C++ and Rust for that reason.

Re:Building Web Apps in Go by austinz on Tuesday March 29, 2016 @02:12AM (#11379778)
My (highly speculative) guess is that your String issues were due to either/both:

- Swift performance issues involving working with strings, some of which have been ameliorated by later releases;

- 'Hidden' bridging between NSString and String, which can be expensive and might have something to do with some of String's APIs actually being Foundation APIs in disguise.

There is much to be done with regards to Swift performance, though. If you have any sample benchmarks I would be interested in writing/running them myself, just for personal edification.

In terms of 'close to the metal', I freely admit this is a ill-defined term I am using for my own benefit. Swift code doesn't execute on something akin to the JVM or CLR; it still requires a heavier runtime than (e.g.) Rust. It is AOT-compiled to machine code. (But then again, this is possible to some degree for Java as far as I can tell, although it is certainly not the most popular way to run Java code.)

I agree that mandatory RC for classes and boxed types makes Swift impractical for a certain definition of 'systems software' typically written in C++ and occasionally Rust. For a different definition, one that encompasses the garbage-collected Go, Swift is theoretically suitable. The language designer has mentioned that he would personally like to see Swift gain some form of borrowing/lifetimes, although even if that did happen Swift would not get it for years to come.

Re:Building Web Apps in Go by fauigerzigerk on Tuesday March 29, 2016 @05:14AM (#11380341)
I tried to avoid bridging as far as possible and I'm working directly with UTF-16 because that's the fastest view by far. I'm using the latest release version of Xcode on a Mac.

The simplest benchmark I used is a function that does the equivalent of

  str.split(/\s*,\s*/)
So it splits a string around a separator and removes any whitespace around the items. For a million strings the numbers I get are as follows:

Swift: 3.5 seconds

Java: 0.31 seconds (after warmup)

So that makes Java more than 10 times as fast as Swift.

Here's the source code. I would be more than happy if you could tell me that I'm doing something horribly wrong (which I frequently do):

    import Foundation

    let N = 1000000

    func generateTestData() -> [String] {
        var a = [String]()
        for _ in 0..<N {
            a.append(",,abc, 123  ,x, , more more more,\u{A0}and yet more, ")
        }
        return a
    }

    func splitAndTrim(s: String, sep: UInt16) -> [String] {
        var result = [String]()
        result.reserveCapacity(10)
        
        let space = NSCharacterSet.whitespaceAndNewlineCharacterSet()
        let cs = s.utf16
        let eos = cs.endIndex
        var begin = eos
        var end = eos
        
        for i in cs.startIndex..<eos {
            let c = cs[i]
            if c == sep {
                result.append(begin == eos ? "" : String(cs[begin..<end.successor()]))
                begin = eos
                end = eos
            } else if !space.characterIsMember(c) {
                if begin == eos {
                    begin = i
                }
                end = i
            }
        }
        
        result.append(begin == eos ? "" : String(cs[begin..<end.successor()]))
        return result
    }

    func doSplits(data: [String]) -> Int {
        var count = 0
        let sep = ",".utf16.first!
        for s in data {
            let parts = splitAndTrim(s, sep: sep)
            count += parts.count
        }
        return count
    }

    let data = generateTestData()
    let start = NSDate()
    let sum = doSplits(data)
    print("elapsed: \(NSDate().timeIntervalSinceDate(start))")
    print("sum: \(sum)")
And here's the Java code:

    import java.util.List;
    import java.util.ArrayList;

    public class ParseTest {
    
        static int N = 1000000;
    
        public static void main(String[] args) {
            List<String> data = generateTestData();
            for (int i = 0; i < 3; ++i) {
                long start = System.currentTimeMillis();
                int sum = doSplits(data);
                System.out.println("elapsed: " +
                        ((System.currentTimeMillis() - start) / 1000.0 + " seconds"));
                System.out.println("sum: " + sum);
            }
        }
    
        static int doSplits(List<String> a) {
            int count = 0;
            for (String s : a) {
                List<String> parts = splitAndTrim(s, ',');
                count += parts.size();
            }
            return count;
        }
    
        static List<String> splitAndTrim(String s, char sep) {
            List<String> result = new ArrayList<>(10);
            int eos = s.length();
            int begin = eos;
            int end = eos;
    
            for (int i = 0; i != eos; ++i) {
                char c = s.charAt(i);
                if (c == sep) {
                    result.add(begin == eos ? "" : s.substring(begin, end + 1));
                    begin = eos;
                    end = eos;
                } else if (!Character.isSpaceChar(c)) {
                    if (begin == eos) {
                        begin = i;
                    }
                    end = i;
                }
            }
    
            result.add(begin == eos ? "" : s.substring(begin, end + 1));
            return result;
        }
    
    
        static List<String> generateTestData() {
            List<String> a = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                a.add(",,abc, 123  ,x, , more more more,\u00A0and yet more, ");
            }
            return a;
        }
    
    }
Re:Building Web Apps in Go by SiVal on Monday March 28, 2016 @05:05AM (#11373318)
Can this headless Swift be compiled to a simple, self-contained, statically-linked, no-runtime-required binary like Go? (A real question, not some sort of advocacy.)
Re:Building Web Apps in Go by pjmlp on Monday March 28, 2016 @09:47AM (#11374204)
Any AOT compiler to native code allows for self-contained, statically-linked, no-runtime-required binaries.

There is nothing special in Go about it.

Re:Building Web Apps in Go by wfsfw4w44 on Monday March 28, 2016 @08:46AM (#11373907)
Since go is a compiled language, you get the benefit on zero startup cost, which you pay when using JVM or NET, or even Python.
Re:Building Web Apps in Go by pjmlp on Monday March 28, 2016 @09:41AM (#11374168)
> which you pay when using JVM or NET

Except Java and NET developers worth their salt are aware of ways to AOT compile their code to native, thus enjoying the same startup time as Go.

Re:Building Web Apps in Go by jjnoakes on Monday March 28, 2016 @10:24AM (#11374388)
Is there a non commercial cross-platfornlm way to aot compile Java?
Re:Building Web Apps in Go by pjmlp on Monday March 28, 2016 @11:02AM (#11374641)
There used to exist GCJ, but its development died when the main developers joined OpenJDK development or moved elsewhere, back in 2009.

There is still the RoboVM version before it got acquired by Xamarin.

There are also Avian and JikesRVM, but it depends a bit what features you are using.

The problem with Java non-comercial AOT compilers is that the majority of the Java shops that really care about AOT compilation don't mind to pay for it, so there isn't a real effort to invest on a free AOT compiler.

The lack of community support for RoboVM was a good example of it.

Even the upcoming AOT compiler in the official JDK will be a commercial feature, at least it was announced as such.

Re:Building Web Apps in Go by beefsack on Monday March 28, 2016 @03:03AM (#11373088)
I actually find web applications a fairly weak use case for Go, it's never incredibly pleasant to do. Network services in general are very compelling, mainly because of the strong standard library.
Re:Building Web Apps in Go by out_of_protocol on Monday March 28, 2016 @05:38AM (#11373388)
I'm totally ok with building services and cli tools using Go but it's not gonna work for web apps - situation is dire and that's ideological position - i.e. don't expect changes there :/

Basically DIY everything outside standard library ( e.g. section 9.1 building CSRF) Personally switched to http://www.phoenixframework.org/ for json apis/web apps

Re:Building Web Apps in Go by andersen1488 on Sunday March 27, 2016 @11:52PM (#11372638)
Go compiles to native binaries, and requires no overhead like the JVM.
Re:Building Web Apps in Go by echlebek on Sunday March 27, 2016 @11:57PM (#11372652)
Like the JVM, Go programs have a runtime that has overhead.
Re:Building Web Apps in Go by jonathanoliver on Sunday March 27, 2016 @11:57PM (#11372653)
Sure it compiles to native binaries which doesn't require a separate VM install, but that doesn't mean it doesn't have overhead.
Re:Building Web Apps in Go by buro9 on Monday March 28, 2016 @04:04AM (#11373206)
I write in Go, and for me it is the sweet spot between all that you've said and only required a single language and a single tool chain.

There is little more to it than that.

Re:Building Web Apps in Go by dcu on Sunday March 27, 2016 @11:26PM (#11372552)
I'd say go is just slightly harder to write than python and as fast as (or faster?) than Java. It takes a lot of less memory than Java and Python for sure. Easier to read than both.

here's an interesting article: http://www.whitesmith.co/blog/why-i-started-to-use-golang-mo...