top | item 11173446

(no title)

austerity | 10 years ago

As someone who is fairly enthusiastic about Go and has implemented a few livelihood-providing production systems in it I am baffled by the number of people who keep trying to use it for application (and especially web application) development.

I mean it does feel like superpower when applied to tasks you'd previously have to use C for. But have you tried any of the modern web development stacks? They are like a zillion times more productive. Hint: PHP is not one of those.

I guess some people just can't get by without the iron hand of the compiler :)

discuss

order

afandian|10 years ago

Ditto. I used it for something that I would have written in C (and had prior). A glorious language. Gives safety to places where pointer arithmetic and function pointers adds danger while keeping structs and arrays of primitives. Plus great libraries and memory management.

And then I thought "why not use it for something web-like". My experience was dreadful. After coming from Python+Django, it felt like writing Java 1.4 (not a good thing). Especially for returning JSON objects with lots of mixed types.

So I switched to Clojure and never looked back (Python would have been an equally valid choice).

Go's a great language, but it's being applied in some very odd (and potentially unsuitable) places.

pramodliv1|10 years ago

I'm running Python + Django with uWSGI. Building the app is a pleasure. With type hints in Python 3.5, the code becomes almost as maintainable as statically typed languages too.

One problem I have is that the application is extremely CPU intensive. I can't get past 35-40 requests per second with 500 concurrent users (at 4 CPU cores, 14 GB RAM), which seemed too expensive economically. (I cached as much data as possible, both at the Nginx tier and with Redis) and tuned the number of uWSGI worker processes.

Do I have to try other languages or do you think I have more room for optimization with Python?

StavrosK|10 years ago

I had the same experience as you. Django (and RoR, I guess?) blows everything else I've tried out of the water in terms of ecosystem, and Python is a joy to program in. Go is fantastic when I want either a small service or a script that I want to deploy as a single executable and have it be reasonably fast, but I find Python much easier to write in. However, that may be because I'm more familiar with Python.

How did you like Clojure? Does the ecosystem it compare well against Django? I tried it once during an on-site interview but was put off by the multi-minute startup times.

coldtea|10 years ago

>Hint: PHP is not one of those.

Hint, PHP is 100% one of those. The bad rap is either because of hipsterism or for issues that have been long solved.

The rest of its warts are no worse than the kind of BS any language has -- in fact before JS got in fashion the same things was said all the time for it too (for its bizarro coercion rules, only fp arithmetic, bs scope rules etc).

true_religion|10 years ago

Modern PHP really isn't all that bad, I still wouldn't recommend people go into PHP development out of fear that they might stumble into one of the pre-modern hellholes that I only barely escaped in the early days of my career.

It's almost an irrational fear, but I remember working on plugins for applications where plugin hooks were non-existent, and the canonical approach was to patch code. I remember applications where there was no frontend server, but rather a sprawl of PHP files each doing one thing and hooking into the 'main' system via a 'require settings.php'.

Apart from that, working within PHP still obliges you to do a lot of hairy things---like working with Drupal. Now Drupal is certainly better architected than say Mambo/Joomla ever was, but it's still a better CMS than it is a web framework and for some odd reason lots of companies insist on building things into Drupal even today.

Now ... all of my recent knowledge is second hand, I've been out of PHP and into Python for at least 5 years now

wpietri|10 years ago

Have those issues long been solved?

I'm not snarking; I honestly don't know. I tried using PHP years ago, threw up my hands in horror, and have never touched it since. I felt a little bad about that, but a few years back Eevee's "PHP: A Fractal of Bad Design" [1] persuaded me I wasn't missing much, and that my "learn a new language" time was better spent on Scala and then Python.

So what's changed in the last few years that makes it 100% as good as Ruby or Python for web development?

[1] https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

untog|10 years ago

I agree, but if someone were starting a new project I'm not sure why I'd recommend PHP over any other stack.

spdionis|10 years ago

I'd say PHP is definitely one of those. Modern PHP web development is pretty productive and definitely high quality.

EDIT after reading the article: I do have to agree that concurrency in PHP is a bit of a pain, but those 3d party tools are pretty easy to use and maintain.

> Without significant forethought to several levels of caching; such as in memory caching, op caching ...

This is so trivial to setup it's not even worth mentioning.

> Sure, PHP has PSR standards etc, but they're fairly new and developers have been slow to adopt them.

Everyone I know and every library I use uses those standards. PHP is pretty standardized now, especially compared for example to js.

PHP frameworks work well out of the box and contain solutions for most use-cases.

Go is nice but when I tried it I really missed something like composer. "go get" and commit your dependencies to the repository? Seriously? That's wrong on so many levels. Meanwhile I think composer is one of the best package managers around.

riquito|10 years ago

> I'd say PHP is definitely one of those

I still don't like it but the landscape definetely changed, and it keeps getting better.

