|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Yeah, but it shows that timestamp fields are super slow to parse for some reason. Unless it changed but I couldn't really find any more recent studies on the subject.
As a sidenote, do you guys also hate encountering stuff like that in the code? (turned example into pseudocode for readability)
i = j = 0; results = []; num1 = count(arr1); num2 = count(arr2); target_number = num1 + num2;
for (k = 0, k < target_number, k++) { if (i >= num1) { append arr2[j] to results;
j++; } elseif (j > num2) { append arr1[i] to results;
i++; } elseif (arr1[i] > arr2[j]) { append arr1[i] to results;
i++; } else { append arr2[j] to results;
j++; } }
I cringe every time
|
On July 21 2015 01:13 Manit0u wrote:Yeah, but it shows that timestamp fields are super slow to parse for some reason. Unless it changed but I couldn't really find any more recent studies on the subject. As a sidenote, do you guys also hate encountering stuff like that in the code? (turned example into pseudocode for readability) i = j = 0; results = []; num1 = count(arr1); num2 = count(arr2); target_number = num1 + num2;
for (k = 0, k < target_number, k++) { if (i >= num1) { append arr2[j] to results;
j++; } elseif (j > num2) { append arr1[i] to results;
i++; } elseif (arr1[i] > arr2[j]) { append arr1[i] to results;
i++; } else { append arr2[j] to results;
j++; } }
I cringe every time 
At the risk of sounding stupid, I hope you are cringing at the terrible variable names, and the use of an unnecessary counter variable k in order to use a for-loop instead of doing that in a, far more intuitive, while loop? Other than that, I don't see too much wrong with that code. Sure, the first two if statements can be made more efficient and break out of the loop immediately, but it's not a big deal and I see worse stuff than that minor inefficiency (if it even is inefficient: depends on your language) every day.
|
It's not really about efficiency. It's about readability. If I'm browsing code I'd like to understand what it does just by skimming over it most of the time. When I have to pause and start to scratch my head trying to figure out when and how 3 different single-letter incrementation variables in a single loop are set, what they do and if this can potentially break things (since you're working with array indices) it's not that great. Notice that in the example above the code does exactly the same thing for two different elseif blocks. If and else blocks also produce the same code. Why is that? Obviously the person who coded it had a good reason to introduce another block instead of simply adding an OR check in the previous one, but there's no comment and nothing in the code itself to indicate why it's so special. It's lazy.
|
On July 21 2015 01:13 Manit0u wrote:Yeah, but it shows that timestamp fields are super slow to parse for some reason. Unless it changed but I couldn't really find any more recent studies on the subject. As a sidenote, do you guys also hate encountering stuff like that in the code? (turned example into pseudocode for readability) i = j = 0; results = []; num1 = count(arr1); num2 = count(arr2); target_number = num1 + num2;
for (k = 0, k < target_number, k++) { if (i >= num1) { append arr2[j] to results;
j++; } elseif (j > num2) { append arr1[i] to results;
i++; } elseif (arr1[i] > arr2[j]) { append arr1[i] to results;
i++; } else { append arr2[j] to results;
j++; } }
I cringe every time 
It really seems pretty fine to me. Took maybe 30 seconds of code reading to understand what it's trying to do, and the variable names are about as expressive as you get with such a generic algorithm. Am I missing something? I'm assuming that the translation to psuedocode has lost some of the impact from what PHP or Java could have made this to look like.
|
I admit that turning it into pseudocode makes it much easier to read, especially that you don't have some long method chains in there that do basically what I've written out here in the end (not to mention misleading variable names apart from i,j,k).
|
On July 21 2015 07:25 Manit0u wrote: It's not really about efficiency. It's about readability. If I'm browsing code I'd like to understand what it does just by skimming over it most of the time. When I have to pause and start to scratch my head trying to figure out when and how 3 different single-letter incrementation variables in a single loop are set, what they do and if this can potentially break things (since you're working with array indices) it's not that great. Notice that in the example above the code does exactly the same thing for two different elseif blocks. If and else blocks also produce the same code. Why is that? Obviously the person who coded it had a good reason to introduce another block instead of simply adding an OR check in the previous one, but there's no comment and nothing in the code itself to indicate why it's so special. It's lazy. Yeah, that´s what I thought. With more intuitive variable names, and the use of a more intuitive while loop instead of a for loop:
while i + j < totalSize { doStuff() }
That code would be completely fine. Especially if you found it in its own method called mergeSortedArrays(arr1, arr2) or something else intuitive like that. If that code was tucked in the middle of some other bigger method without any comment, it could cause some headscratching.
|
Hi TL,
Suppose I want to make a website - say it's sort of like Google in the sense that it has the following components:
1. A front page that has a textbox; the user can enter some stuff which returns and displays some results from my database. 2. A backend which collects information for my database
But I have no knowledge of web development whatsoever (I do know how to code and use SQL, however). What would you suggest I look into to learn?
|
On July 22 2015 05:37 Sufficiency wrote: Hi TL,
Suppose I want to make a website - say it's sort of like Google in the sense that it has the following components:
1. A front page that has a textbox; the user can enter some stuff which returns and displays some results from my database. 2. A backend which collects information for my database
But I have no knowledge of web development whatsoever (I do know how to code and use SQL, however). What would you suggest I look into to learn? Despite my hatred for PHP and my intense desire to recommend neat solutions like Ruby on Rails, I think you should just pick up any old tutorial on Linux-Apache-MySQL-PHP (LAMP) and go from there.
|
On July 22 2015 05:37 Sufficiency wrote: Hi TL,
Suppose I want to make a website - say it's sort of like Google in the sense that it has the following components:
1. A front page that has a textbox; the user can enter some stuff which returns and displays some results from my database. 2. A backend which collects information for my database
But I have no knowledge of web development whatsoever (I do know how to code and use SQL, however). What would you suggest I look into to learn?
So, all you want is an input field on your page linked to a back-end algorithm that fetches data from the database?
On July 22 2015 06:06 Acrofales wrote: Despite my hatred for PHP and my intense desire to recommend neat solutions like Ruby on Rails, I think you should just pick up any old tutorial on Linux-Apache-MySQL-PHP (LAMP) and go from there.
While such a solution would indeed be the simplest, I think that for this endavour Angular would be much more elegant while still being rather simple (since you only have one view and don't have to worry about a gazillion things usually involved in websites like user management and such) - despite my hatred for JS in the back-end.
|
I should add that instead of the "simplest" solution, I am also very much open to learning something that is "popular" or "cutting-edge", if you know what I mean. Java(script) or Python are highly preferred.
On July 22 2015 06:06 Manit0u wrote:Show nested quote +On July 22 2015 05:37 Sufficiency wrote: Hi TL,
Suppose I want to make a website - say it's sort of like Google in the sense that it has the following components:
1. A front page that has a textbox; the user can enter some stuff which returns and displays some results from my database. 2. A backend which collects information for my database
But I have no knowledge of web development whatsoever (I do know how to code and use SQL, however). What would you suggest I look into to learn? So, all you want is an input field on your page linked to a back-end algorithm that fetches data from the database? Show nested quote +On July 22 2015 06:06 Acrofales wrote: Despite my hatred for PHP and my intense desire to recommend neat solutions like Ruby on Rails, I think you should just pick up any old tutorial on Linux-Apache-MySQL-PHP (LAMP) and go from there. While such a solution would indeed be the simplest, I think that for this endavour Angular would be much more elegant while still being rather simple (since you only have one view and don't have to worry about a gazillion things usually involved in websites like user management and such) - despite my hatred for JS in the back-end.
Yes, in the simplest term "input field on your page linked to a back-end algorithm that fetches data from the database" what I am leading towards right now. This by itself is already a highly ambitious project.
|
On July 22 2015 06:28 Sufficiency wrote:I should add that instead of the "simplest" solution, I am also very much open to learning something that is "popular" or "cutting-edge", if you know what I mean. Java(script) or Python are highly preferred. Show nested quote +On July 22 2015 06:06 Manit0u wrote:On July 22 2015 05:37 Sufficiency wrote: Hi TL,
Suppose I want to make a website - say it's sort of like Google in the sense that it has the following components:
1. A front page that has a textbox; the user can enter some stuff which returns and displays some results from my database. 2. A backend which collects information for my database
But I have no knowledge of web development whatsoever (I do know how to code and use SQL, however). What would you suggest I look into to learn? So, all you want is an input field on your page linked to a back-end algorithm that fetches data from the database? On July 22 2015 06:06 Acrofales wrote: Despite my hatred for PHP and my intense desire to recommend neat solutions like Ruby on Rails, I think you should just pick up any old tutorial on Linux-Apache-MySQL-PHP (LAMP) and go from there. While such a solution would indeed be the simplest, I think that for this endavour Angular would be much more elegant while still being rather simple (since you only have one view and don't have to worry about a gazillion things usually involved in websites like user management and such) - despite my hatred for JS in the back-end. Yes, in the simplest term "input field on your page linked to a back-end algorithm that fetches data from the database" what I am leading towards right now. This by itself is already a highly ambitious project.
LAMP for popularity and overall availability of tools/materials to learn. You could theoretically finish a tutorial teaching you how to build LAMP in a couple of hours and have the site you're after.
Python+Django (Django is a library that works as a webserver) if you are comfortable in python, Django isn't a big leap, and is pretty fun. There are some accessible tutorials out there that would have a site like yours ready to go at the completion of it. It is heavily used for page templates.
Ruby on Rails is about as accessible as Django, and a lot of people love it so it has a flourishing ecosystem. Much like python, simply importing the right gem can add a new feature to your webserver. Programming in Ruby feels like Magic in that sense.
Javascript (probably Node.js in your case) also has webservers written in it that could do what you want. If you already have a good handle on Javascript, I'd go with this, otherwise I feel LAMP/Django/RoR have a better ecosystem around them.
|
Thank you all for your responses. I think I'll try Django first and see how that goes (I learned Python recently and I am itchy to use more Python). If it's not to my liking I'll go around and try the ones that uses Javascripts. I think I'll probably steer clear of LAMP for now unless I find the other options insufficient or hard to use.
|
On July 22 2015 07:59 Sufficiency wrote: Thank you all for your responses. I think I'll try Django first and see how that goes (I learned Python recently and I am itchy to use more Python). If it's not to my liking I'll go around and try the ones that uses Javascripts. I think I'll probably steer clear of LAMP for now unless I find the other options insufficient or hard to use.
Probably the way to go. https://docs.djangoproject.com/en/1.8/intro/tutorial01/ will get you started
|
Django seems quite a heavyhanded approach if all you want from it is a webserver and a little bit of a front-end/back-end distinction. Flask will do that just fine.
Not saying that Django isn't great, but it has lots of stuff that just doesn't seem necessary for the application in mind: don't need user management or all its ORM stuff, don't even really need the fancy template language (Flask has its own little template engine).
Here's some people doing the comparison: http://www.quora.com/Should-I-learn-Flask-or-Django
TLDR: Flask is tiny and easy. Django is big and has lots of bells and whistles. If you don't plan on using the bells and whistles, just use Flask.
|
Hmm OK. Flask -> Django -> *.js in that order. Thanks for the suggestion!
|
In case all else fails and for some reason you'd have to go back to LAMP, please use mini (mini2 preferably). At least you'll be using some good practices.
|
On July 22 2015 09:34 Manit0u wrote:In case all else fails and for some reason you'd have to go back to LAMP, please use mini (mini2 preferably). At least you'll be using some good practices.
This is pretty cool. I've started to like MVC after learning Symfony, but it's a bit much for a smaller site I'm trying to build. Might have to give Mini a try.
|
So far so good....!
![[image loading]](http://i.imgur.com/jcV7jqb.png)
I think I'll do a bit more Flask for now.
|
On July 22 2015 14:53 Sufficiency wrote:So far so good....! ![[image loading]](http://i.imgur.com/jcV7jqb.png) I think I'll do a bit more Flask for now.
Will your app be called HAL by any means?
|
On July 22 2015 07:50 RoyGBiv_13 wrote:Show nested quote +On July 22 2015 06:28 Sufficiency wrote:I should add that instead of the "simplest" solution, I am also very much open to learning something that is "popular" or "cutting-edge", if you know what I mean. Java(script) or Python are highly preferred. On July 22 2015 06:06 Manit0u wrote:On July 22 2015 05:37 Sufficiency wrote: Hi TL,
Suppose I want to make a website - say it's sort of like Google in the sense that it has the following components:
1. A front page that has a textbox; the user can enter some stuff which returns and displays some results from my database. 2. A backend which collects information for my database
But I have no knowledge of web development whatsoever (I do know how to code and use SQL, however). What would you suggest I look into to learn? So, all you want is an input field on your page linked to a back-end algorithm that fetches data from the database? On July 22 2015 06:06 Acrofales wrote: Despite my hatred for PHP and my intense desire to recommend neat solutions like Ruby on Rails, I think you should just pick up any old tutorial on Linux-Apache-MySQL-PHP (LAMP) and go from there. While such a solution would indeed be the simplest, I think that for this endavour Angular would be much more elegant while still being rather simple (since you only have one view and don't have to worry about a gazillion things usually involved in websites like user management and such) - despite my hatred for JS in the back-end. Yes, in the simplest term "input field on your page linked to a back-end algorithm that fetches data from the database" what I am leading towards right now. This by itself is already a highly ambitious project. LAMP for popularity and overall availability of tools/materials to learn. You could theoretically finish a tutorial teaching you how to build LAMP in a couple of hours and have the site you're after. Python+Django (Django is a library that works as a webserver) if you are comfortable in python, Django isn't a big leap, and is pretty fun. There are some accessible tutorials out there that would have a site like yours ready to go at the completion of it. It is heavily used for page templates. Ruby on Rails is about as accessible as Django, and a lot of people love it so it has a flourishing ecosystem. Much like python, simply importing the right gem can add a new feature to your webserver. Programming in Ruby feels like Magic in that sense. Javascript (probably Node.js in your case) also has webservers written in it that could do what you want. If you already have a good handle on Javascript, I'd go with this, otherwise I feel LAMP/Django/RoR have a better ecosystem around them. No love for asp .net?
|
|
|
|