Live data from Hacker News

Hyperpolyglot: PHP, Perl, Python, Ruby

hyperpolyglot.org

51–58 of 58 posts

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#51
post #36

Earlier quoted context omitted.

Smalltalk definitely belongs on the list, it's the only one that takes "object-oriented" to its logical conclusion (dispatch can replace control structures). I'd suggest omitting Elisp and ObjC—they're both lackluster imitations of better languages that will do far more for the way you think, unless you happen to be developing for their captive platform (Emacs and iOS, respectively).

> Smalltalk definitely belongs on the list, it's the only one that takes "object-oriented" to its logical conclusion (dispatch can replace control structures). i believe io does this as well.

Unless I misunderstand what you mean, don't a host of languages do this? io, ruby, javascript?

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#52
post #23
post #21

Earlier quoted context omitted.

Different definitions. You seem to be thinking of programs that are valid in multiple languages. The page is more of a dictionary of language constructs.

> The page is more of a dictionary of language constructs. Which would come incredibly useful if you wanted to write a polyglot program. Why else would you use a reference like this? If you wanted to learn a language, or had to hack something in a language you don't know, you'll be better off using resources specific to given language(s).

One would use this when writing a new program or modifying an existing one in a language one doesn't know, but when one does know another one well. Seems quite obvious.

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#53
post #51
post #36

Earlier quoted context omitted.

> Smalltalk definitely belongs on the list, it's the only one that takes "object-oriented" to its logical conclusion (dispatch can replace control structures). i believe io does this as well.

Unless I misunderstand what you mean, don't a host of languages do this? io, ruby, javascript?

Ruby & Javascript have syntax defined in their parsers for control structures. for eg:

  # Ruby
  if someThing() 
    doThis()
  else
    doThisInstead()
  end

  # Javascript/Perl/etc
  if (someThing()) { doThis() }
  else { doThisInstead() }
Whereas Io & Smalltalk requires no new syntax and uses objects & messages:

  # Io
  if(someThing, doThis, doThisInstead)

  # Io like Ruby,etc
  if(something) then(doThis) else(doThisInstead)

  # Io like Smalltalk
  someThing ifTrue(doThis) ifFalse(doThisInstead) 
  
  # Smaltalk
  someThing ifTrue: [doThis] ifFalse: [doThisInstead].

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#54

Earlier quoted context omitted.

I would have liked for Go to have been included, (C style languages) not to mention Smalltalk.

Smalltalk definitely belongs on the list, it's the only one that takes "object-oriented" to its logical conclusion (dispatch can replace control structures). I'd suggest omitting Elisp and ObjC—they're both lackluster imitations of better languages that will do far more for the way you think, unless you happen to be developing for their captive platform (Emacs and iOS, respectively).

I'm pretty sure it use to have Smalltalk on there when I last looked. Its been updated a bit so must of got removed :(

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#55
post #47
post #42

Earlier quoted context omitted.

Yes, but functionally the Ruby example is the equivalent of a public member variable. Since those are public by default in PHP, there is no need to complicate the code by first making it private and then implementing a getter and a setter.

This is a kind of a semantic game. You might say they're "equivalent," but you're still doing different things — and different is very rarely truly equal. For example, the Ruby accessors could be hooked or altered later without changing the interface. Not so if you use a public variable (which Ruby doesn't have, for this very reason). The only language I know of where public variables and accessors are truly intercha…

I agree with your general point, but feel I should point out that this is possible in python using properties:

   class Int(object):
       def __init__(self, value):
           self.value = value

       @property
       def value(self):
           print("Accessing value")
           return self.value

       @value.setter
       def value(self, value):
           print("Setting value")
           self.value = value

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#56
post #51

Earlier quoted context omitted.

Unless I misunderstand what you mean, don't a host of languages do this? io, ruby, javascript?

Ruby & Javascript have syntax defined in their parsers for control structures. for eg: # Ruby if someThing() doThis() else doThisInstead() end # Javascript/Perl/etc if (someThing()) { doThis() } else { doThisInstead() } Whereas Io & Smalltalk requires no new syntax and uses objects & messages: # Io if(someThing, doThis, doThisInstead) # Io like Ruby,etc if(something) then(doThis) else(doThisInstead) # Io like Smallta…

As an aside, Haskell wouldn't need syntax for something like `if', but has it as a convenience. There's no syntax for looping, you can do that with higher-order functions.

Re: Hyperpolyglot: PHP, Perl, Python, Ruby

#58
post #29

Earlier quoted context omitted.

Yeah, #succ is something else. For example, if your object supports #succ then you can use it in ranges. e.g., (1..10), but also ("apple".."kiwis") or ('A'..'Z'). In this case, String#succ returns a string with the last alphanumeric character transformed into its successor, e.g., "apple".succ == "applef". The only time I've used it is implementing the range interface; I've never called it directly, let alone to incre…

I assume you mean "apple".succ == "applf" ?

Yes
Post reply on HN