yoy.be "Why-o-Why"

Delphi, the shrinking island.

2017-05-09 21:48  delphitrend  coding delphi  [permalink]

Is there a language that has a single word for 'the feeling of being on a shrinking island'? Anyway, this is somewhat sad to see, especially that the few most recent Delphi versions gave the impression there was a new uptake with more people getting persuaded, but it doesn't show in the curve.

(via)

'Relax' scripting vs xxm

2017-04-22 13:12  relaxxxm  coding delphi internet  [permalink]

Delphi Relax Web Scripting (Marco Tech Blog)

I'm sorry but I feel I must react. In general I keep silent, in the hope people by themselves will know better, but as I'm getting no input what-so-ever that that is the case, I feel tempted to write something about this.

First about what's at hand. I see this bit of code:

<h2>Employees</h2>
<ul>
@foreach (var emp in employee) {
  <li>@emp.FirstName @emp.LastName (@emp.PhoneExt)</li>
}
</ul>

and it looks kind-of OK. To the untrained eye it looks good and may even look tempting to write more in this syntax. This is a straight-forward example of a template that works with a templating engine that no doubt has many more capabilities and features. And then I thought, learned from practice, what I typically would get asked is to not show " ()" when the PhoneExt field is empty. I would not know how to make that happen in that template syntax. That's mainly because I know nothing about the template syntax. If I look into the documentation, I might find an @if predicate to make it happen, but let's move on:

This is what it could look like in xxm:

