[Pharo-users] Re: Wow - Chat GPT understands Smalltalk

2023-03-15 Thread Esteban Maringolo
It is good with boilerplate code (e.g. SQL queries) or general algorithm
structures. But i.e. I asked it to write me a method to parse a string
(e.g. ISO 8601) and turn it into a DateAndTime, and then asked to write it
as an Excel formula.

It works much better when you can spot the mistakes, you can tell them to
add some considerations to the code or even point the LLM to correct a
message selector to something else. Sometimes you ask it to reprogram
something and it won't do it, as if it doesn't understand what you're
asking.

It is not an expert yet, but it is a great assistant. The only thing is
that is sure is that it will get better.

Best regards,

Esteban A. Maringolo


On Wed, Mar 15, 2023 at 7:49 AM Tim Mackinnon  wrote:

> "#isOdd is not Smalltalk" - doh, I typed it in on my phone and so it just
> goes to show that it highlights the flaw in chatGPT that others have called
> out in other languages. I had meant to find some trickier code samples to
> see how well it does...
>
> Still, it is very interesting how it reasons on this stuff - and I wonder
> if there is way to tell it about these mistakes? For example is it reading
> this email (or will it in the future) and understand that it is #odd and
> not #isOdd.
>
> Tim
>
> On Wed, 15 Mar 2023, at 9:57 AM, Joachim Tuchel wrote:
>
> interesting
>
> #isOdd is not Smalltalk, neither Pharo 10 nor VAST 12  understands this
> message ;-)
>
> If I evaluate your snippet -replacing #isOdd for #odd, I get an empty
> Collection. The divisible by 4 things is somewhat interesting, because (1
> to: 100 by: 4) is amn interval 1,5,9 etc ;-)
>
> So chatGPT is probably a newbie in Smalltalk. Interesting is how logical
> the explanation sounds, you're tempted to believe it...
>
>
> Joachim
>
>
>
> Am 15.03.23 um 10:45 schrieb giorgio ferraris:
>
> it's interesting to see how the answer changes with only a small change on
> the question:
>
> (1 to: 100 by: 4) reject: [:i | i isOdd]
>
> gives:
>
> The code creates a collection of numbers from 1 to 100, incrementing by 4
> at each step using the to:by: message. It then applies the reject: message
> to this collection, which returns a new collection containing all elements
> for which the given block evaluates to false.
>
> In this case, the block is [i | i isOdd], which checks whether a given
> number i is odd using the isOdd method. So the result of the entire
> expression is a collection of all even numbers between 1 and 100 that are
> divisible by 4.
>
> ciao
>
> giorgio
>
>
> On Wed, Mar 15, 2023 at 8:07 AM Tim Mackinnon 
>  wrote:
>
> Of course everyone is talking about ChatGPT, and I saw a post to
> ExplainCode and didn’t expect it to understand Smalltalk, so was impressed
> that it does! Presumably the Tonel Smalltalk code on GitHub has helped
> along with numerous articles?
>
> Try it out: https://whatdoesthiscodedo.com/
>
> I gave this simple example: (1 to: 100 by: 3) reject: [:i | i isOdd]
>
> And got this (neat eh):
>
> The code above is written in the programming language Smalltalk.
>
> It creates a collection of numbers from 1 to 100, incrementing by 3 at
> each step. This is done using the "to:by:" construct where the starting
> value is 1, the ending value is 100, and the increment is 3.
>
> The resulting collection is then filtered using the "reject:" method,
> which takes a block of code as an argument. In this case, the block checks
> whether each element (denoted by the variable i) is odd by using the
> "isOdd" method. If an element is odd, it will be rejected from the
> collection.
>
> So, the final result is a collection of all even numbers from 1 to 100,
> incrementing by 3 at each step.
> Share this explanation with colleagues: whatdoesthiscodedo.com/g/a0ec56e
>
> --
>
> ---
> Objektfabrik Joachim Tuchel  mailto:jtuc...@objektfabrik.de 
> 
> Fliederweg 1 http://www.objektfabrik.de
> D-71640 Ludwigsburg  http://joachimtuchel.wordpress.com
> Telefon: +49 7141 56 10 86 0Fax: +49 7141 56 10 86 1
>
>
>
>


[Pharo-users] Re: Omnibase/Monibase repository removal

2022-08-23 Thread Esteban Maringolo
There is a comment in one of the commits from 2005 (OmniBase-jf.2) that
suggests that OmniBase had a free with restrictions license:

http://www.squeaksource.com/@dZ70JMB-R7RDi4-m/Ox-ysyAT

Also, licensing was messier these days, some of that mess creeps up until
today.


Esteban A. Maringolo


On Tue, Aug 23, 2022 at 2:30 PM PAUL DEBRUICKER  wrote:

> From my reading, it seems like whoever posted OmniBase to github 9 years
> ago added the MIT license without permission and the OmniBase library
> remains closed source.
>
>
>
>
> > On Aug 23, 2022, at 6:46 AM, s...@clipperadams.com wrote:
> >
> > I’m not fully understanding the issue.
> >
> >
> >
> > Is it that:
> >
> >   • The repos are violating the library license (other than the
> erroneous MIT license, which could easily be updated)?
> >
> >   • The fact that OmniBase is not open source violates a principle
> you have in continuing to host it?
> >
> > If the latter, may I suggest you offer to transfer the repo(s) to a
> willing party?
> >
>


[Pharo-users] Re: [Pharo-dev] [ANN] Pharo 10 released!

2022-04-06 Thread Esteban Maringolo
Congratulations to the core team and to the whole list of contributors!

It's always good to see Smalltalk moving forward.

Regards!

Esteban A. Maringolo


On Tue, Apr 5, 2022 at 7:40 AM Esteban Lorenzano  wrote:

> Dear Pharo users and dynamic language lovers:
>
> We have released Pharo version 10  !
>
> Pharo is a pure object-oriented programming language and a powerful
> environment, focused on simplicity and immediate feedback.
>
>
> Pharo 10 was a short iteration where we focused mainly on stability and
> enhancement of the environment :
>
>
>- Massive system cleanup
>-
>   - gained speed
>   - removed dead code
>   - removed old/deprecated frameworks (Glamour, GTTools, Spec1)
>   - All Remaining tools written using the deprecated frameworks have
>been rewritten: Dependency Analyser, Critique Browser, and many other small
>utilities.
>- Modularisation has made a leap, creating correct baselines (project
>descriptions) for many internal systems, making possible the work and
>deployment of minimal images.
>- Removing support for the old Bytecode sets and embedded blocks
>simplified the compiler and language core.
>- As a result, our image size has been reduced by 10% (from 66MB to
>58MB)
>- The VM has also improved in several areas: better async I/O support,
>socket handling, FFI ABI,
>
> Even being a short iteration, we have closed a massive amount of issues:
> around 600 issues and 700 pull requests. A more extended changelog can be
> found at
> https://github.com/pharo-project/pharo-changelogs/blob/master/Pharo100ChangeLogs.md
> .
>
> While the technical improvements are significant, still the most
> impressive fact is that the new code that got in the main Pharo 10 image
> was contributed by more than 80 people.
>
> Pharo is more than code. It is an exciting project involving a great
> community.
>
> We thank all the contributors to this release:
>
> Aaron Bieber, Ackerley Tng, Alban Benmouffek, Alejandra Cossio, Aless
> Hosry, Alexandre Bergel, Aliaksei Syrel, Alistair Grant, Arturo Zambrano,
> Asbathou Biyalou-Sama, Axel Marlard, Bastien Degardins, Ben Coman, Bernardo
> Contreras, Bernhard Pieber, Carlo Teixeira, Carlos Lopez, Carolina
> Hernandez, Christophe Demarey, Clotilde Toullec, Connor Skennerton, Cyril
> Ferlicot, Dave Mason, David Wickes, Denis Kudriashov, Eric Gade, Erik Stel,
> Esteban Lorenzano, Evelyn Cusi Lopez, Ezequiel R. Aguerre, Gabriel Omar
> Cotelli, Geraldine Galindo, Giovanni Corriga, Guille Polito, Himanshu, Jan
> Bliznicenko, Jaromir Matas, Kasper Østerbye, Kausthub Thekke Madathil,
> Konrad Hinsen, Kurt Kilpela, Luz Paz, Marco Rimoldi, Marcus Denker, Martín
> Dias, Massimo Nocentini, Max Leske, Maximilian-ignacio Willembrinck
> Santander, Miguel Campero, Milton Mamani Torres, Nahuel Palumbo, Norbert
> Hartl, Norm Green, Nour Djihan, Noury Bouraqadi, Oleksandr Zaitsev, Pablo
> Sánchez Rodríguez, Pablo Tesone, Pavel Krivanek, Pierre Misse-Chanabier,
> Quentin Ducasse, Raffaello Giulietti, Rakshit, Renaud de Villemeur, Rob
> Sayers, Roland Bernard, Ronie Salgado, Santiago Bragagnolo, Sean DeNigris,
> Sebastian Jordan Montt, Soufyane Labsari, Stephan Eggermont, Steven
> Costiou, Stéphane Ducasse, Sven Van Caekenberghe, Theo Rogliano, Thomas
> Dupriez, Théo Lanord, Torsten Bergmann, Vincent Blondeau.
>
>
> (If you contributed to Pharo 10 development in any way and we missed your
> name, please send us an email and we will add you).
>
> Enjoy!
>
> The Pharo Team
>
> Discover Pharo: https://pharo.org/features
>
> Try Pharo: http://pharo.org/download 
>
> Learn Pharo: http://pharo.org/documentation
> 
>


[Pharo-users] Re: Null Object Pattern

2022-03-21 Thread Esteban Maringolo
Being able to proxy to another object is such an important feature,
that even in ES6 (aka "Javascript") there is a Proxy object [1] that
allows you to intercept/redefine operations for that object.

In the case of Smalltalk, and coming back to the original topic of
this thread, that is even more powerful because you have first class
messages that can be resolved via DNU handling. If anything, I would
like to give the receiver of a message more control of the handling of
such a message rather than having a DNU as the last resort, or worse,
some messages that are written to be sent, but then are inlined during
execution.

Regards,

[1] 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy

Esteban A. Maringolo

On Mon, Mar 21, 2022 at 5:47 PM Tim Mackinnon  wrote:
>
> This has been an interesting thread to read on the side, and I appreciate the 
> thought provoking conversion.
>
> On Sun, 20 Mar 2022, at 6:11 AM, Richard O'Keefe wrote:
>
> An override of #doesNotUnderstand: *is* (an instance of) the problem.
> What part of "you may think you know what to forward now, but just
> wait a couple of months or install an additional package and there
> will be *more* selectors you needed to think about but didn't" is
> hard to understand?
>
>
> However I am confused by the above - as in Pharo and Dolphin (and I suspect 
> other Smalltalks) - you don't have to make your proxy a subclass of Object 
> right? If you want to forward as much behaviour as possible - you can 
> subclass ProtoObject (or equivalent). The width of methods on that is much 
> reduced (59 from a quick glance), and loading other packages doesn't tend to 
> extend at that level, so keeping things much more stable. The downside, is 
> that such objects are tricky to view in an inspector etc.  There is a mocking 
> framework in Pharo called Ghost that leverages this quite well from memory.
>
> So I think that some of the side arguments on downsides might not be quite as 
> bad as indicated.
>
> Tim
>
>


[Pharo-users] Re: Null Object Pattern

2022-03-18 Thread Esteban Maringolo
On Fri, Mar 18, 2022 at 3:24 PM Todd Blanchard via Pharo-users
 wrote:
>
> What, exactly, is inconsistent about a key message isNil being allowed to be 
> overridden?

Overrides are not the issue here.

> There is a VERY simple solution to your problem that does not involve 
> disrupting the platform.

No, it's not a simple solution.

> But you'd rather change the platform.

I'd bet that the change to inline those message sends came after the
implementation of the message sending.

> Part of the reason Smalltalk has not been the greatest platform to build 
> software on is its extreme malleability.  It is a double edged sword for 
> sure.  It is great for research.  Not so hot for actual systems development.

You say that Smalltalk is not so hot for system developments because
it's extremely malleable? What are you measuring it against?

> "The key in making great and growable systems is much more to design how its 
> modules communicate rather than what their internal properties and behaviors 
> should be. " -Alan Kay

That's exactly the point of this conversion, a user might want the
modules to communicate by means of sending messages between them,
so writes the code with that expectation and then an external thing (the
compiler) decides to do something else that involves not actually
sending the message, because it focuses on the "internal properties
and behaviors".

> The inlined methods implement key operations that I believe *should* be 
> immutable.  Because the system is implemented in terms of itself, it is not 
> very hard to completely destroy an image and render it unusable by overriding 
> the wrong message in the wrong class (try overriding #environment at the 
> class level and let me know how long before your image completely packs up 
> under a torrent of walkbacks).

It is still easy to break almost anything, without having to resort to
compiler pragmas. :-)

> If anything, I would like to see more immutable structure in the core 
> classes.  Add methods?  Always.   Casually override anything?  There be 
> dragons there.

Something like  "final" classes and "const" globals or not being able
to extend classes such as [Proto]Object?

In any case, I think the options for this inlining thing were laid on
the table, and there is a partial solution for these looking for
"semantic optimization" (as in true message sends) rather than
performance optimization (as in inlining).

Regards!

Esteban A. Maringolo



>
> On Mar 18, 2022, at 11:06 AM, s...@clipperadams.com wrote:
>
> I feel like you’ve latched onto something that is genuinely a non problem…
>
> I wouldn’t call complexity and lack of consistency a “non problem”, but it 
> sounds like for you the practical implications outweigh my 
> seemingly-somewhat-ideological/niche concerns. Is that a fair summary? In any 
> case, I appreciate your perspective.
>
>


[Pharo-users] Re: Null Object Pattern

2022-03-17 Thread Esteban Maringolo
That is great!

Is it possible to disable it for doits and other playground expressions?

Regards!

Esteban A. Maringolo

On Thu, Mar 17, 2022 at 1:23 PM Marcus Denker  wrote:
> On 17 Mar 2022, at 17:17, Richard Sargent 
>  wrote:
> A pragma might be the way to go.
>  for example.
>
>
>
> There is already the #compilerOptions: Pragma, e.g.:
>
> 
> For example this method compiled the and: as a real send:
> tt
> 
> true and: [ false ]
>
>
> On Thu, Mar 17, 2022 at 8:17 AM Esteban Maringolo  
> wrote:

>> A great trade off would be to be able
>> to enable/disable for certain things instead of it being a global
>> setting.


[Pharo-users] Re: Null Object Pattern

2022-03-17 Thread Esteban Maringolo
Just to add another argument in favor of not inlining some message
sends, is for instance in things like Glorp you need to use a special
selector for #and:/#or: message sends, breaking not only the naming
conventions but also the polymorphism.

E.g. you have to use #AND: and #OR: to avoid inlining.
db read: YourClass where: [:inst | inst name = 'John' AND: [inst color
= 'blue' OR: [inst color = 'red']]].

This is not only annoying, it also causes that if you want to to use
something else as a backend (instead of Glorp), your block doesn't
work anymore, which would perfectly work for a regular collection of
elements using their underscore #and:/#or: equivalents.

The important thing, IMO, is that the core of OO is message sending,
and enabling the receiver what to do with a message, which in the
worst case would mean "I don't understand this message". A procedure
call inverts the responsibility. A great trade off would be to be able
to enable/disable for certain things instead of it being a global
setting.

Regards,

Esteban A. Maringolo

On Thu, Mar 17, 2022 at 11:53 AM James Foster  wrote:
>
> Richard,
>
> I very much admire Dijkstra’s admonition regarding “The Humble Programmer” 
> and was pointing a student to that article just this week.
>
> In any case, I think you’ve demonstrated that you now comprehend the argument 
> against inlining—you just don’t agree. That’s fair and I think the discussion 
> has been clarified. Would it be fair to say that you have an “ideological 
> objection” to allowing a Proxy or Stub to transparently stand in for another 
> object (say, in a two-object-space environment such as Pharo and GemStone)? 
> That is, a domain object can’t be replaced by a Proxy or Stub without a 
> wholesale rewrite of the rest of the application? I respect that as a 
> reasonable position (demanding perfect clarity), but I see a cost to that 
> position as well.
>
> Of course, if you really want to avoid allowing the receiver to chose its 
> response to a message, you can use other messages. So if you want to find out 
> if an object is identical to nil you should use `nil == myObject` to ensure 
> that there was not an override of #’isNil’ or #’==‘ by the object’s class.
>
> James
>
> On Mar 17, 2022, at 2:27 AM, Richard O'Keefe  wrote:
>
> My chief concern is that I am a bear of very little brain,
> and if you change the meaning of #isNil to anything at all
> other than "is the receiver identical to nil" you *WILL*
> (not may) confuse me.  This extends to things that happen
> not to be inlined: if even a god-like Smalltalker like
> Andres Valloud overloads #, to something other than "combine
> the collection that is the receiver with the collection that
> is the argument to yield a new collection" than I *WILL*
> most certainly be confused and find the code unmaintainable.
> Smalltalk being Smalltalk, if you admit an inconsistent
> overload anywhere, I can no longer understand sends of that
> selector anywhere.  One of the things to like about Traits
> is that you can say "this class doesn't just *happen* to
> have selectors x and y, it has them *because* it has this
> whole consistent bundle of selectors."
>
> There are more annotations documented for my Smalltalk
> compiler than are actually implemented.  One that *is*
> implemented is , and it has caught more
> mistakes than I care to admit to.  It's particularly
> important for a bundle of methods with varying arguments
> that are meant to be routed through a single method,
> which *is* meant to be overridden.  It makes sure that
> I override the *right* method.  (Take #= and #~= as an
> obvious example.)
>
> Once you start down the path of lying about things like #isNil
> you find that EITHER you have to go very far down that path
> and override #== and #instVarAt: and a whole lot of other
> things OR you are working with a semantically incoherent system.
>
> "How should a proxy (https://en.wikipedia.org/wiki/Proxy_pattern) to nil 
> respond to the #’isNil’ message?"
>
> It SHOULD NOT LIE.  A proxy *isn't* nil, and it doesn't *behave* like nil,
> even if it is a proxy for nil.  A proxy, qua proxy, can do things that nil
> cannot.  Use another selector, #isEffectivelyNil, or whatever reveals your
> intentions, and give it what semantics you find useful.
>
> "How should the Null Object Pattern 
> (https://en.wikipedia.org/wiki/Null_object_pattern) respond to #’isNil’?"
>
> It should answer false.  Period.  No ifs, buts, quibbles, or maybes.
> The whole *point* of the Null Object Pattern is to return something
> that *isn't* nil, that has quite a different protocol.  If you call
> something that is supposed to return either a Foo or a NullFoo, and
> it gives you nil instead, there is a BUG in what you just called so
> the sooner you find out the better.  What you want is
>
>Foo >> isNullFoo ^false
>NullFoo >> isNullFoo ^true
> and no other class defines #isNullFoo.
>
> That way, when you ask "tripeWorks grobblingMill lastPallet 

[Pharo-users] Re: Null Object Pattern

2022-03-15 Thread Esteban Maringolo
+1

Inlining breaks the fundamental piece of OOP: Message sends.

I'm sure there are use cases where inlining adds a significant
speedup, but for some messages, I prefer them to be sent.

Regards!

Esteban A. Maringolo

On Tue, Mar 15, 2022 at 3:16 PM  wrote:
>
> I had some chaining that was getting too complex due to many nil checks, so I 
> started to refactor using a Null Object.
>
> However, I’m struggling a bit with the refactor due to inlining. Since 
> #ifNil: variants might be inlined, it seems that something like:
>
> anObject with a long chain of messages ifNotNil: [ :result | “…” ]
>
> must be changed into something like:
>
> anObject with a long chain of messages isNil ifFalse: [ anObject with a long 
> chain of messages “…” ].
>
> Obviously, I can use a temp to have:
>
> result := anObject with a long chain of messages.
>
> result isNil ifFalse: [ result “…” ].
>
> But both seem ugly and make me question using this pattern.
>
> What am I missing?
>
> After 40+ years of Moore’s Law, can we turn off these inlines by default?


[Pharo-users] Re: Too many parenthesis - a matter of syntax

2022-01-26 Thread Esteban Maringolo
On Wed, Jan 26, 2022 at 10:58 AM gettimothy via Pharo-users
 wrote:

> I realize this is just a preference, but the denseness forces me to think in 
> Objects and composition rather than process.

I never thought of it this way, but I fully agree with it. Thanks for
putting this in words.

Maybe what we need is better highlighting of the current "scope" where
the cursor is. Navigating in and out of the parenthesis is not
trivial, and it feels like hunting sometimes.

With Futures it would be convenient to be able to link different
#then: and such, but what you might need is a "chained" object
that does all that for you.

I always think of ways to improve the current syntax, but in the end
it seems like anything else feels unnatural, and the net result is not
positive.

So... more objects, less syntax... and better tooling.

Regards,

Esteban A. Maringolo


[Pharo-users] Re: Strategies for (re)using HTTP client

2021-11-03 Thread Esteban Maringolo
Thanks Sven!

I don't know whether I'm going to use it, but it's good that the feature is
there and I have the option of sharing such session among clients.

Regards,

Esteban A. Maringolo


On Wed, Nov 3, 2021 at 1:06 PM Sven Van Caekenberghe  wrote:

> Maybe this helps:
>
>
> https://github.com/svenvc/zinc/commit/d9fe41707b16748b9340540127ec5d77800856b6
>
> > On 1 Nov 2021, at 21:22, Sven Van Caekenberghe  wrote:
> >
> >
> >
> >> On 1 Nov 2021, at 20:03, Esteban Maringolo 
> wrote:
> >>
> >> If I need to use cookies, would it make sense to keep a
> ZnUserAgentSession and assign it to each new client?
> >
> > I don't know or remember, my first reaction would be to say that it was
> not designed for that purpose, but maybe it could be used for that.
> >
> >> I'm asking this in case I have to share cookies between requests. But
> the session variable seems to be private in ZnClient given that it doesn't
> provide any setter.
> >
> > There is the cookie jar object inside the session, maybe you can try to
> share that ?
> >
> > Or you could copy the necessary cookies over ? That certainly seems like
> the safest thing.
> >
> >> Regards,
> >>
> >> Esteban A. Maringolo
> >>
> >>
> >> On Mon, Nov 1, 2021 at 1:39 PM Esteban Maringolo 
> wrote:
> >> Thank you Sven.
> >>
> >> I'll go with instantiating a new client for each request, the less
> state shared, the better :-)
> >>
> >> Regards!
> >>
> >> Esteban A. Maringolo
> >>
> >>
> >> On Fri, Oct 29, 2021 at 12:15 PM Sven Van Caekenberghe 
> wrote:
> >> Hi,
> >>
> >>> On 29 Oct 2021, at 15:42, Esteban Maringolo 
> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I happened to me more than once that I have to create some REST
> service "client" in which I usually wrap an HTTP client inside (ZnClient in
> this case), and all the calls to the service, end up using the HTTP client,
> inside some mutex to serialize the execution.
> >>
> >> Yes, that is a good design. However, whether your REST client object
> wrapping a ZnClient is used by multiple concurrent threads is another
> decision. I would personally not do that. See further.
> >>
> >>> But I don't like that, in particular when some endpoints are better
> with streaming responses (large downloads) and I have to fiddle with the
> client and set it back to the settings before executing the request.
> >>
> >> You only can and should reuse connections to the same endpoint/service
> only, doing similar types of request/responses (let's say simple ones).
> >>
> >> A definitive danger point is authentication and authorization:
> different calls by different users might need different REST call settings,
> each time. Also, caching can be a problem, if user A can see / sees the
> cache of user B.
> >>
> >>> So, long story short... is it always safer to instantiate a new
> ZnClient on a per request basis since no state is shared, but I guess it is
> also less effective if I'm performing several requests to the same server.
> >>
> >> A new instance is definitely safer because it is cleaner. Reusing a
> connection is more efficient when doing multiple calls in (quick)
> succession. The penalty is usually pretty low, you can postpone optimising
> until there is an actual problem.
> >>
> >> Error handling and recovery are also harder in the reuse case (what
> state is the connection in ?).
> >>
> >> ZnClient does a form of automatic reconnection/retry though.
> >>
> >>> What are the recommended approaches here?
> >>>
> >>>
> >>> Esteban A. Maringolo
> >>
> >> HTH,
> >>
> >> Sven
> >
>


[Pharo-users] Re: Strategies for (re)using HTTP client

2021-11-01 Thread Esteban Maringolo
If I need to use cookies, would it make sense to keep a ZnUserAgentSession
and assign it to each new client?

I'm asking this in case I have to share cookies between requests. But the
session variable seems to be private in ZnClient given that it doesn't
provide any setter.

Regards,

Esteban A. Maringolo


On Mon, Nov 1, 2021 at 1:39 PM Esteban Maringolo 
wrote:

> Thank you Sven.
>
> I'll go with instantiating a new client for each request, the less state
> shared, the better :-)
>
> Regards!
>
> Esteban A. Maringolo
>
>
> On Fri, Oct 29, 2021 at 12:15 PM Sven Van Caekenberghe 
> wrote:
>
>> Hi,
>>
>> > On 29 Oct 2021, at 15:42, Esteban Maringolo 
>> wrote:
>> >
>> > Hi,
>> >
>> > I happened to me more than once that I have to create some REST service
>> "client" in which I usually wrap an HTTP client inside (ZnClient in this
>> case), and all the calls to the service, end up using the HTTP client,
>> inside some mutex to serialize the execution.
>>
>> Yes, that is a good design. However, whether your REST client object
>> wrapping a ZnClient is used by multiple concurrent threads is another
>> decision. I would personally not do that. See further.
>>
>> > But I don't like that, in particular when some endpoints are better
>> with streaming responses (large downloads) and I have to fiddle with the
>> client and set it back to the settings before executing the request.
>>
>> You only can and should reuse connections to the same endpoint/service
>> only, doing similar types of request/responses (let's say simple ones).
>>
>> A definitive danger point is authentication and authorization: different
>> calls by different users might need different REST call settings, each
>> time. Also, caching can be a problem, if user A can see / sees the cache of
>> user B.
>>
>> > So, long story short... is it always safer to instantiate a new
>> ZnClient on a per request basis since no state is shared, but I guess it is
>> also less effective if I'm performing several requests to the same server.
>>
>> A new instance is definitely safer because it is cleaner. Reusing a
>> connection is more efficient when doing multiple calls in (quick)
>> succession. The penalty is usually pretty low, you can postpone optimising
>> until there is an actual problem.
>>
>> Error handling and recovery are also harder in the reuse case (what state
>> is the connection in ?).
>>
>> ZnClient does a form of automatic reconnection/retry though.
>>
>> > What are the recommended approaches here?
>> >
>> >
>> > Esteban A. Maringolo
>>
>> HTH,
>>
>> Sven
>>
>


[Pharo-users] Re: Strategies for (re)using HTTP client

2021-11-01 Thread Esteban Maringolo
Thank you Sven.

I'll go with instantiating a new client for each request, the less state
shared, the better :-)

