4 ms·
The commas and dots are operators, not syntax. one, two, three. Is essentially compiled down to: if (one && two && three) { return three; } Whereas one, tw
by Skinney 7y ago
The commas and dots are operators, not syntax.
one,
two,
three.
Is essentially compiled down to:
if (one && two && three) { return three; }
Whereas
one,
two,
three;
one,
four.
compiles down to:
if (one && two && three) { return three; }
else if (one && four) { return four; }
So yeah, it's not syntax.
, === &&
; === ||
. marks end of a condition, so } in C.
- dkersten 7y agoThe issue I see is that a . and a , are tiny little marks on the screen that are super easy to miss and, at a glance, the . , ; all can look the same. Maybe with practice you can spot the differences easier, but certainly as a newcomer to the language its a lot of extra cognitive load. && and || at least are super obvious.
- Skinney 7y agoI don't write Picat, but when I write Prolog the color scheme for Emacs gives those operators a bright color so they stand out.
- dkersten 7y agoRight. As someone who uses raindbow parentheses, I should have immediately thought that it would be solved by the editor. Still, I don't like if readability relies on the editor too much, since you often want to paste or read code elsewhere (on HN, stackoverflow, github, random websites, etc) that may not know about your non-mainstream language.
- masukomi 7y agoif making your editor compensate for the language syntax is the only way to make the language syntax easily readable then the language designer has failed.
- YeGoblynQueenne 7y agoThe comma and dot are natural ways to separate and end statements in natural language. Why are they a problem in a programming language, where you have to be extremely careful about your syntax anyway?
- dkersten 7y agoI think there's two reasons: First, its a trend. Other languages have trained us to not see them so much (as pard68 said), to put much more weight on other things. Its not complete though, many programming languages do use them: to separate elements in a list, to separate parameters, as method.calls, and in numbers 1.0, so that's probably a very minor reason over all. Second, programming languages are very symbol heavy: we use all kinds of operators and special->symbols and (various [brackets]), it just kinda drowns out small symbols that are at the bottom of the line like a , or . and they're just not as obvious as keywords or ink-heavy symbols. But overall, I guess I'm just not used to seeing them in that context and I'd get over it really quickly, just like I very quickly got over Python's significant whitespace or Lisps parentheses. It seems like a big deal until one day suddenly its not anymore.
- YeGoblynQueenne 7y agoAnd the compiler gives a bright (red) color to their absence, also. You do need the Swi-Prolog IDE for that though.
- pard68 7y agoEspecially when you are used to more or less filtering out '.', ',', and ';'.
- pmontra 7y agoThe script is import util. input_data(Tri) => Lines = read_file_lines("triangle.txt"), Tri = new_array(Lines.length), I = 1, foreach(Line in Lines) Tri[I] = Line.split().map(to_integer).to_array(), I := I+1 end. In the mind of an imperative scripting developer those commas are (useless) semicolons. I wrote a little Prolog some 30 years ago. Probably those commas and dots have the same function, logic and, as you write. I understand that it's a core feature of the language, but its really awkward when using Picat imperatively. I've seen this dynamic of obeyibg to tradition in many languages. The vast majority of developers are used to imperative languages. If designers of functional, logic, etc languages want to hijack those developers to their own language they could try to be creative and bold and give those developers a syntax their are familiar with. Elixir has a Ruby like syntax to Erlang and had some success at onboarding Ruby developers. But it wasn't bold. Example: they didn't have courage to turn GenServer into a Class with a CPU. It's still a bag of functions, partly called by clients, partly called by the server, with method names (if it was a class) hidden in arguments and explicit state management. The Reia language was a bolder attempt but unfortunately its designer liked Elixir and killed his project. My guess: there would be many more Reia developers than Elixir ones by now. http://reia-lang.org/ http://reia-lang.org/
- didibus 7y agoI think most designers of alternative paradigm languages also prefer the alternative syntaxes.
- pmontra 7y agoYou're probably right, and those languages risk staying alternative forever.
- pessimizer 7y agoThe idea that typing commas is far more difficult than typing semicolons is common, but bizarre. I feel like you're using a lot of words here to rationalize being accustomed to semicolons or significant whitespace as a logical preference rather than an aesthetic one. Consider commas somewhere between a minimalist and maximalist aesthetic (" " < "," < ";"), but one that values consistency.