• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Drkirby

Corporate Apologist
I need a bit of help, how do I go about passing a variable about of information from a web form to a PHP script?

Basically, I want to make one page that you can click a button to keep adding more input fields, and then pass them all to a PHP script to log them into a MySQL database.
 

Slavik81

Member
Looking to start a holy war here:

I'm going to make a backend that serves clients on mobile and maybe through a web browser. Clients will be able to post a picture and some text. Clients can also view other peoples posts in the nearby area. So similar to craigslist.

SQL or NoSQL?
Given those requirements, I'm not sure it matters. You'd probably be fine regardless of which you chose.
 
Looking to start a holy war here:

I'm going to make a backend that serves clients on mobile and maybe through a web browser. Clients will be able to post a picture and some text. Clients can also view other peoples posts in the nearby area. So similar to craigslist.

SQL or NoSQL?

I'm far from an expert on databases, so take the following with a grain of salt: NoSQL databases have a couple of use cases like when the data you need to save changes very often (document databases, like MongoDB) or when consistency is less important than performance and scaling. For the vast majority of cases I'd recommend SQL. Especially since many modern SQL databases have incorporated features from NoSQL databases (for example, PostgreSQL can store JSON documents and process them) This page describes my viewpoint fairly well (it seems to be somewhat biased, but I personally feel that NoSQL databases are pretty overhyped as well)
 
I need a bit of help, how do I go about passing a variable about of information from a web form to a PHP script?

Basically, I want to make one page that you can click a button to keep adding more input fields, and then pass them all to a PHP script to log them into a MySQL database.

If you dynamically add form elements to the page as the button is clicked I believe a standard form on submit will just package them all up and send them the same as normal. Just settle on a naming convention for the new fields and it should be the exact same process as any form submission. Or did you have a more specific question?
 

FinalD

Member
If you dynamically add form elements to the page as the button is clicked I believe a standard form on submit will just package them all up and send them the same as normal. Just settle on a naming convention for the new fields and it should be the exact same process as any form submission. Or did you have a more specific question?

And if you don't want to create unique names for every added element, you can pass them as an array by ending the name with square brackets.
Code:
<input name="theinput[]" value="1">
<input name="theinput[]" value="2">
<input name="theinput[]" value="3">
$_POST['theinput']:
Code:
array (size=3)
  0 => string '1' (length=1)
  1 => string '2' (length=1)
  2 => string '3' (length=1)
 

CryptiK

Member
Just started Computer Science w/ Mobile Computing as a Major this week. Kind of freaking out since I'm terrible at mathematics but Programming interests me and the only thing that I want to do in the future. So yay hopefully it goes well.
 

oxrock

Gravity is a myth, the Earth SUCKS!
Just started Computer Science w/ Mobile Computing as a Major this week. Kind of freaking out since I'm terrible at mathematics but Programming interests me and the only thing that I want to do in the future. So yay hopefully it goes well.

Rejoice! You can program without any complicated maths! Sadly it's tremendously helpful for efficiency. That won't be an issue while starting off luckily and if you want to to continue down the programming path you can pick up skills as you go.
 
For free, I can't imagine it's too bad. Linux is a little weird since to learn it you really need to use it. Otherwise it just won't stick in your head.

Where are the log files again?
Wait, what do I put after 'dpkg' to install a .deb file?
Why won't my mouse scroll faster?

Yeah, there's a lot to learn, but it's fun.

I'm still wondering why it's so complicated to change mouse scroll speed.
 

Tamanon

Banned
Where are the log files again?
Wait, what do I put after 'dpkg' to install a .deb file?
Why won't my mouse scroll faster?

Yeah, there's a lot to learn, but it's fun.

I'm still wondering why it's so complicated to change mouse scroll speed.

Because they don't want you to use a mouse.:p
 

amrod

Member
You don't have to pay for it, you can work through it at your own pace and submit/test your answers through their website. Paying I think gives you a certificate upon completion and allows you to post on the forum. I think that's the deal anyway. Nothing wrong with supporting a good site however, there's some good stuff.

I wish for the life of me that I could find something similar for C#

