User talk:Marco Sulla

From Rosetta Code

Language

I removed your edit to the user page of the person you are at odds with about 99 bottles as it had unacceptable language.

Please, if you must disagree then do so without the name calling. --Paddy3118 (talk) 20:10, 28 February 2020 (UTC)

Hi Paddy. Sorry, but I'm a bit confused. What in my post you consider "unacceptable language"?
Marco Sulla - talk - GitHub 20:25, 28 February 2020 (UTC)
Use of r*Yard. --Paddy3118 (talk) 03:49, 29 February 2020 (UTC)
Ah. Ahahah... There's a misunderstanding. I wanted to say "Buon Anno in _ritardo_", and I wrongly supposed that in English was the same. Now I searched on Google and the correct phrase is "Belated Happy New Year".
Marco Sulla - talk - GitHub 14:21, 29 February 2020 (UTC)

99 Bottles

First things first - as far as I know you are not the administrator/moderator of the Rosseta Code. I am missing something?

Yep. Your "99 bottles" code is clever. And hackish. And weird. To be serious: you don't want such code in your pacemaker (an small medical device to force heart pulses) if you have one installed inside your body. To be more serious: Python doesn't conform to IEC62304.

Your code shows "how to use Python in (seemingly) serious functional way". Nice try. Lack of comments, some PEP8 violations, too long.

> This is your opinion. You are free to think as you want, but I don't think you should put it in a wiki.

Point taken. It is my opinion. Actually I had written the simplest (but naïve) "99 Bottle" in Python. There is no reason (see the very first line) to think about what you think. Nevertheless, in spare time some changes to the "preamble" will be done - esp. "in my opinion" will be added.

> 2. this solutions is [...] 4. easy for i18n and l10n; 5. open to extensions

Programming is a brain washing job. Seriously. But with IQ > 90 you should notice that that statements are used in an ironic sense. Do you seriously think about the open-close principle in "99 bottle" context? Are you really think that the problem must be translated into right-to-left languages, logographic kanji or (even more complicated) Korean language?

> Functional simplified version is much more simple for i18n.

It doesn't matter: the job must (in IT industry) be done by a professional, who generally has no idea about programming. She/he obtains text strings as input and produce text strings as output. She/he works with resources, not with code.

> Furthermore, how can a script be "open to extensions"?

Yep. There is something about you know nothing?! It is obvious: you can easily modify the "script". Add few lines, change lyric, replace 99 by 666, connect to smtp server. Anything. Why? Because the "script" is so simple, that all these things can be easily done.

> On the contrary, functional versions are extended per se, since you can put everything, not only 99, not only bottle(s) of beer, > not only on the wall, etcetera. And they are much more funny.

You must understand that I don't mind how you write programs. Just your solution shows different possibilities than I showed in my solution. Therefore, in a sense, they complement each other - mine shows how to do a simple thing in a simple (I would even say coarse) way - your how to do a simple thing in a complicated way. Which one is better? We don't need to compare. Because these are examples of Python language capabilities, not competing for who of us is an alpha male.

> If you want a real extendable version, you have to write a module or a class. An overkill IMHO for the task.

True. Anyway OOP is not-so-hard - esp. when the architecture will be planed in UML. More interesting is translate the song structure in EBNF and create a program to translate from EBNF to natural English. And/or use Huffman encoding to code the lyrics with zero redundancy.

N items of something, somewhere, that causes a lot of troubles

you are not the administrator/moderator of the Rosseta Code

Of course. Indeed I only commented your affirmations privately and fixed your code (that was not working). As you can see, a mod removed your comments, not I.

Yep. Your "99 bottles" code is clever. And hackish. And weird.

Can you please moderate your language?

Your code shows "how to use Python in (semingly) serious functional way".

Don't know why you use the quotes, since I never wrote that.

Lack of comments

Well, it's a wiki. You can add them. Or you can give me a Paypal donation, how much you want, and I'll add them :-D

some PEP8 violations

Also your code is not PEP 8 compliant: white space in blank lines. Is _impossible_ to completely adhere to PEP 8. I bet that no file in the py stlib is completely compliant with PEP 8 :-D

too long

First of all, they are only 56 lines of code. "Too long" makes me smile. Anyway, the amount of lines are augmented because I use a more readable style. Do you want it more compact?

