Hacker News new | ask | show | jobs
by wiradikusuma 2945 days ago
Print 1 to 10, as a comma-separated list.

In e.g. Scala, you can do that:

print( 1 to 10 mkString "," )

It's not 100% human language/grammar, but close (and you have auto-completion using IDE). Why would you need another DSL?

(Not trying to bash Avail, nor promote Scala, just curious for its usecases)

2 comments

I'm pretty sure the goal of these "natural language style" programming languages extends beyond printing a comma-delimited list of numbers. This arbitrary example doesn't mean much.
It's not a very good example though - it's not showing me any sort of improvement over actual programming languages - just an intentionally bad bit of code.
No it's an arbitrary example of which their are many more on the site. You're just overly obsessed with that one.
It's the only code example on the 'Introduction' page. I'm sorry for expecting something better.
I agree; defining well-named functions seem a superior solution. In Haskell, it would just be:

print (intercalate ", " [1..10])

I don't buy natural-language-ish programming languages. The grammar becomes far too complicated very quickly. A simple but flexible grammar, a la most functional languages, is superior.

I hope you didn't mean to imply that `intercalate` is a _well-named_ function... I've no idea what it means, and even after a dictionary search it's still not obvious to me why you'd ever name a method like this!
It's kind of a bad name, but not entirely.

This is the definition of intercalate.

---

intercalate [in-tur-kuh-leyt]

verb (used with object), in·ter·ca·lat·ed, in·ter·ca·lat·ing.

1. to interpolate; interpose.

2. to insert (an extra day, month, etc.) in the calendar.