For free courses...

http://www.microsoftvirtualacademy.com/training-courses/c-fundamentals-for-absolute-beginners

for unity how about

http://walkerboystudio.com/html/unity_training___free__.html ?

I am doing pay on Lynda.com & Pluralsight.com (includes www.digitaltutors.com) and am happy with the quality of the courses offered
 
D

Deleted member 30609

Unconfirmed Member
Just started Computer Science w/ Mobile Computing as a Major this week. Kind of freaking out since I'm terrible at mathematics but Programming interests me and the only thing that I want to do in the future. So yay hopefully it goes well.
You live in Melbourne, right? At Monash, the math units aren't too bad. There's a math centre open for help during business hours, open to everyone, every business day.

I assume other unis have similar programs. Go to tutorials and get to know your tutors. Email them or, even better, go to consultation hours if there's something you don't understand. The math needed for this sort of thing isn't insurmountable. Good luck! :)
 

CryptiK

Member
You live in Melbourne, right? At Monash, the math units aren't too bad. There's a math centre open for help during business hours, open to everyone, every business day.

I assume other unis have similar programs. Go to tutorials and get to know your tutors. Email them or, even better, go to consultation hours if there's something you don't understand. The math needed for this sort of thing isn't insurmountable. Good luck! :)
Nah NSW at UoW.

The math based subjects:

Algorithms & Problem Solving
Discrete Mathematics
Understanding Variation & Uncertainty
Algorithms and Data Structures

Logic part of DisMath seems easy enough Numbers though ugh.
 

Drkirby

Corporate Apologist
Ok, I somewhat doubt you guys have an answer, but I'll shot any way.

I need to compute some basic statistic from a MySQL table every day. The table it is pulling data from has 280 Million Rows (And counting!).

The table has 5 columns. The itemType, a Unique Item ID Number, the Owner, a Quality, and a 'equiped bool. (ItemType has an Index, and the ItemID is the Primary Key). 3 of them are used in the calculation of the statistics, ItemID, Quality, and Equiped.

What is done every day is simply count up all the items, and group them in the format of ItemType, Quality, Total Owned, Number Equipped. This operation takes roughly 4 hours, and is done with the call "create table ItemInfo select itemType, itemQuality, count(*) as 'Owned', sum(equiped) as 'equiped' from `itemlist` use index (`itemType`) group by itemType, itemQuality".

Can you guys think of a way to make this take less time?
 

Tamanon

Banned
The only way I can think of it, is if you had a total already set somewhere, and then changed the total whenever a transaction was made. You would add a minute amount of time to each transaction though, and depending on how it was done, might be a lot of work to implement. I'm not good with SQL yet, but if you keep transaction logs, you can just parse those instead of the whole database.

Basically instead of counting everyday, you have the previous day's count, so you can use the transactions to adjust it.
 

Drkirby

Corporate Apologist
I thought of that once, but not sure it would be a great idea, since the system isn't simply accumulative. The state of the equipped and quality values can change over time for the same ID, and I would think it could significantly increase the insertion time.
 

mltplkxr

Member
This is a really old post, but that link was super helpful. I got sidetracked by a summer course I was taking.

I finished recreating Minesweeper in Java. Works almost (doesn't keep a record of your fastest time, doesn't let you make custom game boards, but it does have the main 3 difficulty settings and has a timer for the game in progress) exactly the same as the real one, just looks a little different since I'm using JButtons.

It's a pretty small project but at my level this felt like a big accomplishment.

Thanks and congrats!
 

oxrock

Gravity is a myth, the Earth SUCKS!
Lately I've been focusing on developing my game again. Some people here expressed a desire to be kept updated and I don't mind embarrassing myself in front of an audience. The game was previously known as "Deadly Dungeoneers" but the other day on a whim I decided it should be called "Champion Summons" instead. It's written in python 2.7.8 with pygame as the engine. I have it capped @ 60fps which it hardly dips under despite not making any optimizations yet, so I'm happy there. I wish I could focus more on the coding, it's quite amazing how much time I can waste on my artwork despite it being SOOO bad. Anyway, please take a look guys. There's far more to be done, lots of levels and mechanics yet to be implemented, but it's looking a lot better than it was.

 

