[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Thought experiment: what would you remove from Lua
- From: Sean Conner <sean@...>
- Date: Mon, 17 Sep 2018 16:57:08 -0400
It was thus said that the Great Petri Häkkinen once stated:
>
> > On 7 Sep 2018, at 23.41, Sean Conner <sean@conman.org> wrote:
> >
> > It was thus said that the Great Petri Häkkinen once stated:
> >>
> >> I would remove ’:’ and ’self’. I never use them in my code and they
> >> support bad habits.
> >
> > What bad habbits? The excessive use of OOP?
>
> I’m talking about OOP in general. Every OO codebase I’ve worked with has
> been an overdesigned, hard to maintain mess. In my opinion, the invention
> of OOP was a misstep, leading to analysis paralysis (so many ways to model
> the program as classes) and poor performance (caused by too much emphasis
> on abstractions and code reuse rather than efficient data flow — see Data
> Oriented Design).
>
> Luckily more and more programmers are beginning to realize this (including
> pretty much all experienced programmers I personally know).
While I agree with that (yes, I'm not a fan of OOP myself) I do find the
':' notation worthwile as a form of scope for functions (mostly with
userdata). I find:
config = tls.config()
config:protocols("all")
config:verify_client(true)
config:ca_file("trust_these")
config:cert_file("my_cert")
server = tls.server()
server:configure(config)
connection = server:accept_socket(s)
nicer than:
config = tls.config()
tls.config_protocols(config,"all")
tls.config_verify_client(config,true)
tls.config_ca_file(config,"trust_these")
tls.config_cert_file(config,"my_cert")
server = tls.server()
tls.configure(server,config)
connection = tls.accept_socket(server)
As it stands, my top level tls module [1] only has five functions instead
of some 80 functions---the configuration functions are only available to the
config "object" (for lack of a better term); the context functions are only
available to the "context" (or in this case, "server") object. It's a form
of organization.
-spc
[1] https://github.com/spc476/lua-conmanorg/blob/master/src/tls.c
Rockspec coming soon ...