The future of object-oriented development with 4D

Originally published at: https://events.4d.com/summit2020/session/the-future-of-object-oriented-development-with-4d-2/

The 4D language saw huge enhancements in 4D v17 and v18, with features such as object notation, variant, and formula objects. But this was just the beginning, there’s much more in the pipeline. During this session, Laurent Esnault (4D’s VP of Engineering), will provide insights about recently added features – and about major enhancements currently in development.

13 Likes

first of all - COOL. but why generate or revive the pascal/4D language if there is javascript/typescript. i understand your wish to use it seamless in the debugger (which would be not as easy with another language) - BUT - it seems very artificial (especially those odd $1,… parameters). AND do not forget to make / open this with tables/records.

CLASSES :star_struck: :clap: :raised_hands: :clap: :clap:

4 Likes

Laurent said, at time 04:24, that classes are only be available in Project mode.

That says to me that the plan is for Binary mode to be phased out.

However in Miyako’s presentation on Version Control: he stated that both modes (Project and Binary) will continue to be supported.

So: Which is it?

There are advantages/disadvantages to each mode. I’m currently planning to continue to use Binary mode.

yes, both will be supported.

There will be many new features working in both.

There will be some working only in project mode. CSS is already an example. New modern documentation (MD format) another, which cannot be moved in binary.
Classes, both language (session from LE) and data model (soon to be released session from LR), is another, only available in project mode.

It is not about phase out. Another example for that in compatibility mode. Binary mode is still compatible with features from 4D v6.0/6.5/6.8 - v2004. Features made obsolete 20 years ago
Project is not compatible to this features any longer, so it allows us to open new doors, impossible before.
But it’s not phased out, we keep it for some more years.

1 Like

The object oriented features look nice and well thought out. One thing I really dislike is there is no “End function” or any type of keyword to end the block of statements in the class. This is different from every other 4D language construct. Why not make it consistent with the rest of the language?

My other question is if 4D will ever index properties, class functions, etc, the same way it currently supports project methods and table structures. I’m hesitant to use calls where I can’t easily find their use or revise names. Text only searching is not a good option.

1 Like

Hi John, there’s no ‘End function’ simply because it’s currently useless within 4D language. You couldn’t write anything legal between End function and the next Function, except empty lines or comments.
We may add it in the future if we can find a use case.

About indexing properties and class functions, I imagine you are talking about suggestions in the code editor? We are working on big improvements on that matter, that will come.

3 Likes

Very interresting presentation and and well done !
Thanks

:clap: :raised_hands: :clap:

2 Likes

This is a really cool new feature i am waiting since years :drooling_face:

However,

what about the compiler? Does the compiler find syntax errors, like wrongly named functions?

Second question:
What about private and protected functions?

Third question:
What about destructor?

What Christian said … plus

  • Is it possible to define the properties of a class like I would do in C++? Or are the properties defined dynamically at runtime?
  • How about private, public and protected access specifiers?
  • How about static functions?
  • With the new function syntax, wouldn’t it be a good time to use named parameters instead of numbered parameters?

I like how I can define all the various functions in one window. Would be good if this would be supported for regular project methods as well.

A good use case for an End function statement would be if I want to define a nested function or closure. Similar how you define closures or anonymous functions in JavaScript. The current implementation reminded me of the Python programming language, which uses indenting for control structures.

Anyway, I’m happy to finally see some improvements to the programming language.

2 Likes

Hi Laurent,

I realize the parser does not require an end token because of the way you designed the new language elements. But programming languages are as much for people as they are for parsers and compilers. Consistency is important. I’m not aware of any other programming language that uses syntax or key words to delimit code blocks for some language constructs but not others.

I’m not as concerned about code completion suggestions as I am about finding and renaming. In 4D I can right click on a method name or variable to see where it is used or globally rename it. There is not a way to do that with object properties and I assume the new class functions.

:clap: :clap: :clap:

Excellent news. I’ve been waiting for classes for years, and I’m so glad they’re nearly here. It’s a great start and I’m sure classes will evolve dramatically over time, but there’s plenty there to get started with.

Thanks. :+1:

It’s hard for me to understand on this one (the new “cs” area) that it could not also be supported in Binary mode. This is a bummer: as I was not planning to move to Project mode any time soon: but feel that I may want to use classes soon.

3 Likes

Expanding on what Tony said; I think this is a strong indication that Project mode is the future, and even tho 4D is going to support binary mode going forward, it will be very much the legacy mode and most/all of the cool new features will be in Project mode only.

This is not a criticism, just an observation. But I hope 4D come out and explicitly give us some direction on this.

2 Likes

hi Christian,

The compiler doesn’t detect wrongly named class functions nor bad parameter types, that’s because it needs some static typing information in order to do that. We are working on that.

Regarding private/public/protected, 4D is more like JS than C++. Its fully dynamic nature makes more difficult to implement such things. We recognise the needs however and we are still trying to figure out how to propose a similar concept.

And about destructors: for the same reasons as for Java or Javascript, there is no destructor user function. That’s because that kind of function would be called at unpredictable time, in unpredictable order, possibly in an unstable context, whenever 4D detects there’s no more any reference to an object.

1 Like

Hi Rob,

Properties are defined dynamically at runtime.
Static functions in c++ are like global methods using the class as a namespace. We have no such “namespace” concept in 4D language, but you may emulate it, for example, by using your own “static” property in your objects, the same instance for all, exposing you static functions.
Moreover, the class is a shared object, you can use it to store your static properties as I explained in my video session.

Indeed, we are working on named parameters, as many other improvements…

2 Likes

The project mode opens the door to so many possibilities we are currently investing more on it than on the traditional binary mode. We just scratched the surface of what becomes possible…
But this only concerns the development environment. If a ‘cool feature’ is not related to the development environment or experience, it will be implemented and provided for both modes.

One more thing:

it is (or will it be) possible to subclass a data class?

Attend LR’s session…

Perhaps an acceptable compromise would be to install a project component in your binary host? The idea would be to publish (share) a project method that returns cs, or a class object (for a singleton object), or an instance of a class you define in the component.

I would expect that custom classes would work as long as object notation is enabled in the host. After all, some developers have been using components to “export” custom pseudo-classes using Storage and Formula in v18 LTS, although this new way is much better.

4 Likes