maeh2k

Member
Ok, I somewhat doubt you guys have an answer, but I'll shot any way.

I need to compute some basic statistic from a MySQL table every day. The table it is pulling data from has 280 Million Rows (And counting!).

The table has 5 columns. The itemType, a Unique Item ID Number, the Owner, a Quality, and a 'equiped bool. (ItemType has an Index, and the ItemID is the Primary Key). 3 of them are used in the calculation of the statistics, ItemID, Quality, and Equiped.

What is done every day is simply count up all the items, and group them in the format of ItemType, Quality, Total Owned, Number Equipped. This operation takes roughly 4 hours, and is done with the call "create table ItemInfo select itemType, itemQuality, count(*) as 'Owned', sum(equiped) as 'equiped' from `itemlist` use index (`itemType`) group by itemType, itemQuality".

Can you guys think of a way to make this take less time?

I doubt there's a really easy way. Since you just have one table and don't do any joins, I don't think indexes make any difference. Databases are heavily optimized and I suppose they already handle this query very well.
Maybe you could get the query execution plan from your database and see what exactly it does with your query. If there's any weird stuff there may be ways to optimize it. But it'll still go over 280 million rows. That takes time.

Maybe you could look into how your database is set up for parallel processing. I figure it parallelized that query on its own, but it would still be interesting to know how exactly it uses its resources. The query itself seems ideally suited for parallel computation.

Otherwise, you might have to think of alternative ways to compute the result like Tamanon suggested. Either keep tabs on your statistics in real time or just track the changes day-to-day and update the statistics based only on what's changed.
 

Bollocks

Member
I like Cormen's Introduction to Algorithms. Another one I see people use a lot is Sedgewick, but I really dislike his writing style.

thx, if only amazon would let you preview other chapters than introduction, very useful for that kind of book ._.
 

Tamanon

Banned
My school's starting to offer an Intro to COBOL class now. It's not a Comp Sci class, but one for ICTN(Information Computer Technology, the networking/security stuff). Tempted to take it, since that seems a skill that's dying out, but still useful for some companies.

Not sure how easy it is to keep in shape on it though, since I understand it's a mainframe language.
 
How much would I actually need to know about a programming language before it could get me a job?

I've been learning some Java on my own. I can output the hell out of some Fizzes and Buzzes and if you give me a minute I could even get you the n-th element of the Fibonacci sequence, but... I'm assuming in a real life scenario I won't be getting an urgent message from a bank that really needs to know which one out of the two given numbers is the larger one.

The tutorials I'm reading are all teaching me basic math and logic, which are obviously important, but at the end of the day I still feel like I don't actually know anything. A checklist or something would be pretty sweet.
 
How much would I actually need to know about a programming language before it could get me a job?

I like to think that any reasonable employer would expect you to have the ability to learn whatever they need, instead of coming in totally ready. I don't have much experience, though, so I could be wrong.
 

iapetus

Scary Euro Man
How much would I actually need to know about a programming language before it could get me a job?

Not necessarily very much, but finding the right company to give you a job in that case would be tricky.

Start from the job and work backwards. Go searching for entry level jobs in your area and look at what skills they need. Then learn those skills. Throw in some study on the basics - take a course on algorithms, design patterns, as well as the specific technologies you think you'll need.

You're going up against graduates with computing degrees. For entry level jobs, that will give them an initial advantage, so you have to turn that on its head by showing that you not only have some of the important skills they do, but you have better learning skills and that you've gone out of your way to learn relevant technologies. Most graduates suck at this, in my experience, so it's an easy way to jump ahead of them if you make it to interview.
 

iapetus

Scary Euro Man
Ok, I somewhat doubt you guys have an answer, but I'll shot any way.

[...]

Can you guys think of a way to make this take less time?

Okay, been doing a little more delving. There's a neat example of the sort of thing you need to do here:

http://mysqldba.blogspot.co.uk/2008/06/how-to-pick-indexes-for-order-by-and.html