[[!var emp:TEmployee;
<<h2>Employees</h2>
<ul>>
foreach emp in FDMemTable1 do
begin
<<li>>=[emp.FirstName,' ',emp.LastName,' (',emp.PhoneExt,')']<</li>>
end;
<</ul>

Looks roughly simlar. A little more like Delphi syntax. And in fact it is. If you know [[, ]], << and >> get translated into Context.SendHTML() and Context.Send() calls behind the scenes (full details are here),  you know this code will result in the same output. Without templating engine! Streamed to the user's client! Perhaps even while the data is streaming in from the database server, in case it's a longer list, and in case there is a database server, Marco uses a memory-table for his example.

What I find important is that there's less going on between the native compiled logic and getting the data to the user launching a request. Not only a templating engine looks superfluous, this entire ORM thing is something I don't get. If it's a gigantic database model with so much tables that you clearly benefit from code-completion, then I agree, but I haven't come across something remotely close to that in web projects.

Also the HTTP-server itself is something I think that values extra attention. I've seen platforms and frameworks that offer you a wealth of capabilities and features, but hastily slapped on something that listens on TCP port for basic HTTP requests, in some cases on port 80, but more often 8080 or something else in the thousands. In real web environments, the server(s) has/have a lot more going on: load-balancing, reverse proxies, firewalling, authentication. Since we're in a Post-Snowden-era nowadays, we're all responsible to think about protecting privacy and get that HTTPS in order with the proper certification and encryption... Not to mention HTTP version 2 that's heading full steam towards being generally accepted/expected.

I can image the web-admin responsible for all that, isn't happy with your request to add this newfangled separate thing that's doing its own handling of HTTP requests. ISAPI DLL's or Apache modules play much nicer with existing IIS or Apache installations. (FastCGI is on the table, but for now xxm has SCGI available for other servers.) Even if your 'Delphi HTTP framework' of choice is specifically designed to tap your ORM of choice and offer a REST-API for your data-layer needs, it will still be one more stop along the way between the user's browser, and the delivery-setup, and the front-end, and the page-template, and the data-layer, and the database, and what the user actually needs or wants. I think of this in the postal office when there's twelve people in the queue in front of me.

I don't expect to convince much people of this way of working, but it works great for me. I remember the days with early PHP and ASP and how simple and straight-forward everything was. Knowing these work on scripting engines, I kept worrying about lost performance. This was the core reason to start xxm: employ the speed and power of the Delphi compiler to have a native library serve my websites. And it turns out that Delphi code looks quite nice between HTML to handle server-side logic, if I may say so. It took me a few years to make this happen, but I couldn't do without it any more. And people kind-of appreciate that for using this new application, all they need is their trusted browser and a URL.

HTML: label, no more "for" for me!

2017-04-13 22:44  htmllabelfor  coding internet werk  [permalink]

If only I had known sooner! I forgot where I picked this up, but apparently if you put <label> around an <input>, typically of type checkbox or radio, browsers automatically know the label is for that control. Before, I would write my <input id="x"> first, then a <label for="x"> after. To keep code neat, I would put it on a separate line, but the EOL inbetween would not be clickable to actuate the control. This is a really minor issue, but still. Now that I know you can just write this:

<label><input type="checkbox" name="Toggle1" value="1" checked="1" /> Toggle1: clicking text after a checkbox should toggle the checkbox!</label>

Because, there are two kinds of people: those that click the box to switch a checkbox, and those that click the text right of the checbox. You might not even know that you do, but you do don't you. If you're of the latter type, it's just one of those minor frustrations, that a click on the text-label sometimes doesn't do what you expect, and you have to:

  1. first pick up that's this that's going on, possible because you've selected a bit of the text
  2. align your eyes to the checkbox
  3. align the mouse-cursor over the checkbox
  4. click the checkbox, confirming the previous one or more click are actually wasted

But there you have it. Heaven has great UX. Here we need to make do with what we get. (And need to make sure it's the way we like it for those bits that we have control over.)

A story about two task-keeping-applications.

2017-03-18 17:22  s2tka  coding delphi werk freeware  [permalink]

Let me tell you a story of two task-keeping-applications. Once there was a team that was struggling to keep track of the work it was doing, had done, and still had to do. It was frustrating to work on the team, hard to schedule things, almost impossible to estimate when things where going to get done. And since clients are what they are, changing requirements and additional requests would cause much more disruption than expected of a team that calmly and firmly is determined to deliver the best of market solution.

An internal brainstorming-session about what to do about it, ended in two opposing visions about what decent issue-tracking should be about, and how a system that (co-!)operates with the team members should be structured internally, should behave, and which duties it should perform either by itself, or by effect of using its rules and restrictions correctly as designed.

In an attempt to get to the best solution, two teams were formed to develop each a project based on one of the two views. An evaluation would follow determining a winner, or if would it be possible to synergize the best parts of both into a single system.

A side note: from a managerial point of view this is a very tough decision. Allocating a lot of resources to work on internal structure, takes resources away of the work that brings in revenue, and such undertakings typically risk getting frivolous or spinning out of control. But I guess it's normal that all stop rowing to help keep the boat from sinking. So, apart from being intrinsically aware of the exceptionality of this opportunity, coordinators were given instructions to keep to a strict schedule in these projects and a determined focus on delivering a workable proof-of-concept quick. Sounds like a good work-ethic to apply generally, if you ask me.

A few weeks later progress was made, and the prototypes were already being used to keep track of the issues of these new task-keeping-applications and other projects. The main difference between design visions became apparent soon enough.

One application centered around the list of work items. Care was taken the entry form was extensive enough to have fields for all of the details about a work item, its categorization, its relation to the project, an outline of the projected outcome. An overview would show the current list, possibly filtered for those items assigned to you.

The other application was centered around getting information out of the system, especially structure and relation between items. Users would enter small specific reports, and add them to the best suitable node in a tree-structure, optionally marking relations with other items over branches. The overview showed an expandable structure starting at the root items. It also could have a filter applied, but would potentially show you an entirely different structure of the same data, when using a different relation type.

Having two working prototypes, attention gradually reverted back to the serious work and some of the frustrations of before were abated. After a few months an evaluation was undertaken.

One application had rendered itself useless. The first weeks of usage, a lot of entry happened, but without consensus about categorization, the list was enormous without a clear way of grouping relevant items. Duplicate entries and ambiguous task-descriptions were unresolved, causing confusion.

The other application was doing better. It needed work, but offered a good view of what had to get done.


Enough about the story. Reality, of course, is much more bleak. As no sane manager would make such a shift in resources of a troubled organization, the 'two teams' actually stand for the existing team using an off-the-shelf something badly administered on one side, and on the other side, well, just me, toiling on something potentially better, in my off-time.

I started — like many — with a plain text-file, then a spreadsheet. Then I took the step to design a database for it, but wanted something to do entry and retrieval with roughly the same ease-of-use that a spreadsheet would offer. Working with tree-structures for some other projects, I wanted a single structure to serve as the basis to store data in. Specifically with projects and tasks — as projects tend to have sub-projects, and tasks split into sub-tasks — using branches of a tree would enable to keep this distinction conveniently vague. If you add representation for entities like users and clients into this tree-structure, and relation between nodes over branches, you've got a richness to model much more of the world, and keep track of its changes, past and future.

From there it grew slowly, over years, into what it is now: tx. First versions suffered a notoriously bad interface, but I hope that has improved. For long I was its only user, but some cooperation features have been added since. What's left for me is to keep improving tx where possible, and demonstrating it to people what it's about.

Though entry and structure is important, where a task-keeping-system can really shine is helping to keep an overview. A cleverly designed filter can limit your view to exactly these items that are relevant to you, but in tx you get the additional option of having these items display with exactly those sections of the tree-structure they have in common. Also, I personally feel the most important items on any list, as long as it may be, should be on top. So when tx displays a list of items, they get ordered using their weight, determined by a combination of factors such as task-type and current status. As a task progresses from an active state to a final state, it may move down the list or even fade from view into an archival state.

And there's much, much more I could talk about, but it's all created out of necessity and designed adhering closely to a central vision of what a task-keeping-system should be and what it should be doing for you in order to be able to depend on it.

In conclusion, and for those people that — like me — skip long stories to the last paragraph, it's so very important that information systems succeed at keeping an up-to-date model of reality, and offer you the freedom and easy to update it's view of the world. Especially so with task-keeping software you depend on to keep track of the progress you make with projects, and to help stay on top of what's important. All of that served as the basis for developing tx.

Am I an "old hand"?

2017-01-18 09:23  oldhand  coding dagboek delphi  [permalink]

Am I becoming an 'old hand'? Every time I see someone that doesn't have done as many years of work in Pascal, ask something about generics, I'm troubled again by this generics thing. I don't use it (much). I don't need it. I've been perfectly fine all of this work without them. Yes there is some hype nowadays about functional programming, but there's a grand glacial movement at the base of it: stong type systems. It all started even on the big metalwhere some bright minds had the sense of taking writing logic into a domain of itself with a gentle nod to mathematics, statistics and other adjacent domains. And a lot of great work was done in this domain. A lot. Some great names that now stand on their own came forth.

A recurring theme throughout of it is type systems, or the lack thereof. Or having it bolted on at a later stage. So by the time K&R came along, they took what they needed, what they could make work for them, what they needed to summon the Unix spirit from the depths. Pascal existed at the time, but C, like JavaScript much later, was born out of necessity. Created by the people there and then that needed a new wrench to tighten the new bolts of a new machine. With personal selections here and there, and careful considerations that copy a bit of the zeitgeist of the time.

What's left for us to do is try not to repeat ourselves too much. One way is keep a look-out for patterns and in new projects, know when to apply which one. Or even better, when to switch to another one. This, I think, is where it's starting to get really tough for the younger generation. There's a lot of base-knowledge to cover, some of it is superceded or obsolete, but we can't replace it with studying patterns. I've seen newbies take it on as lawas if it's forbidden to deviate from the design even just a little. Attacking establishments on the base of their deviations from a pattern. There's something to say about attacking the establishment, but blind fury will get you nowhere.

So this generics thing...  It also is in danger of being percieved as a rule, getting over-applied. As if the one true way is using it everywhere or as often as possible. Which is strange from where I stand, since I still see it as a convenience, where you can save on writing bits of code that would otherwise be painfully similar anyway. In operation the work would get handled by this extension to the type system, checking things for you in the background, making sure everything fits. But in the end the things that need to happen, occur much in the same way as if you would have written all those specialisations out in full.

That's why, as it turns out, I don't use them all that much. Perhaps it's also because of my fading belief in the object-oriented way. That too was presented some years ago as the way to go. Everything was supposed to be objects living on the internet. But it too kind of degraded in my view to a convenience, only one of the ways to manage the things inside of your program. Luckily before any of the ORM craze could tinge me. It makes you look around the horizon, in the past where you did more with arrays and pointers, and sideways where others pass messages around all the time. For now I feel like I'm stuck here, waiting for the ground to crack open and offer a new middle ground between interfaces, pointers, traits, channels, monads, and all of the above.

But that's just my humble opinion. I can't tell for sure what the next 60 years of programming machines will bring us.

TIL: 'method modifiers' are not reserved words.

2017-01-05 21:17  TILdirrw  coding delphi  [permalink]

Thing I learned today: 'method modifiers' are not reserved words. Apparently the Object Pascal parser 'consumes' these as labels that just happen to be there or not. Which means in other contexts they're free to use as identifiers, and so they're not reserved words... Strange but OK I guess as this keeps the tokenizer that does its job right before the parser, a little smaller... (How I stumbled upon this is a different story altogether, but one I may be sharing sometime soon...) I searched the documentation a bit and there they're called directives: Fundamental Syntactic Elements: Directives which I thought were things like {$XXX+}, but those are compiler directives...

So these variable names are accepted by the parser/compiler (it doesn't mind the smell at all):

procedure test;
var
stdcall,safecall,cdecl,overload,dynamic,register,abstract,reintroduce:integer;
begin
stdcall:=1;
safecall:=11;
cdecl:=111;
//...
end;

Consider Advice (restored)

2016-12-16 21:15  i1459bis  coding dagboek werk  [permalink]

Consider Advice

I just noticed these went missing since I converted this website to a 'static blog' kind of thing. So I delved up the old backups and fetched these back from the old mdb, and put them up here.

Another Multi-User Dungeon

2016-12-08 23:15  amud  coding delphi freeware  [permalink]

I wanted to make an extra demonstration of WebSockets from/on/with an xxm project. What I also have dreamed about is making a multi-user game where players would navigate a virtual realm and manipulate the objects in it. Problem is that I don't have too much experience with playing existing multi-player online games, and that animated graphics design is not one of my strong points. But still, I wondered if combining the two would lead to something that somehow works.

So I started a project and set out to get something working, without losing too much effort on anything non-essential. Not even on a name for it, so I called it "Another Multi-User Dungeon". I've put the source up on github and host a running version on this computer at home I use to run my xxm projects (so don't shoot me if it's not available, it's not an always-on full-fledged web-server, but it also shows xxm projects don't ask much of a machine to run stabily). Feel free to have a try:
yoy.be/home/amud

The view shows, from top to bottom:

Anything you type into the entry box, when you press enter, is passed on to your in-game persona to speak into the room it is in. Click on items or people to get a list of actions you can do with it or them. Some actions use the last statement that was spoken by your in-game persona, for example 'make a note' from the NoteBloc object (ask for a NoteBloc from the hotel's receptionist). Click on an item again to select it, and in some cases extra actions are available on other items, for example the 'give' action to pass something from your inventory to someone else in the room. Most 'door' objects have a 'go' action that will move your in-game persona to a different room, unless you don't have the key to its lock or the room is fully occupied.

For now I haven't put too much up into the virtual realm. By default you enter the world in the first free room of the Sunburst Hotel, and apart of a welcome leaflet there's not much there. I thought a decent virtual realm would have computer-operated agents you could interact with, so I remembered ELIZA. A lot has changed in the world of chat-bots since then, but I thought it would be nice to have just that in there. It turns out the syntax of the bot-script at its base serves nicely for other roles as well, so I fashioned a receptionist for the hotel that answers back to some questions (and for now can provide you with a NoteBloc if you ask politely). At the city hall, there's a registry office where you can change your display name, and perhaps leave your e-mail address into the internal database, I might make it required for some operations later or if someone wants system support. There's also money you can pick-up and drop, but nothing else you can do with it (yet!).

Under the hood, it's heavily based on a single WebSocket, your 'feed' through which you get information about the virtual realm, and through which you can send commands back. The set of commands is limited and any extra requests lauched by the client-side script use a personalized single-use key based on your personal authentication key stored in LocalStorage. (I could have gone with a cookie, but if the WebSocket were hosted over TLS, LocalStorage offers slightly better security.)

I'm not sure where to take it from here. I've been thinking about creating a shop you could use money to buy things, but then you'd need something you can earn money with... And transporters that could move you to locations further away. But I guess designing more of a city will take some effort already... Perhaps I've got what I wanted: to create a platform that has the basics to build a game on. Only the idea for a specific game isn't there yet. And thinking up a thrilling plot of an exploratory adventure isn't one of my strong points either. If you have ideas please let me know in an issue on GitHub. Perhaps I could hand out a few RoomMaker objects to people and see what they do with it...

DirDiff v2.0.0.460

2016-11-13 21:04  dirdiff2  coding delphi freeware  [permalink]

DirDiff

It feels like this was a very long time in the making, but all the little bits of time here and there probably still amount to a recent number of man-hours... It took a couple of attempts to get "An O(ND) Difference Algorithm and Its Variations" by Eugene W. Myers in an implementation of my own that performed to my liking. I've chosen to use xxHash to speed things up. Once I got that, I continued the grand re-work of DirDiff so it would accept, not 2 files, but n files (or folders); handle the work in background threads, and have both the folder-overview (and XML three) and content in the same window. In case anyone would like to have a peek inside, I've decided to open-source it as well, under the MIT license on github

I've open-sourced my productivity tools

2016-11-12 16:49  tools  coding delphi freeware  [permalink]

I've finally decided to open-source a set of my home-made tools, some of which I use almost every (working) day. Some may be very taylored to my personal taste, others may be easier to use by the broader public. Most are missing documentation, but the typical operation should be self-explanatory. (Except for handy hidden features, should make a list of those somehwere sometime soon...)

These tools have been available here for download in binary form since long, but by putting the source code in a public repository I hope I can inspire anyone that would like to know more what's going on behind the scenes to have a look, and who knows perhaps get someone to make improvements or additions.

→ github.com/stijnsanders/tools

RethinkDB: here to stay or on the way out

2016-10-07 23:23  RethinkDB-in-or-out  coding delphi freeware  [permalink]

I'm worried and confused.  The news these days is that RethinkDB is shutting down, at least the company.  The database itself may live on.  I had been attempting to write a really-thin Delphi wrapper for RethinkDB a number of times before, but got diverted into writing DelphiProtocolBuffer first, because it was used for the base of the server protocol and I couldn't find the Delphi support I was looking for (I'm sorry, but I'm a bit picky). Later it looked like they were planning on dropping this in favor of something else, but I wasn't able to investigate further at that time. In the mean time, I did a CouchDB, PostgreSQL and a MariaDB/MySQL wrapper, and a neat way to tie them together, and kept TMongoWire working, which turns out to be the one in the series of DB connectors that has the most success to date. (And which envolved learning all about PBKDF2...)

So now I'm confused about wether to keep RethinkDB on my to-do list? Or drop it? Or move it up to have a look sooner... Just like MongoDB, it may be that I won't really have a full-grown project anytime soon that is based on RethinkDB, but demand for a thin Delphi wrapper is out there and makes it worth it, I don't know. (Please let me know.)

And I'm worried about this new tale of an open-source-but-also-corporate endeavour going sour. It's only natural that when the projected sales don't appear to manifest, a project is best to get ended cleanly (as I recently witnessed over at the day-job). So I'm rooting for the open-source project to find a good new home. That the eco-system of volunteers may survive the orphanization. That the real-world users may carry enough weight to force the project into a viable after-life.

It's important to have a good climate to have entrepreneurs get enticed to take the step and start a company, but with this series of high-profile undertakings going bust, and aqui-hires where users get left in the dark, it starting to look like it's running out of control. Some people may called it a bubble, but I find the image of a pendulum swinging more appropriate. Is it swinging back already? I'm in no position to tell accurately. But I am worried.

For the record, I have had no economic gain from my open-source undertakings what-so-ever (up till now?) though OpenHub estimates about half a million went into xxm up till now. Not bad for a hobby...
But about RethinkDB, I guess I'll have to wait a little until the dust settles down...

Update 2017-02-06: RethinkDB's assets have been bought from RethinkDB Inc. By something something Linux Foundation, and a re-license to the Apache Public License. Sky is clearing up.

Update 2017-03-06: I've given it another try, and partly because there's a downloadable Windows executable that works, I've got something working. TRethinkDB appears to be able to perform all the basic functions you could require from a driver, but may need some more testing.

Delphi and MySQL or MariaDB

2016-09-15 21:12  libmysql  coding delphi freeware  [permalink]

Tadaa! I added a wrapper around libmysql.dll (to connect with MySQL or MariaDB) to my collection of really (really!) thin wrappers around things like ADO, or LibPQ (to connect with PostgreSQL) or now libmysql.dll. I also had the idea to align them as much as possible into almost the same interface. It's specifically not my point to have them be exactly the same, but very much almost so, just in case when I use this for a project and need to switch database back-end later on, the work that goes into that is minimalised and can concentrate around the different in SQL dialects. (for example the postgres branch here)

https://github.com/stijnsanders/DataLank/blob/master/MyData.pas 

(previously)

AES, DES (TripleDES)

2016-09-09 23:08  aesdes  coding delphi freeware  [permalink]

→ md5

I've added AES and DES. DES may be deprecated, and Triple-DES may be soon, in any way it's cryptographically superceded by other ciphers, but still in use by some systems. I should do some work extra and change array[0..7] of byte into record l,r:cardinal; end;  or even int64 but I needed it only for something small and this works, so I'll leave it at that for now.

TIL: JVM and CIL both use the stack instead of registers.

2016-05-30 16:03  jvmcilstack  coding  [permalink]

Thing I learned today: both JVM and CIL use the stack instead of registers!
JVM: https://jakubdziworski.github.io/enkel/2016/03/16/enkel_3_hello_enkel.html#generating-bytecode-based-on-instructions-queue 
CIL: https://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes(v=vs.110).aspx

Sounds like a bad decision, not only because most other intermediate stuff I've seen uses SSA, but especially it makes the work for JIT-compilers that much harder.

At least, that's my first impression, just from thinking about what a JIT-compiler would have to do: assigning the processor's available registers to what they'll be used for in a section of logic, is a science and an artform all on its own; but if you don't have anything roughly materialized to work with from the beginning, you're bound to eke it out of the given logic and see what it's supposed to do, by following the things that hop on and off the stack... With the lot of guesswork, statistics and heuristics that comes with it.

I guess that's where the recent hype in JIT-compiler innovation comes from. If you get a cleaner conversion to something as if it was written with SSA, you'll probably get better results, but it still feels like a step backward and two steps forward.

And all this because I was comtemplating which back-end to (re)use in case I would have a go at having a play language of my own compile into something executable.

So, sorry guys, but I guess I'm back to looking into LLVM or GCC for a back-end... (unless...)

Microsoft is Coca-Cola.

2016-05-23 10:10  mscc  actueel coding computers  [permalink]

Or, at least, that was what popped into my head when I thought (again) about Microsoft open-sourcing the Windows operating system. Why wouldn't they? Coca-cola gave the super-secret recipe away at some point. It takes a certain stability, and vision, and momentum, to do that, but in my humble opinion both Coca-Cola and Microsoft have that.

Let's see how this could work. It's not because Microsoft would open-source Windows that they should stop selling it. Far from it. You can still buy Coca-cola, right? Have you ever bought cola made from the official Coca-Cola recipe, but concocted by someone else? Would you? Same goes for Windows. If you're in the market for a new computer, and want to run Windows on it, you'll probably go to the source, buy Microsoft, and be sure to get updates (and some free OneDrive space, and an Office365 trial...)

So I really am hopeful. Recently Microsoft has really (really!) opened up quite a bit, and even chose the MIT-license for some things, which was unthinkable just a few years ago. So a logic step would be to go all the way, and release the cash-cows, such as Windows, perhaps SQL Server... Even only perhaps there's a small chance they won't be the cash-cows for much longer... Computer sales is under pressure from smartphones and other hand-held devices. The database landscape is still suffering after-shocks from the NoSQL phenomenon, and from things like PostgreSQL and MariaDB, we roughly know what it takes to run a database anyway. So to ensure cash flowing in in the long run, it's almost a must to open up on old secrets. At least in my humble opinion.

Delphi and PostgreSQL

2016-05-13 00:19  LibPQData  coding delphi freeware  [permalink]

Searching for an alternative way to use PostgreSQL from Delphi? In the spirit of the other as-light-as-it-gets database connector wrappers, I've converted the header(s) to the LibPQ dll. See the LibPQ and LibPQData units in this repository:

https://github.com/stijnsanders/DataLank#datalank 

To start an attempt to move to something more like a generic database layer, I've started this DataLank idea, but it needs more work. Actually I don't intend to develop it all the way into a full-fledged data-layer. Specialities of each specific database solution are so diverse and important, that I really don't want to hide them between an opaque abstraction layer. I want a database connector wrapper to be as light as possible, but also to allow access to the underlying technology. The main point for using DataLank, is to have less work changing DB's by using TDataConnection and TQueryResult types, but not no work. Adapting the used SQL to a different dialect will probably involve updating many (or all) calls the database anyway. But I'll post about that later when I put some more time in. (And perhaps write a libmysql.dll wrapper first...)

postgreSQL: date and time manipulation

2016-05-13 00:06  pg1  coding  [permalink]

Babysteps! I've had the chance to dabble a bit in PostgreSQL, and after (years of) T-SQL, and some MySQL/MariaDB and SQLite, it's yet another SQL dialect to get a hang of. First impressions are good. It feels like a mature dialect. Searching the docs usually helps me find swiftly what I'm looking for. (And there's this ofcourse.) Porting an existing project makes you bump into the differences:

I'll probably hit a lot more like these in the time to come, but that you should use timestamp (or timestamptz) instead of datetime (or datetime2) deserves a separate mention. Especially there's no datediff, dateadd and datepart.

Instead of datepart, there's extract, that's pretty straight-forward, but to replace datediff and dateadd, you do something like it feels it should always have been: plain arithmetic.

PostgreSQL is pretty intelligent about operators (just do select * from pg_operator, wow!) so just subtract two timestamps to get something of type interval,  something like x + interval '2 days' result into exactly what you'd expect, and for constructing, apparently casting is pretty smart, for example:

select now()+(X.X||'day')::interval from (values (0),(1),(2),(3),(4)) X(X)

One more: instead of datediff(dd,x,y)=0 just do this: x::date=y::date pretty obvious if you think about it. Like I said, PostgreSQL made a pretty good first impression.

Play Assembler

2016-05-03 19:17  plasm  coding freeware  [permalink]

Look! It's my first parser in javascript: http://yoy.be/dev/plasm.html

It is also a play thing to try and tame this beast that is assembler. Not any assembler in particular, but just in general what it is to try and make things work with a limited set of registers and instructions and having to shuffle anything that doesn't fit in those to and from memory. If I put more work into this, it could go two ways:

I can evolve the machine code further and try to design a binary encoding for the possible instructions, and have the code turn up in the memory as it is accessed by the normal registers. (It is not now, the I register now indexes into a separate set of instructions, possibly with overlapping values.)

Otherways I could try and build a compiler that compiles code into this set of machine instructions (perhaps based on this one), finding out along the way what is all the fuss about register allocation and heuristic optimizations...

And ofcourse the both meet and I could try to build a compiler straight into these virtual machine instructions, but I have the luxury of not having to do this. And since it's all about learning and exploring by doing, it'll probably get me stuck faster.

But for now I think I'll let this rest for a little while. See how it looks when I come back to it after a while.

See also https://github.com/stijnsanders/plasm

 

SQLite: "collate nocase"

2016-03-11 20:35  sqlitenocase  coding  [permalink]

Learn something new each day! (Or also: I should have known about this!) SQLite is so strict! But in a good way. It's in the little things that come up now and then that you notice how delightfully strict it is designed, with reliability and safety up front. And no extra's. So it's quite logic that sorting a column with string values* is sorted case-sensitive, with al upper-case letters before the lower-case letters. To change this, add collate nocase either to the create table statement or the order by clause of queries. I've picked up somewhere that it's better for performance to have it in the create table statement, but I haven't checked this with the documentation or by testing in a test setup (yet), but for now I just went for updating the tables since changing all the queries would take much more work. That said, updating: not quite. Alter table doesn't have alter column apparently, but it does have a rename to, and insert into TblUpdate select * from Tbl works great, even with an autoincrement primary key (if you fields are still in the same order), so it's a relatively painless transition.

And this barely a week after I find out about the busy timeout!

(*: due to manifest typing different records may hold values of different type in the same field, but in practice you'll usually follow the type as determined by the schema.)

just an idea: var in code for variables of limited scope

2016-02-03 16:18  var-limited-scope  coding delphi  [permalink]

I've been reading around a lot about the new programming languages (Go, Rust, D, WebJavaECMACoffee6asm.ScriptX) and there's ofcourse this thing, but I still do most work for work and distraction in Delphi. So all of a sudden, in a large code block (I know, I know, one is supposed to keep their methods many and small) I thought of something like this:

all_kinds_of_important_code();

var
s:string;
begin
s:=MyObject1.GetSomeString();
ProcessString(s);
StoreStringForFutureReference(s,Now);
end;

more_code_that_makes_the_world_tick(); //perhaps even using 's' but the one declared way above...

In light of the asynchronous programming most languages get pushed upon them, and the need to have 'scope' outliving the usual runtime of the function call, this may have been considered. But purely on the basis of syntax, this could be done. A 'var' token at that point is never valid, so could get used by a parser to initiate a declaration block, followed by a begin/end block, that the compiler would know how to convert into a separate scope (with unwinding, and auto-calling release on interfaces/reference-counted-instances)...

But it currently doesn't. The closest thing you could get is define an anonymous function and call it once there and then, but that may look ugly and is too much code for what it does, in my humble opinion.

So for now I will just be (re-)using a single s:string; on top, I'm afraid. (I feel your sqeam, but I'll be really carefull I promise.)

Types of Information

2015-11-24 11:04  typesofinformation  coding computers werk  [permalink]

I

Not just information

Life would be good if all we had was information. If only we could get all the information. We can't handle that much information, so we build systems to handle the information for us. Strange things happen when information comes in. Good systems are designed to handle these well. In designing information processing systems, you have to cater for the following.

U R
D I

Un-information

Some input signals contain no information. They are either damaged in transport, incomplete, or not of a correct form for the system to handle. Either report them to find out if repair is possible, or keep count of them to be able to report about the health of the system.

Re-information

Some input signals come in twice, and contain the same information. Or do they? If possible try to have the last step in the chain report if an event did take place twice, or if it's an echo on the line. Sometimes a clerk does drop a pack of cards and enters them again just to be sure. Be ready to take only the new cards.

Dys-information

Some information is wrong. Us humans do make mistakes. The system sometimes doesn't know. It processes a signal, of the correct form, holding valid information. Then again, the fact that some information already in the system may be incorrect is also information.

But there's more

Don't expect to get all information. There is always more.

uu uk
ku U R
D I

Known Unknown

More input is coming in. Sometimes we know how much input is still waiting to come in. We'll roughly know how much information there'll be added. In most cases it follows a measurable trend. In some cases it follows the business.

Unknown Known

Information processing is one thing, but does it deliver the required new information? Is there more to mine out of the amassment? Sometimes the numbers can show what you need to know, but do you know where to look?

Unknown Unknown

It's hard to design for things we don't know we don't know (yet). But it serves to be prepared. New things have a knack for looking a lot like something we have already. Sometimes they deserve a new module, sometime just a new category, but don't forget to put the existing items in a category also.

GMail: make the labels menu larger

2015-10-22 09:36  GMailLargerLabelsMenu  coding internet werk  [permalink]

When you don't like it: adapt it.

At work we've been switched to Google Mail for some time now, and to make sense of the mayhem that is the incoming torrent of e-mail, I've been using an extensive set of labels and sub-labels with nice colours and stuff.*

But the list of labels on the pop-up-menu if the 'move' and 'label' buttons is so small, only showing the first few labels, and I had to scroll most of the time.

Is there way to adapt this? It turns out there is. At first I read about user stylesheets, but these got removed from Google Chrome, but there's an extension that does the same:  Stylish 

Install this, and for URL's that start with "https://mail.google.com/mail/", add this:

.aX1 {
max-height: 780px;
top: 92px !important;
}
.aX2 {
max-height: 780px;
top: 92px !important;
}
.aX1 .aXjCH {
max-height: 600px;
}
.aX2 .aXjCH {
max-height: 600px;
}

*: Extra tip: I was searching for something nice to prefix the label-names with that would cause them to get storted (alphabetically) at the end. In theory you could use "zzz " as prefix, but that's ugly. And assumes you'll never have an account named "zzz".
After a bit of searching around the unicode spec, I stumbled upon Bopomofo, so now i use ㄍ and ㄑ which apparently sort past 'z' and look pretty nice.

Results of survey "Designing a new language, what would you use?"

2015-09-14 17:26  plsurvey2results  coding  [permalink]

After having done a first survey, more intended as a joke than in seriousness, I decided to do another survey, (also on reddit) just to get to know a little more on where the people at large are about the things I read about when researching the web for what I need with this toy programming language I started.

As per the last time, I noticed answers come in in the first 24 hours and then nothing, so I thought I'd wait a few days and then process the results. First this: thank you, thank you, thank you very much for the 34 responses.

For back-end, 18 of 33 would use LLVM, 5 JVM, 4 CLR, 4 GCC, just one LuaJIT, and one other offered the gentle advice to use "IR, then translate that IR into whichever backend you want." Which I find strange since that's what I thought a back-end is for... I'm surprised to see so little for JVM, it fuels my suspition that some programming languages are more written about than written in...

For run-time, 19 of 31 would use "FFI to anything C" which makes sense as most do as far as I can tell; 4 JVM, all of which had also JVM for the previous question, again makes sense; 4 CLR, 3 of which had CLR for the previous question, and one LLVM: I have checking out Roslyn high on my to-do list, but I'm not sure if all of the puzzle pieces are out there (yet) to get that working; 2 OCaml, 2 Python, and someone entered "variant of c++" not sure what that is, but it might just be the same as what I meant by "anything C"...

As one could predict, the choices for IDE are a bit more diverse, but roughly what I anticipated:

* 6 emacs
* 4 atom.io, which is pretty good for the new kid on the block
* 4 Eclipse, only 2 of those had JVM on the previous questions
* 4 Microsoft Visual Studio
* 3 IntelliJ IDEA, strangely enough none of those with JVM on the previous questions
* 3 vim
* 2 Code Blocks
* 1 Codelite
* 1 Delphi
* 1 kdevelop
* 1 pharo.org
* 1 "just a text editor"
* 1 "made in this new lang"
* 1 "no ide"
* 1 "shouldn't be tied to an IDE"

To build a parser, 8 out of 30 recommend yacc. 7 advise to roll your own, which kind of surprises me but also not that much, since as someone also points out, it allows you to pay extra attention to having the parser spew out usefull errors when it hits syntax it doesn't understand. 6 would go with GNU Bison, 2 JavaCC, 2 "parser combinations", 1 "recursive decent", 1 "Ada's OpenToken library", 1 Json; those in quotes I should look up as I may have heard about them but am not fully acquainted with (yet!).

For debugger, 18 of 29 would go with gdb, 7 with lldb, 2 with WinDbg, someone would let it depend on the platform, someone else would like to see a "More indepth debugger". And there's someone that would have the debugger be written in the language using meta programming, but this person also left all the questions unanswered, except "pharo.org" for IDE, and "SmallTalk" for the next question. The world needs all kinds of people.

And then the question I was looking forward to the most: projects to learn from

* 9 LLVM
* 9 Lua
* 2 OCaml
* 2 CoffeeScript: which apparently, I noticed, has annotated source right there on the website!
* 2 Haskell (someone wrote "GHC", assuming that stands for the Glasgow Haskell Compiler, I'll count it here)
* 1 Rust
* 1 Smalltalk
* 1 clojure
* 1 DMD
* 1 GCC
* 1 "Ada, a Lisp varient, and probably an ML-language", those are three at once! A LISP variant, I agree, I have clojure in this list but not Scala, strange. And as ML-languages go I've only heard about OCaml.
* 1 "Assembly "Learn e.g. x86 assembly. Without which you will not be able to understand how it is being execute.d=" I don't know what dee equals, but x86 isn't quite the open source compiler I was thinking of. Also I've read this one back to back, does that count?

jsonDoc: JSON object for Delphi based on IUnknown and OleVariant

2015-06-26 21:21  jsonDoc  coding delphi freeware  [permalink]

I was using bsonDoc.pas and bsonUtils.pas from the TMongoWire project in several projects that didn't have anything to do with MongoDB, so I thought this one deserved a repository of its own:

https://github.com/stijnsanders/jsonDoc#jsondoc 

Results of the programming paradigms survey

2015-06-25 00:11  plsurveyresults  coding  [permalink]

A while ago I created a little survey about programming language specifics, and posted it on reddit/programming. Here are the results.

There were 123 responses on May 21st, 8 on May 22nd and one more on the 23rd. I guess then it moved off the first page on reddit... The posted ended on a solid score of zero upvotes.

Whitespace: the majority of you (93 votes) like whitespace to be unimportant to syntax, the others (34) like that it defines scope or levels in code.

Compare-Assign: 121 selected "A single equals-sign "=" is comparison, assignment is something visibily different, e.g. ":=" [Pascal, Nim].", which I find strange, since it's not what the 'top' languages do (C-family, Java, JavaScript). Perhaps I hit a specific public on reddit that happens to prefer sub-top languages that have indeed made a sane selection in operators in comparison and assignment. Perhaps it just the formulation of the question that threw people off.
6 prefer not to use an operator for assignment. Some nice people note that Lisp uses (set! ) for assignment, and Scheme uses equal, which are not really operators. Someone warns not to use == in Java for general comparison. Good to know. (Reminds me to send the daily thank you to the person that once warned me not to use Java.)

Readability: 87 like code to read like human language, against 41 that appreciate that it's for the machines that we're writing. So that's bad news for my attempt at designing a programming language without reserved words...

Subject Object Verb: 109 prefer infix notation (a+b), 15 prefer prefix notation (+ a b), 1 voted postfix (a b +) and 7 prefer something else than operators.

Declarative-Executive: 60 like declarative and executive separate and can live without having them nested, 16 find that declarative and executive should be visually separate but may occur nested, 47 think executive prevails (so they can manipulate their declarative, eew!)

Compiler directives, Pre-compiler: 49 prefer language specific syntax to denote code that is dependent on something external, 39 prefer the linker to be smart enough to ignore unused logic, 38 sticks to the heavy pre-compiler with its own box of tricks.

Garbage collection: 57 likes reference counting; 43 doesn't even bother with clean-up or gives the GC a ping; 26 does their own object lifetime management (or is unwittingly writing leaks).

Multiple Inheritence: 88 claim not to need it; 38 claim to use it; 3 claim do be blissfully oblivious, the lucky bastards.

Concurrency: 80 prefer syntax to work with a parallel workload, 36 likes to just write loops and have the language put the metal to work, 14 roll their own threads.

Generics: Yea 98, Nay 32, the yeas have it. Another reminder I'm part of a (shrinking?) minority...

As I noted in the reddit remarks, I'm not used to setting up surveys like this, and may not have selected the most neutral wordings for the questionnaire, perhaps steering the results a little. In any case, it's nice to hear back from people, and compare where you are in relation to the masses, get to know if your niche is still comfortably narrow.

 

Archive... Search...