5 ms·
I like vectorized languages -- I know R fairly well, and used to use Matlab. J's syntax, where everything is a single character, kind of turns me off. Is that
by chubot 12y ago
I like vectorized languages -- I know R fairly well, and used to use Matlab.
J's syntax, where everything is a single character, kind of turns me off. Is that incidental or is the syntax essential to the language? (In the case of Lisp, the "weird" syntax isn't incidental but rather essential, since code is data)
If it's incidental, I'd like to see some elegant J programs "written out" with some more friendly syntax.
EDIT: If you want a laugh, download the source for J, and run wc -l .c .h.
http://www.jsoftware.com/source.htm http://www.jsoftware.com/source.htm
- minikomi 12y agoCheck out Tracy Harms's talk: http://www.infoq.com/presentations/j-language http://www.infoq.com/presentations/j-language Or, perhaps, this chapter of the (rather dense) "Learning J": http://www.jsoftware.com/help/learning/03.htm http://www.jsoftware.com/help/learning/03.htm
- huehue 12y agoI guess it's a matter of taste. As someone versed in both APL and K/Kona, J's syntax puts me off as well.
- Avshalom 12y agoJ suffers vs APL/K. The verb trains; number of verbs vs number of available symbols; variable lengths and semantic baggage we bring to various symbols contribute to a much worse 'line barf problem'. I understand why Iverson went with ascii but frankly I don't even know APL beyond 'advanced calculator' level but every time I look at an APL program it just seems cleaner.
- seanstickle 12y agoThis is my difficulty with J as well. APL has a better mental "feeling" for me, more like mathematical symbols. Oftentimes, these are pretty direct. Want to drop the first element of a vector? APL: 1 ↓ 1 2 3 4 5 J: 1 }. 1 2 3 4 5 The APL version looks like a drop to me. The J version looks like two characters that I have to remember the meaning of. I'm sure if I was deeply proficient at J, the two-characters would stand out by their meaning, but it's hard for me to get that far when APL is so much cleaner for me to read.
- klibertp 12y agoThe APL version looks like addition (cons, prepending value to a list) to me. The point being that you have to learn the meaning of symbols anyway, no matter which character set they use. Going for easier input (from the keyboard) and sacrificing a bit of legibility for this is a perfectly fine design trade off to me.
- judk 12y agoOf course APL is cleaner. But it requires a special keyboard. J tried to work around that, and flopped. The language need the aliases to be learnable.
- eggy 12y agoThere are aliases built-in and you can define your own. Drop is built-in. To borrow an example above: 1 drop 1 2 3 4 5 NB. this is how to comment 2 3 4 5 NB. drop is }. in J Exactly how did it 'flop'? Popularity, or your understanding of it? Math symbols are cryptic, and Math is not popular, but I would not want to write: "The derivative of x with respect to t" everytime instead of, dx/dt everytime I needed to write a formula. I am sure beginners find 'for' ambiguous unless they have experience with programming as in 'for i = 1 to 10'. It's syntax you are highlighting, not meaning. People extoll the brevity of Haskell, and other functional languages, because they take the time to understand its syntax. J has been around a lot longer, and was created by some very smart people. I didn't choose it for its job market or popularity, but to expand my mind, and further my mathematics studies.
- klibertp 12y ago> where everything is a single character Most things in J are actually two characters, take a look at the Vocabulary (http://www.jsoftware.com/help/dictionary/vocabul.htm http://www.jsoftware.com/help/dictionary/vocabul.htm) > I'd like to see some elegant J programs "written out" with some more friendly syntax The problem with J is that the syntax is highly context sensitive, not the length of identifiers. See here: http://www.jsoftware.com/jwiki/Guides/Language%20FAQ#Guides.2FLanguage_FAQ.2FJ_BNF.Is_there_a_BNF_description_of_J.3F http://www.jsoftware.com/jwiki/Guides/Language%20FAQ#Guides.... Also, you can use aliases for every word, which are defined in stdlib. You can write "each", "cut" etc. if you want. The reason nobody does that is a little complex. J is suited for exploratory programming and rapid prototyping. This means that expressive power per character should be as high as possible - and J delivers on this promise. Also the standard J words you can see in the Vocabulary are all there is to J. Everything else is always defined in terms of those and you can't define words with symbolic names, like you can in Haskell, OCaml etc. - so once you know those, you can say you know the language. And as for reading J code, it's meant to be read with the help of the J system: you have at least three possible representation to choose from when viewing J code, and you have ability to evaluate each subexpression to see what it does. Anyway, J is hard to learn, but after initial hump it's a pleasure to write, and then after a while it becomes possible to read it. In exchange for this difficulty level you get incredible expressive power and performance.