Choosing right programming language
#1
Few month ago started learning web programming, but now I am stuck with making decision. Currently I know 2 programming languages, PHP and Python, I am able to write Backend script in both language, but I am using frameworks, Laravel and Django. In the nearest future I have to  start a large project, and I don't know what to do, I have some time for learning new language too if it's not too difficult. In new project most important is Speed and Security, help me choose.

1) Continue learning PHP and start writing project without using Laravel Framework.
2) Write whole project in Laravel
3) Write whole project in Django
4) Learn other programming language like Ruby or Go

I really like Go, It's too fast, but also complex, I am scraping API's in almost all my web applications, and in Go, I have to use Structs for this, and I find it difficult, but it seems to be best for me.

Also second question, what will be better, write separate applications for Backend and Forntend and use API's or write single app.
Need your opinion.
#2
Choosing a language and framework really depends on the kind of project you’re trying to make.
A “large” project doesn’t provide any clue.
If you could provide more info, it could help in drawing a conclusion.

As for your second question, IMHO making it separate would be better in the long run.
But it also adds a maintenance burden so it really depends on the user.
#3
There will be 3 types of user, normal users, companies and reviewers, normal users can upload post, after reviwers will review, correct and publish it, comapies will rate published posts, something like this. I know, I can write script like this in any programming language, but it will have huge amount of users, all 3 type of customers will have separate control panels.

I am asking this question not only for this project, in general what should I learn 'to be good backend developer'. Improve my knowlidge in PHP or Python or learn other programming languages.
Thanks for reply
#4
I was also going to recommend Go. Because I'm a performance phreak, and since Go compiles down to native code. That would make me very happy. And yes, I honestly understand you. And it's not that the language is complicated. Because it isn't. It's just that it has some nasty quirks and constraints that make it hard to get used to. And because of that I find it hard to learn and experience it.

I'm actually trying to wrap my head around it for months now. I've left it alone for a while then got back to it and every time I find myself leaving it with a bad taste in my mouth because I like the idea behind the language but I don't like several choices made for it.

I guess that what keeps me from getting used to it is that I hate using third party libraries (is there a phobia for this? Cheese). And I have to write everything framework and/or library from scratch. Which puts a dent in my time with the language.

And to be a little on the topic. About using PHP. Man, that language is so dead. People only use it nowadays because a ton of applications are written in it and because it's easy to get used to it. But the language itself doesn't feel right for our current times anymore. Especially since everything is moving towards a REST architecture.

As for Python. All that indentation and weirdness never appealed to me. But as usual, being such an old language and having such a plethora of libraries make it quite competitive on the list of languages to have in your repertoire. And Ruby? Not a chance. Never used that language and probably never will.

If you can't figure out what you need then use a scoring system to help you pick what's best for you. Do you wan't speed? Then Go gives you that but neither of the other mentioned languages. Do you want security? Then all the mentioned languages give you that. So that make +2 for Go and +1 for all the other languages. And you can proceed like this with the remaining requirements.
#5
(2018-04-22, 9:28:04 pm)SLC Wrote:  I was also going to recommend Go. Because I'm a performance phreak, and since Go compiles down to native code. That would make me very happy. And yes, I honestly understand you. And it's not that the language is complicated. Because it isn't. It's just that it has some nasty quirks and constraints that make it hard to get used to. And because of that I find it hard to learn and experience it.

I'm actually trying to wrap my head around it for months now. I've left it alone for a while then got back to it and every time I find myself leaving it with a bad taste in my mouth because I like the idea behind the language but I don't like several choices made for it.

I guess that what keeps me from getting used to it is that I hate using third party libraries (is there a phobia for this? Cheese). And I have to write everything framework and/or library from scratch. Which puts a dent in my time with the language.

Yeah, that's the reason why I don't want to use PHP or Python, but it will be hard as hell and take too much time to learn and write complete CMS with pure go, I think I will start using Iris framework at this stage. What do you think, how long will it take to get used to Iris ?
I know golang basics only

I spent 2 days learning Django and in 2 days I have re-written my web from Laraven to Django, also wrote new ticket sale app with django. But golang took me 1 week to write very simple app. lol
#6
Honestly, Go is made to be used in conjunction with JS frameworks like Vue.js and UI frameworks like Vuetify. Because you don't and actually shouldn't render anything on the server. That would be dumb and no different than PHP. Your back-end should be designed with REST in mind and simply take commands from the front-end on what to do. And all communication is basically done with JSON serialization. Since JSON is supported by Go natively. This way, you move all the unnecessary logic on the client side and reduce the load on your server.