Regards!

Esteban A. Maringolo


On Fri, Oct 29, 2021 at 12:15 PM Sven Van Caekenberghe  wrote:

> Hi,
>
> > On 29 Oct 2021, at 15:42, Esteban Maringolo 
> wrote:
> >
> > Hi,
> >
> > I happened to me more than once that I have to create some REST service
> "client" in which I usually wrap an HTTP client inside (ZnClient in this
> case), and all the calls to the service, end up using the HTTP client,
> inside some mutex to serialize the execution.
>
> Yes, that is a good design. However, whether your REST client object
> wrapping a ZnClient is used by multiple concurrent threads is another
> decision. I would personally not do that. See further.
>
> > But I don't like that, in particular when some endpoints are better with
> streaming responses (large downloads) and I have to fiddle with the client
> and set it back to the settings before executing the request.
>
> You only can and should reuse connections to the same endpoint/service
> only, doing similar types of request/responses (let's say simple ones).
>
> A definitive danger point is authentication and authorization: different
> calls by different users might need different REST call settings, each
> time. Also, caching can be a problem, if user A can see / sees the cache of
> user B.
>
> > So, long story short... is it always safer to instantiate a new ZnClient
> on a per request basis since no state is shared, but I guess it is also
> less effective if I'm performing several requests to the same server.
>
> A new instance is definitely safer because it is cleaner. Reusing a
> connection is more efficient when doing multiple calls in (quick)
> succession. The penalty is usually pretty low, you can postpone optimising
> until there is an actual problem.
>
> Error handling and recovery are also harder in the reuse case (what state
> is the connection in ?).
>
> ZnClient does a form of automatic reconnection/retry though.
>
> > What are the recommended approaches here?
> >
> >
> > Esteban A. Maringolo
>
> HTH,
>
> Sven
>


[Pharo-users] Strategies for (re)using HTTP client

2021-10-29 Thread Esteban Maringolo
Hi,

I happened to me more than once that I have to create some REST service
"client" in which I usually wrap an HTTP client inside (ZnClient in this
case), and all the calls to the service, end up using the HTTP client,
inside some mutex to serialize the execution.

But I don't like that, in particular when some endpoints are better with
streaming responses (large downloads) and I have to fiddle with the client
and set it back to the settings before executing the request.

So, long story short... is it always safer to instantiate a new ZnClient on
a per request basis since no state is shared, but I guess it is also less
effective if I'm performing several requests to the same server.

What are the recommended approaches here?


Esteban A. Maringolo


[Pharo-users] Re: Silly question about storing and displaying currency amounts?

2021-08-30 Thread Esteban Maringolo
I was recently bitten by this wrong "scaled decimal expectation", in
which what I thought was wrong it actually wasn't, or I can't tell
whether it was.

I would expect that a scaled decimal would be something like what
Esteban L. suggests, an integer where you just move the decimal point
for printing, and also a number where you lose precision due to
truncation.

So this: ((1.0s2 / 3) * 3) + 0.01s2
Would yield 1 instead of "1.01s2"

So if you use the "integer only" representation, it is very much like
any currency number would me managed:
((100 / 3) truncated * 3 + 1) / 100

This, of course, yields the right value, but it started truncated from
the beginning.
(0.33s2 * 3) + 0.01s2 "1"

I would appreciate any pointers about learning more about this.
It's embarrassing for me not knowing how each type should work in
order to tell what's right from what's wrong.

Regards!

ps: In my case this wasn't because of money, but another kind of use,
but the situation is the same.

Esteban A. Maringolo

On Mon, Aug 30, 2021 at 9:51 AM Esteban Lorenzano  wrote:
>
> hi,
>
> some time ago there was a "money" package around, that basically had a 
> Currency type that internally stored values as integers (like, 42.0 was 
> becoming 4200). This had some advantages to make this kind of calculus (also, 
> it has the "other" advantage of making you believe that you have a lot more 
> money than what you have ;).
>
> maybe you need to go that direction?
>
> Esteban
>
> On Aug 30 2021, at 2:31 pm, Sven Van Caekenberghe  wrote:
>
> David,
>
> > On 30 Aug 2021, at 14:02, David Pennington  wrote:
> >
> > Hi everyone. I have a little bank analysis package for my own use but 
> > having trouble displaying and storing amounts. I parse out a CSV file from 
> > the bank and convert the amounts from text to ScaledDecimal. I then store 
> > these into a STON file, which converts them back to text. I then read them 
> > in and convert them back to ScaledDecimal again.
> >
> > I am not used to ~Pharo have spent 24 years using VisualAge Smalltalk so I 
> > need a little bit of help because I am getting 1 Penny errors in the 
> > conversions. I can cope with this but I would like to get it right.
> >
> > Can anyone give me a simple means of managing, say, an amount like £76.49 
> > from the bank so that it stops coming back to me as £76.48?
> >
> > David
> > Totally Objects
>
> Working with money is always challenging. I know that many people say 'Use 
> ScaledDecimal' as if that magically solves all problems but it does not. 
> ScaledDecimal is a bit of a dangerous class to use. It is just a fraction 
> with a certain precision. Internally it might be pretty accurate with respect 
> to most operations, its external representation as floating point number can 
> be misleading, as this representation is prone to all problems related to 
> floating point (including the fact that decimal and binary floating point are 
> not the same).
>
> STON does not doing anything wrong as far as I know. Consider the following:
>
> | amount ston |
> amount := 76.49 asScaledDecimal.
> ston := STON toString: amount.
> STON fromString: ston.
> (STON fromString: ston) = amount.
> "true"
>
> | amount ston |
> amount := 76.49 asScaledDecimal: 2.
> ston := STON toString: amount.
> STON fromString: ston.
> (STON fromString: ston) = amount.
> "true"
>
> | amount ston |
> amount := 76.49.
> ston := STON toString: amount.
> STON fromString: ston.
> (STON fromString: ston) = amount.
> "true"
>
> BUT, 76.49 asScaledDecimal already has your penny loss (if rounded to 
> pennies).
>
> HTH,
>
> Sven


[Pharo-users] Re: Private Methods

2021-08-23 Thread Esteban Maringolo
If something, I'd rather have _ as a prefix indicating a private
method, very much like Dart does.
But why use a "syntax" trick when it could be an attribute of the
CompiledMethod itself?

As for many private methods being a code smell... it could be, but it
depends, until you find the right abstractions you might want to keep
private all the stuff that is causing the smell :-)




Esteban A. Maringolo

