Live data from Hacker News

“Screw it, I'll make my own” – The story of a new programming language

breuleux.net

11–20 of 74 posts

Re: “Screw it, I'll make my own” – The story of a new programming language

#11
post #10
post #5

Earlier quoted context omitted.

Well camel-case does reduce the length of the identifier without sacrificing clarity. This can help reduce line length, which, in turn, allows more files to be viewed on a single screen in splits, without wrapping or scrolling. I think this solidifies camel-case as the most practical style, if you ignore aesthetics. The underscore was invented to allow people using typewriters to underline text. I think that the hyph…

The underscore in computing was developed to be able to separate words used as part of a variable name on computers with only upper-case. Quoting https://en.wikipedia.org/wiki/Underscore#History : > IBM's report on NPL (the early name of what is now called PL/I) leaves the character set undefined, but specifically mentions the break character, and gives RATE_OF_PAY as an example identifier It links to the 1964 report…

Meta characters were also added for file, unit, record, and group separators. Some may correctly argue that using these chars to structure data in flat files is a more simple and technically superior solution to the alternatives.

Still, people will stick to what they're familiar with despite the technical benefits. That's why we have CSV, TSV, JSON, etc.

I'd argue that 'most practical' is whatever format most people immediately understand at first glance. That literally means everybody, not just a small subset of programmers who already use a perticular sytling standard.

Re: “Screw it, I'll make my own” – The story of a new programming language

#12
post #5
post #2

[deleted]

Well camel-case does reduce the length of the identifier without sacrificing clarity. This can help reduce line length, which, in turn, allows more files to be viewed on a single screen in splits, without wrapping or scrolling. I think this solidifies camel-case as the most practical style, if you ignore aesthetics. The underscore was invented to allow people using typewriters to underline text. I think that the hyph…

"Well camel-case does reduce the length of the identifier without sacrificing clarity"

I think camelCase easily beats underscores, but I also think it can reduce clarity a bit as soon as one uses abbreviations or mnemonics that commonly are written in all caps in identifiers.

Do you name your class IoChannel or IOChannel? For some, the former is a channel on a moon of Jupiter.

Do you name your variable classId or classID? For some, the former is related to Freud, so one could expect to see classEgo and classSuperego, too.

Made up examples? Yes, but I don't think you can fully ignore aesthetics; I find that camelCasing such terms as ID, IO, XML and HTML in identifiers sacrifices clarity. 'Id' in particular makes me cringe whenever I see it (yes, that makes me a bit of a snob, but I simply cannot get used to it). That certainly applies to cases where a common abbreviation also is a word or easily read as such.

On the other hand, I also think keeping such abbreviations all uppercase in CamelCase identifiers sometimes "doesn't look right", and "doesn't look right" aka "aesthetically ugly" distracts me from understanding code.

Also, the argument that "showing more" implies "more practical" isn't that strong. If it did, we could take an idea from colorForth and remove spaces, replacing them by color or font changes. We also could use multiple statements on a line.

I think I would prefer a language that allowed hyphens and punctuation in identifiers (the latter are really useful for such conventions as using a trailing '?' to indicate a method that tests a Boolean condition, a trailing '!' to indicate methods that mutate their arguments. I also like the Dylan convention of using asterisks to indicate class names.

That is 'think', though, because I don't use one for practical reasons such as the availability of libraries.

Re: “Screw it, I'll make my own” – The story of a new programming language

#13
Curious. Are there examples of programming languages that allow spaces in identifiers? Obviously, it would need to be designed for that.

I'm against the case-sensitive nature of some programming languages, and file systems for that matter. While it makes sense in a computing context (faster), you invent a new mode, just for the computer..

(Fortran was probably case-insensitive because upper-case letters were used first, and when lower-case letters were introduced, care was taken to neatly map them into the character set bit-wise, so one could simply clear the sixth binary digit to turn a lower-case letter into its upper-case equivalent, then continue the string comparison.)

Of course, with Unicode, you need a more complicated check, or you could just ignore Unicode in the language itself for identifiers, yet allow it in literals, data types, etc.

Re: “Screw it, I'll make my own” – The story of a new programming language

#14
post #10

Earlier quoted context omitted.

The underscore in computing was developed to be able to separate words used as part of a variable name on computers with only upper-case. Quoting https://en.wikipedia.org/wiki/Underscore#History : > IBM's report on NPL (the early name of what is now called PL/I) leaves the character set undefined, but specifically mentions the break character, and gives RATE_OF_PAY as an example identifier It links to the 1964 report…

Meta characters were also added for file, unit, record, and group separators. Some may correctly argue that using these chars to structure data in flat files is a more simple and technically superior solution to the alternatives. Still, people will stick to what they're familiar with despite the technical benefits. That's why we have CSV, TSV, JSON, etc. I'd argue that 'most practical' is whatever format most people…

"whatever format most people immediately understand at first glance"

Certainly that's a useful starting point. The problem is in figuring that out when there are multiple, roughly similar representation.

But it also depends on the goal. Sometimes it's better to learn a new format (Einstein notation, bra-ket notation, copy editing and proofreading symbols, modern staff notation for music, shorthand, etc.) than to use a system that a larger subset of people will understand immediately.

Forth is an example of a programming language which is developed for programmer productivity, on the assumption that the programmer will put in the effort to be proficient in the language.

Re: “Screw it, I'll make my own” – The story of a new programming language

#15
post #3
post #2

[deleted]

> I don't understand why people would use a dash "-" inside a symbol No need to use the shift key. At the levels of efficiency that a good language can reach, this matters. Also, dashes match established lexicographical conventions better than underscores because dashes look like hyphens.

In COBOL, dashes are the way of joining words. Very readable actually.

Re: “Screw it, I'll make my own” – The story of a new programming language

#16
post #12
post #5

Earlier quoted context omitted.

Well camel-case does reduce the length of the identifier without sacrificing clarity. This can help reduce line length, which, in turn, allows more files to be viewed on a single screen in splits, without wrapping or scrolling. I think this solidifies camel-case as the most practical style, if you ignore aesthetics. The underscore was invented to allow people using typewriters to underline text. I think that the hyph…

"Well camel-case does reduce the length of the identifier without sacrificing clarity" I think camelCase easily beats underscores, but I also think it can reduce clarity a bit as soon as one uses abbreviations or mnemonics that commonly are written in all caps in identifiers. Do you name your class IoChannel or IOChannel? For some, the former is a channel on a moon of Jupiter. Do you name your variable classId or cla…

> I think camelCase easily beats underscores, but I also think it can reduce clarity a bit as soon as one uses abbreviations or mnemonics that commonly are written in all caps in identifiers.

For my money, I'll take Python conventions of CamelCase for a few things and underscores for the rest. I find underscores a lot more readable (the omnipresence of CamelCase is one of these things that irk me about C#, though it's not as bad as the mutant mix that is Capitalized_underscore which you see in some OCaml codebases).

