Log in

No account? Create an account
Programmer Language Discussions - Rat Ramblings — LiveJournal [entries|archive|friends|userinfo]

[ website | My Website ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Programmer Language Discussions [May. 18th, 2005|03:58 pm]
[Current Mood |geekygeeky]

When language wonks* compare their various languages, unlike other guys, it's all about being small. I found this exchange in a wiki discussion of higher-order functions:

To compute the inner product of two vectors:

a = [ ... ] # your vector here
b = [ ... ] # your other vector here
d = map( (lambda p, q: p * q), a, b ) # work out the products
e = reduce( (lambda x, y: x + y), d, 0 ) # sum them up

I love Python.

sum = a.zip(b).inject(0) { |s, (x,y)| s + x * y }

Yeah, and that's why I prefer Ruby.

innerProd = (sum .) . zipWith (*)

Or Haskell ;)


Or J. >:)

Now, I fully expect someone to come up with a three character solution for Matlab or something. But, if you compute lots of inner products (and hey, who doesn't!) you now know that J is a great language for you! ;)

*Language wonk is not a derisive term. No, really.

[User Picture]From: chipuni
2005-05-19 01:01 am (UTC)
Where can I learn more about J? I haven't heard about that one before...
(Reply) (Thread)
[User Picture]From: nicodemusrat
2005-05-19 05:40 pm (UTC)
J is an interesting functional language descended from APL.
Here's links to download it, find documentation, or see some discussion.
(Reply) (Parent) (Thread)
[User Picture]From: drfgeek
2005-05-19 06:37 am (UTC)
Just curious; what do you think about Perl?
(Reply) (Thread)
[User Picture]From: nicodemusrat
2005-05-19 05:45 pm (UTC)
I use Perl regularly and find that it works well, but I'm still not really fond of it as a language. It's non-intuitive (since there are so many different ways to do things, it's hard to guess; sort of a lack of orthogonality) and difficult to maintain (it requires great discipline by the programmer to keep code comprehensible and consistent).

But, despite its flaws, I must say that it lives up to the first part of its name: Practical.

I'd like to learn more Python so that I can eventually use that as my scripting language of choice.

And you?
(Reply) (Parent) (Thread)
[User Picture]From: drfgeek
2005-05-19 05:53 pm (UTC)
I'm still a newb to programming. Once we got to object oriented programming in my Programming class, my grades really fell out(still passed with a C though). But I think that was mostly due to the fact that we were doing 3 hour assignments in UML for only 10 points; too much effort for too little reward, ya know?
(Reply) (Parent) (Thread)
[User Picture]From: nicodemusrat
2005-05-20 04:53 am (UTC)
Ick. Don't blame ya.

UML isn't really programming. That's like taking a creative writing course and then doing nothing but writing outlines.

There's a common saying which I think is fairly accurate: Perl is the duct tape of programming languages. Handy, inelegant, and flexible.

My language of choice, in case you're curious, is C++.
(Reply) (Parent) (Thread)
[User Picture]From: drfgeek
2005-05-20 05:01 am (UTC)
It wasn't ALL UML. There were some Javascript labs, but that's it. Personally, I think if I had taken a real programming class (like C++) I wouldn't be burnt as I currently am with programming. Damn prerequisits.
(Reply) (Parent) (Thread)
[User Picture]From: nicodemusrat
2005-05-20 10:20 pm (UTC)
Yeah. Definitely give it another chance. (Javascript is not a terribly flexible or elegant language to have to start with, either... An odd choice.)

My language opinions (not that you asked! ;)

C++ is a good solid language with nice mid-level features. Powerful and lets you construct things how you want to (which cuts both ways). I like that freedom and flexibility.

Java (and modern Pascal) is good for learning a "pure" object-oriented approach. It has a formal and restrictive tendency, which might or might not be to your taste.

Python is an elegant higher-level language, sporting a clean syntax and some advanced concepts. It's younger, not as optimized, but quite approachable. It would be a cool language to learn early.

Lisp is a good language to learn but not to use. It embodies concepts that are advanced and fundamentally different. But its minimal and repetitive syntax are not very practical; it has the beauty of abstract mathematics and a similar detachment from real world problems.
(Reply) (Parent) (Thread)
[User Picture]From: traveller_blues
2005-05-19 05:51 pm (UTC)
My housemate said it best:

"Programming in line noise." -:D

(Reply) (Parent) (Thread)
[User Picture]From: foobart
2005-05-19 07:22 am (UTC)
Now, I fully expect someone to come up with a three character solution for Matlab or something.

I think the best you can do in MatLab/Octave is 5 characters:


Of course, if you don't want to spew the result to stdout, you need a 6th character...
(Reply) (Thread)
[User Picture]From: nicodemusrat
2005-05-19 05:46 pm (UTC)
Well done. :) You've still whittled a couple characters off the J example.
(Reply) (Parent) (Thread)
[User Picture]From: harlequeen
2005-05-19 07:33 am (UTC)
I spend a lot of time debugging code. So I love python. It's a bit more long winded, but to the coders out there. "Obfuscate this!"

Also the python code has the assertion lines in it, where the other examples do not.

But then I also know that this is somewhat tongue in cheek.
(Reply) (Thread)
[User Picture]From: nicodemusrat
2005-05-19 05:48 pm (UTC)
From what I've seen of it, Python appears to meet my tastes for language "beauty". I'd like to get a chance to learn more Python and use it at work.

And, yeah, the Python was part of the larger original article. So it includes comments, declarations, and such trivialities. :)
(Reply) (Parent) (Thread)
[User Picture]From: polrbear
2005-05-20 06:30 am (UTC)
I had not heard about J, I will have to look into that one. I used to use C++ but, its been all java for the last (many many) years.
(Reply) (Thread)