On Mon, Aug 23, 2021 at 8:06 AM Tim Mackinnon  wrote:
>
> As many have described, I’ve seen this work reasonably well too - while I’ve 
> seen the pvt prefix convention, I’ve also seen _name used to - which I felt 
> was marginally better (it also means private methods get grouped at the top 
> of the “all list” and not alphabetically in the middle’ish (but it’s a minor 
> thing as browser tools can filter appropriately anyway, and to be honest, 
> showing private at the bottom or in a separate place is better).
>
> It is worth saying however - that lots if pvt methods can be a code smell - 
> it may be better to move them to a separate “policy object” and then focus on 
> better delegation options - which I believe is where Pharo is heading with 
> variables as first class objects (and hopefully Marcus will cover in the U.K. 
> Smalltalk Meetup this week).
>
> Too often we end up up with lots of sub classing and overriding and 
> privatising - when there is a new object that could group all this stuff and 
> the methods can be public in that delegate - while the delegate itself is a 
> “private” object.
>
> I think this should be explored more actually.
>
> Tim
>
> > On 20 Aug 2021, at 11:19, Richard O'Keefe  wrote:
> >
> > One of the claimed benefits of object-oriented programming is 
> > ENCAPSULATION.
> > The idea is that one of the ways a language helps you is by making some 
> > errors
> > difficult or impossible to express.
> > One of the things you need to understand an object is its INVARIANT.
> > For example, astc's SortedCollection includes
> >
> >  methods for: 'checking'
> >invariant
> >  ^(opposite isNil or: [
> >opposite isKindOf: DyadicBlock]) and: [
> >   super invariant and: [
> >   (sortBlock
> > ifNil:[(offset + 2 to: offset + size) allSatisfy: [:i |
> > (array at: i-1) <= (array at: i)]]
> > ifNotNil: [(sortBlock respondsTo: #value:value:) and: [
> > [(offset + 2 to: offset + size) allSatisfy: [:i |
> >   (sortBlock value: (array at: i-1)
> >  value: (array at: i)))]]
> >
> > Private methods are allowed to break the invariant.
> > Public methods are not.
> >
> > For example, consider reversing a SortedCollection.
> > Part of this changes the order of the elements, and can be
> > shared with OrderedCollection.  Part of it swaps the arguments
> > of the sortBlock, and cannot be shared.
> >
> >  methods for: 'rearranging'
> >pvtPrereverse
> >  |t|
> >  opposite
> >ifNil: [
> >  sortBlock ifNil: [sortBlock := Magnitude defaultSortBlock].
> >  t := sortBlock.
> >  opposite := sortBlock.
> >  sortBlock := [:x :y | t value: y value: x]]
> >ifNotNil: [
> >  t := sortBlock.
> >  sortBlock := opposite.
> >  opposite := t].
> >
> > If this method could be called from "outside", it would certainly break
> > the invariant and leave the object in an unusable state.
> >
> > Now a style rule doesn't *quite* prevent this method being called by
> > another object.
> > It is necessary to make sure that #perform: and friends cannot break
> > encapsulation
> > either, and this astc does by simply not creating Selector objects for
> > private methods.
> >
> > Yes, it is a small increase in the complexity of the language, however
> > - you are not forced to write private methods
> > - if you run code that uses the pvt* convention in a Smalltalk that does
> >  not use that convention, it works, it's just not safe any longer
> > - it is not an arbitrary addition to the language, it is a restriction that
> >  makes programming *easier*.
> >
> > Let's look at one additional example.
> > Behavior>>
> > new
> >^ self basicNew initialize
> >
> > This means that *any* object can forcibly reinitialize *any* object it can
> > reach at *any* time.  In astc, it's
> >
> > new
> >"other checks"
> >^self pvtNew pvtPostNew
> >
> > and an object cannot be reinitialised against its will.
> >
> > There is a long standing tradition of "program for the typical case and 
> > trust
> > the omniscient programmer to know what will probably work and what won't"
> > in Smalltalk.  This is why in many Smalltalks
> >  aCollection addAll: aCollection
> > or
> >  aCollection removeAll: aCollection
> > can go insane for some common collections.  And one *DOES* get away
> > with it most of the time.  It's typically when someone else triest to use 
> > your
> > code and doesn't know the assumptions you didn't 

[Pharo-users] Re: Private Methods

2021-08-19 Thread Esteban Maringolo
Public/Private is not just a category, it is also a declaration of
what is the interface of the object.
As I said, it's not critical, but I've been working with and without a
"native" private method, and I prefer working with them.

Namespacing is a different animal, and not as simple to implement as
private methods.

Best regards,

Esteban A. Maringolo

On Thu, Aug 19, 2021 at 9:59 AM Jesus Mari Aguirre
 wrote:
>
> Please keep Pharo simple, why do you need private methods...you can include 
> then in a protocol named private...other language have it...yes...next 
> addition will be namespaces...other...I don't know...at last we have Java
>
> El jue., 19 ago. 2021 9:00, Richard O'Keefe  escribió:
>>
>> Many years ago there was a proposal in the Squeak mailing list about 
>> enforcing
>> a naming convention, "pvt",  I implemented that in my Smalltalk system.  The
>> compiler enforces the rule that pvt.[A-Z].* message can only be sent to
>> (self|super) (basicNew|basicNew: n|new|new: n|pvtNew: n)?
>> in a class method or
>> (self|super) ((class (new|new: n)|pvtSpeciesNew: n|pvtClone)?
>> in an instance method.
>> There are currently
>> 9412 public selectors
>>  793 pvt* selectors and
>>23 private* selectors,
>> where the last group is methods that I *want* to be private in some sense but
>> cannot do with this machinery.  (For example, calling a "private" method on
>> another object known to be of the same class.)
>>
>> I think the evidence shows that this works well enough to be useful, even if 
>> it
>> isn't quite as expressive as I'd like.  And what *that* means is that
>> this can be
>> done with a style check, using the machinery Pharo already has for style 
>> checks.
>>
>>
>>
>> On Wed, 18 Aug 2021 at 08:14, Craig Johnson  wrote:
>> >
>> > Hi All,
>> >
>> >
>> > Just a newb off-the-wall question.
>> >
>> > Is there any good reason why we can't create a true private method in a
>> > Pharo class by putting that method inside an instance or class variable
>> > as a lambda (block).
>> >
>> >
>> > This would reduce one of my biggest bugbears with Pharo, namely the
>> > pollution of the global namespace with every single message name in the
>> > entire system.
>> >
>> >
>> >
>> > Craig


[Pharo-users] Re: Private Methods

2021-08-18 Thread Esteban Maringolo
Hi Noury,

In Dolphin Smalltalk and in IBM/VA Smalltalk, methods can be private,
it's a special attribute of the CompiledMethod, so the visibility
doesn't depend on a category name convention, and you can have both
public and private methods sharing a single category. I used that
attribute extensively in the previously described dialects, and it led
to good method categorization, in the case of Dolphin, it had the nice
thing of adding "Private - ..." to the method comment when you toggle
a method as private.

I'm fine with the current state of everything being public, but if we
were to have that public/private distinction that would be the
simplest solution, having a  pragma could also work, but I
think that in terms of performance it could impact the lookup. I don't
know, however, if that is what the original request was after.

Best regards,

Esteban A. Maringolo

On Wed, Aug 18, 2021 at 9:47 AM Noury Bouraqadi  wrote:
>
> Hi Esteban,
>
> Which first "class attribute" are you referring to? Is it a pragma? Can you 
> provide an example please ?
>
> Thanx
> Noury
>
> On Aug 17 2021, at 10:31 pm, Esteban Maringolo  wrote:
>
> I don't understand the request?
>
> Wouldn't tagging methods as private (as a first class attribute, and
> not only its category) be enough?
>
> What you ask for seems to be a splitted method dictionary of some sort.
>
> Having first class private methods would save you from autocomplete
> selector "pollution" of private methods.
>
> Regards!
>
> Esteban A. Maringolo
>
> On Tue, Aug 17, 2021 at 5:14 PM Craig Johnson  wrote:
> >
> > Hi All,
> >
> >
> > Just a newb off-the-wall question.
> >
> > Is there any good reason why we can't create a true private method in a
> > Pharo class by putting that method inside an instance or class variable
> > as a lambda (block).
> >
> >
> > This would reduce one of my biggest bugbears with Pharo, namely the
> > pollution of the global namespace with every single message name in the
> > entire system.
> >
> >
> >
> > Craig


[Pharo-users] Re: Private Methods

2021-08-17 Thread Esteban Maringolo
I don't understand the request?

Wouldn't tagging methods as private (as a first class attribute, and
not only its category) be enough?

What you ask for seems to be a splitted method dictionary of some sort.

Having first class private methods would save you from autocomplete
selector "pollution" of private methods.

Regards!

Esteban A. Maringolo

On Tue, Aug 17, 2021 at 5:14 PM Craig Johnson  wrote:
>
> Hi All,
>
>
> Just a newb off-the-wall question.
>
> Is there any good reason why we can't create a true private method in a
> Pharo class by putting that method inside an instance or class variable
> as a lambda (block).
>
>
> This would reduce one of my biggest bugbears with Pharo, namely the
> pollution of the global namespace with every single message name in the
> entire system.
>
>
>
> Craig


[Pharo-users] Re: Pharo-SQLite3: closing connections immediately and deleting the database file

2021-08-12 Thread Esteban Maringolo
After I set up the tests I knew that was possible, but never knew how
to actually do it.

Regards!

Esteban A. Maringolo

On Thu, Aug 12, 2021 at 8:55 PM Julián Maestri  wrote:
>
> Not exactly what you are asking for, but did you consider using sqlite in 
> memory?
>
> On Sat, 7 Aug 2021 at 23:23, Esteban Maringolo  wrote:
>>
>> I've been doing exactly that. It is, creating a new DB file for each
>> test, and I was having the same problem as you.
>>
>> I suggested a change to the driver to cover that situation:
>> https://github.com/pharo-rdbms/Pharo-SQLite3/pull/22/files
>>
>> Try applying that change and see if that works.
>>
>> I still prefer to recreate the database, it will give you a full fresh
>> start, and if you want you can halt before the deletion of the db, to
>> analyze its internal state.
>>
>> Best regards!
>>
>>
>> Esteban A. Maringolo
>>
>> On Sat, Aug 7, 2021 at 11:13 PM  wrote:
>> >
>> > Hi
>> >
>> > Actually I will just do a bunch of
>> >
>> > DROP TABLE IF EXISTS
>> >
>> > instead of dropping the db altogether.
>> >
>> > Thanks, Vince


[Pharo-users] Re: Logging Frameworks

2021-08-09 Thread Esteban Maringolo
Hi Gabriel,

I found this Beacon-Server [1] that could work, it would be a good use
case in a docker environment where you have several worker images
talking to a single beacon-server-container.

Regards!

[1] https://github.com/grype/Beacon-Server

Esteban A. Maringolo

On Mon, Aug 9, 2021 at 9:10 AM Gabriel Cotelli  wrote:
>
> Beacon is integrated as part of Pharo now, but the repository includes more 
> logger options. Maybe some option there allows forwarding the logs to a 
> centralized place. I'm also interested in other's experiences regarding 
> logging options because we want to settle on some option as the default for 
> our Pharo components.
>
> On Sun, Aug 8, 2021 at 11:29 AM Esteban Maringolo  
> wrote:
>>
>> What are the current options for logging?
>>
>> Beacon seems to be the most modern one, but the Github repository
>> doesn't seem very active (maybe it forked somewhere else).
>>
>> Given that the logs might come from different worker images, is there
>> something that can work via HTTP or similar? (it is, forwarding the
>> logged events to a server).
>>
>> Regards!
>>
>> ps: I think I've asked this before, but couldn't find my previous
>> question about it.
>>
>>
>> Esteban A. Maringolo


[Pharo-users] Re: Logging Frameworks

2021-08-09 Thread Esteban Maringolo
That is my impression with Beacon, there was a lot of discussion about
it and then never heard of it again.

Is your code available somewhere?

Regards!

ps: There is also TinyLogger that works by means of a DynamicVariable,
but I liked the idea of using objects instead of just strings for
logging (which I'm manually doing now).

Esteban A. Maringolo

On Mon, Aug 9, 2021 at 9:16 AM Norbert Hartl  wrote:
>
> Beacon is a sad story. There was a lot of initiative and motivation for 
> loggers which was killed. But it is still a good foundation to build 
> something useful on top of it. I integrated a syslog option when I was 
> working on beacon. In my projects I’ve done a sender to elasticsearch for 
> logging. Beacon’s design allows all of that. After motivation died nobody put 
> some love into it again. That’s all!
>
> Maybe time to pick it up again. But I personally have too much on my plate 
> right now to take another attempt.
>
> Norbert
>
>
> Am 09.08.2021 um 14:08 schrieb Gabriel Cotelli :
>
> Beacon is integrated as part of Pharo now, but the repository includes more 
> logger options. Maybe some option there allows forwarding the logs to a 
> centralized place. I'm also interested in other's experiences regarding 
> logging options because we want to settle on some option as the default for 
> our Pharo components.
>
> On Sun, Aug 8, 2021 at 11:29 AM Esteban Maringolo  
> wrote:
>>
>> What are the current options for logging?
>>
>> Beacon seems to be the most modern one, but the Github repository
>> doesn't seem very active (maybe it forked somewhere else).
>>
>> Given that the logs might come from different worker images, is there
>> something that can work via HTTP or similar? (it is, forwarding the
>> logged events to a server).
>>
>> Regards!
>>
>> ps: I think I've asked this before, but couldn't find my previous
>> question about it.
>>
>>
>> Esteban A. Maringolo
>
>


[Pharo-users] Logging Frameworks

2021-08-08 Thread Esteban Maringolo
What are the current options for logging?

Beacon seems to be the most modern one, but the Github repository
doesn't seem very active (maybe it forked somewhere else).

Given that the logs might come from different worker images, is there
something that can work via HTTP or similar? (it is, forwarding the
logged events to a server).

Regards!

ps: I think I've asked this before, but couldn't find my previous
question about it.


Esteban A. Maringolo


[Pharo-users] Re: Pharo-SQLite3: closing connections immediately and deleting the database file

2021-08-07 Thread Esteban Maringolo
I've been doing exactly that. It is, creating a new DB file for each
test, and I was having the same problem as you.

I suggested a change to the driver to cover that situation:
https://github.com/pharo-rdbms/Pharo-SQLite3/pull/22/files

Try applying that change and see if that works.

I still prefer to recreate the database, it will give you a full fresh
start, and if you want you can halt before the deletion of the db, to
analyze its internal state.

Best regards!


Esteban A. Maringolo

On Sat, Aug 7, 2021 at 11:13 PM  wrote:
>
> Hi
>
> Actually I will just do a bunch of
>
> DROP TABLE IF EXISTS
>
> instead of dropping the db altogether.
>
> Thanks, Vince


[Pharo-users] Re: [ANN] Bootstrap 5 for Seaside in Pharo

2021-07-30 Thread Esteban Maringolo
Hi Sanjay,

Have you looked at the differences between BS4 and BS5?

Among the main differences are:
- removes jQuery as a dependency and uses vanilla JS instead.
- replaces default looking form elements by styled ones

If you're starting from scratch it might be worth trying it, and maybe
fix whatever glitch there is, otherwise BS4 is pretty stable and suits
most needs.

Regards!

Esteban A. Maringolo

On Fri, Jul 30, 2021 at 10:17 AM Sanjay Minni  wrote:
>
> Hi Torsen
>
> some of the examples seem to be not working, probably same for BS4, BS3
> for instance
> - Collapse
> - dropdowns
>
> Does Javascript have to be also loaded,
> I tried to add "aRoot javascript url: 
> 'https://code.jquery.com/jquery-3.6.0.min.js'.  per your other post but still 
> couldn't get it to work.
> How can I make it work ?
>
> thanks
> Sanjay
>
>
>
> On Fri, 30 Jul 2021 at 17:53, Sven Van Caekenberghe  wrote:
>>
>> Hi Torsten,
>>
>> Great, thanks for doing the Bootstrap series, it has been very useful for 
>> me/us, we use it in several production web apps. We're still on 3 though ;-)
>>
>> Sven
>>
>> > On 30 Jul 2021, at 09:24, Torsten Bergmann  wrote:
>> >
>> > Hi,
>> >
>> > after some of you are using https://github.com/astares/Seaside-Bootstrap4
>> > I wanted to let you know that I just published the new / updated project to
>> > support for Bootstrap 5 web development (https://getbootstrap.com) in 
>> > Seaside
>> > using Pharo.
>> >
>> > Project location is on GitHub:
>> >
>> >https://github.com/astares/Seaside-Bootstrap5
>> >
>> > It might not be fully complete by 100% with all new possibilities of BS5 - 
>> > but
>> > it is usable and tests are green in Pharo 8 and Pharo 9. Examples are 
>> > included,
>> > just follow the instructions on the Github page.
>> >
>> > Feel free to send contributions via PR's.
>> >
>> > Have fun!
>> > T.


[Pharo-users] Re: [ANN] Bootstrap 5 for Seaside in Pharo

2021-07-30 Thread Esteban Maringolo
Yeap, I like how they're built, and it has a good use case for Traits!

I'm using both BS3 and BS4, the latter has more support for CSS Flex
layout (which I still don't master).

Thanks for this! I'll have to catch up and update my related extensions [1].

Best regards!

[1]
https://github.com/eMaringolo/seaside-bootstrap-select
https://github.com/eMaringolo/seaside-bootstrap4-icons

Esteban A. Maringolo

On Fri, Jul 30, 2021 at 9:24 AM Sven Van Caekenberghe  wrote:
>
> Hi Torsten,
>
> Great, thanks for doing the Bootstrap series, it has been very useful for 
> me/us, we use it in several production web apps. We're still on 3 though ;-)
>
> Sven
>
> > On 30 Jul 2021, at 09:24, Torsten Bergmann  wrote:
> >
> > Hi,
> >
> > after some of you are using https://github.com/astares/Seaside-Bootstrap4
> > I wanted to let you know that I just published the new / updated project to
> > support for Bootstrap 5 web development (https://getbootstrap.com) in 
> > Seaside
> > using Pharo.
> >
> > Project location is on GitHub:
> >
> >https://github.com/astares/Seaside-Bootstrap5
> >
> > It might not be fully complete by 100% with all new possibilities of BS5 - 
> > but
> > it is usable and tests are green in Pharo 8 and Pharo 9. Examples are 
> > included,
> > just follow the instructions on the Github page.
> >
> > Feel free to send contributions via PR's.
> >
> > Have fun!
> > T.


[Pharo-users] Re: Zinc exception logging

2021-07-26 Thread Esteban Maringolo
Hi Sven,

That's what I wanted to know, I made a quick change to it and pushed
it to the staging server (where I'm having the error), but I forgot to
simply search for the string, and now I confirm this is returned by
Seaside's response generator in the exception handler.

I don't know where the 4 comes from, and it only happens in
production, but replacing it with another exception handler gives me a
better understanding of what might be going on. It seems there was a
change in some dependency (seems like Glorp) that's affecting my
staging server.

Thanks!

Esteban A. Maringolo

On Mon, Jul 26, 2021 at 3:16 AM Sven Van Caekenberghe  wrote:
>
> Hi Esteban,
>
> > On 26 Jul 2021, at 02:47, Esteban Maringolo  wrote:
> >
> > Is there a way to have a "stack dump" response in Zinc?
> >
> > #debugMode is good for development, but I'm having an "Internal Error:
> > 4", that I don't know how to trace.
> >
> > *   Trying 167.71.182.110...
> > * TCP_NODELAY set
> > * Connected to fore.base.golf (167.71.182.110) port 8090 (#0)
> >> GET /web HTTP/1.1
> >> Host: x.y.z:8090
> >> User-Agent: curl/7.58.0
> >> Accept: */*
> >>
> > < HTTP/1.1 500 Internal Server Error
> > < Content-Length: 512
> > < Content-Type: text/plain;charset=utf-8
> > < Server: Zinc HTTP Components 1.0 (Pharo/8.0)
> > < Date: Mon, 26 Jul 2021 00:45:39 GMT
> > <
> > * Connection #0 to host x.y.z left intact
> > Internal Error: 4
> >
> > Regards!
> >
> > Esteban A. Maringolo
>
> Searching the source code of my image, I only find 'Internal Error' in 
> WAExceptionHandler/WAResponseGenerator, not in Zn code. Furthermore, printing 
> 4 there would be weird (as it is the exception message).
>
> Is this a plain Zn response or a Seaside response ?
>
> I know that Seaside has more logging options.
>
> Zn does not have an exception logging mechanism that dumps a stack trace, 
> only the debugMode for interactive development. I see you used curl, can't 
> you fire the request against your dev image then ?
>
> Sven


[Pharo-users] Zinc exception logging

2021-07-25 Thread Esteban Maringolo
Is there a way to have a "stack dump" response in Zinc?

#debugMode is good for development, but I'm having an "Internal Error:
4", that I don't know how to trace.

*   Trying 167.71.182.110...
* TCP_NODELAY set
* Connected to fore.base.golf (167.71.182.110) port 8090 (#0)
> GET /web HTTP/1.1
> Host: x.y.z:8090
> User-Agent: curl/7.58.0
> Accept: */*
>
< HTTP/1.1 500 Internal Server Error
< Content-Length: 512
< Content-Type: text/plain;charset=utf-8
< Server: Zinc HTTP Components 1.0 (Pharo/8.0)
< Date: Mon, 26 Jul 2021 00:45:39 GMT
<
* Connection #0 to host x.y.z left intact
Internal Error: 4

Regards!

Esteban A. Maringolo


[Pharo-users] Re: The Greatest Contributors to Smalltalk since 1980

2021-07-25 Thread Esteban Maringolo
On Sun, Jul 25, 2021 at 11:31 AM Tim Mackinnon  wrote:
> Isn’t this the wrong question to ask? I’m assuming this is to do with 
> Smalltalk’s 50th anniversary, and of course we are grateful to those early 
> pioneers who did lots of work in the field 20-30 years ago but to me that’s 
> the old history and while it’s interesting to call out, it doesn’t shed life 
> on the day to day energy we have today - whst keeps Smalltalk alive and 
> current.

Hi share the view, it's the wrong question, and it pursues that "hero
worshipping" culture that is already dead (or at least outdated) since
a long time ago.

Additionally, I don't share the "keeping Smalltalk alive" expression,
as if dying was its inevitable outcome. I haven't heard "keeping LISP
alive" (and I don't call LISP as dead either). It would be
self-deceiving to call ourselves mainstream, but that doesn't mean
we're doomed somehow.

So in 50 years we should celebrate the half-century, remember the
history, look at what we did "wrong", and focus on looking forward,
because "the best way to predict the future is to invent it" ;-)

Regards!


Esteban A. Maringolo


[Pharo-users] Re: ZnServer on a cheap server: your experiences

2021-07-22 Thread Esteban Maringolo
Yeap, not much more to add than what Sven said. What's important to
mention is that they are really stable.
I've been running Pharo servers in DO droplets of all sizes, without
issues (some running for months), I only had to upscale one droplet to
more memory, and it was because of a leak I introduced with PGSQL
connections, otherwise, they're pretty lightweight for today's
standards and a normal workload.

I have deployments with nginx and Pharo images as upstreams, and I
have one with Docker swarm and Traefik doing the load balancing among
different Pharo workers and acting as the HTTPS endpoint. I'm removing
this option though and moving back to nginx only.

What I never tried was to host a docker container running Pharo, in
some Docker hosting. It might be the best option as a quick start, but
after doing the math, it's always more expensive than a Droplet.

Best regards,

Esteban A. Maringolo

On Thu, Jul 22, 2021 at 3:21 AM Sven Van Caekenberghe  wrote:
>
> Hi Vince,
>
> That is certainly possible and works well. I would recommend an instance with 
> 1GB RAM, that leaves you some headroom.
>
> Deploying web applications is of course a broad subject, much of the required 
> knowledge is not Pharo specific, but needed anyway.
>
> The last chapter in the Pharo Enterprise book 
> (https://books.pharo.org/enterprise-pharo/) is a good starting point 
> (Deployment). But there are other and different approaches.
>
> A plain HTTP demo instance running on a DO instance can be found here: 
> http://zn.stfx.eu/welcome
>
> For production use you should front with NGINX or something similar to add 
> HTTPS.
>
> May people on this mailing list deploy Pharo server applications, we have 
> tens of them in day to day production doing real work.
>
> Good luck on your journey, you know where to ask questions.
>
> Regards,
>
> Sven
>
> > On 22 Jul 2021, at 07:56, vin...@gmail.com wrote:
> >
> > Anyone here run a web app using plain ZnServer (or subclasses) on a cheap 
> > VPS (i.e., $10/month DO droplet or equivalent). What are your experiences?, 
> > suggestions.
> >
> > I am planning a web app with just plain ZnServer, SQLite3, ATS or 
> > equivalent.
> >
> > Thanks, Vince
> >


[Pharo-users] Re: [Pharo-dev] [ANN] Pharo 9 released!

2021-07-16 Thread Esteban Maringolo
Thanks team. Impressive release.

Keep up the good work!

Esteban A. Maringolo


On Thu, Jul 15, 2021 at 6:14 AM Esteban Lorenzano  wrote:

> Dear World and dynamic language lovers:
>
> The time has come for Pharo 9  !
>
> Pharo is a pure object-oriented programming language and a powerful
> environment, focused on simplicity and immediate feedback.
>
>
> Here are the key features of Pharo 9:
>
>
>- Full redesign of the Spec UI framework (new logic, application,
>style, GTK3 back-end)
>- New tools:
>-
>   - new playground,
>   - new object centric inspector,
>   - new object centric debugger.
>   - better and new Refactorings
>   - class comments are now written in Microdown format (Markdown
>   compatible)
>   - classes now can be defined using a "fluid" api (Preview)
>   - New completion framework that adapts better to edition contexts
>and is customizable
>- Fast universal non-blocking FFI which now uses libFFI as backend.
>- Pharo now supports Windows, OSX, Linux (Ubuntu, Debian, Fedora,
>openSUSE, Arch, Raspbian) and multiple architectures (Intel/ARM 32/64bits).
>- Virtual Machine
>-
>   - Idle VM
>   - Support for ARM 64bits
>   - Support for Apple M1
>   - More than 3000 tests
>   - Built for Ubuntu 18.04, 19.04, 20.04, 21.04, 21.10; Debian 9, 10,
>   Testing; Fedora 32, 32, 34; openSUSE 15.1, 15.2, Tumbleweed; Manjaro; 
> Arch
>   - Uses SDL 2.0 as back-end by default. It supports extended event
>handling, including trackpad support.
>- General speed up due to compiler optimisations and UI simplification.
>- And many, many more tests.
>
>
> These are just the more prominent highlights, but the details are just as
> important. We have closed a massive amount of issues: around 1400 issues
> and 2150 pull requests.
>
> A more extended changelog can be found at
> https://github.com/pharo-project/pharo-changelogs/blob/master/Pharo90ChangeLogs.md
> .
>
> While the technical improvements are significant, still the most
> impressive fact is that the new code that got in the main Pharo 9 image was
> contributed by more than 90 people.
>
> Pharo is more than code. It is an exciting project involving a great
> community.
>
> We thank all the contributors to this release:
>
> Aaron Bieber, Ackerley Tng, Alban Benmouffek, Ale Cossio, Alexandre
> Bergel, Alistair Grant, Allex Oliveira, Angela Chia-Ling, Arturo Zambrano,
> Asbathou Biyalou-Sama, Ben Coman, Benoit Verhaegue, Carlo Teixeira, Carlos
> Lopez, Carolina Hernandez, Charles A. Monteiro, Christoph Thiede,
> Christophe Demarey, Clotilde Toullec, Cyril Ferlicot, Damien Pollet, Daniel
> Aparicio, David Bajger, David Sánchez i Gregori, Denis Kudriashov, Ellis
> Harris, Eric Brandwein, Eric Gade, Erik Stel, ErikOnBike, Esteban
> Lorenzano, Esteban Villalobos, Evelyn Cusi Lopez, Evelyn Cusi Lopez, Ewan
> Dawson, Francis Pineda, Francis Pineda, Gabriel Omar Cotelli, Geraldine
> Galindo, Giovanni Corriga, Guille Polito, Himanshu jld, Johan Brichau,
> Jonathan van Alteren, Jordan Montt, Julien Delplanque, Kamil Kukura, Kasper
> Østerbye, Kurt Kilpela, Laurine Dargaud, Marco Rimoldi, Marcus Denker,
> Martin Dias, Martin McClure, Massimo Nocentini, Max Leske, Maximilian
> Ignacio Willembrinck Santander, Milton Mamani Torres, Moussa Saker,
> Myroslava Romaniuk, Nicolas Anquetil, Norbert Hartl, Nour Djihan, Oleksandr
> Zaitsev, Pablo Sánchez Rodríguez, Pablo Tesone, Pavel Krivanek, Philippe
> Lesueur, Pierre Misse, Rakshit P., Rob Sayers, Roland Bernard, Ronie
> Salgado, Sean DeNigris, Sebastian Jordan Montaño, Serge Stinckwich, Stephan
> Eggermont, Steven Costiou, Stéphane Ducasse, Sven Van Caekenberghe, Thomas
> Dupriez, Théo Lanord, Théo Rogliano, Todd Blanchard, Torsten Bergmann,
> Vincent Blondeau, Wéslleymberg Lisboa.
>
>
> (If you contributed with Pharo 9 development in any way and we missed your
> name, please send us an email and we will add you).
>
> Enjoy!
>
> The Pharo Team
>
> Try Pharo: http://pharo.org/download 
>
> Learn Pharo: http://pharo.org/documentation
> 
>


[Pharo-users] Flattening traits

2021-07-12 Thread Esteban Maringolo
Hi,

What is the way, ideally programmatic, to flatten traits into regular
methods of their user classes?

I remember there was an option in the UI, but I couldn't find it, and
there is nothing about it in the general documentation [1].

Thanks!

[1] 
https://github.com/pharo-open-documentation/pharo-wiki/blob/master/General/Traits.md

Esteban A. Maringolo


[Pharo-users] Re: Communication between different images

2021-07-01 Thread Esteban Maringolo
On Thu, Jul 1, 2021 at 3:00 PM Jesus Mari Aguirre
 wrote:
>
> As far as I know, zmq doesn't need a broker but subscribers should know the 
> address of the publisher, if the network increases its complexity with more 
> publishers you need a broker,  that is a proxy on zmq.
> If I understand well you need any of them should be able to publish a change 
> to all of the other images?

I want to broadcast notifications of updated objects so they can be
recomputed or reloaded from the database to reflect the latest
changes.
The change might happen in any of the worker images, either by user UI
or API call.

Regards!

Esteban A. Maringolo


[Pharo-users] Re: Communication between different images

2021-07-01 Thread Esteban Maringolo
Hi Sven,

Thanks, now I understand better the use of QoS and session ID with a
practical use case.

How do you deal with the lifetime of each "listener" (subscriber) on
each image? I mean, how stable is it?

E.g.
MQTTClient new
  open;
 subscribeToTopic: '/updates';
 runWith: [ :message |
   Transcript cr; show: '[UPDATED]'; space; show: message contents
asString; cr.
];
yourself.

You just fork that and it will continue to receive messages until you
close the connection? Is there a watchdog class/library to ensure
things like this continue working? (I'm used to having my images
living for months sometimes).

Thanks in advance.

Regards!


Esteban A. Maringolo


On Wed, Jun 30, 2021 at 5:00 AM Sven Van Caekenberghe  wrote:
>
>
>
> > On 30 Jun 2021, at 01:28, Esteban Maringolo  wrote:
> >
> > I like the Ansible approach using RabbitMQ, in particular because it
> > would also work to delegate tasks to workers (even if in the same
> > image), and the task queue would be preserved, whilst in MQTT if there
> > are no subscribers for a topic, then all messages sent to it are
> > discarded.
>
> That is correct but less of a problem in practice than it seems to be at 
> first sight.
>
> As a client, you normally have to be able to start from scratch and load 
> everything that came before the moment you start up.
>
> When a client with a specific ID has connected once with clean session false, 
> QoS 1 and a subscription, the persistence of the queue will be enabled for a 
> as long as the server lives (and maybe even beyond restarts).
>
> There is absolutely no question that Rabbit MQ has much more functionality, I 
> found Mosquitto MQTT very nice to work with, but as always, YMMV.
>
> Sven


[Pharo-users] Re: Communication between different images

2021-06-29 Thread Esteban Maringolo
Hi Gabriel,

I like the Ansible approach using RabbitMQ, in particular because it
would also work to delegate tasks to workers (even if in the same
image), and the task queue would be preserved, whilst in MQTT if there
are no subscribers for a topic, then all messages sent to it are
discarded.

Is there a way to "start fresh" when subscribing to a queue?, it is,
to receive only messages _after_ you subscribed to it?

How do you ensure that the publisher/subscriber (and particularly this
last) keeps running for the lifetime of an image? It is, what are the
failover/recovery options?

Regards!

Esteban A. Maringolo

On Tue, Jun 29, 2021 at 3:44 PM Gabriel Cotelli  wrote:
>
> If you want to use Rabbit you can also take a look at Ansible for connecting 
> using the protocol instead of STOMP.
>
> On Tue, Jun 29, 2021 at 3:11 PM Esteban Maringolo  
> wrote:
>>
>> As far as I understand, ZeroMQ does not require a broker to perform
>> the communication between publishers and subscribers, I don't know how
>> that is implemented (what do they connect to? how each client
>> discovers each other?).
>>
>> I already got MQTT running, It's not completely clear to me how the
>> QoS setting works (atLeastOnce, exactlyOnce, atMostOnce), I don't
>> remember using that setting in Java (it probably had a sensible
>> default).
>>
>> Regards!
>>
>>
>> Esteban A. Maringolo
>>
>> On Tue, Jun 29, 2021 at 2:45 PM Jesus Mari Aguirre
>>  wrote:
>> >
>> > Maybe ZeroMQ fits you, but unlucky is not documented and there are only a 
>> > few examples. I use ir in my jupyter kernel. You can install my port to 
>> > pharo64 uFFI doing:
>> >
>> > Metacello new
>> > baseline: 'JupyterTalk';
>> > repository: 'github://jmari/JupyterTalk:master/repository';
>> > load:'zmq'
>> >
>> > But it needs ZeroMQ previously installed on your system.
>> > It was ported from http://smalltalkhub.com/#!/~panuw/zeromq now it is at: 
>> > https://github.com/dellani/zeroMQ but I'm not sure if the original repo 
>> > works on newer PharosI had no time to contact the original author to 
>> > join both repos...
>> >
>> >
>> >
>> > El mar, 29 jun 2021 a las 4:56, Esteban Maringolo () 
>> > escribió:
>> >>
>> >> Hi,
>> >>
>> >> I'm rearchitecting a web app to perform updates only when necessary
>> >> (instead of computing them all the time) on each request, I can have a
>> >> global announcer and subscribers to know when to update within an
>> >> image, but is there a way to have something like that but for
>> >> inter-image coordination?
>> >>
>> >> I'd only need to communicate the id and the class name (or a similar
>> >> identifier), so on other images they'll update accordingly, and if
>> >> there is an update in one image, it will notify the other images. The
>> >> common data is on the database, so this is just to avoid re-reading a
>> >> lot of things.
>> >>
>> >> Is a message queue a good fit for this? Pub/Sub?
>> >> What is available in Pharo that works without having to set up a lot of 
>> >> things?
>> >>
>> >> Thanks!
>> >>
>> >> Esteban A. Maringolo


[Pharo-users] Re: Communication between different images

2021-06-29 Thread Esteban Maringolo
As far as I understand, ZeroMQ does not require a broker to perform
the communication between publishers and subscribers, I don't know how
that is implemented (what do they connect to? how each client
discovers each other?).

I already got MQTT running, It's not completely clear to me how the
QoS setting works (atLeastOnce, exactlyOnce, atMostOnce), I don't
remember using that setting in Java (it probably had a sensible
default).

Regards!


Esteban A. Maringolo

On Tue, Jun 29, 2021 at 2:45 PM Jesus Mari Aguirre
 wrote:
>
> Maybe ZeroMQ fits you, but unlucky is not documented and there are only a few 
> examples. I use ir in my jupyter kernel. You can install my port to pharo64 
> uFFI doing:
>
> Metacello new
> baseline: 'JupyterTalk';
> repository: 'github://jmari/JupyterTalk:master/repository';
> load:'zmq'
>
> But it needs ZeroMQ previously installed on your system.
> It was ported from http://smalltalkhub.com/#!/~panuw/zeromq now it is at: 
> https://github.com/dellani/zeroMQ but I'm not sure if the original repo works 
> on newer PharosI had no time to contact the original author to join both 
> repos...
>
>
>
> El mar, 29 jun 2021 a las 4:56, Esteban Maringolo () 
> escribió:
>>
>> Hi,
>>
>> I'm rearchitecting a web app to perform updates only when necessary
>> (instead of computing them all the time) on each request, I can have a
>> global announcer and subscribers to know when to update within an
>> image, but is there a way to have something like that but for
>> inter-image coordination?
>>
>> I'd only need to communicate the id and the class name (or a similar
>> identifier), so on other images they'll update accordingly, and if
>> there is an update in one image, it will notify the other images. The
>> common data is on the database, so this is just to avoid re-reading a
>> lot of things.
>>
>> Is a message queue a good fit for this? Pub/Sub?
>> What is available in Pharo that works without having to set up a lot of 
>> things?
>>
>> Thanks!
>>
>> Esteban A. Maringolo


[Pharo-users] Re: Communication between different images

2021-06-29 Thread Esteban Maringolo
Hi Sven,

I thought about both RabittMQ and MQTT too.

For RabittMQ I noticed you provide a docker config to get a container
running quickly.
What is the easy-go solution for MQTT?

Regards!

Esteban A. Maringolo

On Tue, Jun 29, 2021 at 3:15 AM Sven Van Caekenberghe  wrote:
>
> Hi Esteban,
>
> > On 29 Jun 2021, at 04:55, Esteban Maringolo  wrote:
> >
> > Hi,
> >
> > I'm rearchitecting a web app to perform updates only when necessary
> > (instead of computing them all the time) on each request, I can have a
> > global announcer and subscribers to know when to update within an
> > image, but is there a way to have something like that but for
> > inter-image coordination?
> >
> > I'd only need to communicate the id and the class name (or a similar
> > identifier), so on other images they'll update accordingly, and if
> > there is an update in one image, it will notify the other images. The
> > common data is on the database, so this is just to avoid re-reading a
> > lot of things.
> >
> > Is a message queue a good fit for this? Pub/Sub?
> > What is available in Pharo that works without having to set up a lot of 
> > things?
> >
> > Thanks!
> >
> > Esteban A. Maringolo
>
> RabbitMQ (for which there is the STOMP client 'STAMP' 
> https://github.com/svenvc/stamp) is one option, but it is a bit more complex.
>
> I guess Redis would work too 
> (https://medium.com/concerning-pharo/quick-write-me-a-redis-client-5fbe4ddfb13d).
>
> More recently I have been using MQTT (with the client 
> https://github.com/svenvc/mqtt) which is much simpler.
>
> You post a message on a topic and have one or more listeners see it. You can 
> even arrange for the broker to keep the messages you miss (within a 
> reasonable window) - which is very nice for all kinds of reasons (especially 
> operational). I have a system in production that uses this mechanism to 
> coordinate different images (and handle ingress of data) for more than a year 
> now.
>
> Sven


[Pharo-users] Communication between different images

2021-06-28 Thread Esteban Maringolo
Hi,

I'm rearchitecting a web app to perform updates only when necessary
(instead of computing them all the time) on each request, I can have a
global announcer and subscribers to know when to update within an
image, but is there a way to have something like that but for
inter-image coordination?

I'd only need to communicate the id and the class name (or a similar
identifier), so on other images they'll update accordingly, and if
there is an update in one image, it will notify the other images. The
common data is on the database, so this is just to avoid re-reading a
lot of things.

Is a message queue a good fit for this? Pub/Sub?
What is available in Pharo that works without having to set up a lot of things?

Thanks!

Esteban A. Maringolo


[Pharo-users] Re: Rounding in Floats

2021-06-16 Thread Esteban Maringolo
I didn't know there were decimal floats.

Are they used elsewhere?

Esteban A. Maringolo

On Wed, Jun 16, 2021 at 11:20 AM Konrad Hinsen
 wrote:
>
> On 16/06/2021 15:52, Sven Van Caekenberghe wrote:
> > I am also a bit intrigued by this. Like you said: several other programming 
> > languages (I tried a couple of Common Lisp and Scheme implementations) do 
> > the same as Pharo, but handheld calculators, normal and scientific, do not.
>
> Handheld calculators use decimal floats, not binary floats. That doesn't
> remove rounding issues, but it makes conversion to and from print
> representations loss-free.
>
>
> Konrad


[Pharo-users] Re: Rounding in Floats

2021-06-16 Thread Esteban Maringolo
On Wed, Jun 16, 2021 at 10:52 AM Sven Van Caekenberghe  wrote:
>
> I am also a bit intrigued by this. Like you said: several other programming 
> languages (I tried a couple of Common Lisp and Scheme implementations) do the 
> same as Pharo, but handheld calculators, normal and scientific, do not.
>
> I think that going for 1/10 fractions/precision is not going to help: you got 
> a division by 113 in your formula 
> [https://en.wikipedia.org/wiki/Handicap_(golf)], this will give smaller 
> fractions.

And the reasons behind why they chose 113 are still unknown, because
that number is used to get a
"difficulty coefficient", so if the course is rated a 125, then
125/113 will give you roughly a ~1.1 coefficient.
They could have used 100.

> The problem is not the calculation (modern 64-bit floats as in Pharo are 
> plenty accurate), it is how you handle results. You should just round it 
> correctly and be done with it.

> Note that
> a roundTo: 0.01. (1e-14) still gives 4.5
> it is only one step further that you hit the limit and get the ugly but 
> correct result.

I'm not doing that, and I only store the original number (which has a
fixed decimal) and the "rounded" (to no decimals) number, all
intermediate numbers are re-calculated (maybe cached) but not stored
elsewhere. What I might be doing wrong is to store the original index
as float instead of a Decimal number.

> When computing with money, you would be inclined to put everything in cents 
> (because you cannot divide them further). But once you start computing 
> percentage discounts or taxes, you again get problems. At each of those steps 
> you must make sure that no cents are lost.

And that includes adding a "rounding" item for any difference in all
invoices, orders, etc.

Regards!

Esteban A. Maringolo


[Pharo-users] Re: Rounding in Floats

2021-06-16 Thread Esteban Maringolo
On Wed, Jun 16, 2021 at 10:49 AM Richard O'Keefe  wrote:
> The problem is that while it is possible to read the ANSI Smalltalk standard 
> as requiring ScaledDecimals to be fixed point numbers (which are a kind of 
> exact rational number of the form x * 10**y, x and y integers), in Squeak and 
> Pharo ScaledDecimal numbers are NOT fixed-point numbers.  They are unlimited 
> rational numbers with the scale being used for printing purposes only.  This 
> creates enormous confusion and I really don't see any point in Squeak/Pharo 
> ScaledDecimal existing at all.

I only used decimals in other platforms, and only for accounting
purposes, but to me if two scaled decimals print the same but answer
false to #= then something is wrong conceptually. I can identify the
issue, but the reasoning behind how it works, or even more, how to fix
it, is above my level.

> There *is* point in having fixed-point decimal numbers as they are a perfect 
> match for SQL data bases and several programming languages.

That's the only use I gave it.
So if we divided 10.0s1 / 3 ended up with 3.3s1 each, and we had to
calculate the rounding errors (0.1s1 in this case) to make all
balance.

> I've now located a PDF of the USGA Rules of Handicapping.  Wow.  128 pages.

That's just USGA, there is a "World System" but each "region" or local
federation does a variation of the "world system". So Belgium does one
thing, Australia another one, Argentina another one, England decided
to only take one part...  standards, they call it :-)

I Implemented a couple of them.

> And with all that they couldn't explain the calculations precisely.

Try to ask one federation how they calculate the PCC, and they won't
tell you, it's like the coca-cola formula.

>  Rounding
> arrives in more than one place.  For example you might have to average the
> best 1-8 of the last (as many as are available up to 20) scores and then round
> to one decimal, but it is not stated how ties are to be broken (which can 
> arise
> for the best 2, 4, 6, or 8).

In this computation, the tie doesn't matter, because you start with an
_already rounded_ number (called a "differential"), so it doesn't
matter if you choose 11.4 from the 5th or 11.4 from the 19th. The
rounding happens at the very end and determines a new rounded (to one
decimal) number that's going to be used in other formulas (like the
one that re-kicked this thread).

The ties in competitions are solved differently. In real tournaments
by playoff, or in amateur tournaments either by playoff or by a hole
by hole comparison. If that even happens[*], there is the option to
toss a coin to untie it.

[*] In +400 tournaments managed by my software (involving ~15000
scorecards), that never happened.


So to wrap up and bring it back to the topic, a proper ScaledDecimal
implementation would help me storing the numbers as such guaranteeing
no floating point funny thing happens, but since there is no such
thing, I'll rather build the scaled decimals manually (e.g.
ScaledDecimal fromFraction: 67/10) or not use scaled decimals and try
to use the Fractions directly wherever possible.

It's always good to learn new things.


[Pharo-users] Re: Rounding in Floats

2021-06-16 Thread Esteban Maringolo
On Wed, Jun 16, 2021 at 9:13 AM Konrad Hinsen
 wrote:
>
> On 15/06/2021 16:05, Esteban Maringolo wrote:
> > And in this particular case, it might cause issues, since the "full
> > precision" (whatever that means) must be retained when using such a
> > number to derive another one.
>
> To me, "full precision" means "no precision is ever lost in arithmetic
> operations". If that's what you need, your choices are
>
> 1) Integers
>
> 2) Rational numbers (fractions)

> Pharo has 1) and 2).

Yeap, I'll switch to 2.

What I'm not totally convinced of is whether to store numbers as
integers (knowing beforehand the decimal precision, and converting it
to fractions when read back) or if to store them as scaled decimals
(which internally hold a fraction).

Thanks!


[Pharo-users] Re: Rounding in Floats

2021-06-15 Thread Esteban Maringolo
Hi Sven,

I accidentally skipped this.

How is this different from the GRNumberPrinter?

Where is the code available?

Thanks!

Esteban A. Maringolo

On Mon, Jun 14, 2021 at 6:30 PM Sven Van Caekenberghe  wrote:
>
> BTW, I recently wrote my own float printer, as an experiment.
>
> NeoJSONFloatPrinter lowPrecision print: a.
>
> => 4.5
>
> What I wanted was a human friendly, compact float printer, that tries to go 
> for the shortest, simplest number. It prefers integers and goes to scientific 
> notation when needed, while limiting the precision. Maybe it is interesting 
> to look at the code.
>
> But I am far from an expert.
>
> > On 14 Jun 2021, at 23:23, Sven Van Caekenberghe  wrote:
> >
> >
> >
> >> On 14 Jun 2021, at 22:44, Esteban Maringolo  wrote:
> >>
> >> I'm coming back to this because I've been bitten by these floating
> >> points things again.
> >>
> >> If in Pharo [1] you do:
> >> a := 6.7 + (32.8 - 35)
> >>
> >> It will produce:
> >> 4.497
> >>
> >> Which, when rounded, will produce 4.
> >
> > But,
> >
> > a roundTo: 0.1 "=> 4.5"
> >
> >> In other places [2] I do the same simple addition and subtraction it
> >> produces 4.5, that when rounded will produce 5.
> >>
> >> I know now that Pharo doesn't lie to me while other systems do, and
> >> all that Richard pointed to before.
> >>
> >> The issue here is that I'm following some calculation formula that was
> >> defined in some of the "other" systems, and so when I follow such a
> >> formula I get these edgy cases where my system produces a different
> >> output.
> >>
> >> In this case the formula is for golf handicap calculations, and it
> >> caused my system to give 4 instead of 5 to a player, resulting in
> >> giving the first place to a player other than the one deserved.
> >> It was no big deal (it's not The Masters), but these cases appear from
> >> time to time.
> >>
> >> Is there any way to "configure" the floating point calculation to
> >> behave as the "other systems"?
> >>
> >> What is the best way to anticipate these situations, am I the only one
> >> being bitten by these issues?
> >>
> >> Thanks in advance for any hints about these problems.
> >>
> >>
> >> Best regards,
> >>
> >> [1] Dolphin Smalltalk, JS, Python, Ruby, Dart produces the same output as 
> >> Pharo.
> >> [2] VisualWorks, VAST, Excel, VB and all calculators I tried
> >>
> >>
> >>
> >> Esteban A. Maringolo
> >>
> >> On Tue, Sep 8, 2020 at 12:45 AM Esteban Maringolo  
> >> wrote:
> >>>
> >>> On Tue, Sep 8, 2020 at 12:16 AM Richard O'Keefe  wrote:
> >>>>
> >>>> "7.1 roundTo: 0.1 should return 7.1"
> >>>> You're still not getting it.
> >>>
> >>> I was until Konrad explained it.
> >>>
> >>>> Binary floating point CANNOT represent either of those numbers.
> >>>> You seem to be assuming that Pharo is making some mistake.
> >>>> It isn't.  All it is doing is refusing to lie to you.
> >>> 
> >>>> The systems that print 7.1 are LYING to you,
> >>>> and Pharo is not.
> >>>
> >>> I'm not assuming a mistake from Pharo, I had a wrong expectation what
> >>> to get if I round to that precision.
> >>> I don't know whether other systems lie or simply fulfill user
> >>> expectations, if you send the #roundTo: to a float, I did expect to
> >>> get a number with the same precision.
> >>> That is my expectation as a user. As in the other thread I expected
> >>> two scaled decimals that are printed equal to also be compared as
> >>> equal  (which they don't).
> >>>
> >>> Whether there is a good reason for those behaviors is beyond my
> >>> current comprehension, but it certainly doesn't follow the "principle
> >>> of least surprise".
> >>>
> >>> In any case, the method proposed by Tomohiro solved my issues.
> >>>
> >>> Regards,
> >>>
> >>> Esteban A. Maringolo


[Pharo-users] Re: Rounding in Floats

2021-06-15 Thread Esteban Maringolo
Hi Richard,

> Whether 6.7 - 2.2 gives 4.5 or something else is a subtle issue,
> starting with the fact
> that 6.7 and 2.2 cannot be represented precisely in floating-point
> format.  In this particular case, the errors happen to match up.
> What you *can* rely on in Smalltalk is that (67/10) - (22/10) = (9/2).
>
> Let's just consider h * s / 113 + (r - p).
> If h, s, r, and p are all exact numbers (Integers or Fractions) the
> result will be an exact number.
> So what kinds of number are h, s, r, and p, and *why* are they
> like that?  If you are reading them from a file, consider that
> Fraction readFrom: '6.7' readStream >>> (67/10)

I'm not reading them from a file, although some numbers come from an
API as a JS number (float).

Using Fractions wherever possible seems to be the right solution to
this. And given that I already know the precision (it's always 1
decimal as much) I can turn everything into that and store them as
DECIMAL in the database.

I'm reluctant to perform such a change because everything has been
working fine and this is just an edge case, but I think it is the
right thing to do.

> Is there a specification you could show us?

There is no specification other than the formulas:
https://www.usga.org/content/usga/home-page/handicapping/roh/2020-rules-of-handicapping.html

Section III -> Rules 6.1 and 6.2

There is only a remark after 6.1b that you must retain full precision
in intermediate calculations.
"the full calculated value is retained and rounding occurs only after
the Playing Handicap calculation."

> Some test data?

Not that I could find, I've been adding cases to my tests to assert it
behaves properly.

Thanks!


Esteban A. Maringolo

On Tue, Jun 15, 2021 at 4:13 AM Richard O'Keefe  wrote:
>

>
>
> On Tue, 15 Jun 2021 at 14:24, Esteban Maringolo  wrote:
> >
> > On Mon, Jun 14, 2021 at 10:37 PM Richard O'Keefe  wrote:
> >
> > > For what it's worth, I expected ScaledDecimal to act like fixed point
> > > arithmetic, and implemented it that way in my own Smalltalk library, where
> > > two ScaledDecimals *do* print the same if and only if they are numerically
> > > exactly the same.
> > > What Squeak and Pharo do is exceedingly odd: a ScaledDecimal
> > > is an exact rational number (Integer or Fraction) combined with a 
> > > precision that
> > > is used for printing, not for calculation.
> >
> > I pointed out before the weird behavior of ScaledDecimals in Pharo,
> > two ScaledDecimal that print the same are not equal. Giving some weird
> > comparison issues as result.
> >
> > > There really isn't any principle of least surprise when it comes to 
> > > floating-
> > > point arithmetic.  It's full of surprises and edge cases.  Excel in 
> > > particular
> > > is notorious for messing up due to trying to pretend all is well.
> > > In this particular case, the exact result is 4.5
> >
> > Well... for the end user, it produces what they'd expect. So it might
> > mess up, but in a spreadsheet 6.7 - 2.2 should give 4.5.
> >
> > > There are at least three rules for rounding such numbers: rounding out 
> > > (5),
> > > rounding in (4), and rounding in [banker'salgorithm] (4 here, but 5.5 -> 
> > > 6).
> > > So you are pushing up against an edge case for exact hand calculation!
> >
> > I implemented a Float>>#roundedHandicap method that does something
> > like the banking algorithm, but rounds positive numbers towards the
> > next integer and negative numbers towards zero.
> > E.g.
> > 0.49 -> 0
> > 0.5 -> 1
> > -0.5 -> 0
> > -0.51 -> -1
> >
> > Nothing uses more than one decimal, so a ScaledDecimal would work but
> > the specification says that it should use all possible precision in
> > intermediate calculations, so I cannot use it.
> >
> > > I think you need to re-express your entire calculation to use exact 
> > > arithmetic.
> >
> > I really don't know how to do this, any pointers?
> >
> > Nothing is more straightforward than addition and subtraction to me,
> > 6.7 - 2.2 is the simplest it can get.
> >
> > The common formula here is: h * s / 113 + (r - p), but in this
> > particular case s was 113 so it removed the "troubling" part.
> >
> > > That or get agreement on "de minimis non curat lex".
> >
> > I had to search for that expression. Now I know, I agree.
> >
> > Regards,
> >
> > Esteban A. Maringolo
> >
> >
> >
> > >
> > >
> > > On Tue, 15 Jun 2021 at 08:45, Esteban Maringolo  
&

[Pharo-users] Re: Rounding in Floats

2021-06-15 Thread Esteban Maringolo
Well... fixed point numbers (aka ScaledDecimals) had their issues as well.

And in this particular case, it might cause issues, since the "full
precision" (whatever that means) must be retained when using such a
number to derive another one.

E.g. in my case:
ch := 6.7 + (32.8 - 35). "course handicap"
allowance := 0.85. "85%"
ph := (ch * allowance) roundedHandicap. "playing handicap"

The #roundedHandicap is like #rounded but rounds -0.5 towards -1
instead of toward 0.

My first approach was to use fixed points, but then I hit issues where
some results also produced "wrong" numbers (according to the
reference), also in Pharo some ScaledDecimals compare as different
even when they're printed as the same (which is not correct, IMO).

I just tested using everything as fractions and converting to float
(or ScaledDecimal) at the very last step and it produces the expected
result. I'll review and convert whatever is needed (including database
fields) to work with this. The good thing is that all the involved
numbers only have one decimal as much.

Thanks!

Esteban A. Maringolo

On Tue, Jun 15, 2021 at 3:48 AM Steffen Märcker  wrote:
>
> Have you considered using fixed-point arithmetic? For example:
> 7.1s2 roundTo: 0.1s2
>
> The rule of thumb I stick to is to use FP only if I know the inaccuracies
> won't bite me. Funny enough, both 7.1 and 0.1 are already not accurately
> representable as floats. (And by coincidence, I prepared exam questions
> about floats for my students yesterday. )
>
> Kind regards,
> Steffen
>
>
> Konrad Hinsen schrieb am Dienstag, 15. Juni 2021 07:02:30 (+02:00):
>
>  > On 15/06/2021 01:03, Esteban Maringolo wrote:
>  > > Sure, but what initiated this thread was a reference to roundTo: 0.1
>  > > which produced a "wrong" output.
>  > >
>  > > (9.1 + (-2.0)) roundTo: 0.1 "=> 7.1005"
>  > > 7.1 roundTo: 0.1 "=> 7.1005"
>  > >
>  > > However, at this point I know that Pharo "does the right, raw, thing"
>  > > (at least compared to other mainstream languages), but it still
>  > > produces a surprise effect.
>  >
>  > That's the "floating point surprise" that everyone has at some point, no
> matter the language and runtime system. If that surprise is a problem for
> you, are you sure that floating-point arithmetic is what you really want?
> Maybe your needs are better served with integers and fractions.
>  >
>  >
>  > Konrad.
>  >
>  >
> --
> Gesendet mit Vivaldi Mail. Laden Sie Vivaldi kostenlos von vivaldi.com
> herunter.


[Pharo-users] Re: Rounding in Floats

2021-06-14 Thread Esteban Maringolo
On Mon, Jun 14, 2021 at 10:37 PM Richard O'Keefe  wrote:

> For what it's worth, I expected ScaledDecimal to act like fixed point
> arithmetic, and implemented it that way in my own Smalltalk library, where
> two ScaledDecimals *do* print the same if and only if they are numerically
> exactly the same.
> What Squeak and Pharo do is exceedingly odd: a ScaledDecimal
> is an exact rational number (Integer or Fraction) combined with a precision 
> that
> is used for printing, not for calculation.

I pointed out before the weird behavior of ScaledDecimals in Pharo,
two ScaledDecimal that print the same are not equal. Giving some weird
comparison issues as result.

> There really isn't any principle of least surprise when it comes to floating-
> point arithmetic.  It's full of surprises and edge cases.  Excel in particular
> is notorious for messing up due to trying to pretend all is well.
> In this particular case, the exact result is 4.5

Well... for the end user, it produces what they'd expect. So it might
mess up, but in a spreadsheet 6.7 - 2.2 should give 4.5.

> There are at least three rules for rounding such numbers: rounding out (5),
> rounding in (4), and rounding in [banker'salgorithm] (4 here, but 5.5 -> 6).
> So you are pushing up against an edge case for exact hand calculation!

I implemented a Float>>#roundedHandicap method that does something
like the banking algorithm, but rounds positive numbers towards the
next integer and negative numbers towards zero.
E.g.
0.49 -> 0
0.5 -> 1
-0.5 -> 0
-0.51 -> -1

Nothing uses more than one decimal, so a ScaledDecimal would work but
the specification says that it should use all possible precision in
intermediate calculations, so I cannot use it.

> I think you need to re-express your entire calculation to use exact 
> arithmetic.

I really don't know how to do this, any pointers?

Nothing is more straightforward than addition and subtraction to me,
6.7 - 2.2 is the simplest it can get.

The common formula here is: h * s / 113 + (r - p), but in this
particular case s was 113 so it removed the "troubling" part.

> That or get agreement on "de minimis non curat lex".

I had to search for that expression. Now I know, I agree.

Regards,

Esteban A. Maringolo



>
>
> On Tue, 15 Jun 2021 at 08:45, Esteban Maringolo  wrote:
> >
> > I'm coming back to this because I've been bitten by these floating
> > points things again.
> >
> > If in Pharo [1] you do:
> > a := 6.7 + (32.8 - 35)
> >
> > It will produce:
> > 4.497
> >
> > Which, when rounded, will produce 4.
> >
> > In other places [2] I do the same simple addition and subtraction it
> > produces 4.5, that when rounded will produce 5.
> >
> > I know now that Pharo doesn't lie to me while other systems do, and
> > all that Richard pointed to before.
> >
> > The issue here is that I'm following some calculation formula that was
> > defined in some of the "other" systems, and so when I follow such a
> > formula I get these edgy cases where my system produces a different
> > output.
> >
> > In this case the formula is for golf handicap calculations, and it
> > caused my system to give 4 instead of 5 to a player, resulting in
> > giving the first place to a player other than the one deserved.
> > It was no big deal (it's not The Masters), but these cases appear from
> > time to time.
> >
> > Is there any way to "configure" the floating point calculation to
> > behave as the "other systems"?
> >
> > What is the best way to anticipate these situations, am I the only one
> > being bitten by these issues?
> >
> > Thanks in advance for any hints about these problems.
> >
> >
> > Best regards,
> >
> > [1] Dolphin Smalltalk, JS, Python, Ruby, Dart produces the same output as 
> > Pharo.
> > [2] VisualWorks, VAST, Excel, VB and all calculators I tried
> >
> >
> >
> > Esteban A. Maringolo
> >
> > On Tue, Sep 8, 2020 at 12:45 AM Esteban Maringolo  
> > wrote:
> > >
> > > On Tue, Sep 8, 2020 at 12:16 AM Richard O'Keefe  wrote:
> > > >
> > > > "7.1 roundTo: 0.1 should return 7.1"
> > > > You're still not getting it.
> > >
> > > I was until Konrad explained it.
> > >
> > > > Binary floating point CANNOT represent either of those numbers.
> > > > You seem to be assuming that Pharo is making some mistake.
> > > > It isn't.  All it is doing is refusing to lie to you.
> > > 
> > > > The systems that print 7.1 are LYING to you,
> > > > and

[Pharo-users] Re: Rounding in Floats

2021-06-14 Thread Esteban Maringolo
Hi Sven,

> > If in Pharo [1] you do:
> > a := 6.7 + (32.8 - 35)
> > It will produce:
> > 4.497
> > Which, when rounded, will produce 4.

> But,
> a roundTo: 0.1 "=> 4.5"

Sure, but what initiated this thread was a reference to roundTo: 0.1
which produced a "wrong" output.

(9.1 + (-2.0)) roundTo: 0.1 "=> 7.1005"
7.1 roundTo: 0.1 "=> 7.1005"

However, at this point I know that Pharo "does the right, raw, thing"
(at least compared to other mainstream languages), but it still
produces a surprise effect.

In particular when people go to Excel to "check that your system does
the right thing", uses the same formula and it gives a different
result to them. Then open a calculator (or a physical one) and it
gives the same number as Excel. So an hour after the fact you're
arguing about floating point implementations to non-technical people
:-)

Regards!

Esteban A. Maringolo


[Pharo-users] Re: Rounding in Floats

2021-06-14 Thread Esteban Maringolo
I'm coming back to this because I've been bitten by these floating
points things again.

If in Pharo [1] you do:
a := 6.7 + (32.8 - 35)

It will produce:
4.497

Which, when rounded, will produce 4.

In other places [2] I do the same simple addition and subtraction it
produces 4.5, that when rounded will produce 5.

I know now that Pharo doesn't lie to me while other systems do, and
all that Richard pointed to before.

The issue here is that I'm following some calculation formula that was
defined in some of the "other" systems, and so when I follow such a
formula I get these edgy cases where my system produces a different
output.

In this case the formula is for golf handicap calculations, and it
caused my system to give 4 instead of 5 to a player, resulting in
giving the first place to a player other than the one deserved.
It was no big deal (it's not The Masters), but these cases appear from
time to time.

Is there any way to "configure" the floating point calculation to
behave as the "other systems"?

What is the best way to anticipate these situations, am I the only one
being bitten by these issues?

Thanks in advance for any hints about these problems.


Best regards,

[1] Dolphin Smalltalk, JS, Python, Ruby, Dart produces the same output as Pharo.
[2] VisualWorks, VAST, Excel, VB and all calculators I tried



Esteban A. Maringolo

On Tue, Sep 8, 2020 at 12:45 AM Esteban Maringolo  wrote:
>
> On Tue, Sep 8, 2020 at 12:16 AM Richard O'Keefe  wrote:
> >
> > "7.1 roundTo: 0.1 should return 7.1"
> > You're still not getting it.
>
> I was until Konrad explained it.
>
> > Binary floating point CANNOT represent either of those numbers.
> > You seem to be assuming that Pharo is making some mistake.
> > It isn't.  All it is doing is refusing to lie to you.
> 
> > The systems that print 7.1 are LYING to you,
> > and Pharo is not.
>
> I'm not assuming a mistake from Pharo, I had a wrong expectation what
> to get if I round to that precision.
> I don't know whether other systems lie or simply fulfill user
> expectations, if you send the #roundTo: to a float, I did expect to
> get a number with the same precision.
> That is my expectation as a user. As in the other thread I expected
> two scaled decimals that are printed equal to also be compared as
> equal  (which they don't).
>
> Whether there is a good reason for those behaviors is beyond my
> current comprehension, but it certainly doesn't follow the "principle
> of least surprise".
>
> In any case, the method proposed by Tomohiro solved my issues.
>
> Regards,
>
> Esteban A. Maringolo


[Pharo-users] Re: [ANN] Pharo-ODBC

2021-06-14 Thread Esteban Maringolo
Thank you John! This is very good news!

Best regards,

Esteban A. Maringolo

On Mon, Jun 14, 2021 at 6:29 AM John Aspinall  wrote:
>
> There is now an ODBC framework for Pharo, available at the pharo-rdbms github 
> site:
>
> https://github.com/pharo-rdbms/Pharo-ODBC
>
> This is based on the Dolphin Smalltalk Database Connection ODBC framework. 
> Provided a suitable driver manager is installed this should work on MacOS and 
> Linux in addition to Windows.
>
> Thanks to InfOil for supporting the development, to Torsten for tidying up 
> and hosting the code, and Andy and Blair (Dolphin developers) for the 
> original framework.
>
> Regards,
>
> John Aspinall


[Pharo-users] SQLite3 primitiveFailed after FFI call

2021-04-30 Thread Esteban Maringolo
Hi all,

I'm having a strange issue when executing a query with the SQLite3
driver (via GLORP).

In:
SQLite3Library>>#apiPrepare: dbHandle withSQLText: anSQLText with:
textSize with: sHandle with: tail
"int sqlite3_prepare_v2(sqlite3*, const char*, int, sqlite3_stmt**,
const char **)"

^ self ffiCall: #(int sqlite3_prepare_v2 (sqlite3* dbHandle, String
anSQLText, int textSize, sqlite3_stmt** sHandle, const char** tail))

After the FFI call, I get a primitive failed error when some part of
the FFI machinery sends instVarAt: index to the undefined object.

This is the call stack:
PrimitiveFailed(Exception)>>signal
PrimitiveFailed class(SelectorException class)>>signalFor:
UndefinedObject(ProtoObject)>>primitiveFailed:
UndefinedObject(ProtoObject)>>primitiveFailed
UndefinedObject(Object)>>instVarAt:
SQLite3Library>>apiPrepare:withSQLText:with:with:with:
SQLite3Library>>prepare:on:with:
SQLite3PreparedStatement>>prepare:
SQLite3Connection(SQLite3BaseConnection)>>prepare:
SQLite3Connection>>execute:with:
SQLite3Driver>>basicExecuteSQLString:binding:
SQLite3Driver>>basicExecuteSQLString:
PharoDatabaseAccessor>>basicExecuteSQLString:
PharoDatabaseAccessor>>executeCommandUnbound:
QuerySelectCommand(DatabaseCommand)>>executeUnboundIn:

If I run the same query via an external SQL tool (sqlite3) it works,
returning a single row with a single value as expected.

What's weird is that this doesn't fail always, since it's a very
common query in the app.

Any ideas?

Esteban A. Maringolo


[Pharo-users] Re: creating a subclass in system browser

2021-04-27 Thread Esteban Maringolo
It's been there as a refactoring for a while. Why a refactoring? Who
knows...


Esteban A. Maringolo


On Tue, Apr 27, 2021 at 1:59 PM kmo  wrote:

> / a red circled exclamation point (hovering says 'Refactorings' - which
> has a
> menu for the +New subclass./
>
> That sounds completely horrible. Surely that's never going to remain in the
> official release.
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>


[Pharo-users] Re: Announcements - and whether its bad to check if a subscription would be handled?

2021-04-27 Thread Esteban Maringolo
The bubbling up is very common in UI, I don't know how it is implemented
though.
I don't know if event handling is programmed using events or imperative
calls to continue "bubbling" up, or... the event is handler by the
container presenter and passed down to the target (e.g. a button).

So the end user of the event registers the handling of an event directly at
the component (presenter in MVP), regardless of who fires it. And it is the
event object or the listener of the event that decides to stop its
propagation.

Regards,

Esteban A. Maringolo


On Tue, Apr 27, 2021 at 12:50 PM Tim Mackinnon  wrote:

> Hi guys - yes that fire and forget was always how I had viewed
> announcements, and potentially my scenario is misusing "announcements"
> which is why I was interested in views here.
>
> However - as announcements are typically a mechanism for farming out
> processing to others - how does one handle the scenario that you might only
> want one object to handle the announcement (and not others)?
>
> in my specific example, with MVP - a view, totally decoupled in a web
> browser, wants to pass on a button click to a presenter - however it not
> clear what the best mechanism to bubble up that handling should be? If the
> immediate presenter of the view can handle it - great - but if not, how
> would you continue to broadcast wider to see if someone higher up the
> parent component chain can handle it?
>
> If you go fire and forget (which is how I had viewed announcements prior
> to this specific case) - then you have the problem a different way - when
> someone processes an announcement it might already have been handled
> earlier and so the consumer either has to check first, or their work is
> simply ignored as the announcement payload could just filter a response out.
>
> In my head, I'm sort of thinking this is akin to CPU interrupt chaining -
> where an interrupt can cascade up a stack if not handled OR like object
> inheritance where an object can choose to override a message and stop it
> from cascading up the inheritance chain.
>
> Maybe announcements aren't intended for this at all - although it seems an
> elegant way to handle it - with just 1 method addition to Announcer (but it
> does slightly expose things - albeit in a structured way - and similar to
> the similar #hasSubscriber:).
>
> I'm sure it "depends" - but interested in other observations from the
> field, as I'm sure I'm not the first person to hit something like this.
>
> Tim
>
> On Tue, 27 Apr 2021, at 3:51 PM, Sven Van Caekenberghe wrote:
> > The whole idea is to decouple producers and consumers, like in
> > messaging systems.
> >
> > You should not care if there are other listening, just like the
> > listeners should not care if there is someone posting data.
> >
> > Asking for subscribers is introducing a coupling.
> >
> > The announcement mechanism will/should deal with this in an efficient
> way.
> >
> > > On 27 Apr 2021, at 16:03, Tim Mackinnon  wrote:
> > >
> > > From my rather long ramble below - I am still curious if its
> distasteful to have a method on Announcer
> > >
> > > hasSubscriptionsHandling: anAnnouncement
> > > "Answer true if I have any subscribers to anAnnouncement"
> > >
> > > ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
> > >
> > > Tim
> > >
> > > On Thu, 22 Apr 2021, at 11:34 PM, Tim Mackinnon wrote:
> > >> Hi everyone - I’ve always thought the article on announcements many
> > >> years ago was very cool - and we don’t seem to use them as much as we
> > >> could (but equally they aren’t a panacea to be overused everywhere
> > >> either - and they do get used in Pharo to some extent).
> > >>
> > >> Anyway, I’ve been playing around with CodeParadise (CP is a very cool
> > >> project, and Erik is very supportive and thinking about how to write
> > >> web apps a different way… I’m fascinated),
> > >>
> > >> And - CP uses announcements as mechanism to send events from the View
> > >> Client (in a web browser) to a Presenter on the server (which makes
> > >> total sense).
> > >>
> > >> In taking things for a spin, I hit an interesting problem on how in a
> > >> web component world, you should display a spelling test of words -
> > >>
> > >> e.g. SpellingTest — has many —> SpellingWord(s).
> > >>
> > >>
> > >> Initially I bunged it all in a single presenter with its associated
> > >> view, and it was a bit messy, and Erik guided me down a route (that
> CP
> > >> nicely supports) - that my SpellingTest view should have the
> name/date
> > >> of the test as well as an add word input field, but the list of
> current
> > >> Words (which I had bunged into a table) - were actually more elegant
> as
> > >> sub-components - hence a WordView - which renders a single word in a
> > >> DIV, and for the edit screen I was creating, a Delete button next to
> > >> the word (so you could delete it). So a 1 to many relationship
> > >> essentials.
> > >>
> > >> This is where the announcements kick in (and lead to my 

[Pharo-users] Re: Announcements - and whether its bad to check if a subscription would be handled?

2021-04-27 Thread Esteban Maringolo
Exceptions are real, so your use case might justify it.
In my experience I never had to test whether an announcer has some
subscription, and before using announcements whether an object has some
"listener" to some event.

I always saw announcements as a fire and forget kind of architecture.

Not sure if I'm answering your question (probably not), but let's start
this conversation :-)

Esteban A. Maringolo


On Tue, Apr 27, 2021 at 11:04 AM Tim Mackinnon  wrote:

> From my rather long ramble below - I am still curious if its distasteful
> to have a method on Announcer
>
> hasSubscriptionsHandling: anAnnouncement
> "Answer true if I have any subscribers to anAnnouncement"
>
> ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
>
> Tim
>
> On Thu, 22 Apr 2021, at 11:34 PM, Tim Mackinnon wrote:
> > Hi everyone - I’ve always thought the article on announcements many
> > years ago was very cool - and we don’t seem to use them as much as we
> > could (but equally they aren’t a panacea to be overused everywhere
> > either - and they do get used in Pharo to some extent).
> >
> > Anyway, I’ve been playing around with CodeParadise (CP is a very cool
> > project, and Erik is very supportive and thinking about how to write
> > web apps a different way… I’m fascinated),
> >
> > And - CP uses announcements as mechanism to send events from the View
> > Client (in a web browser) to a Presenter on the server (which makes
> > total sense).
> >
> > In taking things for a spin, I hit an interesting problem on how in a
> > web component world, you should display a spelling test of words -
> >
> > e.g. SpellingTest — has many —> SpellingWord(s).
> >
> >
> > Initially I bunged it all in a single presenter with its associated
> > view, and it was a bit messy, and Erik guided me down a route (that CP
> > nicely supports) - that my SpellingTest view should have the name/date
> > of the test as well as an add word input field, but the list of current
> > Words (which I had bunged into a table) - were actually more elegant as
> > sub-components - hence a WordView - which renders a single word in a
> > DIV, and for the edit screen I was creating, a Delete button next to
> > the word (so you could delete it). So a 1 to many relationship
> > essentials.
> >
> > This is where the announcements kick in (and lead to my ultimate
> question).
> >
> > When you click the Delete button, if I use a sub component - my view
> > will generate a DeleteWordAnnouncement - which gets fed to my
> > SpellingWordPresenter - however words in this sense don’t naturally
> > know their parent (the SpellingTest) - and its the parent test that has
> > a #deleteWord: method.
> >
> > I’ve been taking with Erik, on different ways to elegantly handle this.
> >
> > a) you could change the model so words know their parent (in my case,
> > I’m using a 3rd party model for Flashcards, and they just don’t know
> > this - and adapting them would be a nuisance
> > b) my TestPresenter could listen to announcements on the WordPresenter
> > - and I could get some communications between presenters (although
> > normally the Presenters just get events from Views, and pure domain
> > models - so it feels a bit abnormal to consider another Presenter as a
> > sort of model - but I could live with this
> > c) given the composable nature of views/presenters (and CP is base on a
> > WebComponent model) - you could bubble up Announcements, so that if an
> > event isn’t handled by a view’s immediate presenter, you could re-route
> > it to the parent of the View (the component owner) and see if it’s
> > presenter could do something.
> >
> >
> > I think (c) has a certain expectation to it - in fact when I converted
> > my initial one-presenter attempt into components, I still had listener
> > code in my TestPresenter that was expecting to get a deleteWord
> > announcement and I was initially surprised that I wasn’t getting it (as
> > it was now just going to the Word component I had refactored out).
> >
> > So I wonder if others here would expect things to work this way too
> > (and are there other examples in the wild that lead you here - or scare
> > you away from this?).
> >
> > Back to  my Announcement question - if C is a good idea - why doesn’t
> > the Announcer class let you check if if will handle a particular
> > announcement? The API has  #hasSubscriber: and #hasSubscriberClass: ,
> > but its missing:
> >
> > hasSubscriptionsHandling: anAnnouncement
> >   "Answer true if I have any subcribers to anAnnouncement"
> >
> >   ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
> >
> >
> > And I am wondering if this is because it's a bad thing to expect to be
> > able to check? In my case above, I would want to do this to know if CP
> > should instead try announcing a message to a parent presenter because
> > the current presenter won’t handle it.  In my example above, my
> > WordComponentView will broadcast that the delete button was clicked,
> > but its 

[Pharo-users] Re: Postgres P3 Driver in seaside/web apps - strategy for "prepare:"

2021-04-19 Thread Esteban Maringolo
Not completely related, but also not unrelated. (?)

You can pool your connections in the server side by means of pg_bouncer [1]
to scale tenfold (or more) the connectivity to your PostgreSQL server.
So you can program with P3Client and then when you need to scale the
connectivity, simply do it on the server side.

Of course if you have 1000s of P3Clients on a single image, then it might
take a big toll on the memory use, so it also depends on how you balance
connections.

Best regards,

[1] https://www.pgbouncer.org/config.html

Esteban A. Maringolo


On Mon, Apr 19, 2021 at 2:52 PM Sven Van Caekenberghe  wrote:

> Hi Sanjay,
>
> > On 19 Apr 2021, at 18:14, Sanjay Minni  wrote:
> >
> > Hi
> >
> > using the P3 Postgres driver
> >
> > what is the optimised way of using the following in a seaside/web
> > application
> >  statement := client prepare: ...
> >  statement execute:
> >  statement close.
> >
> > Sven readme on the drivers page
> > "prepared statements ... need to be closed, prepared statement exist ...
> > single session / connection ..."
>
> First make sure that you give each session in your (seaside) web
> application its own connection/client to the database. P3Client is meant to
> be used single threaded, it is your responsibility to protect this. Make
> sure these are initialised and disposed of properly - use logging.
>
> Second, I would not put time in trying to gain performance with prepared
> statements until you can prove that it makes a real, measurable difference.
> PostgreSQL is very fast. But this is IMHO.
>
> See further.
>
> > Typically in a desktop app I would fire the "prepare" statements(s) once
> > when open the particular UI / window (say typically 2 or 3 statements in
> a
> > UI) and then "close" when I exit
> >
> > How does this work in a multi-tabbed browser app
> > lets say I open a tab with a particular UI and fire the "prepare"
> statement
> >
> > now what if the tab idles for too long - and then i press send/save. The
> > program would have just fired the "execute ..." assuming the prepare is
> > active. would the prepare / session have been automatically closed ?
> >
> > - when should i typically fire the prepare statement
>
> Either upfront when you connect, or each time when you need them (see
> further). The scope of a prepared statement is the connection/session.
>
> Preparing 10s of statements upfront that you might not need could increase
> connection time.
>
> > - how should i test if the session / prepare is still active or needs to
> be
> > refired
>
> There is P3Client>>#preparedStatementNamed:
> You best use P3Client>>#prepare:named: then.
>
> > - how are orphan prepare statements disposed off ny the database /
> program
>
> They get thrown out when the connection closes.
>
> HTH,
>
> Sven
>
> PS:
>
> There is also P3ConnectionPool that can protect against concurrent access,
> prepare connections, warm up, on top of its base functionality of pooling,
> of course. But a challenge with connection pooling is what to do when
> errors occur.
>
> > thanks for pointers
> > Sanjay
> >
> >
> >
> > -
> > cheers,
> > Sanjay
> > --
> > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>


[Pharo-users] Re: We haven't had a design debate in a while - thoughts on CD.buy article...

2021-04-16 Thread Esteban Maringolo
I saw a tweet about that, and I think that the example is misleading, maybe
intentionally so.

I don't think anybody would model it that way, in any case you'd have
aProduct.buy() or aProduct.addToCart(aCart).

If you think it with the typical dog.bark() it certainly makes more sense
than bark(dog).

Regards!

Esteban A. Maringolo


On Fri, Apr 16, 2021 at 5:20 AM Tim Mackinnon  wrote:

> Hi guys - someone pointed out this article from a UK colleague which seems
> to be causing a flurry of discussion - but I always like the insights of
> this group. I had an instant reaction when I read it - but curious what
> people here think in 2021.
>
>
> https://www.linkedin.com/posts/jasongorman_the-year-is-2021-and-people-still-think-activity-6787650079764303872-SJzz
>
> Tim
>


[Pharo-users] Re: Whats the easiest/cheapest way to run a Pharo web app in 2021?

2021-04-13 Thread Esteban Maringolo
I really like the Dockerize option, seems pretty straight forward, I wonder
how you could manage volumes for DB containers, static assets and how
flexible/configurable is the routing/scaling.

Unless, as it seems, everything is stateless there.


Esteban A. Maringolo


On Tue, Apr 13, 2021 at 8:36 AM Tim Mackinnon  wrote:

> These are some useful inputs - its definitely getting to a place where a
> little pocket money gives you a real environment to hobby deploy to (even
> professionally if you are careful i guess).
>
> Sven - presumably this Graviton setup is an EC2 instance - and so you
> patch your own OS and provide any additional pieces like SSL cert etc
> right? (which I know you are ace at doing - but I find that that I
> painfully learn how to do it one month, and then 6 months later have to
> relearn it all again).
>
> So I'm interested in how reasonable it is to live higher up the food chain
> - where it seems that a Docker image insulates you (in theory) from a lot
> of this. Is this true - and are options like dockerize.io (or others that
> perhaps I am missing) viable options for the time constrained?
>
> (really appreciate all the input in this thread everyone - its very
> instructive)
>
> Tim
>
> On Tue, 13 Apr 2021, at 7:43 AM, Sven Van Caekenberghe wrote:
> > Although my main instance is on Digital Ocean, I have a test/play
> > instance on AWS.
> >
> > This is really hip & cool: it is an AWS Graviton 2 instance (Amazon's
> > own ARM64 CPU, much like Apple Silicon) [
> > https://aws.amazon.com/ec2/graviton/ ]. I run a small t4g.micro
> > instance, 1GB RAM, 8GB Disk.
> >
> > Last bill was just USD 2.89 which is crazy cheap for a full month 24/7.
> >
> > Thanks to the fact that Pharo has a full JIT VM on ARM64, this is crazy
> > fast as well.
> >
> > I am sure that the reason this is so cheap is the fact that it is super
> > efficient.
> >
> > You can try this easily for yourself.
> >
> > > On 13 Apr 2021, at 01:57, Esteban Maringolo 
> wrote:
> > >
> > > What do you use that's so cheap/affordable?
> > >
> > > El lun., 12 de abril de 2021 04:48, Norbert Hartl 
> escribió:
> > >
> > >
> > > > Am 12.04.2021 um 04:02 schrieb Jeff Gray :
> > > >
> > > > Considering easiest and cheapest, there's always self hosting, or
> are you
> > > > discounting that idea?
> > > > Most geeks have a bit of spare hardware laying around and broadband
> > > > up-speeds aren't too bad.
> > > > I'm guessing that if we are in the $5 a month ball park then we
> aren't
> > > > needing a guaranteed up time.
> > > >
> > >
> > > My cloud instance is 3€/month. With an additional 20% amount the
> instance has a backup. And setting it up is way simpler then getting
> dynamic DNS updates and all of that configured. Times have changed a bit.
> > >
> > >
> > > Norbert
> >
>


[Pharo-users] Re: Whats the easiest/cheapest way to run a Pharo web app in 2021?

2021-04-12 Thread Esteban Maringolo
What do you use that's so cheap/affordable?

El lun., 12 de abril de 2021 04:48, Norbert Hartl 
escribió:

>
>
> > Am 12.04.2021 um 04:02 schrieb Jeff Gray :
> >
> > Considering easiest and cheapest, there's always self hosting, or are you
> > discounting that idea?
> > Most geeks have a bit of spare hardware laying around and broadband
> > up-speeds aren't too bad.
> > I'm guessing that if we are in the $5 a month ball park then we aren't
> > needing a guaranteed up time.
> >
>
> My cloud instance is 3€/month. With an additional 20% amount the instance
> has a backup. And setting it up is way simpler then getting dynamic DNS
> updates and all of that configured. Times have changed a bit.
>
>
> Norbert


[Pharo-users] Re: Whats the easiest/cheapest way to run a Pharo web app in 2021?

2021-04-02 Thread Esteban Maringolo
I've been running a Pharo application since August last year,
initially setup with everything inside a Docker swarm (database,
reverse proxy and Pharo workers for the UI and REST API).

I wanted to give Docker a try because I thought it was going to be
"better". After having some issues with the Swarm networking affecting
PostgreSQL connections [1], I ended up having a hybrid that is not the
best of both worlds (I wouldn't say it's the worst either).

So my summary is that unless you have several host machines, having a
"swarm" is completely overkill and brings more friction than anything
else.
The plus of docker is that from Gitlab everytime I push a commit to
master, a new docker image is created and I can update things smoothly
on the server by pulling the image and upgrading the stack service.

"Whenever I have time" I plan to make the reverse proxy external to
docker (I currently use traefik as a container), and just keep the
database and Pharo workers as docker containers.

As for the stability, I only shut it down for upgrades, but in
February I tried with a single VM+image serving everything (just to
measure real use) and albeit it was a little slower, it handled
everything perfectly [2] without a single hiccup.


Regards,

[1] https://twitter.com/emaringolo/status/1296635983358763010
[2] https://twitter.com/emaringolo/status/1360247046553362432

Esteban A. Maringolo


On Fri, Apr 2, 2021 at 6:33 AM Tim Mackinnon  wrote:
>
> Thanks Sanjay - you have reminded me that I have some similar notes somewhere 
> (now located) that did the command line foo to get things running - looking 
> at mine there was quite a big of dance to provide a way to gracefully stop 
> and start the image so that you can easily and automatically redeploy your 
> changes (read: use Github  actions or Gitlab CI).
>
> So I’m curious on whether Docker is now sufficiently stable stable/easy/cheap 
> to make it a viable alternative - and whether that is also cost efficient.
>
> Pablo wrote a recent blog post on running Pharo in Docker using the BA images 
> - https://thepharo.dev/2021/02/24/running-pharo-9-in-docker/ - but while easy 
> on the surface, if anything goes wrong - there seems to be very little debug 
> output to know what has happened (I’ll post separately on this - as I’m 
> looking at comparing options here).
>
> With Docker options, I notice that dockerize.io (not used, just a quick 
> search) - has a micro plan for $2/m - but is 500mb ram enough (there is a $5 
> one for 1gm ram).
>
> Or - I stick with DigitalOcean and roll my own like before - and perhaps that 
> has got a bit simpler.
>
> I’m still curious what the wider community is doing.
>
>
> Tim
>
> On 2 Apr 2021, at 05:43, Sanjay Minni  wrote:
>
> Hi Tim
>
> Here are my notes on installing Pharo in a DigitalOcean Ubuntu droplet.
> I usually go thru a Windows Command prompt box having installed xfec4 in the 
> ubuntu droplet, but the command line connect and graphical remote may be 
> easier for a Linux users. my ssh public key is also in the DO droplet
> Now the first step for me is a installing Pharo launcher thru command line 
> and then everything is thru graphical interface
>
> Installing and checking Pharo-Launcher, Installing Pharo 8 64 bit from 
> pharo.org (instructions as on Pharo.org)
> 1. In Windows 10 command prompt connect thru > ssh root@
> 2. cd
> 3. curl -o pharo-launcher.zip -L 
> https://files.pharo.org/pharo-launcher/linux64
> 4. unzip pharo-launcher.zip
> or thru the GUI-> extract here
> (pharo-launcher files will be extracted in ./pharo-launcher)
> Now while connected to the linux graphical interface thru windows remote 
> terminal and in the GUI
> 5. Create a icon on desktop thru right-click “Create Launcher” for 
> pharo-launcher
> 6. Create pharo images thru pharo-launcher
>
> hope this is of use
>
> Sanjay Minni
>
> On Thu, 1 Apr 2021 at 16:31, Tim Mackinnon  wrote:
>>
>> Hi everyone - its been a few year since I last hosted a little Pharo web app 
>> - and the last time I did, Sven pointed me to DigitalOcean and creating a 
>> tiny instance and configuring an Ubuntu server and then copying a pharo 
>> image on to that. It recall it wasn’t too bad, albeit a bit fiddly…
>>
>> Now several years later - I can’t recall the exact steps, and vaguely recall 
>> there was something about 32bit vs 64bit setup etc - but am wondering if 
>> things have advanced a bit and whether its much simpler these days? I’ve 
>> seen references to Docker images for Pharo, and am wondering if now that is 
>> a prime time way to easily get a small demo application up and running with 
>> minimal fuss.
>>
>> Does anyone have advice - or something to point me to?
>>
>> Ideally I want to hook something up in Gitlab CI do deploy to this thing 
>> automatically (this is where I got to a few years ago - but in picking 
>> things back up I am hoping this has all got much simpler).
>>
>> Tim
>
>


[Pharo-users] Simple statistics package?

2021-03-08 Thread Esteban Maringolo
Hi,

I need to perform simple statistical analysis over a small set of
objects (~10-1000 max), basic stuff like getting the quartiles, mean,
average of a certain set and perform moving averages.

I'm looking for something where I can pass a collection of objects of
my domain, an accessor and get the values mentioned above.

I know there is PolyMath, but it seems to be oriented towards heavy
number crunching and mathematical abstractions as its input. E.g. The
PMHistogram works on pure numbers, so once I build it, I cannot know
which of my objects fall into what group of the histogram.

Does such a thing exist?

Regards!

Esteban A. Maringolo


[Pharo-users] Re: [ANN] Foliage: a static site generator

2021-01-18 Thread Esteban Maringolo
Hi Norbert,

Thanks for sharing it!


ps: In spanish a sheet of paper and a tree leaf also share the same
word, so "Follaje" means the same thing.

Esteban A. Maringolo

On Mon, Jan 18, 2021 at 11:11 AM Norbert Hartl  wrote:
>
> Hi,
>
> I’ve been toying around with a web site generator the last months. Some 
> people were showing interest and asked me to release it. It is still pretty 
> basic but I manage my blog with it . I’m all open ears about what you think, 
> what doesn’t work and what is missing.
>
> Please read about it
>
> https://norbert.hartl.name/blog/2021-01-17-foliage-released.html
>
> Hopy you like it,
>
> Norbert
>


[Pharo-users] Re: is there a better way

2021-01-06 Thread Esteban Maringolo
To avoid doing something like that, and for a web scrapping tool I
wrote, I implemented a basic subclass of ZnClient (called
ZnCachingClient) that used a disk cache where each key/file was the
hash of the requested URL.

I haven't used in a while but it should continue to work, in any case,
I published it in a Github repository:
https://github.com/eMaringolo/zinc-caching-client

Best regards,

Esteban A. Maringolo

On Wed, Jan 6, 2021 at 3:37 PM Richard Sargent
 wrote:
>
>
>
> On Wed, Jan 6, 2021 at 10:34 AM Roelof Wobben via Pharo-users 
>  wrote:
>>
>>
>> Thanks,
>>
>> Right now im downloading/fetching the images every time again.
>>
>> As I see it, the biggest bottleneck is that I have 10 images.
>> And for all 10 I fetching the image and the data I could display when a
>> user wants it.
>> So that will be 20 calls to the api.
>>
>> So maybe some cache could be handy.
>> Any hints how to make a cache in smalltalk.
>
>
> Dictionary coupled with #at:ifAbsentPut:
>
>>
>> Roelof
>>
>>
>>
>> Op 6-1-2021 om 19:19 schreef Sven Van Caekenberghe:
>> > Roelof,
>> >
>> > Working with multiple high resolution images, as I believe you are
>> > doing, is always going to be a real challenge, performance wise. It
>> > just takes time to transfer lots of data.
>> >
>> > First you have to make sure that you are not doing too much work
>> > (double downloads, using too high resolutions for previews or
>> > browsing). Also, make sure your ultimate client (the browser) can
>> > cache as well if applicable (set modification dates on the response).
>> >
>> > Next you could cache images locally (on your app server) so that next
>> > time you need the same image, you do not need to download it again. Of
>> > course, this only helps if your hit rate is higher than zero (if you
>> > actually ask for the same image multiple times).
>> >
>> > It is also possible to do multiple download requests concurrently: if
>> > the other end is fast enough, that can certainly help.
>> >
>> > HTH,
>> >
>> > Sven
>> >
>> >> On 6 Jan 2021, at 18:11, Roelof Wobben via Pharo-users
>> >>  wrote:
>> >>
>> >>
>> >> I did it on the root document and see this :
>> >>
>> >> 
>> >>
>> >> So as far as I see it , The most time it taken by getting all the
>> >> data from all the 10 images.
>> >>
>> >> I hope someone can look at me if im on the right track and will help
>> >> me to figure out faster ways to achieve the same
>> >>
>> >> Roelof
>> >>
>> >>
>> >>
>> >> Op 5-1-2021 om 05:16 schreef Richard O'Keefe:
>> >>> Before you take another step, explore the root document.
>> >>>
>> >>> Profiling is easy.
>> >>> Open a Playground.
>> >>> Type an expression such as
>> >>> 3 tinyBenchmarks
>> >>> Right click and select 'Profile it'.
>> >>>
>> >>> More generally, in a browser, look at the "Tool - Profilers"
>> >>> class category. The classic approach was
>> >>> MessageTally spyOn: [3 tinyBenchmarks]
>> >>> If I understand correctly, 'Profile it' uses TimeProfiler,
>> >>> which has a nicer interface. (This is in Pharo 8.)
>> >>>
>> >>>
>> >>> On Sun, 3 Jan 2021 at 23:03, Roelof Wobben  wrote:
>> >>> I want that the code fetches a url and some data from the
>> >>> Rijksmuseaum api.
>> >>> And as far as I see it the second it not pointless because it
>> >>> getting more detailed info about the painting as in the first get.
>> >>>
>> >>> I did not profiled it because I never learned how to do that in Pharo.
>> >>>
>> >>> Roelof
>> >>>
>> >>>
>> >>>
>> >>> Op 3-1-2021 om 01:09 schreef Richard O'Keefe:
>>  What do you want the code to do?
>>  Have you profiled the code to see where the time is going?
>> 
>>  A quick look at the code shows
>>  - Paintings does one web get
>>  - each Painting does two more web gets
>>  ! and the first of those seems to be pretty pointless,
>>  as it refetches an object that Paintings already fetched
>>  and just looked at.
>> 
>> 
>> 
>>  On Sun, 3 Jan 2021 at 01:16, Roelof Wobben via Pharo-users
>>   wrote:
>>  Hello,
>> 
>>  I have now this code : https://github.com/RoelofWobben/Rijksmuseam
>> 
>>  but it seems to be slow.
>> 
>>  Can anyone help me with a way I can use a sort of cache so the page
>>  looks first at the cache if a image is there .
>>  If so, take the image from there , if not , ask the api for the url of
>>  the image.
>> 
>>  Roelof


[Pharo-users] Re: Easiest light weight cloud/web persistence for Pharo?

2020-10-06 Thread Esteban Maringolo
Hi Pierce,

On Mon, Oct 5, 2020 at 10:22 PM Pierce Ng  wrote:

> On Mon, Oct 05, 2020 at 11:23:25PM +0100, Tim Mackinnon wrote:
> Many options. Great time sinks. :-) Have fun.
>
> 

> - Choose Boring Technology - http://boringtechnology.club/

This made my day. Thank you :-)


Esteban A. Maringolo


[Pharo-users] Re: [Pharo-dev] [ANN] Pharo Consortium New Gold Member: InfOil

2020-09-30 Thread Esteban Maringolo
As a former employee of the company I'm really happy to see this
finally happening!

Best regards!

Esteban A. Maringolo

On Wed, Sep 30, 2020 at 11:13 AM Marcus Denker  wrote:
>
>
> The Pharo Consortium is very happy to announce that InfOil has joined the 
> Consortium as a Gold Member.
>
> InfOil is an Argentinian company focused on software development for the Oil 
> and Gas industry with clients
> in Latin America, Cuba, and Canada.
>
> About
> - InfOil: http://www.infoil.com.ar
> - Pharo Consortium: http://consortium.pharo.org
>
> The goal of the Pharo Consortium is to allow companies and institutions to 
> support the ongoing development
> and future of Pharo.
>
> Individuals can support Pharo via the Pharo Association:
>
> - http://association.pharo.org


[Pharo-users] Re: Standalone html builder (a la seaside without seaside?)

2020-09-29 Thread Esteban Maringolo
Hi Jan,

Nice work, the "Eleven" framework goes in the direction of what I was
experimenting with for Seaside, but instead of trying to introduce that in
Seaside without breaking everything else (as I failed to some extent) you
went directly to replace and redo most of the stuff there (some with
simplifications).

It's nice to see that you have ideas like OneTimeCallback and a FormHandler
in it, because I had something similar going on.
I didn't understand why you have a CSRF list of tokens in the Session.

Thinking of Seaside, I think this would be something nice to introduce in
Seaside 4.0 :-)

Regards!


El mar., 29 de septiembre de 2020 05:38, Jan Blizničenko <
jan.bliznice...@fit.cvut.cz> escribió:

> Hello,
>
> I am using https://github.com/JanBliznicenko/eleven for one of my
> projects.
> It is also a full framework, yet much simplier than Seaside and stateless
> and I believe only the HTML building functionality can be used
> indpendently.
>
> Example:
> htmlObject := HtmlBody
> with:
> (HtmlDiv
> class: 'content'
> with:
> (HtmlAnchor new
> href: 'https://pharo.org';
> targetBlank;
> with: 'Pharo website';
> yourself)).
> String streamContents: [:stream | htmlObject renderFor: nil on: stream]
>
> The nil I am passing in the last line is there in place of an ELRequest
> entity and is not needed for simple HTML tags without custom components.
> You
> might check it out. Be aware that my former colleague created it for our
> specific project and I have never used it in any other place, so I just
> HOPE
> it would work like I imagine. It is also not documented or tested at all.
>
> Best regards,
> Jan
>
>
> Tim Mackinnon wrote
> > Hi - has anyone ever managed to extract the html builder out of seaside -
> > or written something equivalent?
> >
> > I often find I want to build some HTML, but don’t want the full seaside -
> > and was wondering if anyone has managed to extract it, or have something
> > similar?
> >
> > This combined with Renoir from BA-ST would give a good little light
> weight
> > web potential to run with Zinc.
> >
> > Tim
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>


[Pharo-users] Re: Standalone html builder (a la seaside without seaside?)

2020-09-28 Thread Esteban Maringolo
I've been playing with something like that, but still using Seaside.

I was calling it "WAStatelessApplication", which is nothing but a way
to route requests to components, and have these components not using
callbacks nor continuations.

I'm really comfortable with the Seaside canvas way of doing HTML, so
I'll eventually end up building it, but currently it is just another
abandoned project.

For a very few specific things, I used a RESTful handler and a
WABuilder to generate the HTML output, using regular components to
render it.

Regards!

Esteban A. Maringolo

On Mon, Sep 28, 2020 at 2:28 PM Tim Mackinnon  wrote:
>
> Hi - has anyone ever managed to extract the html builder out of seaside - or 
> written something equivalent?
>
> I often find I want to build some HTML, but don’t want the full seaside - and 
> was wondering if anyone has managed to extract it, or have something similar?
>
> This combined with Renoir from BA-ST would give a good little light weight 
> web potential to run with Zinc.
>
> Tim


[Pharo-users] Re: why is ZnEasy choking on this and languages as c# and ruby not

2020-09-27 Thread Esteban Maringolo
Hi Roelof,

As pointed in the Discord chat, and just for others to know, the HTTP
response is not correct since it doesn't set any MIME Type, so Zinc
(ZnEasy) does the correct thing that it is to assume the content is
application/octet-stream, so you get a ByteArray. If you decode such
bytearray using UTF8 you'll get the "text" you're expecting.

Just out of curiosity, can you show us a snippet of how you do that in
C# and Ruby?

Regards,

Esteban A. Maringolo

On Sun, Sep 27, 2020 at 2:35 PM Roelof Wobben via Pharo-users
 wrote:
>
> Hello,
>
> In a project of mine I do this :
>
> (ZnEasy get: 
> 'https://www.rijksmuseum.nl/api/nl/collection/SK-C-1368/tiles?key=14OGzuak') 
> contents .
>
> but this is given me a bytearray.
>
> When I do the same in other languages I know like c# or ruby I get a 
> dictionary like I suspect.
>
>
> Can som one explain to me why this happens with ZnEasy.
>
> Regards,
>
> Roelof
>


Re: [Pharo-users] Rounding in Floats

2020-09-07 Thread Esteban Maringolo
On Tue, Sep 8, 2020 at 12:16 AM Richard O'Keefe  wrote:
>
> "7.1 roundTo: 0.1 should return 7.1"
> You're still not getting it.

I was until Konrad explained it.

> Binary floating point CANNOT represent either of those numbers.
> You seem to be assuming that Pharo is making some mistake.
> It isn't.  All it is doing is refusing to lie to you.

> The systems that print 7.1 are LYING to you,
> and Pharo is not.

I'm not assuming a mistake from Pharo, I had a wrong expectation what
to get if I round to that precision.
I don't know whether other systems lie or simply fulfill user
expectations, if you send the #roundTo: to a float, I did expect to
get a number with the same precision.
That is my expectation as a user. As in the other thread I expected
two scaled decimals that are printed equal to also be compared as
equal  (which they don't).

Whether there is a good reason for those behaviors is beyond my
current comprehension, but it certainly doesn't follow the "principle
of least surprise".

In any case, the method proposed by Tomohiro solved my issues.

Regards,

Esteban A. Maringolo



Re: [Pharo-users] Getting rid of .sources file for deployment

2020-09-07 Thread Esteban Maringolo
Hi Stef,

I don't know what's the demand for such a feature.

In the Windows and Desktop era it might have been very important, but
I don't see that kind of integration these days, when most system
integrations happen at the HTTP level.

For my particular case I don't need a DLL.

Regards!

Esteban A. Maringolo

On Mon, Sep 7, 2020 at 1:55 PM Stéphane Ducasse
 wrote:
>
> I would like also to be able to deploy a pharo app as a dll juts time and 
> money.
>
> S.
>
> On 7 Sep 2020, at 17:28, Esteban Maringolo  wrote:
>
> Hi Davide,
>
> Thanks for the thorough response, but I think you're over
> dimensioning, and to some extent missing, my initial purpose and
> intention.
>
> I don't want to protect from somebody attempting to reverse engineer
> my application, that's impossible (more so given your references).
> I simply want to disable the option to open the IDE, even with all
> tool menus disabled.
>
> In Java if I deliver a .jar or .war anybody could reverse engineer it,
> but launching it won't open the development environment.
>
> For comparison with other Smalltalks I've used:
> * VisualWorks enables the distribution of a "headless" IMAGE (and
> parcels) without sources, if you revert that image to be headful all
> source code will be decompiled using meaningless variables.
> * Dolphin has the concept of SessionManager that is the entry point to
> the image startup, if you save your image with a Headless Session
> manager, then no GUI loop will start, same thing if you deploy as a
> COM component.
> * VAST produces its own ICX file where you can choose what to include
> in it, it's not simply saving the image but building a new one from
> within the development image, it's one step further.
> * VSE had the SLL (similar to DLLs), if you don't bind the IDE's SLLs
> then there is no way to start the IDE (I never built a headless VSE
> app though).
>
> So what I'd like is an always Pharo headless image or Pharo headless
> vm, instead of being controlled by a parameter in the VM.
>
> Regards,
>
> Esteban A. Maringolo
>
> On Mon, Sep 7, 2020 at 12:04 PM Davide Grandi  wrote:
>
>
> Ok, I'll give you a result, meanwhile fixing some imprecisions.
>
> The "class" is CogVmSimulator but it's use is very far from my knowlegde,
> I recalled having seen a picture of Pharo-in-Pharo (or Squeak-in-Squeak)
> running under this simulator.
> It lives near the Cog side (or the OpenVM side) of Squeak/Pharo
> (If I'm not wrong Squeak ran into an emulator, before walking on his
> legs-his VM).
>
> There are many of these simulator, for other Smalltalk :
> - Hobbes and others for Xerox (thanks to files of Mario Molczko and/or
>   Bitsavers
> - Dan Ingalls Apda Smalltalk + old Smalltalk -72 /-76
> and maybe others I don't yet know about
>
> The reason is quite simple : the object memory is written to disk
> and the spec of executing Smalltalk are known either from the books
> or by the source.
>
> The root is Xerox's SystemTracer, a class that wrote a running image
> to disk, optionally changing object format (see the Green Book).
>
> So :
> - if you can read the image
> - you can run into a simulator
> - or decode it without to much effort (5 emulators for Xerox V2 image,
> so far).
> (try to open an image with a text editor : intriguing !)
>
> I don't know how Cincom or Instantiations protect the released st code,
> but for Pharo and Squeak this is not a point : they are all open.
>
> So, as if you wanna "protect" names and methods of a running image ...
> ... you have to (IMHO) :
> - encrypt executable and image (and modify the VM)
> - or obfuscate your classes and methods renaming it to
>   C1, C2, ..., m1:p1:p2: and so on (keeping a map for debugging)
>
> Sorry to be imprecise about names and locations
> apart from suggest to see 4 emulators 4 running in a squeak image
> running ... in javascript in your browser (so total is 5) at :
> https://smalltalkzoo.thechm.org/HOPL-Squeak.html?earlyst80
> (thanks to Vanessa Freudemberg & Dan Ingalls).
>
> Sorry again & best regards,
>
> Davide Grandi
>
> On 06/09/2020 23:51, Esteban Maringolo wrote:
>
> If somebody gets to open the image and loads it with an Smalltalk
> Emulator to execute it I'll ask him/her to start working together, and
> even teach me how to do it.
>
> I don't want to shield the image from being accessed, just want to
> make it harder than simply removing the '--headless' parameter to the
> VM executable.
> Of course removing sources is a plus (I do for a VW deployed image),
> but even for this particular piece of software that I'm asking for, I
> don't need it.
>
> If I wanted to mak

Re: [Pharo-users] Getting rid of .sources file for deployment

2020-09-07 Thread Esteban Maringolo
Hi Davide,

Thanks for the thorough response, but I think you're over
dimensioning, and to some extent missing, my initial purpose and
intention.

I don't want to protect from somebody attempting to reverse engineer
my application, that's impossible (more so given your references).
I simply want to disable the option to open the IDE, even with all
tool menus disabled.

In Java if I deliver a .jar or .war anybody could reverse engineer it,
but launching it won't open the development environment.

For comparison with other Smalltalks I've used:
* VisualWorks enables the distribution of a "headless" IMAGE (and
parcels) without sources, if you revert that image to be headful all
source code will be decompiled using meaningless variables.
* Dolphin has the concept of SessionManager that is the entry point to
the image startup, if you save your image with a Headless Session
manager, then no GUI loop will start, same thing if you deploy as a
COM component.
* VAST produces its own ICX file where you can choose what to include
in it, it's not simply saving the image but building a new one from
within the development image, it's one step further.
* VSE had the SLL (similar to DLLs), if you don't bind the IDE's SLLs
then there is no way to start the IDE (I never built a headless VSE
app though).

So what I'd like is an always Pharo headless image or Pharo headless
vm, instead of being controlled by a parameter in the VM.

Regards,

Esteban A. Maringolo

On Mon, Sep 7, 2020 at 12:04 PM Davide Grandi  wrote:
>
> Ok, I'll give you a result, meanwhile fixing some imprecisions.
>
> The "class" is CogVmSimulator but it's use is very far from my knowlegde,
> I recalled having seen a picture of Pharo-in-Pharo (or Squeak-in-Squeak)
> running under this simulator.
> It lives near the Cog side (or the OpenVM side) of Squeak/Pharo
> (If I'm not wrong Squeak ran into an emulator, before walking on his
> legs-his VM).
>
> There are many of these simulator, for other Smalltalk :
> - Hobbes and others for Xerox (thanks to files of Mario Molczko and/or
>Bitsavers
> - Dan Ingalls Apda Smalltalk + old Smalltalk -72 /-76
> and maybe others I don't yet know about
>
> The reason is quite simple : the object memory is written to disk
> and the spec of executing Smalltalk are known either from the books
> or by the source.
>
> The root is Xerox's SystemTracer, a class that wrote a running image
> to disk, optionally changing object format (see the Green Book).
>
> So :
> - if you can read the image
> - you can run into a simulator
> - or decode it without to much effort (5 emulators for Xerox V2 image,
> so far).
> (try to open an image with a text editor : intriguing !)
>
> I don't know how Cincom or Instantiations protect the released st code,
> but for Pharo and Squeak this is not a point : they are all open.
>
> So, as if you wanna "protect" names and methods of a running image ...
> ... you have to (IMHO) :
> - encrypt executable and image (and modify the VM)
> - or obfuscate your classes and methods renaming it to
>C1, C2, ..., m1:p1:p2: and so on (keeping a map for debugging)
>
> Sorry to be imprecise about names and locations
> apart from suggest to see 4 emulators 4 running in a squeak image
> running ... in javascript in your browser (so total is 5) at :
> https://smalltalkzoo.thechm.org/HOPL-Squeak.html?earlyst80
> (thanks to Vanessa Freudemberg & Dan Ingalls).
>
> Sorry again & best regards,
>
>  Davide Grandi
>
> On 06/09/2020 23:51, Esteban Maringolo wrote:
> > If somebody gets to open the image and loads it with an Smalltalk
> > Emulator to execute it I'll ask him/her to start working together, and
> > even teach me how to do it.
> >
> > I don't want to shield the image from being accessed, just want to
> > make it harder than simply removing the '--headless' parameter to the
> > VM executable.
> > Of course removing sources is a plus (I do for a VW deployed image),
> > but even for this particular piece of software that I'm asking for, I
> > don't need it.
> >
> > If I wanted to make the source public, I'll publish it in
> > Github/Gitlab, otherwise I'd rather keep the code private.
> >
> > Regards,
> >
> > Esteban A. Maringolo
> >
> > On Sun, Sep 6, 2020 at 6:29 PM Davide Grandi  wrote:
> >> I mean that with SmalltalkEmulator, the Smalltalk interpreter
> >> written in Smalltalk, one can execute an image looking at
> >> classes, methods and maybe executing code at will.
> >>
> >> And the only practical form of protection I see in Squeak/Pharo
> >> is to obfuscate code.
> >>
> >> Maybe I'm wrong.
> >>
> >>   Davide Grandi
&g

Re: [Pharo-users] Rounding in Floats

2020-09-07 Thread Esteban Maringolo
Hi Tomohiro,

Thanks, that certainly is the simplest solution that does exactly what I need.

Maybe roundTo: should be considered harmful when using Floats.
(and it is very unlikely anybody is going to round to something other
than a power of 10)

Best regards!


Esteban A. Maringolo

On Mon, Sep 7, 2020 at 9:51 AM Tomohiro Oda  wrote:
>
> Esteban,
>
> You can instead use `7.1 round: 1` to get 7.1.
> It's not the problem of the rounding algorithm.
> It's because IEEE float can't express the exact value of 0.1.
> ---
> tomo
>
> 2020年9月7日(月) 21:28 Esteban Maringolo :
> >
> > Hi Sven,
> >
> > On Mon, Sep 7, 2020 at 9:10 AM Sven Van Caekenberghe  wrote:
> >
> > > > On 6 Sep 2020, at 22:21, Esteban Maringolo  wrote:
> > > >
> > > > It is not for printing but for testing. I want to assert that a
> > > > certain calculation gives the expected result.
> > >
> > > Then you should use #assert:closeTo: and friends.
> > > (9.1 + (-2.0)) closeTo: 7.1 precision: 0.1.
> >
> > I remembered about it, and implemented my own
> > #assertDifferential:equals: which I first did convert to
> > ScaledDecimals and then compares with #roundedByScale.
> >
> > > Floats should always be compared using an epsilon (precision) value in 
> > > tests, not using equality.
> >
> > Sure, but 7.1 roundTo: 0.1 should return 7.1.  Shouldn't it?
> >
> > Regards!
> >
> > Esteban A. Maringolo
> >
>



Re: [Pharo-users] Rounding in Floats

2020-09-07 Thread Esteban Maringolo
Hi Sven,

On Mon, Sep 7, 2020 at 9:10 AM Sven Van Caekenberghe  wrote:

> > On 6 Sep 2020, at 22:21, Esteban Maringolo  wrote:
> >
> > It is not for printing but for testing. I want to assert that a
> > certain calculation gives the expected result.
>
> Then you should use #assert:closeTo: and friends.
> (9.1 + (-2.0)) closeTo: 7.1 precision: 0.1.

I remembered about it, and implemented my own
#assertDifferential:equals: which I first did convert to
ScaledDecimals and then compares with #roundedByScale.

> Floats should always be compared using an epsilon (precision) value in tests, 
> not using equality.

Sure, but 7.1 roundTo: 0.1 should return 7.1.  Shouldn't it?

Regards!

Esteban A. Maringolo



Re: [Pharo-users] Getting rid of .sources file for deployment

2020-09-06 Thread Esteban Maringolo
If somebody gets to open the image and loads it with an Smalltalk
Emulator to execute it I'll ask him/her to start working together, and
even teach me how to do it.

I don't want to shield the image from being accessed, just want to
make it harder than simply removing the '--headless' parameter to the
VM executable.
Of course removing sources is a plus (I do for a VW deployed image),
but even for this particular piece of software that I'm asking for, I
don't need it.

If I wanted to make the source public, I'll publish it in
Github/Gitlab, otherwise I'd rather keep the code private.

Regards,

Esteban A. Maringolo

On Sun, Sep 6, 2020 at 6:29 PM Davide Grandi  wrote:
>
> I mean that with SmalltalkEmulator, the Smalltalk interpreter
> written in Smalltalk, one can execute an image looking at
> classes, methods and maybe executing code at will.
>
> And the only practical form of protection I see in Squeak/Pharo
> is to obfuscate code.
>
> Maybe I'm wrong.
>
>  Davide Grandi
>
> On 06/09/2020 22:27, Esteban Maringolo wrote:
> > On Sun, Sep 6, 2020 at 12:52 PM Davide Grandi  
> > wrote:
> >> Does "competition" has SmalltalkEmulator ?
> >> A Smalltalk-written VM will defeat any simple obfuscation scheme.
> > Sorry, but I don't understand what you  mean.
> >
> > Best regards,
> >
> --
> Ing. Davide Grandi
> email: davide.gra...@email.it
> mobile   : +39 339 7468 778
> linkedin : http://linkedin.com/in/davidegrandi
>
>



Re: [Pharo-users] Getting rid of .sources file for deployment

2020-09-06 Thread Esteban Maringolo
On Sun, Sep 6, 2020 at 12:52 PM Davide Grandi  wrote:
>
> Does "competition" has SmalltalkEmulator ?
> A Smalltalk-written VM will defeat any simple obfuscation scheme.

Sorry, but I don't understand what you  mean.

Best regards,



Re: [Pharo-users] Rounding in Floats

2020-09-06 Thread Esteban Maringolo
Hi Sven,

On Sun, Sep 6, 2020 at 11:57 AM Sven Van Caekenberghe  wrote:
> > On 6 Sep 2020, at 16:06, Esteban Maringolo  wrote:

> > (9.1 + (-2.0)) roundTo: 0.1.
> > "7.1005"

> > Is this a bug?
>
> Maybe.
>
> But I would not approach the problem of rounding like that.
> You probably want to control how numbers are printed.

It is not for printing but for testing. I want to assert that a
certain calculation gives the expected result.
And then it fails because of the difference above when it is
"semantically" correct.

> I would keep the numbers themselves at maximum internal precision and only do 
> something when printing them.

I do. I'm implementing the full WHS specification [1], and it mentions
that most calculations should preserve the maximum internal precision
and even introduces some weird situation where you have an "index"
that is rounded and another one that is called the same way but must
not be rounded because is going to used to compute some other value.

For most calculations it specifies it must round to 1 decimal or even
to no decimal, based on a round up if the decimal is greater or equal
than zero (e.g. 1.5 becomes 2), except for negative numbers, in which
case it rounds "down" (-1.5 becomes 1).

> 1 / 3 asFloat printShowingDecimalPlaces: 1.
>
> Since you like Seaside, the following is even much more powerful (has *many* 
> options):
> GRNumberPrinter new precision: 1; print: 1/3 asFloat.

I'm already using the GRNumberPrinter and also the Date printer to
print these values.

Regards!

[1] https://en.wikipedia.org/wiki/Handicap_(golf)#World_Handicap_System



[Pharo-users] Rounding in Floats

2020-09-06 Thread Esteban Maringolo
Hi,

Continuing with my issues with decimals, I'm having one issue that is
not clear to me why it happens.

If I do:
(9.1 + (-2.0)) roundTo: 0.1.
"7.1005"

I expect to get a single decimal Float (rounded with whatever
precision, but a single decimal).

Even if I do something like this:
7.1 roundTo: 0.1

It gives the wrong result.

In VW and VAST it provides the right result.
(9.1 + (-2.0)) roundTo: 0.1 "7.1"

In Dolphin it also returns the wrong result, it seems to use the same
algorithm to round it.

Is this a bug?

Esteban A. Maringolo



Re: [Pharo-users] Getting rid of .sources file for deployment

2020-09-06 Thread Esteban Maringolo
Stef,

On Sat, Sep 5, 2020 at 12:49 PM Stéphane Ducasse
 wrote:
> just a question what if a bad guy you want to protect from is just smart
> and use a default vm.

You're talking about decompiling and I'm talking about not making it
trivial to see the code, internals and other things.
Security is always what you can afford to protect form, with enough
resources anybody can crack most of the existing software.

> I mean what kind of thieves do you want to protect from?

Think of it this way... as it is is like saving a six digits password
in plaintext on a file, what I propose is to have the same file, but
with the password encrypted with a lousy crypto (still easy to crack
with a dictionary attack but not as easy as seeing it at plain sight).

I'm not trying to protect from thieves, but from the competition.
This client part of the software runs in a computer where there is
also the software it's going to replace (eventually).

I simply want to obfuscate a little so it's not trivial to open it.
I'm not asking about encrypted image files. :-)

> Because you can let everything and block the menu + the DNU and other 
> exception
> and nobody even you will be able to access the code.
> If you remove all the  menu and toolbar + DNU + exception ...

I followed most of the guidelines to deploy it obfuscated [1].
But if there is a guide for obfuscation, it means that there is some
need for it, I just want to go one extra step.

Thanks!

[1] 
https://github.com/pharo-open-documentation/pharo-wiki/blob/master/General/DeployYourPharoApplication.md#sources-obfuscation

Esteban A. Maringolo



Re: [Pharo-users] Getting rid of .sources file for deployment

2020-09-04 Thread Esteban Maringolo
Hi Jan,

I wasn't aware of such a method, actually it doesn't have many users in
the system.
I'll do this and check whether this works.

Esteban A. Maringolo


On Wed, Sep 2, 2020 at 5:19 PM jan.struz  wrote:
>
> Hi Esteban,
>
> you can try this for all methods requiring source code, before removing 
> .sources file:
>
> someCompiledMethod embeddSourceInTrailer.
>
> This works since Pharo 3.0 or so...
>
> Jan
>
> Save The World!
>
> 
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.



Re: [Pharo-users] Getting rid of .sources file for deployment

2020-09-04 Thread Esteban Maringolo
My compromise would be to disable the GUI version of the VM.

How can I compile a VM with the --headless setting hardcoded? Where to start?

Esteban A. Maringolo

On Fri, Sep 4, 2020 at 2:39 PM Stéphane Ducasse
 wrote:
>
> Thanks James
>
> This is pretty much the right questions :)
> And I would love to have money to solve the problems the way I would like but 
> life is a compromise.
>
> S
>
> On 3 Sep 2020, at 20:50, smallt...@jgfoster.net  
> wrote:
>
>
> On Sep 3, 2020, at 9:49 AM, Trygve Reenskaug  wrote:
>
> The .sources file has been optional for as long as I can remember.
> Is it OK for list that somebody breaks this tradition?
> Trygve
>
>
> Hi Trygve,
>
> I’m not sure what you mean by this question.
>
> Are you asking, “Is it acceptable to have code that relies on reflection in 
> order to operate properly?” To this question I would answer “yes” since some 
> things are easier to do using reflection.
>
> Or are you asking, “Would it be better to not have FFI at all until it can be 
> implemented without reflection?” To this question I would answer  “no” since 
> people that don’t want reflection can choose to forego features that require 
> it.
>
> Or are you asking, “Would it be nice if someone could do the work to 
> implement FFI without reflection?” To this question I would answer “yes.” 
> Unfortunately, there is a cost involved.
>
> So were you asking one of those questions or something else?
>
> James
>
>
> 
> Stéphane Ducasse
> http://stephane.ducasse.free.fr / http://www.pharo.org
> 03 59 35 87 52
> Assistant: Aurore Dalle
> FAX 03 59 57 78 50
> TEL 03 59 35 86 16
> S. Ducasse - Inria
> 40, avenue Halley,
> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> Villeneuve d'Ascq 59650
> France
>



Re: [Pharo-users] Scaled decimals comparisons

2020-09-02 Thread Esteban Maringolo
Hi Richard,

+1 to what was asked by Stef.
How hard is it to bring your knowledge, and existing implementation,
into a "proper" implementation of ScaledDecimal (or FixedPoint) in
Pharo?

Regards!

Esteban A. Maringolo

On Wed, Sep 2, 2020 at 12:12 PM Stéphane Ducasse
 wrote:
>
> Richard
>
> we are really interested in improving Pharo on that aspect.
> Now I’m really not good with such domain.
> Can you send us some code and tests?
>
> S.
>
> On 2 Sep 2020, at 12:31, Richard O'Keefe  wrote:
>
> The behaviour of ScaledDecimal in Squeak and Pharo is
> - different from what the ANSI Smalltalk standard says
> - different from what other Smalltalks do (not that they agree)
> - completely different from decimal arithmetic in COBOL, PL/I, or SQL
> - seriously confusing.
>
> What you EXPECT is an exact rational number that is equal to an
> integer divided by a power of 10, so that the printed
> representation faithfully represents the value with no error.
> What you GET in Pharo is a rational number that PRINTS with
> a given number of decimal places but that is all.
>
> Thus we expect that
>   x := 10/3 asScaledDecimal: 2.
>   x asString ==> '3.33s2'
>   y := x+x+x.
>   y asString ==> '9.99s2'
> But no, y asString => '10.00s2'.
>
> Here's what the comment in the VW class FixedPoint says:
> "There are two possible ways to express FixedPoint numbers.  One is as a 
> scaled Integer, but the problem here is that you can lose precision during 
> intermediate calculations.  For example, a property that seems useful is that 
> the calculation (1.000 / 7 * 7) should give you back the number 1.000.
>
> For this reason, we have adopted an alternative representation, which is a 
> slight variation on Fraction.  The number is expressed as the ratio of a 
> numerator to a denominator, with the addition of a precision that is used for 
> printing and for rounding.  The number is not usually rounded off to its 
> scale, but if an intermediate result must be rounded to its scale before 
> being used, the messages #roundedToScale and #truncatedToScale may be used."
>
> The last sentence in the first paragraph is one I cannot agree with.
> If I want a calculation where (1/7 * 7) gives me back 1, then I use
> exact Fractions. If I am using ScaledDecimal, it is because I *want*
> fixed point decimal numbers, with the properties appropriate to fixed
> point decimal numbers.  Wanting something that I could use to talk to
> databases like MariaDB I found that I had to write my own FixedPoint
> class, only to find that VW called ScaledDecimal FixedPoint.  *Sigh*.
>
> Unless and until the current ScaledDecimal is ripped out and buried
> in an unmarked grave at a crossroad with a stake through its heart,
> you may wish to add VW-compatibility methods
>
> roundedToScale
>|t|
>t := 10 raisedToInteger: scale.
>^(numerator * t / denominator) rounded / t asScaledDecimal: scale
>
> truncatedToScale
>|t|
>t := 10 raisedToInteger: scale.
>^(numerator * t / denominator) truncated / t asScaledDecimal: scale
>
> and then use
>
>   aScaledDecimal roundedToScale = anotherOne roundedToScale
>
> Note that the ANSI standard, which was agreed to by a whole bunch of
> Smalltalk experts, says "A  converted to a 
> will be a fraction having the same numeric value but having an integer
> numerator and a denominator which is ten raised to
> the power of the ’s scale factor."
> Try "(10.00s2 / 3) asFraction" in your Smalltalk, and if the
> result has a denominator of 3, SOMEONE stuffed up.
>
>
>
>
> On Tue, 1 Sep 2020 at 16:08, Esteban Maringolo  wrote:
>>
>> Hi,
>>
>> I was doing some basic calculations based on a formula, and I wanted
>> to convert the result to a scaled decimal in order to avoid having
>> these "loose" decimals in 10th position or something similar.
>>
>> So I did the following:
>> 82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1 -> 9.5s1
>>
>> But When I do this in a test:
>> (82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1) = 9.5s1
>>
>> It fails because the comparison returns false.
>>
>> I guess this is the proper behavior, but I'd expected that the
>> conversion from a Float to a scaled decimal would have eliminated the
>> extra precision from the formula.
>>
>> I can do a roundTo: 0.1 before converting, but I'd like to know what
>> would be the proper way of dealing with this.
>>
>> Thanks!
>>
>> Esteban A. Maringolo
>>
>
> 
> Stéphane Ducasse
> http://stephane.ducasse.free.fr / http://www.pharo.org
> 03 59 35 87 52
> Assistant: Aurore Dalle
> FAX 03 59 57 78 50
> TEL 03 59 35 86 16
> S. Ducasse - Inria
> 40, avenue Halley,
> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> Villeneuve d'Ascq 59650
> France
>



Re: [Pharo-users] Scaled decimals comparisons

2020-09-01 Thread Esteban Maringolo
Hi John,

I was doing a similar rounding in the test assertion, I think your
method is better and broadly usable (and maybe convenient for an
#equals: implementation).

Thanks!

Esteban A. Maringolo

On Tue, Sep 1, 2020 at 4:33 AM John Aspinall  wrote:
>
> Dolphin shows the same behaviour. I added the following method to 
> ScaledDecimal to help:
>
> roundedByScale
>
> | scaleFactor |
>
> scaleFactor := 10 ** scale.
>
> ^(ScaledDecimal newFromNumber: (fraction * scaleFactor) rounded 
> scale: scale) / scaleFactor
>
>
> Translating slightly for Pharo:
>
> roundedByScale
>
> | scaleFactor |
>
> scaleFactor := 10 ** scale.
>
> ^(ScaledDecimal newFromNumber: (self * scaleFactor) rounded scale: 
> scale) / scaleFactor
>
>
> You can then do:
>
> (82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1) roundedByScale = 
> 9.5s1  "true"
>
>
> HTH.
>
> John
>
>
>
>
>
>
>
> > On 1 Sep 2020, at 05:17, Esteban Maringolo  wrote:
> >
> > As a follow up to this, adding a roundTo: before converting into a
> > ScaledDecimal does not work.
> >
> > (((91 - (2 * 35.9) - (0 / 2) * (113/121))  roundTo: 0.1)
> > asScaledDecimal: 1) = 17.9s1
> >
> > So how do you compare two ScaledDecimals that _should_ be the same?
> >
> > Regards!
> >
> > Esteban A. Maringolo
> >
> > On Tue, Sep 1, 2020 at 1:07 AM Esteban Maringolo  
> > wrote:
> >>
> >> Hi,
> >>
> >> I was doing some basic calculations based on a formula, and I wanted
> >> to convert the result to a scaled decimal in order to avoid having
> >> these "loose" decimals in 10th position or something similar.
> >>
> >> So I did the following:
> >> 82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1 -> 9.5s1
> >>
> >> But When I do this in a test:
> >> (82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1) = 9.5s1
> >>
> >> It fails because the comparison returns false.
> >>
> >> I guess this is the proper behavior, but I'd expected that the
> >> conversion from a Float to a scaled decimal would have eliminated the
> >> extra precision from the formula.
> >>
> >> I can do a roundTo: 0.1 before converting, but I'd like to know what
> >> would be the proper way of dealing with this.
> >>
> >> Thanks!
> >>
> >> Esteban A. Maringolo
> >
>
>



Re: [Pharo-users] Scaled decimals comparisons

2020-09-01 Thread Esteban Maringolo
It evaluates to false in VW too.

I guess it is a matter of internal representation, since
ScaledDecimals/FixedPoints are a Fraction after all.

What is weird, and I'd say wrong (at least from the UX perspective) is
that in Pharo (and Dolphin):
((91 - (2 * 35.9) - (0 / 2) * (113/121))  roundTo: 0.1) -> 17.902

While in VW and VAST they round the float properly:
((91 - (2 * 35.9) - (0 / 2) * (113/121))  roundTo: 0.1) -> 17.9

Regards!

Esteban A. Maringolo

On Tue, Sep 1, 2020 at 1:24 AM jtuc...@objektfabrik.de
 wrote:
>
> Interesting. Your expression evaluates to true in VA Smalltalk.
>
>
> Am 01.09.20 um 06:17 schrieb Esteban Maringolo:
> > As a follow up to this, adding a roundTo: before converting into a
> > ScaledDecimal does not work.
> >
> > (((91 - (2 * 35.9) - (0 / 2) * (113/121))  roundTo: 0.1)
> > asScaledDecimal: 1) = 17.9s1
> >
> > So how do you compare two ScaledDecimals that _should_ be the same?
> >
> > Regards!
> >
> > Esteban A. Maringolo
> >
> > On Tue, Sep 1, 2020 at 1:07 AM Esteban Maringolo  
> > wrote:
> >> Hi,
> >>
> >> I was doing some basic calculations based on a formula, and I wanted
> >> to convert the result to a scaled decimal in order to avoid having
> >> these "loose" decimals in 10th position or something similar.
> >>
> >> So I did the following:
> >> 82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1 -> 9.5s1
> >>
> >> But When I do this in a test:
> >> (82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1) = 9.5s1
> >>
> >> It fails because the comparison returns false.
> >>
> >> I guess this is the proper behavior, but I'd expected that the
> >> conversion from a Float to a scaled decimal would have eliminated the
> >> extra precision from the formula.
> >>
> >> I can do a roundTo: 0.1 before converting, but I'd like to know what
> >> would be the proper way of dealing with this.
> >>
> >> Thanks!
> >>
> >> Esteban A. Maringolo
> >
>
> --
> ---
> Objektfabrik Joachim Tuchel  mailto:jtuc...@objektfabrik.de
> Fliederweg 1 http://www.objektfabrik.de
> D-71640 Ludwigsburg  http://joachimtuchel.wordpress.com
> Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1
>
>
>



Re: [Pharo-users] Getting rid of .sources file for deployment

2020-09-01 Thread Esteban Maringolo
Hi Stef,

That was the first thing I tried, but PharoADO (it is, PharoCOM) needs
the source in order to do some of its stuff.

But even so, I'd still like to have a VM that is used only for running
the image headless, without any GUI (nor IDE).

Regards!

Esteban A. Maringolo

On Mon, Aug 31, 2020 at 10:20 AM Stéphane Ducasse
 wrote:
>
> If this is for obsfucation why not simply providing an empty source/changes 
> file?
> And you can remove the decompiler (but then after you will never debug 
> anymore your application).
>
> S
>
> Hi Stef,
>
> Thanks for the support.
>
> I don't know if there is a way to do that for FFI except if you
> somehow modify the methods during execution to include the arguments
> in the method itself instead of relying on the source code for
> reflection.
>
> What would help in the meantime is to have a VM that is headless all
> the time (something like a forced --headless parameter), otherwise it
> is really easy for somebody to remove the --headless parameter and
> fire your image and navigate your code with all the power a Smalltalk
> IDE provides.
>
>
> Is there a way to compile a VM with such an option? (basically a
> HeadlessPharoConsole.exe).
>
> Regards!
>
> Esteban A. Maringolo
>
> On Sat, Aug 29, 2020 at 2:46 AM Stéphane Ducasse
>  wrote:
>
>
> Hi
>
> I’m really interested in this.
> Because we should be able to ship without the sources.
> FFI needs the source at some point but I guess that this is the first time
> and that the information could be stored in the compiledMethod.
> But I do not remember.
>
> Now may be esteban or pablo can give you some hints
> but frankly we are super super super busy
> but if you have a way and that Pharo should be changed to support this 
> scenario let
> us know we will support you.
>
> S
>
> On 29 Aug 2020, at 04:49, Esteban Maringolo  wrote:
>
> Hi,
>
> Is there a way to get rid the .sources file in a deployment scenario?
>
> I followed this guide [1], but I cannot get rid of the .sources files,
> because I'm using PharoADO (which uses PharoCOM) and it uses some
> reflection for FFI and for some reason that implies using the .sources
> file. I installed the FFICompilerPlugin as per the instructions, but I
> don't have a way to tell whether I did in the right place/moment, nor
> how to assess its proper installation.
>
> If such [2] .sources file cannot be removed, what is the criteria for
> the lookup, can it be renamed or modified via some parameter/config?
>
> Thanks!
>
> [1] 
> https://github.com/pharo-open-documentation/pharo-wiki/blob/master/General/DeployYourPharoApplication.md#sources-obfuscation
> [2] Pharo8.0-32bit-0932da8.sources in my case
>
>
> Esteban A. Maringolo
>
>
> 
> Stéphane Ducasse
> http://stephane.ducasse.free.fr / http://www.pharo.org
> 03 59 35 87 52
> Assistant: Aurore Dalle
> FAX 03 59 57 78 50
> TEL 03 59 35 86 16
> S. Ducasse - Inria
> 40, avenue Halley,
> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> Villeneuve d'Ascq 59650
> France
>
>
>
> 
> Stéphane Ducasse
> http://stephane.ducasse.free.fr / http://www.pharo.org
> 03 59 35 87 52
> Assistant: Aurore Dalle
> FAX 03 59 57 78 50
> TEL 03 59 35 86 16
> S. Ducasse - Inria
> 40, avenue Halley,
> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> Villeneuve d'Ascq 59650
> France
>



Re: [Pharo-users] Scaled decimals comparisons

2020-08-31 Thread Esteban Maringolo
As a follow up to this, adding a roundTo: before converting into a
ScaledDecimal does not work.

(((91 - (2 * 35.9) - (0 / 2) * (113/121))  roundTo: 0.1)
asScaledDecimal: 1) = 17.9s1

So how do you compare two ScaledDecimals that _should_ be the same?

Regards!

Esteban A. Maringolo

On Tue, Sep 1, 2020 at 1:07 AM Esteban Maringolo  wrote:
>
> Hi,
>
> I was doing some basic calculations based on a formula, and I wanted
> to convert the result to a scaled decimal in order to avoid having
> these "loose" decimals in 10th position or something similar.
>
> So I did the following:
> 82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1 -> 9.5s1
>
> But When I do this in a test:
> (82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1) = 9.5s1
>
> It fails because the comparison returns false.
>
> I guess this is the proper behavior, but I'd expected that the
> conversion from a Float to a scaled decimal would have eliminated the
> extra precision from the formula.
>
> I can do a roundTo: 0.1 before converting, but I'd like to know what
> would be the proper way of dealing with this.
>
> Thanks!
>
> Esteban A. Maringolo



[Pharo-users] Scaled decimals comparisons

2020-08-31 Thread Esteban Maringolo
Hi,

I was doing some basic calculations based on a formula, and I wanted
to convert the result to a scaled decimal in order to avoid having
these "loose" decimals in 10th position or something similar.

So I did the following:
82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1 -> 9.5s1

But When I do this in a test:
(82 - (2 * 35.9) - (0 / 2) * (113/121) asScaledDecimal: 1) = 9.5s1

It fails because the comparison returns false.

I guess this is the proper behavior, but I'd expected that the
conversion from a Float to a scaled decimal would have eliminated the
extra precision from the formula.

I can do a roundTo: 0.1 before converting, but I'd like to know what
would be the proper way of dealing with this.

Thanks!

Esteban A. Maringolo



Re: [Pharo-users] CV/OCR Library

2020-08-31 Thread Esteban Maringolo
Hi Eric,

Thanks for the reference. I'll look into it!

Regards!

Esteban A. Maringolo

On Mon, Aug 31, 2020 at 10:06 AM Eric Gade  wrote:
>
> Hi Esteban,
>
> I know that Sean D has wrapped the Tesseract OCR library:
> https://github.com/seandenigris/Tesseract-St
>
> On Mon, Aug 31, 2020 at 8:42 AM Esteban Maringolo  
> wrote:
>>
>> Hi,
>>
>> Does anybody know if there is an OCR or some CV library available for Pharo?
>>
>> I would like to make an experiment with recognizing the content of
>> some fixed size form, and of course I prefer to do it with Smalltalk
>> whenever possible.
>>
>> Regards!
>>
>> Esteban A. Maringolo
>>
>
>
> --
> Eric



[Pharo-users] CV/OCR Library

2020-08-31 Thread Esteban Maringolo
Hi,

Does anybody know if there is an OCR or some CV library available for Pharo?

I would like to make an experiment with recognizing the content of
some fixed size form, and of course I prefer to do it with Smalltalk
whenever possible.

Regards!

Esteban A. Maringolo



Re: [Pharo-users] Getting rid of .sources file for deployment

2020-08-31 Thread Esteban Maringolo
Hi Stef,

Thanks for the support.

I don't know if there is a way to do that for FFI except if you
somehow modify the methods during execution to include the arguments
in the method itself instead of relying on the source code for
reflection.

What would help in the meantime is to have a VM that is headless all
the time (something like a forced --headless parameter), otherwise it
is really easy for somebody to remove the --headless parameter and
fire your image and navigate your code with all the power a Smalltalk
IDE provides.

Is there a way to compile a VM with such an option? (basically a
HeadlessPharoConsole.exe).

Regards!

Esteban A. Maringolo

On Sat, Aug 29, 2020 at 2:46 AM Stéphane Ducasse
 wrote:
>
> Hi
>
> I’m really interested in this.
> Because we should be able to ship without the sources.
>  FFI needs the source at some point but I guess that this is the first time
> and that the information could be stored in the compiledMethod.
> But I do not remember.
>
> Now may be esteban or pablo can give you some hints
> but frankly we are super super super busy
> but if you have a way and that Pharo should be changed to support this 
> scenario let
> us know we will support you.
>
> S
>
> On 29 Aug 2020, at 04:49, Esteban Maringolo  wrote:
>
> Hi,
>
> Is there a way to get rid the .sources file in a deployment scenario?
>
> I followed this guide [1], but I cannot get rid of the .sources files,
> because I'm using PharoADO (which uses PharoCOM) and it uses some
> reflection for FFI and for some reason that implies using the .sources
> file. I installed the FFICompilerPlugin as per the instructions, but I
> don't have a way to tell whether I did in the right place/moment, nor
> how to assess its proper installation.
>
> If such [2] .sources file cannot be removed, what is the criteria for
> the lookup, can it be renamed or modified via some parameter/config?
>
> Thanks!
>
> [1] 
> https://github.com/pharo-open-documentation/pharo-wiki/blob/master/General/DeployYourPharoApplication.md#sources-obfuscation
> [2] Pharo8.0-32bit-0932da8.sources in my case
>
>
> Esteban A. Maringolo
>
>
> 
> Stéphane Ducasse
> http://stephane.ducasse.free.fr / http://www.pharo.org
> 03 59 35 87 52
> Assistant: Aurore Dalle
> FAX 03 59 57 78 50
> TEL 03 59 35 86 16
> S. Ducasse - Inria
> 40, avenue Halley,
> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> Villeneuve d'Ascq 59650
> France
>



Re: [Pharo-users] PostgresV2 Driver available?

2020-08-30 Thread Esteban Maringolo
Hi,

My question was done in a quest to crack an issue with Postgres which
was already solved, and it involved the connection, but it wasn't the
driver nor the server, but a firewall in between.

So I don't see the need, nor I think it would be advisable, to use the
v2 driver when the P3 is available and well tested and proven in
production.

Regards!

Esteban A. Maringolo

On Sun, Aug 30, 2020 at 9:06 AM Stéphane Ducasse
 wrote:
>
> Jan
>
> may be we should host your version to pharo-rdbms?
> So that people can find it.
>
> S.
>
>
> On 30 Aug 2020, at 13:49, Jan Blizničenko  wrote:
>
> Hello,
>
> actually, I do, although not with Garage or Glorp.
>
> I am not sure how exactly is related version in
> https://github.com/pharo-rdbms/garage and the one on
> deprecated.smalltalkhub.com/#!/~PharoExtras/PostgresV2 ,
> but I migrated the smalltalkhub one to
> https://github.com/JanBliznicenko/PostgresV2 and updated dependencies for my
> own purposes. It might be, however, actually even older than the one in
> garage repository.
>
> Best regards,
> Jan
>
>
> Esteban A. Maringolo wrote
>
> Hi,
>
> Is anybody using the "old" PostgresV2 driver in Pharo 8?
>
> I just checked in the pharo-rdbms/garage repository and of course
> everything is very old there. But I'm having a few issues with P3 that
> I didn't have before (with the PgV2) and I want to be test whether
> there is something related with the connection or the problem lies
> somewhere else.
>
> Regards!
>
> Esteban A. Maringolo
>
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>
> 
> Stéphane Ducasse
> http://stephane.ducasse.free.fr / http://www.pharo.org
> 03 59 35 87 52
> Assistant: Aurore Dalle
> FAX 03 59 57 78 50
> TEL 03 59 35 86 16
> S. Ducasse - Inria
> 40, avenue Halley,
> Parc Scientifique de la Haute Borne, Bât.A, Park Plaza
> Villeneuve d'Ascq 59650
> France
>



[Pharo-users] Getting rid of .sources file for deployment

2020-08-28 Thread Esteban Maringolo
Hi,

Is there a way to get rid the .sources file in a deployment scenario?

I followed this guide [1], but I cannot get rid of the .sources files,
because I'm using PharoADO (which uses PharoCOM) and it uses some
reflection for FFI and for some reason that implies using the .sources
file. I installed the FFICompilerPlugin as per the instructions, but I
don't have a way to tell whether I did in the right place/moment, nor
how to assess its proper installation.

If such [2] .sources file cannot be removed, what is the criteria for
the lookup, can it be renamed or modified via some parameter/config?

Thanks!

[1] 
https://github.com/pharo-open-documentation/pharo-wiki/blob/master/General/DeployYourPharoApplication.md#sources-obfuscation
[2] Pharo8.0-32bit-0932da8.sources in my case


Esteban A. Maringolo



Re: [Pharo-users] Checking baseline before publishing

2020-08-28 Thread Esteban Maringolo
Hi Jonathan,

I never thought of SmalltalkCI for that (I use Gitlab) but in essence
it still requires a trial and error approach (of committing the
Baseline and loading it afterwards to see if it works).

Metacello has a "record" operation that basically does a dry run of
the load, but I don't know if there is a way to do it using the
Baseline in the image instead of one in a repository.

Regards!

Esteban A. Maringolo

On Fri, Aug 28, 2020 at 10:10 AM Jonathan van Alteren
 wrote:
>
> Hi Esteban,
>
> You might want to give smalltalkCI a try: 
> https://github.com/hpi-swa/smalltalkCI
>
> I've recently started using it myself, with GitLab CI and GitHub Actions, but 
> one of the cool things is that you can use it to test your build locally.
>
> For example, create a .smalltalk.ston file for your project which loads the 
> baseline that you want to test, like this:
>
> SmalltalkCISpec {
>   #loading : [
> SCIMetacelloLoadSpec {
>   #baseline : 'MyProject',
>   #directory : 'source',
>   #load : [ 'default' ],
>   #onWarningLog : true,
>   #platforms : [ #pharo ]
> }
>   ],
>   #testing : {
> #categories : [ 'MyProject-Tests' ]
>   }
> }
>
> Then clone the smalltalkCI repo locally and open a terminal on its location, 
> for example /Users/johndoe/git/smalltalkCI. You can then simply use 
> smalltalkCI to build a Pharo image of your baseline, which effectively tests 
> the correct working of your baseline:
>
> bin/smalltalkci -s "Pharo64-8.0" /Users/johndoe/git/MyProject/.smalltalk.ston
>
> By default, it will run all tests in the image, but you can change the list 
> of tests being run by modifying the .smalltalk.ston file accordingly (see 
> https://github.com/hpi-swa/smalltalkCI#testcase-selection).
>
> Hope this helps!
>
> Kind regards,
>
> Jonathan van Alteren
>
> Founding Member | Object Guild B.V.
> Sustainable Software for Purpose-Driven Organizations
>
> jvalte...@objectguild.com
> On 27 Aug 2020, 04:12 +0200, Esteban Maringolo , wrote:
>
> Hi,
>
> How can I check that my baseline works without having to publish
> everything, check that it fails and then going to the origin, fixing,
> etc?
>
> I might be particularly idiot to always miss something, I usually have
> to try at least four times (in a blank image) that my Baseline,
> dependencies, etc. works as expected.
>
> There must be some other way.
>
> Esteban A. Maringolo
>



[Pharo-users] Pharo.exe and PharoConsole.exe VM Difference

2020-08-27 Thread Esteban Maringolo
Hi,

What is the difference between the Pharo.exe and PharoConsole.exe?
They have the same size, but are binary different.

I'd expect the PharoConsole to run headless by default, but it is not the case.

So... is this documented anywhere?

Thanks!

Esteban A. Maringolo



[Pharo-users] Checking baseline before publishing

2020-08-26 Thread Esteban Maringolo
Hi,

How can I check that my baseline works without having to publish
everything, check that it fails and then going to the origin, fixing,
etc?

I might be particularly idiot to always miss something, I usually have
to try at least four times (in a blank image) that my Baseline,
dependencies, etc. works as expected.

There must be some other way.

Esteban A. Maringolo



Re: [Pharo-users] Iceberg "adopt commit" behavior

2020-08-24 Thread Esteban Maringolo
Thanks Sean, I switched to use that, I didn't know about the "DO NOT
CHECK OUT..." option.

This sequence is so convenient it might be worth having as a single
click option (repair > discard > do not checkout).

Regards!

Esteban A. Maringolo

On Sat, Aug 22, 2020 at 8:24 AM Sean P. DeNigris  wrote:
>
> Esteban A. Maringolo wrote
> > So... rephrasing the question... What is the recommended way to work
> > with external files in the same repository as these of Tonel?
>
> Here is what I do (although I'm not sure if it's "the" way). This is off the
> top of my head because I'm not in front of an image right now:
> 1. Change external files
> 2. Commit via command line
> 3. In Pharo, "repair" from Iceberg
> 4. Choose discard image changes and load repository version
> 5. Select "DO NOT CHECK OUT ANY PACKAGES" **Important if you have changes in
> image you don't want to lose**
>
> Since you didn't check out any packages, the code loaded in Pharo didn't
> change. In essence, you just synced Iceberg with the filesystem/git
>
>
>
> -
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>



Re: [Pharo-users] Iceberg "adopt commit" behavior

2020-08-21 Thread Esteban Maringolo
Hi Pablo,

I did the following:
1. Have Pharo with no changes in the current branch.
2. Edit an external file (foo.txt) and commit just modifying this file.
3. Go to Pharo, select the recently created commit and do an "Adopt
commit" command on it.
4. Make some change and commit in Iceberg

The changes in foo.txt are gone, the file is back to the state of step 1.

I would have done a "Checkout existing branch" from 3, but then the
local "master" is not available.

So... rephrasing the question... What is the recommended way to work
with external files in the same repository as these of Tonel?

Regards!

Esteban A. Maringolo

On Thu, Aug 20, 2020 at 9:34 AM teso...@gmail.com  wrote:
>
> Yes, it should work. The same if you repair the repository doing a
> checkout loading the changes from the repository (there should not be
> changes)
>
> Tell us if you have any questions
>
> Thanks!
>
> On Thu, Aug 20, 2020 at 2:21 PM Esteban Maringolo  
> wrote:
> >
> > Hi Pablo,
> >
> > Thanks for the answer.
> >
> > So my workflow of editing files outside of Pharo, committing them, and
> > then adopting the latest commit would be safe? (as long I don't modify
> > files modified by Pharo).
> >
> > Best regards!
> >
> >
> > Esteban A. Maringolo
> >
> > On Thu, Aug 20, 2020 at 6:46 AM teso...@gmail.com  wrote:
> > >
> > > Hi,
> > >   the adopt commit operation has nothing to do with the rebase. It
> > > sets the reference commit of the image to the given commit. It does
> > > not affect the git repository.
> > > The image knows at any moment the commit it has loaded (or it supposed
> > > to have loaded).
> > > The adopt operation overrides the reference commit with the selected
> > > one, it does not affect the loaded code.
> > > There is risk of doing so, it changes the commit in the image but
> > > without changing the repository nor the loaded code. So, it can
> > > produce a detached working-copy, and also it affects the records of
> > > changes the image has.
> > >
> > > On Thu, Aug 20, 2020 at 5:16 AM Esteban Maringolo  
> > > wrote:
> > > >
> > > > Hi,
> > > >
> > > > What does the "Adopt commit" mean?
> > > >
> > > > It seems like a rebase, but I'm not sure.
> > > >
> > > > I often have ongoing changes in my image, and also changes in the
> > > > filesystem (css, js, Dockerfile, etc.). So what I do is to commit on
> > > > the filesystem, and then "adopt" the recently created commit, and then
> > > > commit in Iceberg (and probably push).
> > > >
> > > > Is this okay? Is there any risk in doing this?
> > > >
> > > > Regards!
> > > >
> > > > Esteban A. Maringolo
> > > >
> > >
> > >
> > > --
> > > Pablo Tesone.
> > > teso...@gmail.com
> > >
> >
>
>
> --
> Pablo Tesone.
> teso...@gmail.com
>



Re: [Pharo-users] CannotWriteData errors in P3 and Seaside

2020-08-20 Thread Esteban Maringolo
Hi all,

Good news. :-)

On Thu, Aug 20, 2020 at 6:36 PM Esteban Maringolo  wrote:

> > Is it not so that in Docker all network connections in/out/between 
> > instances are mediated by some management software ?
> > I even thought it was nginx. Maybe I am totally wrong here.
>
> No, it is not that, but inside a Swarm all containers run in a
> "overlay network" (basically a VPN) that is independent of the host
> network, this way you can distribute containers among different hosts.

> All the packages are routed by Docker itself, and apparently there is
> an issue there, that if a connection is idle for a certain time, it
> silently stops routing packages, leaving both sides of the connection
> unaware of it.

I finally was able to pinpoint what was causing this issue that gave
me a lot of headaches.

It effectively was the "overlay network" [1] of my Docker Swarm [2]
deployment. The "mesh" router was terminating idle connections after
10 minutes (I noticed this exact timing some days ago).

So configuring the PostgreSQL server container to use the host network
instead of the overlay made all my connections stable again. No more
silent drops. No more GlorpDatabaseReadError. And now with some
additional health checks in place that will help me when there is an
actual issue with the connections.

Maybe there is another way to make it work within the overlay, but
that's not something I'm interested in doing right now.

So P3 behavior was okay (again), PostgreSQL was not doing anything odd
either, it was what was sitting in between.

Best regards,

[1] https://docs.docker.com/network/overlay/
[2] I have a Swarm with 1 nginx for static content, 1 PostgreSQL and 1
Traefik as an HTTP gateway for several replicas of a Seaside
application.



Re: [Pharo-users] CannotWriteData errors in P3 and Seaside

2020-08-20 Thread Esteban Maringolo
Hi all,

On Thu, Aug 20, 2020 at 3:02 PM Sven Van Caekenberghe  wrote:

> >> I don't know what is going on inside Socket, I just stated my opinion.
> > Maybe there is something to investigate here?

> Is it not so that in Docker all network connections in/out/between instances 
> are mediated by some management software ?
> I even thought it was nginx. Maybe I am totally wrong here.

No, it is not that, but inside a Swarm all containers run in a
"overlay network" (basically a VPN) that is independent of the host
network, this way you can distribute containers among different hosts.

All the packages are routed by Docker itself, and apparently there is
an issue there, that if a connection is idle for a certain time, it
silently stops routing packages, leaving both sides of the connection
unaware of it.
https://github.com/moby/moby/issues/31208

> What if you change
>
> P3DatabaseDriver >> connect: aLogin

> by inserting
>
>  verbose: true
>
> before the last statement.
>
> You could also make a subclass of P3DatabaseDriver.

I could, but that would only log one extra CONNECT entry, not of much use.


> > At this point I'm factoring out what might be causing this. It's an
> > issue that only happens to me in production, and I don't have a better
> > instrumentation in place to debug it.

I think I found the culprit, now I need to know how to bypass or setup
the network to avoid these situations.

Luckily this will be solved soon. :-)

Regards.



Re: [Pharo-users] CannotWriteData errors in P3 and Seaside

2020-08-20 Thread Esteban Maringolo
Hi,

I'm replying to the list as well... because the last two mails got
replied to our personal addresses.

On Thu, Aug 20, 2020 at 11:55 AM Sven Van Caekenberghe  wrote:
> > On 20 Aug 2020, at 15:31, Esteban Maringolo  wrote:
> >
> > Hi Sven,
> >
> > If a socketstream doesn't know the state of the connection, then what
> > is the #socketIsConnected method for? In particular the
> > #isOtherEndClosed test.
> >
> > ZdcAbstractSocketStream>>#socketIsConnected
> >  ^socket isConnected and: [ socket isOtherEndClosed not ]
>
> I don't know what is going on inside Socket, I just stated my opinion.

Maybe there is something to investigate here?

> With logging enabled, I can do the following:
>
> $ grep P3 server-2020-08-20.log | grep CONNECT | tail -n 20
> 
> 2020-08-20 14:43:06 [P3] 30513 DISCONNECTING 
> psql://client-xyz:hiddenpassword@client-xyz-db:5432/client-xyz
> 2020-08-20 14:44:06 [P3] 30516 CONNECTED 
> psql://client-xyz:hiddenpassword@client-xyz-db:5432/client-xyz
> 2020-08-20 14:44:06 [P3] 30516 DISCONNECTING 
> psql://client-xyz:hiddenpassword@client-xyz-db:5432/client-xyz
> 2020-08-20 14:44:06 [P3] 30517 CONNECTED 
> psql://client-xyz:hiddenpassword@client-xyz-db:5432/client-xyz
> 2020-08-20 14:44:06 [P3] 30517 DISCONNECTING 
> psql://client-xyz:hiddenpassword@client-xyz-db:5432/client-xyz
>
> The number after [P3] is the session identifier (backend process id) of that 
> connection. You should see each one being opened and closed in pairs.

Yes, I noticed the pid, and compared it with what I had on the
pg_stat_activity table.

I don't get the CONNECTED log because there is no way to set the
logging in the P3DatabaseDriver before it creates (and connects) the
P3Client.
Maybe there could be a setting on P3Client class to set verbosity
globally? Or at the P3DatabaseDriver instead.

Summarizing... I'm pretty confident that P3 works correctly and also
the PG server.
At this point I'm factoring out what might be causing this. It's an
issue that only happens to me in production, and I don't have a better
instrumentation in place to debug it.

Again, thanks for the support.

Regards.



Re: [Pharo-users] Iceberg "adopt commit" behavior

2020-08-20 Thread Esteban Maringolo
On Thu, Aug 20, 2020 at 10:48 AM Sean P. DeNigris  wrote:
> > The image knows at any moment the commit it has loaded (or it supposed
> > to have loaded).
>
> For posterity, that info can be accessed via e.g. `anIceLibgitRepository
> workingCopy referenceCommit shortId`

This comes really handy, so I add how do I get the IceLibgitRepository
instance? (given I provide the name).

Regards!

Esteban A. Maringolo



Re: [Pharo-users] Iceberg "adopt commit" behavior

2020-08-20 Thread Esteban Maringolo
Hi Pablo,

Thanks for the answer.

So my workflow of editing files outside of Pharo, committing them, and
then adopting the latest commit would be safe? (as long I don't modify
files modified by Pharo).

Best regards!


Esteban A. Maringolo

On Thu, Aug 20, 2020 at 6:46 AM teso...@gmail.com  wrote:
>
> Hi,
>   the adopt commit operation has nothing to do with the rebase. It
> sets the reference commit of the image to the given commit. It does
> not affect the git repository.
> The image knows at any moment the commit it has loaded (or it supposed
> to have loaded).
> The adopt operation overrides the reference commit with the selected
> one, it does not affect the loaded code.
> There is risk of doing so, it changes the commit in the image but
> without changing the repository nor the loaded code. So, it can
> produce a detached working-copy, and also it affects the records of
> changes the image has.
>
> On Thu, Aug 20, 2020 at 5:16 AM Esteban Maringolo  
> wrote:
> >
> > Hi,
> >
> > What does the "Adopt commit" mean?
> >
> > It seems like a rebase, but I'm not sure.
> >
> > I often have ongoing changes in my image, and also changes in the
> > filesystem (css, js, Dockerfile, etc.). So what I do is to commit on
> > the filesystem, and then "adopt" the recently created commit, and then
> > commit in Iceberg (and probably push).
> >
> > Is this okay? Is there any risk in doing this?
> >
> > Regards!
> >
> > Esteban A. Maringolo
> >
>
>
> --
> Pablo Tesone.
> teso...@gmail.com
>



[Pharo-users] Iceberg "adopt commit" behavior

2020-08-19 Thread Esteban Maringolo
Hi,

What does the "Adopt commit" mean?

It seems like a rebase, but I'm not sure.

I often have ongoing changes in my image, and also changes in the
filesystem (css, js, Dockerfile, etc.). So what I do is to commit on
the filesystem, and then "adopt" the recently created commit, and then
commit in Iceberg (and probably push).

Is this okay? Is there any risk in doing this?

Regards!

Esteban A. Maringolo



Re: [Pharo-users] CannotWriteData errors in P3 and Seaside

2020-08-19 Thread Esteban Maringolo
I kept looking into this, and still haven't found what might be causing it.

However, I was trying to "salvage" that until I find a solution, and
run a "healthcheck" to be sure that the GlorpSession has an active
connection, and then I found that a P3Client reports as connected even
when it's not.

I connected to a PostgreSQL database running in a Docker container,
stopped the container, and the driver continues to report as
connected, even way after the server was stopped (the timeout is using
the default 10 seconds).

The ZdcSocketStream reports both ends of the socket as connected, when
the server side certainly isn't.

I noticed also that in P3Client>>connect it calls #ensureOpen, and it
takes the socket as open when it is not, so as soon as it tries to
flush the data written to it, a `CannotWriteData` exception is
signaled.

In my case I'm developing on Pharo 8 on Windows with PostgreSQL
running in Docker on WSL2 (ubuntu), but on the server it is a 100%
Linux deployment.

Any ideas?

Esteban A. Maringolo

On Mon, Aug 10, 2020 at 5:44 PM Esteban Maringolo  wrote:
>
> Looking at the Postgres side of the log I find that the connection was
> reset from the other side (it is Pharo).
>
> The reason for that is yet unknown to me. Since I don't do anything
> (that I'm aware of).
>
> golfware_database.1.9sl4bt9j6cv5@gw| 2020-08-10 20:02:35.939 UTC
> [132] LOG:  could not receive data from client: Connection reset by
> peer
> golfware_database.1.9sl4bt9j6cv5@gw| 2020-08-10 20:06:58.083 UTC
> [139] LOG:  could not receive data from client: Connection reset by
> peer
> golfware_database.1.9sl4bt9j6cv5@gw| 2020-08-10 20:06:58.083 UTC
> [137] LOG:  could not receive data from client: Connection reset by
> peer
> golfware_database.1.9sl4bt9j6cv5@gw| 2020-08-10 20:33:20.163 UTC
> [166] LOG:  could not receive data from client: Connection reset by
> peer
> golfware_database.1.9sl4bt9j6cv5@gw| 2020-08-10 20:35:22.019 UTC
> [168] LOG:  could not receive data from client: Connection reset by
> peer
> golfware_database.1.9sl4bt9j6cv5@gw| 2020-08-10 20:37:33.091 UTC
> [177] LOG:  could not receive data from client: Connection reset by
> peer
>
> I'll have to keep looking.
>
> Best regards!
>
> Esteban A. Maringolo
>
>
> On Mon, Aug 10, 2020 at 5:35 PM Esteban Maringolo  
> wrote:
> >
> > My Seaside session isn't closing the connection, only when
> > unregistered, but this seems to be something else I don't know.
> >
> > I saw there is logging, and I need to set it up in general (including
> > Fuel serialized stacks).
> > Looking in the web apparently there is the need for a keepalive that
> > is not in place.
> > What disturbs me is that it doesn't happen in development. Making things 
> > harder.
> >
> > Regards!
> >
> > Esteban A. Maringolo
> >
> > On Mon, Aug 10, 2020 at 5:02 PM Sven Van Caekenberghe  wrote:
> > >
> > > Hi Esteban,
> > >
> > > I have a web app with P3 under Seaside in production and it works fine. 
> > > But that is without Glorp, nor any connection pooling.
> > >
> > > You say the connection seems closed, maybe the closing got triggered by 
> > > your app somehow ? How do you clean up expired sessions ? How do you 
> > > handle logouts ?
> > >
> > > P3 does normally reconnect automatically, IIRC.
> > >
> > > You could try to enable logging in P3Client, that is a recent addition. 
> > > It should show you what happens to your connections.
> > >
> > > Sven
> > >
> > > > On 10 Aug 2020, at 21:15, Esteban Maringolo  
> > > > wrote:
> > > >
> > > > Hi all, Sven ;-)
> > > >
> > > > I'm having erratic P3 errors in a recent application I wrote using
> > > > Pharo, Seaside and Glorp with P3 as driver.
> > > >
> > > > Each Seaside session has a GlorpSession, which in turn has a
> > > > P3Connection in its accessor. I don't know why, but sometimes the
> > > > P3Connection socket is closed, and then when trying to read from the
> > > > database, it cannot write the query to the P3 socket and exception is
> > > > raised, and it isn't handled by the P3DatabaseDriver (automatically
> > > > trying to reconnect?).
> > > >
> > > > I don't know if I'm doing something wrong, I plan to migrate the
> > > > GlorpPooledDatabaseAccessor and also use the P3ConnectionPool, but I
> > > > want to be sure that the current setup works of if maybe I'm exceeding
> > > > some limit or timeout that causes the connection to be closed.
> > > >
> > > > Regards!
> > > >
> > > >
> > > > Esteban A. Maringolo
> > > >
> > >
> > >



  1   2   3   >