Re: “Screw it, I'll make my own” – The story of a new programming language

#17
post #13

Curious. Are there examples of programming languages that allow spaces in identifiers? Obviously, it would need to be designed for that. I'm against the case-sensitive nature of some programming languages, and file systems for that matter. While it makes sense in a computing context (faster), you invent a new mode, just for the computer.. (Fortran was probably case-insensitive because upper-case letters were used fir…

> Curious. Are there examples of programming languages that allow spaces in identifiers? Obviously, it would need to be designed for that.

At least Tcl allows spaces in identifiers, but to 'use' such identifiers one does have to add a bit of extra 'sugar' to prevent the code parser from interpreting the spaces as token separators:

Example of spaces in a variable name:

    $ rlwrap tclsh 
    % set "var name with spaces" "contents of the variable"
    contents of the variable
    % puts ${var name with spaces}
    contents of the variable
    % set "var name with spaces"
    contents of the variable
Example of spaces in a procedure (function) name (the first line defines the procedure):

    % proc {my space proc} {string} {puts "'my space proc' called with string='$string'"}

    % {my space proc} "hello how are you"
    'my space proc' called with string='hello how are you'
    % "my space proc" "the quick brown fox"
    'my space proc' called with string='the quick brown fox'
    % set pn "my space proc"
    my space proc
    % $pn "this that and the other"
    'my space proc' called with string='this that and the other'
So there you have at least one example.

Re: “Screw it, I'll make my own” – The story of a new programming language

#18
> There is a bit of a catch-22 in language design where the more a language is used, the clearer it becomes which parts of it are problematic and should change, but the harder it gets to actually change them. To hone a language you must use it, but applications require that a language's features remain stable, robust, set in stone, and therefore as imperfect as they were at that moment. Furthermore, the more delays are suffered in fixing flaws or plugging holes, the more likely it gets that a dependency is fostered upon them. The options you do not explicitly and insistently leave open, tend to close and seal themselves before you know it.

This rings very true. I look at Ceylon and the features I'm most jealous of are things that Scala would and should just do, except for the need to retain compatibility with 10 years of existing applications and libraries, so instead they're enhancement proposals for the version after the version after the next version, and in the meantime we get by with macros that more-or-less cover the most important use cases. And Scala is relatively young as languages go - its warts are nothing to those of, say, C++. Sometimes I wonder if language design can only advance by new languages killing existing languages - past a certain point it seems impossible to change a language in the ways that it needs to be changed to become good.

Re: “Screw it, I'll make my own” – The story of a new programming language

#19
post #13

Curious. Are there examples of programming languages that allow spaces in identifiers? Obviously, it would need to be designed for that. I'm against the case-sensitive nature of some programming languages, and file systems for that matter. While it makes sense in a computing context (faster), you invent a new mode, just for the computer.. (Fortran was probably case-insensitive because upper-case letters were used fir…

Algol 68 allows spaces in identifiers. That means one has to use one of the "stropping" techniques to distinguish keywords from identifiers--case stropping (IF p THEN foo ELSE bar FI), quote stropping a la the old IBM Algol F Algol 60 compiler ('if' p 'then' foo 'else' bar 'fi'), and at least one other I don't remember offhand.
Post reply on HN