
Show HN: Lima, a Swift-based DSL for responsive iOS development - gk_brown
https://github.com/gk-brown/Lima
======
Klonoar
Sometimes I feel like the only one who's totally fine with AutoLayout as-is.
IMO it is hands-down the most straightforward and easy to understand way of
constructing UI, and I've dealt with an insane number of UI toolkits over the
years.

Furthermore, anytime I see someone complaining about it and I check out their
solution with AL... they've overcomplicated how they're setting constraints
and doing the layout, and it ends up usually being the issue more than AL
itself.

~~~
cuddlybacon
> Sometimes I feel like the only one who's totally fine with AutoLayout as-is.

Agreed. It took me a while to find some idioms I like, but once I did that I
like it quite a bit more than what I was doing in HTML land (note: not a
webdev). It probably helps in my case that this is a solo project so I had the
freedom to try a bunch of different styles until I found one I like.

I find the bad part is how user events are handled, particularly when multiple
parts of the UI need to be changed. This, like autolayout, could be an issue
of inexperience.

------
oh_hello
This looks great, but I don't see huge advantages over UIStackView. Can you
explain what they are?

~~~
gk_brown
For one, you can't create a hierarchy of UIStackViews and their contents
declaratively. But UIStackView also forces you to think in terms of content
hugging and compression resistance priorities, which (to me) isn't as natural
as widths, heights, or weights.

------
matchbok
Pretty cool. All of the layout options for iOS are pretty subpar (coming from
a web/android background):

IB/storyboard are trash (WYSIWYG is so 90s and dragging and poking around a
huge visual editor is a huge time sink)

AutoLayout is verbose and complex, even with helper libraries.

It'd be super cool if we could use something like XML with Lima.

~~~
dep_b
> AutoLayout is verbose and complex, even with helper libraries.

I don't think they can get much shorter than this:

    
    
        private func addConstraints() {
            introduction.attach(sides: [.top, .leading, .trailing], 8.layoutGuideRespecting)
            contact
                .attach(sides: [.leading, .trailing], 8)
                .space(8, .below, introduction)
            spinner.center()
            error
                .attach(sides: [.leading, .trailing], 8)
                .space(8, .below, contact)
    
            create.attach(sides: [.top, .bottom, .trailing], 3)
        }
    

And honestly the stuff I needed to do to get CSS working let alone cross-
browser until very recently was really not as consistent, clean or predictable
as auto layouts. I think you just got used to the suffering.

The only thing I really like about CSS is the arbitrary lines you can draw in
the sand like "if it gets over 1000px wide then move the menu to the right".

~~~
matchbok
Agreed... I'd much prefer a declarative layout language though. With complex
layouts, it's hard to debug AL if you aren't the one who built it.

Even stackviews, which was Apple admitting that simple layouts are too verbose
to do with AL, are a mess.

~~~
oflannabhra
Rumor is that official, cross-platform declarative layouts are coming to iOS
from Apple [0].

[0] -
[https://daringfireball.net/2018/04/scuttlebutt_regarding_ui_...](https://daringfireball.net/2018/04/scuttlebutt_regarding_ui_project)

~~~
tijs
Did that not turn out to be uikit port to macos?

[https://thehackernews.com/2018/06/porting-ios-apps-
macos.htm...](https://thehackernews.com/2018/06/porting-ios-apps-macos.html)

~~~
oflannabhra
No, I believe it is the case that Gruber conflated two separate projects
(which might both be part of the same overall vision). The first was codenamed
"Marzipan" and has been announced (and leaked and reported by Gurman). The
second is what Gruber is speaking of in that article, and relates to laying
out views. It has not been announced, but is codenamed Amber. Gruber clarified
this post-Marzipan announcement in a tweet [0]. More info from Gurman [1].

[0] -
[https://mobile.twitter.com/gruber/status/1014490721909444608](https://mobile.twitter.com/gruber/status/1014490721909444608)

[1] - [https://mjtsai.com/blog/2018/05/01/scuttlebutt-regarding-
app...](https://mjtsai.com/blog/2018/05/01/scuttlebutt-regarding-apples-cross-
platform-ui-project/)