Essentially you need to play with EXPLAIN as you tweak your indexes, and you *will* need composite indexes rather than a single one. It *might* be as simple as a composite index on itemType and itemQuality in your case, but you'll need to do some playing around and making sure your query uses an index with EXPLAIN to get it done.

Once it *is* done, you might find it makes a big difference, though.
 
Go searching for entry level jobs in your area and look at what skills they need. Then learn those skills.

Most of the job offers I've seen are basically "Java developer wanted. Required skills: you should know Java".

That's kind of what made me post here in the first place, because I have no idea what counts as "knowing Java".
 

upandaway

Member
Most of the job offers I've seen are basically "Java developer wanted. Required skills: you should know Java".

That's kind of what made me post here in the first place, because I have no idea what counts as "knowing Java".
Googling "entry level java developer skills" seems to be shooting up some solid subjects, if that's any use.

I think getting a mobile app out there would get you through a skillset too

Not necessarily very much, but finding the right company to give you a job in that case would be tricky.

Start from the job and work backwards. Go searching for entry level jobs in your area and look at what skills they need. Then learn those skills. Throw in some study on the basics - take a course on algorithms, design patterns, as well as the specific technologies you think you'll need.

You're going up against graduates with computing degrees. For entry level jobs, that will give them an initial advantage, so you have to turn that on its head by showing that you not only have some of the important skills they do, but you have better learning skills and that you've gone out of your way to learn relevant technologies. Most graduates suck at this, in my experience, so it's an easy way to jump ahead of them if you make it to interview.
On that subject, is there anything special I should be doing while doing my degree? All I did so far was use some open source libraries to write stuff and put it up on git.
 
Most of the job offers I've seen are basically "Java developer wanted. Required skills: you should know Java".

That's kind of what made me post here in the first place, because I have no idea what counts as "knowing Java".

Are you familiar with AbstractSingletonProxyFactoryBeanInterfaceModuleObserverStrategyPattern?

(I just made that up but it might be a real Java thing)
 

mltplkxr

Member
My school's starting to offer an Intro to COBOL class now. It's not a Comp Sci class, but one for ICTN(Information Computer Technology, the networking/security stuff). Tempted to take it, since that seems a skill that's dying out, but still useful for some companies.

Not sure how easy it is to keep in shape on it though, since I understand it's a mainframe language.

It is dying out. If you intend on working in the financial sector, take it. If you're interested hand-on experience with part of the history of computer programming, take it. Otherwise, pass. It's interesting in a historical kind of way but it's unwieldy. It was a class given to filter out students in my degree. IMHO, to file with punch cards in the annals of computer science.
 

iapetus

Scary Euro Man
On that subject, is there anything special I should be doing while doing my degree? All I did so far was use some open source libraries to write stuff and put it up on git.

The simple answer to that (and it's quite a trite one, but true nonetheless) is this: stuff that is not part of your degree.

The number of graduates applying for jobs I've seen whose entire experience consists of having done the bare minimum they needed to to pass their degree course is mindboggling. As a result, anyone who's done more than that is going to stand out.

Write some stuff. Contribute to open source projects - having patches to a free reporting library accepted pretty much got me through at least one interview in the past. Learn new technologies that are nothing to do with your degree course just because they seem cool.

At the end of the day, if you're the sort of person who codes because they like to code and learns because they like to learn then you will stand out from the crowd and you will be better than the rest when it comes to work. Anything you can do to develop that attitude and demonstrate that attitude is good.
 

mltplkxr

Member
How much would I actually need to know about a programming language before it could get me a job?

I've been learning some Java on my own. I can output the hell out of some Fizzes and Buzzes and if you give me a minute I could even get you the n-th element of the Fibonacci sequence, but... I'm assuming in a real life scenario I won't be getting an urgent message from a bank that really needs to know which one out of the two given numbers is the larger one.

The tutorials I'm reading are all teaching me basic math and logic, which are obviously important, but at the end of the day I still feel like I don't actually know anything. A checklist or something would be pretty sweet.

On Java:
Pick up a Java certification book. Outside of a good introductory book like Hortsmann's book or a Head First, I find cert books are a great way to learn Java. They are structured as learning tools. You get an explanation of some concepts, then exercices, then more explanation, then more exercices, etc. They start with the most basic things, and go all the way to the essential ones, and they give you insights into the pitfalls and quirks of a language.

On working as a programmer/software dev:
As you have found out, knowing a language does not mean knowing how to program or how to develop software.

Read The Pragmatic Developper and Code Complete 2.

Another thing you could look into is Java Interviews Explained. It covers computer science topics like algorithms, data structures, etc., and how to know your stuff.

Since you are targeting Java, try to find a book that explains object oriented software development. A guy I knew had a book that went through the development of a full application from requirements to modeling to development. I can't find it but something like that would be good.

Finally, a word of caution on design patterns. Try to avoid using patterns for now. IMHO, they are an advanced topic. I mean, look into it, know them well enough to understand how some programs and APIs are structured but don't use them. A huge problem in Java is that people hear about patterns and how they are these magical train tracks to the best programs ever. These same people then break down their requirements to fit patterns. Hilarity ensues. They end up with overly complicated programs that are hard to maintain, hard to understand and, hard to expand. Everything patterns are supposed to help you avoid.

Things like this old joke : )

