ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Julia question
I recently started looking at Julia. As I slogged through the HTML file that's included in the julia-doc package, there's mention of two ways to perform integer division (you know, "9/4 = 2"): "div(9, 4)" and "9 :^h- 4" or ":^h-(9, 4)" (where ":^h-" is my way of representing the division sign we learned in grade school). (See `integer divide' in the attached table from the Julia docs.)
Since keyboards don't provide that symbol any more, and the only way to obtain it in the julia(1) tool is the tab completion of "\div" (i.e. "9 \div<tab> 4") is there a good reason for even providing a means of using non-keyboard characters in Julia programs? I mean other than, perhaps, making APL programmers more comfortable? I can see they could allow one to write code that actually appears like real mathematical equations -- there are a ton of these tab-completed symbols one can specify -- but can that actually be practical? Or have I gotten so used to using things like "floor(9 / 4)" (or similar) that my mind is just a little boggled by this?
Any Julia folks out there who can provide some insight?
Common keyboards are limited to as few as 84 or as many as 104 keys, depending. Even if each key has two possible characters and we allocate none for things like return, shift, etc there is no way to include all of the possible characters on this keyboard. That does not make the symbol invalid or impossible to use. When you start to consider all of the natural language character sets that can be in use for coding on the planet things get even more interesting! Clearly, limiting the set of characters that can be used for coding to ONLY those directly available with a single or double hit on a common keyboard is prohibitively restrictive. It may have made sense back when all of the coding was done by people with one common language, but we grew beyond that LONG ago. Moreover we gained the power, of necessity, to reprogram our I/O devices and create multi-use keystroke sets to add additional levels of characters.
The symbol you are seeking should be available, just using a different key sequence. If not, it can be programmed to a set of keystrokes with the proper utility. It is common for coders to do such customization for specific editors, IDEs, or languages to achieve superior productivity.
I would not give up on the symbol, or disrespect the language, just because your keyboard does not make it easily available. Perhaps all you need is a Julia coding specific keyboard, or macro set.
Julia has a tab completion for unicode symbols. I don't have it installed on this machine to test it for you but I think if you type:
\div followed by a tab it might give you what you want. (U+000F7)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Original Poster
Rep:
Quote:
Originally Posted by SoftSprocket
Julia has a tab completion for unicode symbols. I don't have it installed on this machine to test it for you but I think if you type:
\div followed by a tab it might give you what you want. (U+000F7)
I'm aware of that. But unless I switch to an IDE that's Julia-aware (Emacs isn't and neither is Geany), it's only available when using julia(1).
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Original Poster
Rep:
Quote:
Originally Posted by wpeckham;6174434[snip
The symbol you are seeking should be available, just using a different key sequence. If not, it can be programmed to a set of keystrokes with the proper utility. It is common for coders to do such customization for specific editors, IDEs, or languages to achieve superior productivity.
I would not give up on the symbol, or disrespect the language, just because your keyboard does not make it easily available. Perhaps all you need is a Julia coding specific keyboard, or macro set.
I've seen APL keyboards before... but not for about 35 years.
I'm not giving up on the symbol... or disrespecting the language. I'm curious whether using the myriad of Unicode/tab-completion symbols is all that common (or really necessary). I suspect that one will find that there is Julia source code out there that looks the output of TeX's math mode which would be very readable by a mathematician but a bear to modify without learning a lot tab completion sequences. I've seen some that allow you to use a turtle (or a camel, etc.) as a variable. I'm not sure I want to read a file full of emojis -- and I've seen code example online that look like that -- and try and makes sense of the algorithm. From my current perspective, it would seem like going back to an old document using TeX/LaTeX after not having used it for quite a while and needing to modify equations---I'd be running to grab a copy of the TeXbook. I'm simply wondering whether coding in Julia using all the mathematical symbols available as tab-completion codes is actually popular. Personally, I think I'd would find it with a long and arduous learning curve and, even after the climb, a horribly slow way to code ("Is it '\xyz<tab>'? Aw heck.. that's not it. Maybe it's..."). Perhaps after trying it out to perform some real task it will all become clear.
Math operators and graphical variables aside, there seems to be some real advantages to Julia. Being compiled, it whups Python's backside in a lot of computational applications when the amount of data gets large. It's seen as a possible successor to Fortran and almost as fast as that old warhorse (faster in some things according to some benchmarks). Things that got me interested in looking at it in the first place. There's a lot to learn about it, though.
I know. It's right there in the operator list. My question wasn't really about how one uses that function. It was whether there's a lot of people actually using the division symbol. Or any of the other special/math symbols. I wonder when I'll encounter a Julian source file where the algorithm is perfectly readable but none of the explanatory comments are. That'll be strange---sort of like the pre-AltaVista days of reading foreign language technical journals and saying to yourself "Yeah... I think I see what they're up to but until I can translate the prose...".
I found that out after originally posting. It's not something that I would have naturally looked for in Emacs. At least not while editing a chunk of Julia. It usually is able to discern what language you're coding in and Julia isn't one of the ones it recognizes automatically. It seems I might have to learn enough Lisp to get Emacs to recognize the "#!/usr/bin/julia" shebang and say to itself: "A Ha! Julia! Set TeX input mode." :^D
Someone's come up with a special monospaced font for Julia that is intended to make the special characters look better. I've installed it and it look pretty good... even for non-Julia code.
It seems I might have to learn enough Lisp to get Emacs to recognize the "#!/usr/bin/julia" shebang and say to itself: "A Ha! Julia! Set TeX input mode." :^D
You'll probably want to install julia-mode.el, looks like it has something to handle math symbol insertion:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.