qcubed / common

common classes for all the QCubed framework - v4
MIT License
0 stars 5 forks source link

Discussion - QCubed in another language #7

Closed vaibhav-kaushal closed 5 years ago

vaibhav-kaushal commented 6 years ago

This issue is a continuation from here. The following was said by Spekary in the linked comment:


When I looked, Swift was Mac only, and did not have many 3rd party libaries that would be typical for PHP and web development. I like Go because of

  1. Large developer community
  2. Easy learning curve and some built-in structures and work-flow that make coding quick. Compile time is usually about a second after I make changes, so its easy to work with.
  3. Web services are a popular use for Golang. WebSockets are pretty easy, making multi-user live update possible.
  4. Built-in documentation system, that isn't all that powerful, but is functional enough and more importantly, easy to use, so it will get done.
  5. Strongly typed. Many errors get caught at compile time.
  6. Some tools developed at the core of Go for code generation, so generation is emerging as part of the ecosystem.
  7. The Jetbrains people created a nice IDE with source level debugging capabilities.
  8. Its compiled, and the runtime is very fast. You connect your web app direct to a tcp socket. Apache is not needed (though its possible to put Apache or something like it in front of the Go app if needed.)
  9. Garbage collection.
  10. Go App Services supports it in a low-cost mode.

That said, there are some limitations:

  1. Inheritance is difficult. Its possible, and I created a programming pattern to make virtual functions work, but this limitation makes true frameworks like QCubed a little awkward. Go only uses interfaces.
  2. Large frameworks are discouraged by the community. Go programmers like to use Go in microservices as the back end for mobile and web apps. The community frowns on large frameworks. I don't really care what the community thinks on this.
  3. No built-in serialization of objects, though there is library support for serializing objects. Currently I am just keeping formstate in memory. It isn't a big deal, I think a server can support about 1000 simultaneous users pretty easily this way. But if someone wants to distribute the app across multiple servers, then formstate will need to be serialized into a database. This is not too difficult, but I am going to wait until I am running a server that actually has that many users before I do the work.
  4. The Go developed template language is kind of limitted and not all that fast since the scripts are interpretted. I developed a template language and app that compiles the template into Go code, and allows you to switch into and out of Go code sort of like how PHP lets you. It is working fine.
  5. Go has a concept of exporting structures and functions, but not a permission system (like private, protected and public functions and objects). It also does not allow circular imports, where two namespaces use functions or structures from the other. This can create some frustration when architecting a project, as you have cross-purposes when you create a namespace. A single namespace is used for organizing code both logically and on disk, defining API interfaces, and organizing documentation. So, you cannot just create a namespace to provide some organization, as that also creates an API interface that cannot have circular references. I think this might be the biggest frustration I have with Go, 2nd only to the lack of built-in virtual function support.

What are your thoughts on Swift?

vaibhav-kaushal commented 6 years ago

Let me answer this the same way you did.

Pros

  1. The community is big, almost as big as that of Go and just as supportive. The number of forks/stars indicate Swift is just as popular. Considering Go was launched in 2009 and Swift in 2014, this is already an attractive point.
  2. Swift is not for Mac alone. It supports Linux (tested on Ubuntu LTS releases) and on Macs, so feasible for server-side applications.
  3. Swift too is compiled. So the performance is great. They are struggling with optimizing String data manipulation like C and I think in time they will fix this.
  4. Swift environment can take single files as scripts and run them in interpreter mode (more as reading the contents and running them through REPL).
  5. Of course, there is a REPL prompt. In addition, XCode supports playgrounds which are quick and easy way to write and visualize for quick and dirty tests (also helps early in learning).
  6. Swift is by Apple and is used for creating iOS and Mac apps - that is a huge advantage. It attracts more developers and there is a learning incentive that if you learn Swift, you know at least 30% of what Mac and iOS development would feel like. If you are already a Mac developer or iOS developer, reading server side code is easier. So the Traction is there.
  7. No pointers. I have seen even seasoned developers stay away from C/C++ (I myself am in that list) just to avoid the pointers. And it's a great thing for being memory safe.

Juxtaposed against Go

  1. Compiled like Go.
  2. Strongly typed but has the flexibility of having optionals in the data type. So if you want to go strict, performance increases. If you can sacrifice some cycles, you get flexibility.
  3. ARC - so no Grabage collection (in traditional, Java sense) needed.
  4. There are great projects written in Swift which make use of recently released NIO module and complement the WebSockets and in general Node like architecture over Swift.
  5. There are generation systems for Swift too. Just Google them. One of the best is Sourcery.
  6. For Mac, XCode is the IDE. If you are in Ubuntu, Jetbrains has a plugin for Swift that goes into CLion.
  7. If you launch a Vapor project, you too are launching just the Vapor server which can handle requests the way Go would, or NGinx would.
  8. The performance is not as high as Go. This is mainly because Go needs the VM to run and everything is managed by the runtime whereas Swift uses system calls. So it's a tad bit slower but catching up.
  9. Swift is inspired from Ruby and Python at large so it really, actually feels like them - with full Object Orientation and support for Protocol oriented Programming as well. I urge you to read this PDF.