Are you familiar with AbstractSingletonProxyFactoryBeanInterfaceModuleObserverStrategyPattern?

(I just made that up but it might be a real Java thing)

Patterns are very important to solve problems and improve the structure of applications. However, there are a lot of basic concepts to master before applying patterns.

"The simplest thing that works." and "Done is better than perfect." are two mottos to keep mind.
 

maeh2k

Member
That's not the case; indexes can help with the GROUP BY clauses.

http://dev.mysql.com/doc/refman/5.0/en/group-by-optimization.html

I figured the database could maybe optimize the query a lot more. Just looking at the query from a algorithmic perspective, you'd only have to run over all rows once and keep a count of equipped and owned items. You'd only end up with relatively few rows.
If you really need to create a temporary table for 280 million rows that would be rather inefficient.

Drkirby, could you share some results of your optimization efforts? I'd be interested.
 

NotBacon

Member
Has anyone heard anything about this Linux course?

https://www.edx.org/course/linuxfoundationx/linuxfoundationx-lfs101x-introduction-1621#.U9fSnGK9KK0

Is it worth looking into? Or are there better alternatives?

It's really not that in-depth. I got 97% on the final without looking at any course material. But if you're really new to Linux, it might be helpful.

My school's starting to offer an Intro to COBOL class now. It's not a Comp Sci class, but one for ICTN(Information Computer Technology, the networking/security stuff). Tempted to take it, since that seems a skill that's dying out, but still useful for some companies.

Not sure how easy it is to keep in shape on it though, since I understand it's a mainframe language.

Why would you subject yourself to this.

How much would I actually need to know about a programming language before it could get me a job?

The tutorials I'm reading are all teaching me basic math and logic, which are obviously important, but at the end of the day I still feel like I don't actually know anything. A checklist or something would be pretty sweet.

- Data structures and algorithms. I suggest Cormen's Intro to Algorithms. It is your new bible.

- Then I would suggest 1 or 2 large projects. e.g. Android app, web app with spring/hibernate/tomcat, desktop app. Make them interesting to yourself and you will be motivated.

- (Optional) C Primer Plus to really learn programming at it's
2nd to
lowest level. Bits, bytes, and pointers oh my!
 
Can anybody recommend a good C(++) algorithm book? That covers the basic essentials

Cormen's Algorithms book is what was used when I was in school. My professor for that class was an asshole though.

How much would I actually need to know about a programming language before it could get me a job?

I've been learning some Java on my own. I can output the hell out of some Fizzes and Buzzes and if you give me a minute I could even get you the n-th element of the Fibonacci sequence, but... I'm assuming in a real life scenario I won't be getting an urgent message from a bank that really needs to know which one out of the two given numbers is the larger one.

The tutorials I'm reading are all teaching me basic math and logic, which are obviously important, but at the end of the day I still feel like I don't actually know anything. A checklist or something would be pretty sweet.