> Meanwhile I think composer is one of the best package managers around.

Apart from the fact that it uses gigabytes of ram on real projects. At work we ended up using it outside virtual machines, to later copy back the dependencies.

onion2k|10 years ago

I do have to agree that concurrency in PHP is a bit of a pain

It is, but the overwhelming majority of tasks in a web app don't happen concurrently, so it doesn't matter.

When it does matter just use something else.

aries1980|10 years ago

> Go is nice but when I tried it I really missed something like composer. "go get" and commit your dependencies to the repository?

Why is this a pb? Makes your app is more resilient to external outages and no need to git clone all the repos with historical data.

aws_ls|10 years ago

The point is, it is broad. You gained by using it in a traditional case where earlier you would have used C.

But I've used it in the web app scenario. Replacing Java (jetty/tomcat servlets with pure Java code) with Golang. My own discovery was it could replace the jetty/tomcat with servlets part seamlessly, just with a bunch of http url handlers. I know it could be possible still more easily in other languages/stacks which are "zillion" times more productive.

Now, we all know that nothing comes free. For e.g. C++ templates cause compilation to take more time; have heard people complain about Ruby/ROR (including one on this page); I myself hated the Java configuration of the app servers, even in minimalist use of just a Servlet (the least needed for a web app thing), not to forget the SOAP-Servlets (Axis et al) before JSON ( good common sensical structure IMHO from the XML schemas/dtds (any one remember them?!)) became fashionable.

So the bloat/overhead can be in terms of useless jargon (e.g. the latter part of above para) which are too verbose and mean something very simple. Slowness e.g. Ruby/Rails. Or simply memory bloat (Which means more servers for the same amount of app processing capability).

So please do understand that there could be reasons other than "just can't get by without the iron hand of the compiler", where people use Go. :-)

People who have come to realize they wasted a decade chasing promises whether they were called OOP, EJBs, SOAP, XML, App Server, etc. Only to have been left with mysterious crashes because of "out of memory exceptions" (heck, jetty/tomcat are open source, but does any app developer should be debugging them. No, right? )

So there are also people disillusioned by the promises they fell for earlier. Who now prefer the minimalist approach. And actually very much appreciate when the wise people developing Golang, are hesitant to add a thing like Generics, despite the pressure from many quarters.

To summarize, why I use it:

Don't try to make it too easy for me, and pinch me at wrong times (when I start to get more users for e.g). Just Give me speed and give me transparency baby. I know how to make it work.

Edit: Typos and minor rephrase

Mick-Jogger|10 years ago

I'd love to hear more about replacing tomcat. Can you lead me to some info material on that topic. In our company we rely heavily on application servers, faster alternatives are always worth checking out.

goldbrick|10 years ago

Yep. When you're talking about "web development" and your first argument is about "concurrency", your odds of doing it wrong are likely very high. Learn to profile, learn to cache appropriately, learn to set up data pipelines based on access patterns. Many of us who have learned the dangers of threading the hard way consider it a last resort, and just because you have wonderful primitives like goroutines and channels doesn't mean you shouldn't think first. I'm inclined to link to JRuby's first rule of writing concurrent code: https://github.com/jruby/jruby/wiki/Concurrency-in-jruby#con...

Also, it's relative newness combined with the fact that it is on the lower level of things means that basic tasks that have been iterated to precision on other platforms are still very raw around the edges and require quite a bit more boilerplate, which is not at all suited to almost all "web development".

I know, I know. "But it's faster!" I'd take a clean, cohesive system that can scale horizontally even if it takes me 5 times the servers of my entire-system locking clusterfuck that makes me guess about data.

There is probably an interesting metaphor to be made that is corollary to the adage about the hammer, something about how if you give that man a screwdriver he starts looking for nails to pound with it?

joncalhoun|10 years ago

You likely see this because web applications are one of the most common things developers build, and it is easier to learn a language when you start by building something you are familiar with.

When I learned Ruby I came from a Java background, and being able to search for things like "java interfaces in ruby" was incredibly helpful. It is a very succinct way of defining what you are trying to do in the new language, and often leads to a useful post explaining how to do what you want to do (even if that means doing it a completely different way in the new language).

I suspect this is also why you see frameworks like Revel gaining so much popularity in Go. Developers coming from Rails, etc all want something they are familiar with, and Revel looks familiar. It may not be the best way to build web apps in Go (I don't know), but limiting what you have to learn has its benefits.

I personally view this as a positive thing. It makes it easier for developers to learn Go and find out what it is useful for so that when they can benefit from it they realize it.

kqr|10 years ago

> I guess some people just can't get by without the iron hand of the compiler

Hey, Haskell and Scala exist!

esaym|10 years ago

Don't worry, I once read a similar article about how C++ can be great for scripting (and that was just a few years ago.)