News for hackers. Stuff that matters.
Re:A minimal blog engine written in Go, compatible with Ghos... by Kabukks on Saturday April 25, 2015 @02:40PM (#9439176)
Author of Journey here (thanks Maksadbek for posting it on HN). I'm going to repost my comment from Reddit:

I've been working on this blog engine in my spare time for the last few months. My blog has been running on it without hiccups for about a month now (low volume, 700 visits a day tops).

I'd like some opinions if anyone has the time to try it out. (Worth pursuing? Any ideas for features? Should I die in a fire because my code quality sucks?)

Thanks :)

Re:A minimal blog engine written in Go, compatible with Ghos... by Maksadbek on Saturday April 25, 2015 @02:46PM (#9439199)
Author of the post here. I found your blog engine awesome. It inspired me to create my blog. Thanks for such a good project :)
Re:A minimal blog engine written in Go, compatible with Ghos... by syntern on Saturday April 25, 2015 @02:46PM (#9439198)
Looks like it is a neat project, thanks for open sourcing it. Do you plan to support static export?
Re:A minimal blog engine written in Go, compatible with Ghos... by mixu on Saturday April 25, 2015 @03:56PM (#9439397)
If you need static export, I wrote a project a while back that converts markdown to static output with Ghost theme support: https://github.com/mixu/ghost-render
Re:A minimal blog engine written in Go, compatible with Ghos... by Kabukks on Saturday April 25, 2015 @03:33PM (#9439334)
It's not yet planned, but definitely something that would be useful. I'll add it to the list.

Here's my high priority feature list right now:

Gzip support, hashes for serving static assets, multi-user support, support for all of the Ghost theme helpers, MySQL, Postgres, and Google App Engine support.

Re:A minimal blog engine written in Go, compatible with Ghos... by ChuckMcM on Saturday April 25, 2015 @05:04PM (#9439557)
One of the reasons I started playing with Ghost is because generating the site statically allows for a lot of performance on a $5 VPS with nothing special but a fat internet pipe. As blogs are typically not heavy on the "interaction" aspects of things, this works really well.

So consider this a vote for "static site support". If I were to express that as a requirement it would be something like "Site is served off a set of static pages that were generated on demand as the content on them or around them changed."

Re:A minimal blog engine written in Go, compatible with Ghos... by bootload on Sunday April 26, 2015 @06:12AM (#9441224)
"One of the reasons I started playing with Ghost is because generating the site statically allows for a lot of performance on a $5 VPS with nothing special but a fat internet pipe. As blogs are typically not heavy on the "interaction" aspects of things, this works really well."

Wrote my own engine for exactly this reason.

All python, no templates and only one imported module (markdown) which I'm going to use pythons (why not in the first place?). I concur with the idea. Whole blog is about 1.4Mb of text. Images are hosted so it's AUD3.5/month to host the blog + domain.

It's not Ghost compatible. I based my template on Jeckyl. That is YAML front-matter followed by markdown. All contained in text files. It's a bit slot at the moment but works a charm.

What format are you following?

Re:A minimal blog engine written in Go, compatible with Ghos... by ChuckMcM on Sunday April 26, 2015 @01:07PM (#9442417)
Heh, same. Used FrontPage for a while to basically "push" static pages to my site, then played with Blosxom for a bit but never published anything with it, wrote my own in Perl with Template toolkit and Markdown, and as that was going along, heard about and downloaded Ghost. Then built a 'theme' that matched my original skeumorphic notebook theme and basically have what I need to push the button on it (but haven't for some reason).
Re:A minimal blog engine written in Go, compatible with Ghos... by bootload on Sunday April 26, 2015 @04:08PM (#9443078)
previous

* hotdog (binary) -> site (worked there)

* blosxom (perl) -> site

* perl -> TT -> ftp -> site

* python -> webpy -> appengine -> site

now * python -> markdown -> ftp/ssh -> site

future

* [some back-end language/Rpi] -> js [front-end/iPad] -> [some transport layer] -> site

I'm trading simplicity for speed and turn-around. The tool-chain is all cli, vim + browser. At some stage soon I'll write either an api/server to allow a simple interface to speed up process.

The basic ideas are based on Dave Winer and Scripting.com

Re:A minimal blog engine written in Go, compatible with Ghos... by Yhippa on Sunday April 26, 2015 @12:58AM (#9440600)
I wish Octopress was this easy to use.
Re:A minimal blog engine written in Go, compatible with Ghos... by tankenmate on Saturday April 25, 2015 @05:53PM (#9439689)
I had a look at the docs on github (I haven't checked the source yet) but it doesn't mention if it supports more than one domain (or SNI, but I'm assuming it would piggy back on Go's support for SNI).

If it doesn't yet support multi domain will it ever?

Re:A minimal blog engine written in Go, compatible with Ghos... by Kabukks on Saturday April 25, 2015 @06:07PM (#9439721)
Interesting. I haven't thought about that. It should be possible, but is not implemented yet. Go does indeed support SNI, but I'm using ListenAndServeTLS at the moment + I'm loading only one SSL certificate right now.

I'll add that to the list as well. I think that might be a useful feature.

Re:A minimal blog engine written in Go, compatible with Ghos... by monk_e_boy on Saturday April 25, 2015 @06:00PM (#9439700)
How did using Go feel compared with other languages, I'm a php, ruby, python guy. Just wondering your opinion on why you chose Go?
Re:A minimal blog engine written in Go, compatible with Ghos... by Kabukks on Saturday April 25, 2015 @07:49PM (#9439951)
I chose Go because I wanted to learn it ;) In retrospect tough, I couldn't have wished for a better language to write a web server in. I especially like the opinionated handling of code formatting and memory safety (it won't let you compile if you have a unused variable for example) and the consistent error handling (I know, a lot people seem to dislike Go's error-oriented programming style).
Re:A minimal blog engine written in Go, compatible with Ghos... by wting on Saturday April 25, 2015 @08:25PM (#9440042)
Unused variables have nothing to do with memory safety. At most they'll take up some stack or heap space.

https://en.wikipedia.org/wiki/Memory_safety

Memory safety is enforced in Go via best practices–like C and C++ ecosystems. However because of gc and channels race conditions happen less often in Go but there's no explicitly tooling to prevent them from happening:

http://research.swtch.com/gorace

Re:A minimal blog engine written in Go, compatible with Ghos... by Kabukks on Saturday April 25, 2015 @08:38PM (#9440073)
You are right. I was thinking about the general fail-safety of my programs. Not letting me compile saved me from overlooking a (return) value more than once.
Re:A minimal blog engine written in Go, compatible with Ghos... by threeseed on Saturday April 25, 2015 @08:47PM (#9440086)
You could accomplish the same thing by incorporating a code checker as part of your build process.

That way you would be catching a lot more code issues then just unused imports, variables etc.

Re:A minimal blog engine written in Go, compatible with Ghos... by Immortalin on Sunday April 26, 2015 @04:11AM (#9440976)
It would really great if you could convert it into a modular CMS with ecommerce features similar to Drupal Commerce.
Re:A minimal blog engine written in Go, compatible with Ghos... by zura on Saturday April 25, 2015 @03:15PM (#9439287)
Regarding Golang's if-hell e.g. in https://github.com/kabukky/journey/blob/master/database/upda...

Couldn't you use panic/recover locally, inside functions - just for having a single error handling code?

Re:A minimal blog engine written in Go, compatible with Ghos... by pdq on Saturday April 25, 2015 @03:23PM (#9439306)
No, panic/recover is a major hack.

Rob Pike has written ideas here on how to clean up error handling if-blocks: http://blog.golang.org/errors-are-values

Re:A minimal blog engine written in Go, compatible with Ghos... by burntsushi on Saturday April 25, 2015 @05:37PM (#9439656)
No, it's not a "major hack." That blog post is excellent, but it just doesn't always apply.

The panic/recover idiom is extremely useful in parsers. For example, Go's JSON decoder: http://golang.org/src/encoding/json/decode.go

Re:A minimal blog engine written in Go, compatible with Ghos... by pdq on Saturday April 25, 2015 @07:51PM (#9439959)
The difference is that in parsers, errors are almost certainly fatal. As opposed to a runtime SQL error, where it could be a user error, value error, or other database error, which can be recovered from.

Panic/recover are usually meant to catch "coding" and "assertion"-type errors (null pointers, array overflows, etc), not runtime errors. The latter is what the "error" values are used for.

Re:A minimal blog engine written in Go, compatible with Ghos... by burntsushi on Saturday April 25, 2015 @08:32PM (#9440057)
I'm pretty sure you've misunderstood. Did you read the code I linked you to? Look at how it handles errors internally. Go's standard JSON decoder isn't going to crash your program if it fails to parse JSON---that would be disastrous. It exposes regular errors to the user. But internally, it uses panic/recover because it elides a lot of manual error checking.
Re:A minimal blog engine written in Go, compatible with Ghos... by thirsteh on Saturday April 25, 2015 @08:12PM (#9440008)
Panic/recover is no problem as long as it does not traverse API boundaries, i.e. affects the user of your package, unless it really is a "fatal user error" in a function that wouldn't otherwise return an error.
Re:A minimal blog engine written in Go, compatible with Ghos... by superuser2 on Saturday April 25, 2015 @10:08PM (#9440256)
Interesting. That's basically the Maybe monad.
Re:A minimal blog engine written in Go, compatible with Ghos... by lorddoig on Saturday April 25, 2015 @04:03PM (#9439415)
I haven't written go in a while, but I recall being rather dissatisfied with the so-called 'if-hell'. I've been wondering lately - is there any reason why you couldn't/shouldn't use monads for this? Nothing obvious popping out of Google.

"gonads" would be my choice of name for this library.

Re:A minimal blog engine written in Go, compatible with Ghos... by rlp on Saturday April 25, 2015 @04:30PM (#9439480)
Love the name! But there's no way Go's feeble type system supports anything remotely like a Monad.
Re:A minimal blog engine written in Go, compatible with Ghos... by stcredzero on Saturday April 25, 2015 @05:56PM (#9439692)
Here's what GIlad Bracha might say about that:

http://www.infoq.com/presentations/functional-pros-cons?utm_...

Re:A minimal blog engine written in Go, compatible with Ghos... by tptacek on Saturday April 25, 2015 @05:31PM (#9439634)
Since they're wrapping things in transactions anyways, they could just defer the error check to the end (or for that matter rework their interface to the database to stop after the first error is detected).
Re:A minimal blog engine written in Go, compatible with Ghos... by 4ydx on Saturday April 25, 2015 @10:07PM (#9440253)
Re:A minimal blog engine written in Go, compatible with Ghos... by 4ydx on Sunday April 26, 2015 @03:00AM (#9440812)
This is a simple way of dealing with repetitive error handling.
Re:A minimal blog engine written in Go, compatible with Ghos... by arthurbrown on Saturday April 25, 2015 @07:36PM (#9439928)
I've written a tiny package that does just that in a controlled way, using named returns to bubble the error out.

https://github.com/dagoof/failure

[Docs] https://godoc.org/github.com/dagoof/failure

Re:A minimal blog engine written in Go, compatible with Ghos... by dpritchett on Saturday April 25, 2015 @03:25PM (#9439314)
I have never messed with panic, I read that code and I think I'd make a function that takes functions - the error handling response is the same every time. Maybe even put the list of calls in an actual list and invoke them with an iterator.
Re:A minimal blog engine written in Go, compatible with Ghos... by vardump on Saturday April 25, 2015 @07:10PM (#9439860)
Explicit error recovery is not hell, it's a blessing. Much easier to understand and to maintain than exception handling.
Re:A minimal blog engine written in Go, compatible with Ghos... by tomjakubowski on Saturday April 25, 2015 @07:49PM (#9439948)
There is a third way. See Haskell's Either l r, or Rust's Result<T, E> types. See http://lucumr.pocoo.org/2014/10/16/on-error-handling/ and http://lucumr.pocoo.org/2014/11/6/error-handling-in-rust/

I don't know why so often, the immediate reaction to legitimate criticism of this wart in Go is to argue against exceptions, even when nobody has even brought up exceptions as an alternative.

Re:A minimal blog engine written in Go, compatible with Ghos... by thirsteh on Saturday April 25, 2015 @08:20PM (#9440031)
In fact, Either/Maybe can function like safer versions of both paradigms: Functors allow you to build a program of many functions that will terminate with 'Nothing' or 'Either l' as long as any one of them experiences an error, without thinking about errors, and it still lets you explicitly handle any errors if you want to, this time on the sum type Maybe or Either, meaning that you usually handle both the error and non-error case, or receive a compiler warning.

I agree that, probably universally, the people who fervently argue for either exceptions or explicit Go-style error handling don't know about Maybe/Either/Result. Then again, all this is pretty much impossible to replicate in Go.

Re:A minimal blog engine written in Go, compatible with Ghos... by Dewie2 on Sunday April 26, 2015 @12:01PM (#9442152)
Thank you for mentioning this. It's frustrating that every time someone complains about Go's error-handling style, the first assumption is that the complainer then necessarily has to prefer exceptions. In truth, errors-as-values are very elegant in languages like Haskell IMO. And errors-as-values are not at all something that Go has managed to put back on the roadmap in a modern language against the grain of everyone else (the "exception people") as many seem to imply, including Rob Pike in his "errors as values" article.
Re:A minimal blog engine written in Go, compatible with Ghos... by vezzy-fnord on Saturday April 25, 2015 @08:26PM (#9440044)
Option types are nice. The fourth way (and I think the best) is supervision trees, though this is more applicable when you have multiple units of execution... which Go does, so not having something similar out of the box seems strange.

That said, even something as simple as errors being literal values that you can pattern match on is surprisingly versatile. Exceptions don't necessarily have to be awful weights that spill down all over the call stack, either. They can be distilled to a more basic catch/throw mechanism for shuffling around error properties and states.

Re:A minimal blog engine written in Go, compatible with Ghos... by threeseed on Saturday April 25, 2015 @08:46PM (#9440082)
Personally I love option types but working on a large Scala project at the moment it sometimes results in non ideal behaviour from developers especially those coming from the Java world.

What I've seen a lot of is swallowing of errors. For example readFromFile().orElse("") where there is no indication from an outsider that anything wrong happened. A cool feature would be logging any instance of when orElse was the result.

Would be curious how these work in other languages.

Re:A minimal blog engine written in Go, compatible with Ghos... by Jweb_Guru on Sunday April 26, 2015 @12:54PM (#9442353)
The trick is to make it very ergonomic to return the error. I thought Scala had do notation to make this the case. In Rust, the try! macro (which returns on error) is shorter than almost any other way to handle an error, so people usually use that.
Re:A minimal blog engine written in Go, compatible with Ghos... by threeseed on Saturday April 25, 2015 @08:36PM (#9440067)
I'm confused what makes exception handling so troublesome ?

Personally I find them essential in particular for larger codebases. They allow for centralised, consistent error handling behaviour. For example paging application support teams only for certain types of errors.

And you can always emulate explicit error recovery with exceptions. So what is so bad about having the flexibilty to accomodate different styles of error handling.

Re:A minimal blog engine written in Go, compatible with Ghos... by xienze on Saturday April 25, 2015 @10:28PM (#9440298)
Yeah, I don't understand the objection to exceptions either. I _think_ the reason is because people treat them much the same was as errors in C/Go/etc., i.e., "I have to catch them here and recover right away." If you're doing it that way, you're doing it wrong. Design the system such that exceptions can be rethrown (bubbled up) and defer the handling as long as possible.
Re:A minimal blog engine written in Go, compatible with Ghos... by mike_hearn on Sunday April 26, 2015 @02:14PM (#9442691)
Nothing. This is one of those "Go doesn't have it, so it must be bad" things. The way Go handles errors is a throwback to C and was abandoned by literally every single imperative language for good reasons.
Re:A minimal blog engine written in Go, compatible with Ghos... by 4ydx on Sunday April 26, 2015 @03:16AM (#9440850)
Honestly I wish that golang forced you to acknowledge all return values from methods even if you simply ignore them ( _ = Method() ). When I read the docs for any method calls in golang I like being able to see that something returns an error just by looking at the function signature. Certainly I might not know how to handle all the error variations, but not having to decide if I need to wrap something in try/catch... I dunno it just resonates with me.