Live data from Hacker News

Rust, Macros, λ-calculus/Church numerals, oh my

github.com

71–80 of 82 posts

Re: Rust, Macros, λ-calculus/Church numerals, oh my

#71
post #30

Earlier quoted context omitted.

100% this. To understand code written with Greek letters you'd also need to understand the author's intentions for using said letters. Is mu an average or coeff of friction? Why should I lean on a crutch of context for a casual skim of code? It doesn't help readability and it surely isn't enjoyable to write.

It all depends on context. Short identifiers absolutely help readability. I feel like some people absolutely go too far with overly verbose variable names, especially in Java or C#. Notation matters. What if I told you that to add two numbers you had to write it out as plus(number, number)? Clearly you'd riot. The reason people complain about short IDs is because they're not used to it, but there are a lot of domains…

I thought Racket (starting with BSL) to incoming freshman at Northeastern University, and they would nearly riot every year when we tell them it's `(+ 1 1)` for the next 4 months (at least).

Re: Rust, Macros, λ-calculus/Church numerals, oh my

#72
post #30

Earlier quoted context omitted.

100% this. To understand code written with Greek letters you'd also need to understand the author's intentions for using said letters. Is mu an average or coeff of friction? Why should I lean on a crutch of context for a casual skim of code? It doesn't help readability and it surely isn't enjoyable to write.

It all depends on context. Short identifiers absolutely help readability. I feel like some people absolutely go too far with overly verbose variable names, especially in Java or C#. Notation matters. What if I told you that to add two numbers you had to write it out as plus(number, number)? Clearly you'd riot. The reason people complain about short IDs is because they're not used to it, but there are a lot of domains…

[deleted]

Re: Rust, Macros, λ-calculus/Church numerals, oh my

#73
post #24

Earlier quoted context omitted.

Because people in non-English-speaking countries are perfectly within their rights to name source code entities in their native language instead of either having to mangle words into ASCII representations (possibly even leading to ambiguities in case of near-homonyms that have identical ASCII bastardizations!) or being forced to awkwardly translate domain terminology into English which is a task that may be any of th…

I'm not disagreeing with you because sometimes it's just project requirements - but as a developer in a non-English-speaking country - the idea of writing code in a non-English language is ridiculous to me. Programming languages and standard libraries are written in English, programming terminology is invented in English, the international community adopted english as a defacto standard, almost all third party APIs e…

Sure one should stick with English when working on an industrial standard codebase that many people on the western hemisphere will work on. Unless off course these folks are limited to the southern continents where Spanish or French might be more appropriate.

And outside the western hemisphere where off course if the code base is unlikely cross, say, outside the Chinese borders, where Mandarin would be more appropriate.

Then there are non-industrial standard codebases, say a hobby project. I’m sure that somewhere in Guinea-Bissau there is a 17 year old learning Python at this moment, really happy that they can write Portuguese special characters as variable names in python 3 (if only the documentation had been translated to Portuguese).

Just because English is the appropriate language in by far the majority of cases, does’t mean we should deny the possibility of not using it.

Re: Rust, Macros, λ-calculus/Church numerals, oh my

#74
post #2

While it's definitely cute and amusing, this is exactly why languages that specify their source code in non-ascii encodings are a bad idea. Fully 92.6% of working programmers have no idea how to produce a λ or γ on their input device of choice. Maybe a third of those could eventually find it with a character picker tool. Java started this (in the unicode era anyway -- yeah yeah, APL). The community quite sanely rejec…

> While it's definitely cute and amusing, this is exactly why languages that specify their source code in non-ascii encodings are a bad idea. Clearly full Unicode-enabled source code is the future, just look at how amazing it can be: http://baldi.me/blog/emoji-in-sql

Oh man, I really like this but I can definitely imagine a whole lot of people who would hate this.

Re: Rust, Macros, λ-calculus/Church numerals, oh my

#75
post #11

Earlier quoted context omitted.

I disagree. I looked through the source code to Principia a while back, and it makes really effective use of Greek script, black-letter script, math symbols, etc for implementing a physics engine. (It's a mod for Kerbal Space Program that implements n-body gravitation.) It's really well written and used just enough to make things more understandable. (They've got a great units system too; it's worth reading the code…

>Here's a random selection: https://github.com/mockingbirdnest/Principia/blob/master/phy... I don't think r² as a variable name is a good idea. It may look natural for some (including myself), but for others it implies a function while not being one.

Yea, that's fair; it's definitely one of the more surprising things that they do. On the other hand, it's pretty common to pass around squared values that the math says that you ought to have taken the root of, when you know how long it takes to do that root. You're going to end up with some kind of convention for it, so it might as well be a short one.

Re: Rust, Macros, λ-calculus/Church numerals, oh my

#76

Earlier quoted context omitted.

Greek letters are good for transcribing equations that were written with Greek letters. The equations were written like that because you only get one letter per variable and you need more than 26 variables across multiple equations, which you want to be consistent. You only get one letter per variable because on paper you write down each equation about fifty times as you work with it, so it's kept short as much as po…

100% this. To understand code written with Greek letters you'd also need to understand the author's intentions for using said letters. Is mu an average or coeff of friction? Why should I lean on a crutch of context for a casual skim of code? It doesn't help readability and it surely isn't enjoyable to write.

If it's hard to write then you can just improve your editor; there are lots of ways to do that, and most of them involve improving the software rather than hardware. Having a lousy editor is no excuse!

Re: Rust, Macros, λ-calculus/Church numerals, oh my

#77
post #58

Earlier quoted context omitted.

You don't think λ-calculus deserves the symbol `λ!` in Rust? Anyone who is learning or interested in λ-calculus should be aware of what it means (that's the whole point). I generally agree we should all be so fortunate as to be able to read the code put in front of us. And you clearly know how to type a λ, you did it 6 times in your post.

> And you clearly know how to type a λ I copy-pasted it. If there is no source to copy-paste from I'd have to use google. Don't want to be forced to do either in my code.

Your computer has better tools that don't require you to google it. Even the character picker is better, since it doesn't require loading a webpage (and some operating systems have better character picker programs than others). Emacs lets you directly search for a character by name; perhaps your favorite editor has a similar capability. If it doesn't, perhaps you could improve your editor.

Re: Rust, Macros, λ-calculus/Church numerals, oh my

#78
post #13

Earlier quoted context omitted.

Hmm. What would you attack? That is, if you were writing a crate that I was thinking of using in my program, how would homographs allow you to compromise my code?

The best attack is of an alias of a popular crate. Duplicate the functionality/behavior/version number but include a subtle backdoor.

How would people end up using your evil crate though? I guess you could rely on having people copy and paste code from your documentation or tutorials, but if they just type the name then they get the original.

Re: Rust, Macros, λ-calculus/Church numerals, oh my

#79
post #61
post #37

Earlier quoted context omitted.

that only opens the emoji picker, not a generic unicode picker.

It has Emoji, old school smileys and Symbols where you can actually find stuff like the lambda symbol (at least in Windows ver 1903)

Those don't seem to be covered by the search function.
Post reply on HN