Live data from Hacker News

Show HN: Lima, a Swift-based DSL for responsive iOS development

github.com

11–20 of 21 posts

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#11
post #2

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.

I used to think that but now completely disagree. I’ve been making iPhone apps for too long, and storyboard/ib is so much faster and easier then any of the other options. I only use it for building constraints, and sometimes need to make them programmatically.

There’s a lot of stuff in there though that I ignore because of the issues you mentioned above. If you just keep it to simple constraints it’s great

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#12
post #9

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…

Agreed. About the only thing I do on top of it is add some operators for setting up AutoLayout, so I can write code like

  NSLayoutConstraint.activate([
      label.topAnchor ≈ view.topAnchor,
      label.leadingAnchor ≈ view.leadingAnchor + 8,
      label.centerXAnchor ≈ view.centerXAnchor,
      view.bottomAnchor ≥ label.bottomAnchor
  ])

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#13
post #9

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…

Same. Especially now that we have NSLayoutAnchor. Sure, it wasn't ideal when VFL was more widely used, but these days it works great and is as readable as any DSL I've seen.

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#14
post #4

Earlier quoted context omitted.

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.

Rumor is that official, cross-platform declarative layouts are coming to iOS from Apple [0]. [0] - https://daringfireball.net/2018/04/scuttlebutt_regarding_ui_...

That would be amazing. I really like using Storyboards if only just to better separate layout from logic but there are so many downsides to them that I just don't really use them all of the time.

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#15
post #2

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.

Even before iOS 9 (anchors) the verbose autolayout was better than anything available for the web. Now there is CSS Grid which makes it easier but there is no mechanis that could describe relationship between elements like AL can. Throw in a couple extensions for NSLayoutAnchor and it’s a very pleasant experience. As for IB—it’s a matter of taste. I had no real problem with it, but at the end layout purely in code is the best option for me.

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#16
post #3
post #2

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.

> 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…

I think UIStackView would be much simpler solution for this ;)

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#17
post #9

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…

> 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.

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#18
post #8

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

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.

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#19
post #2

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.

Actually, Lima is partly a move away from using XML:

https://gkbrown.org/2018/11/04/introducing-lima/

Re: Show HN: Lima, a Swift-based DSL for responsive iOS development

#20
post #16
post #3

Earlier quoted context omitted.

> 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…

I think UIStackView would be much simpler solution for this ;)

UIStackView is a step in the right direction, but it doesn't go far enough. It's still not truly declarative; it requires you to think in terms of content priorities; and it doesn't support z-ordering.
Post reply on HN