So it should actually be easier to develop because you can separate your front-end from the back-end and help you get rid of the nasty template syntax. You can basically think of it like this. Do I want to get started easy or do I want to continue to work easy? Because Go will be hard to get started with but easy to continue with once you get the grasp on it. Whereas PHP and the others will give you an easy start but you'll experience hell when you application grows. Take myBB for example and the amount of redesigns and re-writes they had to make because it got a little popular.

Do you know what's sad about languages like PHP? The fact that they're interpreted. So you can actually write some code in file and until you run that code under the right conditions you never know you could have a bug in there. Even a simple bug like a wrong name. Could explode in production ad give you hell. Whereas with Go, everything has to be good at compile time. If it doesn't fail at compile time then it'll be hard to occur at run-time. That's why I'm only using compiled languages that are statically typed. Much harder to mess up in there.

To me, the Go syntax is quite easy. In fact, coming from C++, it feels like a children toy. But because it feels like a children toy, it has some things that don't appeal to me anymore and have a hard time to grasp them since I've outgrown them. So I kinda have to go back a little to get used to it. But like I said, the syntax is easy. It just has a few disappointing quirks and constraints that could be overlooked once you get used to it.

Your choice, take the pros and cons. Weigh them and use the results to make a pick. No one else can make this choice for you. Normally I would've roasted you for asking this question. Wouldn't be the first time. Because this question is not something that can be answered by someone else other than you. What others can do in this case is tell you their opinions or experiences. But you still have to make the choice yourself in the end.
#7
I have 2 month before we start working on our project, let's see if I learn enough to start with Go, thanks for your help.
If not, I will write this project in Laravel and then re-write it in Go.

One more question, If I have API, which contains too much data(fields) and I want only 2 of them, in stucts, I should define it's whole structure and use 2, or defining only this 2 field will be enough ?
#8
(2018-04-22, 10:40:30 pm)Nevermind23 Wrote:  One more question, If I have API, which contains too much data(fields) and I want only 2 of them, in stucts, I should define it's whole structure and use 2, or defining only this 2 field will be enough ?

I'm a bit confused by that question. I don't think I fully understand what you mean. But I believe the the solution to what I think you're having problems with is inheritance. More specifically, Go's struct embedding feature. Basically, you split your fields into different structs and then combine/embed them as you see fit.

PHP Code:
package main

import 
(
    
"fmt"
)

type Ident struct {
    
FirstName string
    LastName string
}

type Contact struct {
    
Email string
    Phone string
}

type Location struct {
    
Country string
    City string
}

type Profile struct {
    
Ident
    Contact
    Location
}

func main() {
    
up := Profile{Ident{"Jon""Doe"}, Contact{"no.email@to.me""01001101110002"}, Location{"Distopia""Bamboocha"}}
    
fmt.Println(up)

Code:
{{Jon Doe} {no.email@to.me 01001101110002} {Distopia Bamboocha}}

try.
#9
This is my struct:
Code:
type Post struct {
    Id int `json:"post_id"`
    Title string `json:"post_title"`
}

type Data struct {
    Post `json:"data"`
}
And this is API response:

Code:
{"data":[{"post_id":1,"post_title":"Title","post_description":"Description","post_views":"1000"},{"post_id":2,"post_title":"Title 2","post_description":"Description 2","post_views":"1002"}]}

Will this work, if I haven't post_description and post_views in struct ?
Hope you understand
#10
Oh, do you mean to deserialize that JSON text into a Data object and that only implements a subset of the things available in the JSON text and discard/ignore the rest? Because that should work (theoretically):

PHP Code:
package main

import 
(
    
"fmt"
    "encoding/json"
)

type Post struct {
 
   Id int `json:"post_id"`
 
   Title string `json:"post_title"`
}

type Data struct {
 
   Posts [] Post `json:"posts"`
}

func main() {
    
j:= []byte(`{
        "posts":
        [
            {
                "post_id":1,
                "post_title":"Title",
                "post_description":"Description",
                "post_views":"1000"
            },
            {
                "post_id":2,
                "post_title":"Title 2",
                "post_description":"Description 2",
                "post_views":"1002"
            }
        ]
    }
`)
    
:= Data{}
    
err := json.Unmarshal(j, &d)
    if 
err != nil {
 
           fmt.Println("error:"err)
    }
    
fmt.Println(len(d.Posts))
    
fmt.Println(d)


The problem was that you specified `Post `json:"data"` to be an embedded struct that should also be serializable to JSON. I'm not even sure that makes sense. But then you had an array of Posts in the JSON text. Once you change the Data structure to contain an array(slice in go) of Posts, everything works as usual. Assuming this is what you intended. (try)

Anyway, I'm starting to get off-topic so I'll end this here.




Users browsing this thread: 1 Guest(s)