<lang python>import io, string def generate_n_items_somewhere_song(items="bottles of beer", item="bottle of beer", where="on the wall", initial_number=99, zero_items="No more", action1="Take one down, pass it around", action2="Go to the store, buy some more"):

   strofa_tpl = string.Template(string.Template("""$i $items1 $where\n$i $items1\n$action\n$j $items2 $where\n\n""").safe_substitute(where=where))
   with io.StringIO() as song:
       for k in range(initial_number, -1, -1):
           if k == 0:  i, action, j = zero_items, action2, initial_number
           else:  i, action, j = k, action1, k - 1
           if i == 1: items1, j = item, zero_items
           else:  items1 = items
           if j == 1:  items2 = item
           else:  items2 = items
           song.write(strofa_tpl.substitute(i=i, j=j, action=action, items1=items1, items2=items2))
       return song.getvalue().rstrip()

print(generate_n_items_somewhere_song())</lang>

14 lines of of unreadable code.

There is no reason (see the very first line) to think about what you think

Excuse me, the first line of what? Can you quote?

But with IQ > 90 you should notice that that statements are used in an ironic sense.

Well, I suggest you to put false laughs, as in old sitcoms.

It doesn't matter: the job must (in IT industry) be done by a professional, who generally have no has no idea about programming. She/he obtains text strings as input and produce text strings as output. She/he works with resources, not with code.

This is ironical or not?

Taking it seriously, the function takes a number of parameters. You can pass this parameters to the function simply reading ini files that contains the localized strings: en_US.ini, it_IT.ini, de.ini... And you have to localize only 7 little strings.

On the contrary, the simple version requires to translate the entire text, two times. And furthermore it's not a simple text, is a template. Your professional must know also that (s)he have not to touch the strings with {something}. Furthermore, they have to move them appropiately, if the language requires another position in the text. And where you want to put them? In one file or in two files? Your apparent simple code makes the things much more complicated, as you can see.

you can easily modify the "script". Add few lines, change lyric [...]

Ah. So the script can be easily _modified_, not extended. Ok, my function can be modified too. If you want, I release it under LGPL :-D

You must understand that I don't mind how you write programs. Just your solution shows different possibilities than I showed in my solution. Therefore, in a sense, they complement each other - mine shows how to do a simple thing in a simple (I would even say coarse) way - your how to do a simple thing in a complicated way. Which one is better? We don't need to compare. Because these are examples of Python language capabilities, not competing for who of us is an alpha male.

I completely agree, but your interminable comments to your code, your harsh words about the works of the other people and comments about the IQ of the people seems not to conform to what you say here :-D

True. Anyway OOP is not-so-hard - esp. when the architecture will be planed in UML.

Well, thank you very much for the suggestion. I think the next time I'll write an ABC class it will be useful.

Marco Sulla (talk) 23:20, 19 January 2020 (UTC)


> First of all, they are only 56 lines of code. "Too long" makes me smile.
> Anyway, the amount of lines are augmented because I use a more readable style.
> Do you want it more compact? 16 lines of of unreadable code.
Oh, boy, sixteen LOC, ugh, ugh. I am really really impressed.
But mine is essentially only 3 lines of code (except templates).
When solving problems it is important to know what task we have to solve. The task was not about showing off your (dubious) functional programming skills. The goal was to write the lyrics of the song (by the way, not very proudly of drunken customs) - no matter how. And this means that I could even use one print(s) statement and the goal would be achieved.

Okay. Fisrt of all, this is my talk page. You can't remove all the content of it. I hope you done this by mistake.
Oh, boy, sixteen LOC, ugh, ugh. I am really really impressed. But mine is essentially only 3 lines of code (except templates).
And you are <<not competing for who of us is an alpha male>>? :-D
I wanted only to show you that the length of my code is very short. But if you measure the quality of code in number of lines, don't use Python. Use a language that allows you to write all in a single line :-D
The task was not about showing off your (dubious) functional programming skills.
Anonymous\d+, I will not tolerate another insult. Another one and I will simply ignore you forever, as you never existed.
The goal was to write the lyrics of the song no matter how
Exactly! I _completely_ agree! So, why you started to do a lesson of programming, questioning about the other's work and IQ? Why do you start a fight with the length of the code? Maybe you wrong site, you want Code Golf?
Are you seriously make all this problems for such a trivial task? Coding should be _inventive_. Coding should be _funny_. And questioning with you about the number of characters in the code is not funny at all. So please, let realize we have simply wrote trivial pieces of code of a trivial task and take it easy.
Marco Sulla (talk) 23:20, 19 January 2020 (UTC)