Live data from Hacker News

Weird Lexical Syntax

justine.lol

81–90 of 234 posts

Re: Weird Lexical Syntax

#81
post #76

Earlier quoted context omitted.

Jury's out re: whether I feel this in my gut. Need more time with the lisps for that. But re: cognitive load maybe it goes like: 1. 1 language to rule them all, fancy syntax 2. Many languages, 1 simple syntax to rule them all 3. Many languages and many fancy syntaxes Here in the wreckage of the tower of babel, 1. isn't really on the table. But 2. might have benefits because the inhumanity of the syntax need only be c…

I think 3 is not only a natural state, but the best state. I don’t think we can have 1 language that satisfies the needs of all people who write code, and thus, we can’t have 1 syntax that does that either. 3 seems the only sensible solution to me, and we have it.

I dunno, here in 3 the hardest part of learning a language has little to do with the language itself and more to do with the ecosystem of tooling around that language. I think we could more easily get on to the business of using the right language for the job if more of that tooling was shared. If each language, for instance did not have it's own package manager, its own IDE, its own linters and language servers all with their own idiosyncrasies arising not from deep philosophical differences of the associated language but instead from accidental quirks of perspective from whoever decided that their favorite language needed a new widget.

I admire the widget makers, especially those wrangling the gaps between languages. I just wish their work could be made easier.

Re: Weird Lexical Syntax

#82
post #44

Earlier quoted context omitted.

I have never seen this in Java! Is there any use cases where it could be useful?

I don't know about usefulness but it does let us write identifiers using Unicode characters. For example: public class Foo { public static void main(String[] args) { double \u03c0 = 3.14159265; System.out.println("\u03c0 = " + \u03c0); } } Output: $ javac Foo.java && java Foo π = 3.14159265 Of course, nowadays we can simply write this with any decent editor: public class Foo { public static void main(String[] args) {…

I wonder if full unicode range was accepted because some companies are writing code in non-english.

Re: Weird Lexical Syntax

#83
post #77
post #19

Earlier quoted context omitted.

> Maybe it was hard to use backtick in the 70’s and 80’s, but today[2] you could use backtick to start a string and a single quote to end it. That's how quoting works by default in m4 and TeX, both defined in the 70s. Unfortunately Unicode retconned the ASCII apostrophe character ' to be a vertical line, maybe out of a misguided deference to Microsoft Windows, and now we all have to suffer the consequences. (Unless w…

See also: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

This is an excellent document. I disagree with its normative conclusions, because I think being incompatible with ASCII, Unix, Emacs, and TeX is worse than being incompatible with ISO-8859-1, Microsoft Windows, and MacOS 9, but it is an excellent reference for the factual background.

Re: Weird Lexical Syntax

#84

Earlier quoted context omitted.

I am surprised to hear that structural editing has been a hurdle for you, and I think I can offer a piece of advice. I also used to be terrified by its apparent complexity, but later found out that one just needs to use parinfer and to know key bindings for only three commands: slurp, barf, and raise. With just these four things you will be 95% there, enjoying the fruits of paredit without any complexity — all the re…

Thanks very much for the advice, it's timely. It's not so much the editing itself but the unfamiliarity of the ecosystem. It seems it's a square-peg I've been crafting a round hole of habits for it: I guess I should use emacs? How to even configure it such that these actions are available? Or maybe I should write a plugin for helix so that I can be in a familiar environment. Oh, but the helix plugin language is a sch…

I never bothered with structural editing on Emacs. I just use the sentence/paragraph movement commands. M-a, M-e, M-n, M-p, M-T, M-space, etc.

Re: Weird Lexical Syntax

#85
post #36

> Every C programmers (sic) knows you can't embed a multi-line comment in a multi-line comment. And every Standard ML programmer might find this to be a surprising limitation. The following is a valid Standard ML program: (* (* Nested (**) *) comment *) val _ = print "hello, world\n" Here is the output: $ sml Given how C was considered one of the "expressive" languages when it arrived, it's curious that nested commen…

This is not just true of Standard ML; it's also true of regular ML.

Re: Weird Lexical Syntax

#86

> Perl also has this goofy convention for writing man pages in your source code The world corpus of software would be much better documented if everywhere else had stolen this from Perl. Inline POD is great.

Perl and Python stole it from Emacs Lisp, though Perl took it further. I'm not sure where Java stole it from, but nowadays Doxygen is pretty common for C code. Unfortunately this results in people thinking that Javadoc and Doxygen are substitutes for actual documentation like the Emacs Lisp Reference Manual, which cannot be generated from docstrings, because the organization of the source code is hopelessly inadequate for a reference manual.

Re: Weird Lexical Syntax

#87
Wouldn’t be possible to let the LLM do the highlighting? Instead of returning code in plain text, it could return code within html with the appropriate tags. Maybe it’s harder than it sounds… but if it’s just for highlighting the code the LLM returns, I wouldn’t mind the highlighting not being 100% accurate.

Re: Weird Lexical Syntax

#88
post #87

Wouldn’t be possible to let the LLM do the highlighting? Instead of returning code in plain text, it could return code within html with the appropriate tags. Maybe it’s harder than it sounds… but if it’s just for highlighting the code the LLM returns, I wouldn’t mind the highlighting not being 100% accurate.

Would be much slower and eat up precious context window.

Re: Weird Lexical Syntax

#89
post #61
post #46

Earlier quoted context omitted.

Having a simple syntax might be fine for computers but syntax is mainly designed to be read and written by humans. Having a simple one like lisp then just makes syntactic discussions a semantic problem, just shifting the layers. And I think an complex syntax is far easier to read and write than a simple syntax with complex semantics. You also get a faster feedback loop in case the syntax of your code is wrong vs the…

I don't understand your distinction between syntax and semantics. If the semantics are complex, wouldn't that mean the syntax is thus complex?

lisp's syntax is simple - its just parenthesis to define a list, first element of a list is executed as a function.

but for example a language like C has many different syntaxes for different operations, like function declaration or variable or array syntax, or if/switch-case etc etc.

so to know C syntax you need to learn all these different ways to do different things, but in lisp you just need to know how to match parenthesis.

But of course you still want to declare variables, or have if/else and switch case. So you instead need to learn the builtin macros (what GP means by semantics) and their "syntax" that is technically not part of the language's syntax but actually is since you still need all those operations enough that they are included in the standard library and defining your own is frowned upon.

Re: Weird Lexical Syntax

#90
post #62
post #43

Earlier quoted context omitted.

There are 3 things I find funny about that comment: ML didn’t have single-line comments, so same level of surprising limitation. I’ve never heard someone refer to C as “expressive”, but maybe it was in 1972 when compared to assembly. And what bearing does the comment syntax have on the expressiveness of a language? I would argue absolutely none at all, by definition . :P

> ML didn’t have single-line comments, so same level of surprising limitation. It is not quite clear to me why the lack of single-line comments is such a surprising limitation. After all, a single-line block comment can easily serve as a substitute. However, there is no straightforward workaround for the lack of nested block comments. > I’ve never heard someone refer to C as “expressive”, but maybe it was in 1972 whe…

> Fortran 77 lacked function pointers

But we did have dummy procedures, which covered one of the important use cases directly, and which could be abused to fake function/subroutine pointers stored in data.

Post reply on HN