There's a wonderful book out there called Programming Interviews Exposed, I suggest picking it up, reading through it and seeing if you can do most of the questions in Java. If you can, then you'll probably be able to get through an entry level interview and in to an actual job.

As for succeeding at the job, I think it really depends on the industry/position. Think about the kinds of companies/products you want to work on. Think about all the different features or systems involved in those software applications. Which ones do you think you could design and implement on your own or mostly on your own? If you were doing it on your own, how much time would you spend looking things up on Stack Overflow and how much time would you spend actually implementing and testing?

No one reasonable expects you to be an expert at your first job, but if you can't walk without having to Google how to tie your shoes, then you're probably not ready.
 

Chris R

Member
Ok, I somewhat doubt you guys have an answer, but I'll shot any way.

I need to compute some basic statistic from a MySQL table every day. The table it is pulling data from has 280 Million Rows (And counting!).

The table has 5 columns. The itemType, a Unique Item ID Number, the Owner, a Quality, and a 'equiped bool. (ItemType has an Index, and the ItemID is the Primary Key). 3 of them are used in the calculation of the statistics, ItemID, Quality, and Equiped.

What is done every day is simply count up all the items, and group them in the format of ItemType, Quality, Total Owned, Number Equipped. This operation takes roughly 4 hours, and is done with the call "create table ItemInfo select itemType, itemQuality, count(*) as 'Owned', sum(equiped) as 'equiped' from `itemlist` use index (`itemType`) group by itemType, itemQuality".

Can you guys think of a way to make this take less time?

What data type are the various columns? I remember talking about this at the bar with you but I don't know if you ever made that part clear. I just think something must be going wrong, 4 hours sounds way too long, even with 280,000,000 rows. If you can post your schema I think that might help
 

iapetus

Scary Euro Man
To help we need the output from:

explain select itemType, itemQuality, count(*) as 'Owned', sum(equiped) as 'equiped' from `itemlist` use index (`itemType`) group by itemType, itemQuality
 

msv

Member
Ok, I somewhat doubt you guys have an answer, but I'll shot any way.

I need to compute some basic statistic from a MySQL table every day. The table it is pulling data from has 280 Million Rows (And counting!).

The table has 5 columns. The itemType, a Unique Item ID Number, the Owner, a Quality, and a 'equiped bool. (ItemType has an Index, and the ItemID is the Primary Key). 3 of them are used in the calculation of the statistics, ItemID, Quality, and Equiped.

What is done every day is simply count up all the items, and group them in the format of ItemType, Quality, Total Owned, Number Equipped. This operation takes roughly 4 hours, and is done with the call "create table ItemInfo select itemType, itemQuality, count(*) as 'Owned', sum(equiped) as 'equiped' from `itemlist` use index (`itemType`) group by itemType, itemQuality".

Can you guys think of a way to make this take less time?
You should have an index on ItemType + ItemQuality if you'll do a group by on that set. Not 100% about this, but it should speed up the group by no?

What do you do with the ItemInfo table? Log it and use it again? How many records does it usually have? Does mysql perhaps automatically create a PK on the entire set or is it smart enough to use itemtype+itemquality?
 

Chris R

Member
Also it might be quicker to group on the equipped value as well. Since it's a bit value you would get an extra row per each itemType and itemQuality grouping but it might be faster. Does MySQL offer an estimated execution plan that allows you to see just where the slowdown is coming from? I know SQL Server does (love that feature!)
 

Kansoku

Member
Quick question. I've been using Java since I began college, and now I need to use C++. The problem is my teacher wants the things we'll make to run on Linux, and I'm too lazy to put dualboot on my PC, so is there a way to make some code in Windows and compile it for use in Linux?
 

maeh2k

Member
Quick question. I've been using Java since I began college, and now I need to use C++. The problem is my teacher wants the things we'll make to run on Linux, and I'm too lazy to put dualboot on my PC, so is there a way to make some code in Windows and compile it for use in Linux?

Just use a virtual machine instead of dual booting. Try Virtualbox and just install Mint or something.
 
Top Bottom