Cons

The ones you mentioned about Go do not exist here and I have not practiced enough to encounter any, so far. The one thing I keep hearing is that they change the internal representations of the 'String' data type which makes some functions slower and some faster but they have been getting better at it and it does not cause bugs to prop-up.

It doesn't run on Windows can be counted as a Con but I mostly count that as a Plus, actually. They are not avert to Windows but the lower-level stuff is all built on UNIX-like calls so Windows goes out of question for obvious reasons. While the developer team says if someone does it, they would welcome it, but it is not on their minds. It's like how C# does not get love from Microsoft for Linux. Mono was created by someone else, outside of Microsoft.

kukrik commented 6 years ago

Good friends @spekary and @vaibhav-kaushal!

I ask the question that whether QCubed is lagging behind? Do we have to abandon QCubed 4v, because there is a fear that it will not develop more?

Maybe there's an alternative to doing two branches of GO and Swift on QCubed. But leave QCubed 4v calm and develop it further. We'll see which one is more viable. That would be Solomon's compromise???

spekary commented 6 years ago

No, not abandoned. Its maturing at this point. Php is an excellent language for small projects, for new programmers, for people who want to work in an environment that is easy to script, and for quick prototyping.

Go is great for a project that demands high performance, or has multiple people working on the same data. It is not quite as natural of a fit as PHP because of some of the quirks of Go, but the performance gains on a larger project outweigh some of the pain I think. It really is significantly faster, but you would only really notice if you had many people simultaneously using a machine.

Swift looks interesting, but it doesn't have a Windows toolset, and the Linux side is pretty new and just emerging now. Its a more cumbersome language to learn, but is very expressive. Speed tests show its very fast, not quite as fast as Go, but close enough that most people will not care. The open source community appears much smaller than Go's to me, but the Vapor framework shows promise, and has some similarities to QCubed, like a code generated ORM. However, for the most part, the tooling is limitted to XCode, or a Linux editor plus command-line tools, so its hard to tell what the development process is like. Online, some say its great, and others found a lot of pain once a project got around 70K lines.

But QCubed will be the more mature for quite some time. I have a project right now that is data intensive, but really only a handful of users, so PHP is a great fit for that. Another project I am working on might grow to 1000 users simultaneously, so GO is a much better fit for that. It all depends on the goals of the project.

vaibhav-kaushal commented 6 years ago

I think QCubed should go on. I think QCubed is good. Except that we are not focussing on web 3.0 - the rise of front-end framework where all software including web pages fetch data from the server using APIs. Apart from that, QCubed is good.

Of course we have to do development for QCubed but I too think that we should recreate the framework in one of the rising languages. I choose Swift for its clear Object Orientation and rather supportive community. Fact is - those languages me and @spekary were talking about - Swift and Go do not need yet another framework. Frameworks are hard to build and difficult to maintain. Having written a large part of documentation of QCubed myself, I can say that maintaining documentation and keeping it up to date is also a great challenge in itself.

I am inclining more towards writing a QCubed-style generator for Vapor. Because:

  1. I am used QCubed style ORM, form control/validations.
  2. I think Vapor is a nice framework already.
  3. Vapor is a swift-only framework. So I don't need to worry about a lot of underlying stack which is the case with Kitura and Perfect.
  4. I think Swift is an easier one to use and develop around. I find Go's semantics over inheritance very confusing and I guess most others will find it too.

For that matter, I think I am moving with Vapor but to rewrite a Swift based framework is not on my mind.

spekary commented 6 years ago

Go's inheritance stuff is actual very simple. Maybe too simple. It doesn't really have inheritance, but composition. But I have found a pattern that lets you program just like inheritance, so its surmontable. Look at my "goradd" project.

I will try to take some time over the next month to learn some Swift and evaluate it.

There may still be some code sharing possible. The qcubed.js file might be usable by multiple branches.

Regarding Web 3.0. I am not convinced. Web 3.0 is largeley a programming style designed for large scalable deployments. To do it using frameworks like React, you have to have a very good idea of what you want before you start. Change management is difficult.

QCubed is more for medium to smaller sites, where you need to quickly create a website then manage its change over time.

matthiaz commented 5 years ago

So we agree that Go and Swift have their purpose but that this is not for QCubed. QCubed remains PHP. Close ticket?