[Cuis-dev] [IMPROV] Add convenience method to read JSON strings

Nicola Mingotti nmingotti at gmail.com
Thu Aug 12 03:15:47 PDT 2021


Hi Gerald

thank you a lot for the links and the example !
I will try to study it by the end of the day.

  Q.  IC, I hope you are allowed to publish the results of your work.

This is a web shop with a very unusual interface. IMO the interface
is really new so I will try to get some kind of legal protection before
making it public. Just to avoid our competitors to copy it the next month.

The client side is just JS. The server side is more interesting
because the data structures are complex. Here my guess is that Smalltalk can
play a big role in complexity reduction. Up to now I guess yes, it can 
work !!
It seems a lot more manageable than Ruby+Mongo. My main difficulty
is that I "flattened the data structures" horribily to make them enter 
Mongo,
it works, but it is UGLY, I can't touch the database if i don't have at 
hand my notes.
This is what i want to change. The system must be understandable, even
1 year from now and possibly without a thick manual.

I have a few bits of luck for this project. I don't have that much data 
to manage, it can fit in RAM, and it will
not be a service with 100_000 clients per day, it is a niche market. So 
persistency and performance aren't
high in my list of priorities now.

Bye
Nicola


On 8/12/21 11:20 AM, Gerald Klix wrote:
> Hi Nicola,
>
> Please see below.
>
> On 8/12/21 10:17 AM, Nicola Mingotti via Cuis-dev wrote:
>>
>> Hi Gerald,
>>
>> On 8/12/21 9:11 AM, Gerald Klix wrote:
>>> May I suggest to to implement it this way:
>>> --- snip ---
>>> Json readFrom: aString readStream
>>> --- snap ---
>>> (See SequenceableCollection>>#readStream, inherited by String))
>>>
>> your version is nicer to the eye ;)
> But probably slower without an inlining JIT. ;)
>>
>> There is something i don't understand though. I can arrive up to
>> PositionableStream class>> on:
>> ---------------
>> on: arg1
>>      ^ self basicNew on: arg1.
>> ---------------
>> After that, I can't find where "basicNew on:" is implemented.
> I feared for some time,
> that you might come up with this sort of question :»]
>
> For most #basicNew-sends the method Behavior>>#basicNew
> will respond. Please note it's on the instance side of
> Behavior.
>
> In anticipating the obvious next question:
>
> How does this all work?
>
> This is a nice article about classes and meta-classes,
> explaining their history and providing a side-look
> into other programming languages
> https://courses.cs.washington.edu/courses/cse341/04wi/lectures/17-smalltalk-classes.html 
>
>
> This article contains some words by Alan Kay and
> quotes by Peter Deutsch about the Metaclass
> design decision:
> http://worrydream.com/EarlyHistoryOfSmalltalk/
>>
>>
>>> If your JSON documents are bigger, it might be more efficient
>>> to convert the HTTPSocket to a SocketStream and read directly from
>>> it, but I do not know whether this is possible without much effort.
>>
>> Actually the JSON strings I send/receive can be a bit large. Because 
>> they represent objets with inside
>> packed quite a bit of information e.g. pictures. I would say never 
>> larger then 1 MByte, if possible.
>>
>> Still at the moment I will not worry about efficiency. I am trying to 
>> convert a Ruby+Mongo
>> server side of an app into Cuis. I have time till end of the month to 
>> make it work.
> IC, I hope you are allowed to publish the results of your work.
>>
>> For the moment I am going to replicate the database as a list of 
>> objects in memory,
>> I will consider persistency better in a second step ;)
> My own attempts at this topic are not to successful for the time being:
> http://the_haver.klix.ch/#my-journey-into-databases
>
>
>>
>> Bye
>> Nicola
>>
>>
>>
>>>
>
> --- snip/snap ---
>
>
> Best Regards,
>
> Gerald



More information about the Cuis-dev mailing list