[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 39
File: Revy_Black_Lagoon_OP.jpg (299 KB, 2000x1124) Image search: [Google]
Revy_Black_Lagoon_OP.jpg
299 KB, 2000x1124
old thread: >>53966502

What are you working on /dpt/?
>>
>>53972937
Java > all other languages
>>
>>53972977
this to be honest family
>>
i got the hardest part sorted out. it's incredible what beauty you can create with some math expressions

>>53972977
also this
>>
>>53973029
Hardest part of what
>>
>>53972977
>>53973021
serial ports don't work in Java
>>
>>53973077
of a graphical effect for my game
>>
>>53973114
Post results
>>
BASED STROUSTRUP
>>
>>53973189
What's that from?
>>
rust > cpp > haskell > java
>>
>>53973235
https://github.com/isocpp/CppCoreGuidelines/blob/master/docs/Introduction%20to%20type%20and%20resource%20safety.pdf

>>53973236
flip around rust and cpp. Garbage collection failure.
>>
File: haskelel2.jpg (745 KB, 1920x1080) Image search: [Google]
haskelel2.jpg
745 KB, 1920x1080
>>53973236
>haskell
>>
Has anybody used dale?
https://github.com/tomhrr/dale
>>
>>53973457

brb lads, gonna have some fun...
function curry(func, num_args)
num_args = num_args or debug.getinfo(func, "u").nparams
if num_args < 2 then return func end
local function helper(argtrace, n)
if n < 1 then
return func(unpack(flatten(argtrace)))
else
return function (...)
return helper({argtrace, ...}, n - select("#", ...))
end
end
end
return helper({}, num_args)
end

function flatten(t)
local ret = {}
for _, v in ipairs(t) do
if type(v) == 'table' then
for _, fv in ipairs(flatten(v)) do
ret[#ret + 1] = fv
end
else
ret[#ret + 1] = v
end
end
return ret
end
>>
>>53973525
fugg, always quote people I don't mean to.
>>
>try to get my ruby project on windows running
>project relies on Dir.glob
>Dir.glob("*") on linux will return something like
["dirName\" , "dirName\", "file.ext"]
>[".\dirName", ".dirName\", ".\file.ext"]

Why bother
>>
public class Event {

private int eventTime;

public Event(int eventTime){
this.eventTime = eventTime;
}

public int getEventTime() {
return eventTime;
}

public void setEventTime(int eventTime) {
this.eventTime = eventTime;
}

}


i want to be able to make events have a custom variable with 2 types, either a departure or an arrival. how can i do that in java?
>>
>>53973525
>curry
Where is that loo?
>>
>>53973640
B-Boolean?
>>
>>53973640
enum
>>
>>53973640
class with a enum field to specify departure or arrival, and whatever data it needs to hold.
>>
>>53973900
>>53973918
got it thanks, i didn't know you had to import it and to type.arrival
>>
>>53973189
>STROUSTRUP
>based

pick one.
>>
>>53974058
kys
>>
>>53974058

Don't lie. Stroustrup is based.
>>
File: gamer modern male.png (248 KB, 730x350) Image search: [Google]
gamer modern male.png
248 KB, 730x350
>>53974071
>>
>>53974071
>>53974072

stroustrup has no idea how to program irl, he's a fucking idiot
>>
>>53974058
how dare you mock Stroustrup
>>
file = open(r"Animal Farm.txt","r")
for line in file:
if "Animal Names" not in "Animal Farm.txt":
file = open(r"Animal Farm.txt","a")
file.write("Animal Names")
file.close()


I'm trying to write to a notepad in python 3. The for loop is supposed to make sure the title "Animal Names" is there, and if it isn't then to write it. However all I get is an infinite loop even if the title is already there, what's going on?
>>
File: 1438298163240.jpg (24 KB, 500x461) Image search: [Google]
1438298163240.jpg
24 KB, 500x461
>>53974149
LOLWUT
>>
>>53974149

But you're a rockstar programmer, right?
>>
>>53974262
Wasn't he arrested yesterday for having child pornography on his laptop?
>>
>>53974282

ofc not but anyone who has worked in real life applications can see that that guy has no idea how to program outside of academic type of programs that are not even realistic in most cases.
>>
>>53974266
file = open(r"Animal Farm.txt","r")
if "Animal Names" not in file:
file = open(r"Animal Farm.txt","a")
file.write("Animal Names")
file.close()

i presume is what you meant to write
>>
>>53974283
It was on an external an external hard drive, but yeah.
>>
>>53974283
>>53974336
[citation needed]
>>
File: 1459615313704.png (431 KB, 304x590) Image search: [Google]
1459615313704.png
431 KB, 304x590
>>53974317
well goddamn, thanks!
>>
>>53974311

He created the world's greatest programming language. Cut him some slack.
>>
/dpt/ if I'm using a service that provides an API key for developer use, what can I do to prevent an end user from obtaining and potentially abusing that key? I don't want someone to just run `strings` against the binary and take my key but I also don't want to have them provide their own.

Is there some standard obfuscation practice for this type of thing? I don't need it to be impossible to retrieve just not simple.
>>
>>53974283
wat
>>
>>53974356
>>53974407
It was on ars technica. Look it up.
>>
>>53974283
reference where https://en.wikipedia.org/wiki/Bjarne_Stroustrup
>>
>>53974367
Only use the key server side, not client side.
>>
>>53974425
?
>>
>>53973236

>cpp
Are you actually talking about the C preprocessor, or C++? Is your shift key broken, or is the + key just too far for you to reach?

>>53974366

Sometimes, it can be hard to tell if you're more of a C++ or C# fanboy.
>>
>>53974425
no it wasn't. fuck off back to /b/ with your shitty bait
>>
>>53974459
cpp is a pretty common notation of c++
>>
File: 1457911349799.jpg (93 KB, 725x484) Image search: [Google]
1457911349799.jpg
93 KB, 725x484
>>53974459
>his keyboard layout requires the shift key to type +
>>
>>53974459

Definitely the latter, but you'd have to be a dummy not to appreciate how much of an improvement C++ is over C.
>>
>>53974483
no it isn't it's just the file extension and for URLs for technical reasons. the language is called C++
>>
>>53974459
>>53974483
even ISO use it
>>
>>53974519
only for compatibility reasons you massive autist
>>
Object tier list for languages:

"write once run anywhere" tier:
C# > Java
"muh concurrency/microservice" tier:
go > node.js
"drivers" tier:
C += x86
"OOP first year cs" tier:
c++
"quick n dirty" tier:
python > lua > ruby
"data science" tier:
python > julia > R
>>
>>53974594
"write once run anywhere" tier:
F#
"muh concurrency/microservice" tier:
F#
"drivers" tier:
C += x86
"OOP first year cs" tier:
c++
"quick n dirty" tier:
F#
"data science" tier:
F#
>>
>>53974593
you got rekt kid, let this be a lesson. see ya on the boards...
>>
File: Dutch.png (114 KB, 566x317) Image search: [Google]
Dutch.png
114 KB, 566x317
Black lagoon thread winner. The other thread has been discussing dick cages for the last hour.
>>
>>53974486

I can type a + without using the shift key, but then it would be rather far from the p key that it would be more convenient. Otherwise, + requires an = and a shift key. Also, DVORAK users can blow it out their ass.

>>53974489

Indeed, although I often recommend C to new programmers over C++, because of the simpler syntax. I learned C++ first, and it took quite a while for me to really get C++ as more than just the C features and classes/cout. I think it would have been much easier to just learn C first, and then get a tutorial to show how C++ expands upon C. Maybe not start with std::cout, but start with classes and templates, and the go on from there until one can see what exactly cout is. And then you can easily say "oh, it's an object, with a method, that's been overloaded a billion times, and since the type of an object can be guessed at compile time, the performance may be better than printf for some cases."

>>53974594

>lua
>better than Ruby

Also, your list is missing Smalltalk.
>>
>>53974676
ruby is the slowest. and dont link that garbage jit you know nobody uses. pypi and luajit are actually seeing use
>>
>Can't get wxwidgets to work at all
>googling errors just gives me more errors
>googling those errors leads to posts ending in "wait, nevermind guys, I figured it out on my own"

Welp, I'm officially going to learn Java today. Wish me luck.
>>
>>53974729
What are you trying to make?
>>
>>53974729
Whats the problem faggot
>>
>>53974787
>>53974753
Everything, everything is the problem. I can't even fucking compile.
>>
File: 1459982292708.jpg (1 MB, 2699x4055) Image search: [Google]
1459982292708.jpg
1 MB, 2699x4055
Where can I find info on how to make graphs like pic related? I want to connect a user to another but last time I did this and had like ~5000 users it was slow as FUCK

web based btw
>>
>>53974838
>tfw no gf
>>
File: 1459067983755.jpg (37 KB, 348x342) Image search: [Google]
1459067983755.jpg
37 KB, 348x342
>>53974838
>graphs like pic related
>>
>>53974838
>Where can I find info on how to make graphs like pic related?
That's not a graph anon. That's a woman.
>>
>>53974838
that's a complicated graph anon, can't help you there.
>>
File: graph.png (15 KB, 925x712) Image search: [Google]
graph.png
15 KB, 925x712
>>53974901
>>53974892
>>53974868
sorry wrong pic
>>
>>53974838
>~5000 users it was slow as FUCK
should probs avoid graphs with so many users....
>>
>>53974838
I would like to have sex with that graph
>>
>>53974925
brb, gotta fap
>>
>>53974720

First off, Ruby is actually competitive with Python in terms of speed. Second off, Lua's type system is complete shit. If you want to judge a language as an object oriented language, you might as well not compare that weakly typed bullcrap with Ruby. Ruby is the logical successor to smalltalk. Everything is an object, even integers, types, and messages. Every operation is seen as passing a message. 2 + 2 is sending the message + to the object 2 with the parameter 2, which is another object. Python is the same way, but it's an ugly mess to try and treat in this way. There's a reason Ruby is more preferred for domain specific languages. It's cleaner and more consistent in being the next smalltalk, and has none of Python's __method__ bullshit.
>>
>>53974829
Useless piece of shit
>>
File: ashley benson1.jpg (555 KB, 1768x3000) Image search: [Google]
ashley benson1.jpg
555 KB, 1768x3000
fugg
>>
>>53974925
Drawing a graph for 5000 users is a lot of work, can't you do it some other way?
>>
File: computerman.jpg (13 KB, 400x226) Image search: [Google]
computerman.jpg
13 KB, 400x226
I know half of you couldn't manage to tie your shoes, but how early is too early to get into a management position? I'm about 2 years out of school and am already the de facto team lead at a major financial institution.
>>
File: VoXkyCJ.jpg (276 KB, 800x1193) Image search: [Google]
VoXkyCJ.jpg
276 KB, 800x1193
We posting 3d waifus in here?

What books should I read to understand terminology better? I had to teach myself everything due to a lack of resources, and because of that I feel like I'm really under everything.
>>
Why does everyone on /g/ shill C so hard anymore?
>>
>>53975288
Would you rather shill C++?
>>
>>53975288
The C shillers died of old age
>>
>>53974838
>>53974925
Graphviz
>>
These 3D waifus are awful.
>>
File: 3d_Nazi_042.jpg (89 KB, 600x402) Image search: [Google]
3d_Nazi_042.jpg
89 KB, 600x402
>>53975386
>These 3D waifus are awful.
>>
>>53975386
Sweaty, veiny, sweaty bags of skin. Just think of all the bacteria and puss on all the skin? Bleh..
>>
>>53975255
Programming related how?
>>
>>53975422
>>53975423

I meant they aren't black enough.
>>
>>53975551
You are worst than lolifags.
>>
>>53975588

Not even.
>>
how do i let multiple methods access the same input stream in java?
>>
think i'm gonna apply to get a masters in CS to be honest
>>
>>53975214
no
>>
>>53975678
same way you'd make them access any variable
>>
>>53975880
i can just pass input streams to functions like that? i assumed they were something special
>>
>>53975734
>he wasn't already recommended to the / a post grad adviser / program by a professor in his senior year

If you're interested in the research, go for it. Though I'm not sure how successful your application will be without an existing recommendation.
>>
>>53975339
fuck me this documentation sucks
>>
>>53975965
Just generate a dot file.
>>
>>53975934
yeah just remember to close them when you're done with them
>>
>stackoverflow is down
so which is more efficient. an iterator or a for-each loop
>>
>>53975988
so i open it in main, pass it to the functions while open, and then at the end of main close it?
>>
I'm looking to learn programming using Java. Absolute beginner here, CS major. Recommended resources/tutorial/book/course?

Again, I want my focus to be on the programming itself NOT the language.
>>
>>53976036
That's it
>>
i did some poking around and this professor at my school wrote his own language cinnameg. i googled it to see if it was popular and all i got was some stack overflow questions with 0. i just realized this dude completely fucked over every single one of his students who relied on stack overflow and google to do assignments. glad i dodged that bullet topkek
>>53976097
if you're a CS major, wouldn't you want to focus on learning the language? you should probably know programming in general already...
>>
>>53976097
>CS major

what year lol
>>
>>53976027
If you're worrying about performance loss from this, you have other problems. I still use foreach generally, iterators are trendier now, it all probably gets compiled to the same thing.
>>
>>53975987
what
>>
>>53976027
a foreach loop is an iterator.
>>
>>53976241
>>53976238
I just transferred, and I had some problems with the registration so I didn't get to register any programming/CS related courses, just the basics.
>>
>>53976260
https://en.wikipedia.org/wiki/DOT_(graph_description_language)
>>
>>53976027
for each loops use the underlying iterator so performance should be the same
>>
>>53976027
Almost certainly they are just as efficient.
>>
I'm using gosu and ruby

god damn it

If I want an object to be drawn at any time, it has to be drawn ALL the time. I can't just have something pop up momentarily and disappear. That can't be right.
>>
Asking in what I guess is the correct thread:

I'm going through http://neuralnetworksanddeeplearning.com/ and its neat, any other suggestions for learning neural networks?
>>
File: 1459880941714.png (143 KB, 229x345) Image search: [Google]
1459880941714.png
143 KB, 229x345
someone knows some go? I'm porting a library to parse files from go to java and there are some strange things.

var pixelData uint16
pixelData = palette[set*256+int(index)]

is that an array? can't find any variable 'set'. very strange indeed.
>>
>>53976281
best way to do it is to just jump in. maybe watch a tutorial on how to get whatever IDE you want to use set up first though, but other than that just use google for what you don't know and make programs. here's some programs to make:

Hello World, make it print hello world to the terminal

a program that lets the user enter 2 numbers, and then prints which number is bigger

i can come up with these all day
>>
>>53976027
for(int i... is faster
>>
>>53976522
It's either an array or a map. 'set' isn't a reserved word, so look harder.
>>
>>53976522
>var pixelData uint16
>not uint16 pixelData
how can you defend this
>>
>>53976587
Should clarify it's probably a slice rather than an array.
>>
>>53976605
Having the types trail variable name makes type signatures with higher order functions much more readable.
>>
>>53972937
A node.js based chan software that's actually good and not broken.
>>
>>53976645
>node.js based
>not broken
i've got bad news
>>
>>53976607
it has to be a short because it's get handed to a function that returns a byte array. go is really strange.
>>
>>53976650
Well PHP ain't much of an option these days
>>
>>53976666
what's the alternative these days
>>
So, I'm not sure why the following code is storing an extra character.

package main

import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
)

func main() {
payload := "\x52\x94\xad"

schema := `
CREATE TABLE IF NOT EXISTS tblData(
id INTEGER PRIMARY KEY NOT NULL,
data BLOB
);
`

db, _ := sql.Open("sqlite3", "test.db")
_, _ = db.Exec(schema)

insData, _ := db.Prepare(`INSERT INTO tblData(data) VALUES(?)`)
_, _ = insData.Exec(payload)
_, _ = insData.Exec(payload[0:2]) // straightforward thought
}


I expect 3 bytes to be stored, specifically "0x52 94 ad"
What is stored is this:

sqlite3 test.db "select data from tblData where id = 1;" | hexdump -C
52 94 ad 0a

sqlite3 test.db "select data from tblData where id = 2;" | hexdump -C
52 94 0a


Is there some way to supress that newline character?
>>
>>53976693
Node.js
Because PHP is showing it's age by being shitty.
I mean seriously. I used to be a PHP dev but now I'm going 100% node.js because it's not 100% broken.
>>
>>53976666
Nice quads
Checked
>>
what are some job titles that deal with low-level programming?
>>
File: sort.png (29 KB, 656x813) Image search: [Google]
sort.png
29 KB, 656x813
Let's say I wanted to chnge this program so it could sort float and double numbers, at a glance, what would I have to change?
>>
>>53976708
Are you sure that's in the db and not just added by the sqlite tool?
>>
>>53976752
facility manager
>>
>>53976752
embedded systems
>>
>>53976756
The numbers are retrieved from a txt file, each line of which is assigned to an array.
>>
>>53976712
ASP.NET
>>
>>53976756
jesus christ
>>
>>53976708
>Exec
I don't know the language, but if it isn't strictly typed or this function is overloaded to handle strings, it is likely interpreting the variable payload as a string instead of simply binary data.

You may want to do some more testing, though - empty string, longer string, then finally a numeric variable that is the value you want stored.
>>
>>53976764
That's a good point, I'll look into that. Thanks.

I was honestly going with the quickest way to verify that the data had been written correctly.
>>
>>53976708
Are you sure that isn't just coming from sqlite itself?
>>
File: 1459702589670.jpg (31 KB, 600x337) Image search: [Google]
1459702589670.jpg
31 KB, 600x337
another go question
currentPos, _ := reader.Seek(0, 1)

wtf does that _ mean?
>>
>>53976820
It means "ignore the second value returned by this function"
>>
>>53976820
reader.Seek(0, 1) returns a tuple but we don't care about the second item.
>>
>>53976797
The actual program has the data stored as []byte. And the data does end up in the db correctly minus perhaps that newline.

>>53976764
>>53976806
point out the most likely answer.
>>
>>53976820
Ignore the second return value.

Not meaning to come off condescending but if you didn't know that one, you should probably read up on the language more; it's not like there's a lot to memorize.
>>
File: 1458432921992.jpg (517 KB, 1920x1080) Image search: [Google]
1458432921992.jpg
517 KB, 1920x1080
>>53976830
>>53976833
ah nice, thanks

>>53976843
it's ca. 1000 lines and Im almost done. no need to put more effort in it as needed.
>>
>>53976764
>>53976806
sqlite> select length(data) from tblData where id = 1;
3
sqlite> select length(data) from tblData where id = 2;
2


again, thanks.
>>
kpop waifus are the superior 3D waifus.
>>
>>53976788
I'll pretend you didn't suggest asp.net
Java would be a better solution. But node.js is pretty good considering it's speed, ability to scale, and speed.
>>
>>53976927
Java is fucking garbage.

>Considering it's speed, ability to scale, and speed.
You said speed twice. Java and C# are about 10 times faster than node. Not considering their ability to do stuff like multithreading.
>>
At this point I am working on figuring out why end users of 4chan are such retarded shit tier level animu affogts.
>>
File: 1459517058760.png (436 KB, 596x720) Image search: [Google]
1459517058760.png
436 KB, 596x720
>>53976979
>>
>>53976979
What's your favorite infinite sum?
>>
File: water_dont_be_rude.png (223 KB, 362x391) Image search: [Google]
water_dont_be_rude.png
223 KB, 362x391
>>53976979
>>
How hard is it to learn programming for Android? I have an app I really need to make for personal use, nothing else fills the niche.

>no programming experience whatsoever
>>
File: 1459521801574.png (77 KB, 370x370) Image search: [Google]
1459521801574.png
77 KB, 370x370
>>53977014
(-1)^n/2n+1

Because it's pie, the best number in the world and I'm such a nerd XD. Look how many digits I can remember 3.141592653
>>
>>53976491

>I can't just have something pop up momentarily and disappear
Err... I've used Gosu before, and you certainly can. Just don't draw the object after a few frames. When I used it, it was for a scrolling shooter game, and bullets were fairly temporary things. They stay on the screen until the fly off the screen or hit something. I would store the bullets inside of a draw queue, and basically, they'd keep getting their draw methods called as long as they remained in the queue. If they reached a condition that would make them no longer need to be drawn, they'd remove themselves from the queue. This might not be the best approach to this problem, but it clearly shows that objects can retain themselves on the screen for only a limited time if you so desire.
>>
  1 #include <stdio.h>
2
3 int main()
4 {
5
6 int i;
7
8 for (i = 1; i <= 100; i++)
9 {
10 printf("Your were %d\n", i);
11
12 /*I had to use 1 year before the actual age
13 and I input the i++ to make sure it gets
14 the age of the wanted year.
15 */
16 if (i == 15)
17 {
18 i++;
19 printf("You are now %d\n", i);
20 break;
21 }
22 }
23 return 0;
24 }

I am learning C so be gents with me
>>
>>53976952
>Implying asp.net is better then java
Also node.js is surprisingly fast for something that doesn't multi-thread.
Also it can thread, just people don't.
Node.js is designed for doing small operations very quicky. I.E. Webpages...
>>
>>53977062

Eh, it's not too hard. Documentation can be a pain, but it's just Java and XML.

>>53977149

for (i = 1; i <= 100; i++)
{
printf("Your were %d\n", i);


I recommend you print out a copy of the GNU style guide and set it on fire.
>>
Hey guys, beginning CS student here. Missed the last two lectures about arrays and I'm sorta blundering my way through this latest assignment. One part of the assignment is to find the largest and smallest inputs in an array then print the index number they're stored in. I know what I'm doing wrong but I'm not sure how to fix it.
for(int i = 0; i < arraySize; i++ {
if(array[i] > largest){
largest = i + 1;
}
}
>>
>>53977182
>Also node.js is surprisingly fast for something that doesn't multi-thread.
And yet still slower. So why the fuck should anyone use it?

The only reason to use it is if you know JS already and don't want to bother learning something better.

>Also it can thread
Web Workers have so much overhead and limitations they are hardly worth the effort. That's why they are not used.

>Node.js is designed for doing small operations very quicky. I.E. Webpages...
And failing at it.
>>
>>53977149
Please stop using the emacs auto-indenter, or at least change the style it uses.
>>
>>53977260
I am using VIM :( sorry I put the softtabbing set equal to 2 spaces
>>
OK I've been wanting to learn a programming language for a while now and I have an idea for a little utility. I'd make a positional audio visualizer to overlay games. What language would this be easiest in(I understand that it would be a infuriating process any way I go)?

I would probably learn whatevers good for that as my first language, and go from there after I understand programming as a whole.
>>
>>53977231
Have you seen benchmarks of node.js?
It's impressively good.
Not to mention it's widespread use in large web applications like netflix. Obviously it's doing something right if large companies are using it to provide low latency content.
>>
>>53977221
largest contains in index into the array, not the value of the array at that index.
if(array[i] > largest)

This comparison isn't going to tell you anything meaningful.
if(array[i] > array[largest])

will tell you if the array element is actually bigger.

largest = i + 1;

Array indexes are 0 based, and computer scientists count from 0. Don't add 1 to it. Also, adding 1 is going to screw up the comparison above.
largest = i;
>>
/dpt/ I want to get into embedded systems (or maybe low-level graphics processing) but I have next to no experience. What do?
>>
>>53977285
>little util
>positional audio visualizer
>555comeonnow.jpg
>>
>>53977289
>Have you seen benchmarks of node.js?
Yes, that's why I know how slow it is.

Keep telling me how "impressively good" it is. It's still slower than better alternatives and offers nothing but one less language to learn.
>>
>>53977406
I haven't seen a single benchmark where it's beaten for it's low latency web delivery.
Also your failed to come up with an excuse why large websites use it for low latency web content
>>
>>53977221>>53977221
>if(array[i] > largest){
>largest = i + 1;
Dude, what?

I am going to describe your algorithm in plain English:
Goal: To find the highest number in a list of numbers
Repeatedly, for each number in the list:
Take the number and compare it to what we've already written down as the largest. If that number is bigger than what we wrote down as the largest, change what we wrote down as the largest to be one more than that number's position on the list.
Example:
The fifth number in the list is 175.
Our old largest number candidate is only 14.
Since 175 is larger than 14, we write down 6 (1 + the fifth list position)

for(int i = 0; i < arraySize; i++ { // compile error, missing closing parenthesis
if(array[i] > largest){
largest = i + 1; // logic error
}
}

largest = INT_MIN;
// up here, first set largest to the lowest value
// otherwise, if largest already had an number in it that is bigger than any in the array
// the code will not give you the biggest number in the array,
// but what largest already had.

for(int i = 0; i < arraySize; ++i)
{
if( array[i] > largest )
largest = array[i];
}

>>
>>53977221

int smallestIndex;
int largestIndex;
for(int i = 0; i < arraySize; i++){
if(array[i] < smalest){
smallest = array[i];
smalestIndex = i;
}
if(array[i] > largest){
largest = array[i];
largestIndex = i;
}
}
print smallestIndex
print largestIndex
>>
>>53977260
What's wrong with the auto-indenter?

I like using it, especially with the BSD style.
>>
>>53977285
>I'd make a positional audio visualizer to overlay games.
You mean a program that, for a game such as counter-strike, listens to the stereo sound effects and computes the position in the game where it is coming from, to display it on screen?

If so, that will be an amazingly difficult project and not at all suited for a beginner. I don't want to discourage you, but you should probably forget about this idea except as a long-term goal.
>>
>>53977424
>I haven't seen a single benchmark where it's beaten for it's low latency web delivery.
Have you found one where it beat ASP.NET?

Fucking facebook was written in PHP. That hardly means PHP is good for low latency. Node probably has acceptable latency, but it's certainly not going to be faster than ASP.NET.

http://web.ageofascent.com/asp-net-core-exeeds-1-15-million-requests-12-6-gbps/
>>
>>53977100
okay well yeah as it happens what I'm doing is trying to find a way to work bullets so thank you
>>
>>53977464
>I like using it, especially with the BSD style.
That's fine, but the default GNU style is fucking shit.
>>
>>53977315
I know array indexes start at 0, I was adding 1 because the table the array prints out is supposed to print out "Month" then whatever index that value belongs to +1.
But holy shit thank you so much. Seems to be working so far.
>>
>>53974838
What do you mean
Just use a JavaScript graph software that will run client side
>>
>>53977496
>I was adding 1 because the table the array prints out is supposed to print out "Month" then whatever index that value belongs to +1
Do that at the end.
>>
>>53977488
Oh, yeah. I definitely can't deny that.

GNU code in general is fucking shit, but I can't resist emacs, it's like the McDonalds of text editors (it's more like a lisp machine than that, though).
>>
>>53976507
Maybe http://www.deeplearningbook.org/?
>>
>>53976820
Go to the Go website and do the Tour
>>
>>53977430
Oh I forgot that closing parenthesis when I typed it up in my original post, whoops. Thanks for the help.
>>53977433
Thank you as well.
>>
>>53977474
Actually I have
and facebook uses a modified PHP
asp.net is better for larger calculations, file operations, etc.
Overall if you're serving shit from a DB node comes out on top by a bit.
Also that is not a benchmark you linked... There is no direct comparison. there's no listing of what hardware is used and how node.js can compare to that.
How about you use your brain before typing?
>>
>>53977221
int smallestIndex;
int largestIndex;
for(int i = 0; i < arraySize; i++){
if(array[i] < array[smallestIndex]){
smallestIndex = i;
}
if(array[i] > array[largestIndex]){
largestIndex = i;
}
}
print smallestIndex
print largestIndex

FTFM
>>
>>53977566
Assuming C or C++, use of uninitialised variables on the first loop.
>>
>>53977564
>and facebook uses a modified PHP
Now it does. Only because they wrote it in normal PHP and realised that was a clusterfuck, and it was cheaper to write their own version of PHP with static typing (lacking in node.js) than port the whole thing to something not broken.

>asp.net is better for larger calculations, file operations, etc.
And everything else

>Overall if you're serving shit from a DB node comes out on top by a bit.
Yeah?

>there's no listing of what hardware is used and how node.js can compare to that.
Huh?? You think on certain machines node will be faster than ASP and on others it won't??

>How about you use your brain before typing?
LOL What?? You say that as if you just said something really damning. All you did was moan about some of my points not having enough detail for you. You haven't shown any reason to use node at all.
>>
>>53977467
Ah yes, it's more like a long term goal, I just want to start with a language that(eventually) will be suited to this kind of thing.

I realize that this would be an extremely difficult and stressful project, so I would wait to be fluent in a language(made quite a few programs) before trying to tackle this.
>>
Is it possible to do something like this?

Mysql table called posts, I make a query that goes to each post and searchs for something like
[quote="WILDCARD"]randomshit[/quote]
and saves the original poster plus what's inside the wildcard?
>>
can someone spot what i'm doing wrong?
http://pastebin.com/W8nVQJMA
it's honestly not that long a program, i promise. I copied the psuedocode from the book and just implemented it, but i had to make a time variable and update it to keep track of the time which was talked about in the chapter but not in the psuedocode. this is my output

Processing an arrival event at time: 1.
Processing an departure event at time: 6.
Processing an arrival event at time: 2.
Processing an departure event at time: 7.
Processing an arrival event at time: 4.
Processing an departure event at time: 9.
..etc

which is wrong because it should be

Processing an arrival event at time: 1.
Processing an arrival event at time: 2.
Processing an arrival event at time: 4.
Processing an departure event at time: 6.
Processing an departure event at time: 11.
..etc

time's bouncing around and people aren't having to wait, but i don't know how to fix it. it's supposed to be event driven, so i'm not supposed to just increment time by 1 in the while loop. but they didn't discuss how to actually do the time variable in the text, they just said you had to do it and then didn't elaborate at all. if you don't believe me read walls and mirrors java 3rd edition
>>
>>53977597
int smallestIndex = 0;
int largestIndex = 0;
int [] array = {0,1,9,3,4,5};
for(int i = 0; i < array.length; i++){
if(array[i] < array[smallestIndex]){
smallestIndex = i;
}
if(array[i] > array[largestIndex]){
largestIndex = i;
}
}
System.out.println(smallestIndex);
System.out.println(largestIndex);

Now it even compiles in java!
>>
>>53977670
mysql doesn't support regex searches.
>>
>>53977633
>You think on certain machines node will be faster than ASP and on others it won't?
No you autistic fucker
There's no way to quantify how effective it is when only the raw results and not the method is posted.
There is no direct way to compare asp.net and node.js with that article. 1.1m request per second don't mean much without what hardware is behind it to quantify it.
That's what I'm trying to say.
I've also given your lots of reasons why node.js is better. You on the other hand have failed to produce any facts when asked.

How about you give me some reasons why I should use Microsoft abomination of a programming language asp. net
>>
>>53977343

learn C, and this isn't even fanboying
>>
what a coincidence I'm also doing getLargest / getSmallest

int priorityQueue::getSmallest()
{
int smallest = array[0];
int lowIndice;
for (int i = 0; i < size - 1; i++)
{
if (array[i] < smallest)
{
smallest = array[i];
lowIndice = i;
}
}
array[lowIndice] = array[count--];
return smallest;
}
>>
>>53977670
SELECT poster, some_string_shit(post) FROM table WHERE column LIKE '%[quote="%"]%[/quote]%';
>>
>>53977740
I know C, just not the libraries. The problem is a lack of experience in this one area
>>
>>53977709
>1.1m request per second don't mean much without what hardware is behind it to quantify it.
LOL!! Yeah anon. No matter what hardware you run it on, it's a safe bet you won't make up for a 150k requests per seconds vs a 1200k requests per second gap.

>How about you give me some reasons why I should use Microsoft abomination of a programming language asp. net
Speed
Static typing
Strong typing
A very mature, full features and well tooled language that is C#.
Capability of using even better langugaes like F#
Languages that are not broken peices of shit like JS

All the productivity benefits that come with Static typing and strong typing, the powerful IDE features they enable such as much more bugs caught at compile time, autocompletion and refactoring.

Scales much better in modestly large projects.

I don't understand the benefit of node whatsoever unless you are simply trying to avoid working in anything besides JS.
>>
>>53977803
>LOL!! Yeah anon. No matter what hardware you run it on, it's a safe bet you won't make up for a 150k requests per seconds vs a 1200k requests per second gap.
Uwot anon?
Where are you getting that 150k RPS number from? Also ofc hardware makes a difference. Especially in cloud based computing.
>>
>>53977838
>Where are you getting that 150k RPS number from?
>>53977633
>Also ofc hardware makes a difference. Especially in cloud based computing.
LOL. I hate to break it to you anon. But the "cloud" is just a bunch of normal computers in a room somewhere.
>>
>>53977635
Fair enough. I should also point out that using a tool like this would probably be considered cheating in most gaming contexts, but you probably know that already.

In regards to languages, for a project like this, the intrinsic complexity of the problem will dwarf the particular challenges of the language you use; as a consequence, any general-purpose language, such as C++, java, or maybe C#, will do. Scripting languages such as Python will probably complicate things in this project, though they are easier to learn as a beginner, which may or not be a good tradeoff for you.

If I were to attempt a project like this, I would probably use C++ as my language of choice; besides suitability of the language, it also stands the best chance of having libraries available to help with all the sound processing magic. But C++ is also notoriously complex and beginner-unfriendly, so focusing on that may be more challenging than necessary. Java and friends (which includes C#) are sort of the middle ground between suitability for the project and accessibility to beginners.

All of these languages listed have excellent general-purpose applicability and career opportunities, so that's a nice bonus.
>>
>>53977861
I fucking know, and you can parallelize requests for increase RPS.
Cloud computing allows for easy scale ability.
Now go home anon, you're drunk
>>
File: qt fox.jpg (425 KB, 1280x960) Image search: [Google]
qt fox.jpg
425 KB, 1280x960
>>53977685
please respond, have a fox for your time
>>
>>53977894
>Cloud computing allows for easy scale ability.
These comparisons are obviously being made on a single machine. Are you retarded? In any case, why would running these services on 10 computers be any different than on 1?

You asked me why someone should use ASP.NET, and I told you. You haven't given me any reason to use node.
>>
>>53977923
I'll admit I didn't see that little datapoint for node.js and I was obviously making incorrect asumptions based upon there not being any demonstrations on how that machine runs node.js
Also for the record I hate JS, it's just the best option. and ASP.net is just.... ewwwwwww
I like node.js because it's quick, better then PHP, not completely fucked up, and not a .net based language. I made a restful API in 5 minutes with sails.

I guess my stigma comes from my background in malware, where the moment you see ".net" you back away very quickly.
>>
>>53977985
hold up....

What is your issue with ASP.NET exactly?

Because .NET used to build malware sometimes?
>>
>>53977922
post the rest of the code
>>
>>53977922
also post the file you're reading from
>>
>>53978049
public class Customer {
private int arrivalTime;
private int transactionLength;

public Customer(int arrivalTime, int transactionLength){
this.arrivalTime = arrivalTime;
this.transactionLength = transactionLength;
}
public int getArrivalTime() {
return arrivalTime;
}
public void setArrivalTime(int arrivalTime) {
this.arrivalTime = arrivalTime;
}
public int getTransactionLength() {
return transactionLength;
}
public void setTransactionLength(int transactionLength) {
this.transactionLength = transactionLength;
}
}


public class Event {

public enum type {
arrival, departure
}

private int eventTime;
private int transactionLength;
private type eventType;

public Event(int eventTime, int transactionLength, type eventType){
this.eventTime = eventTime;
this.transactionLength = transactionLength;
this.setEventType(eventType);
}

public int getEventTime() {
return eventTime;
}

public void setEventTime(int eventTime) {
this.eventTime = eventTime;
}

public type getEventType() {
return eventType;
}

public void setEventType(type eventType) {
this.eventType = eventType;
}

public int getTransactionLength() {
return transactionLength;
}

public void setTransactionLength(int transactionLength) {
this.transactionLength = transactionLength;
}

}


that's it, just a customer class and an event class that are basically the same thing
>>
>>53978062
1 5
2 5
4 5
20 5
22 5
24 5
26 5
28 5
30 5
88 3


// end of the text file

the left number's the time the customer arrives and the right one's the length their transaction will take when they're being served. i looked online about the book and a bunch of people shit on it for having bad/incorrect pseudocode and stuff like that so i might have to completely toss my current implementation and start from scratch without looking at the book
>>
>>53977985
Why Node.js is better than php? It;s client language.
>>
>>53978108

Javascript and PHP are both complete shit. But Javascript at least doesn't have nearly as much inconsistent and inane bullshit as PHP.

PHP should be used only where COBOL should be used -- maintaining old applications and porting old applications to a less shitty language infrastructure.
>>
File: 1453768732023.gif (2 MB, 277x342) Image search: [Google]
1453768732023.gif
2 MB, 277x342
welp, i finished the codeacademy javascript course and now i'm trying to write my own basic programs.

tonight I started with the idea "I want to make a window that opens up when you click an exe that says 'Hello World!' and then tells you to press any key to close."

now I'm downloading visual studio because apparently javascript doesn't like opening windows that aren't browser windows

i feel like pic related because i can read the script now, i just can't understand any of it
>>
>>53977430
But in your example largest would print 175 not 5.
>>
>>53978047
Very shitty malware
Any malware in .net is instantly made by skids, without needed features.
>>
>>53978108
PHP is one of the WORST languages for anything.
PHP is old, outdated, slow, insecure, and just plain poor.
>>
>>53978246
Right, sorry, I misread his original post. I was thinking of the largest number, not index.
>>
>>53978350
So in other words, you're just triggered by .NET due to bad malware made in .NET?
>>
>>53978381
That plus shitty syntax
Basically yes
Plus my dislike for MS and their programming languages.
>>
>>53978245
As you've found out, javascript is a language specifically for manipulating what goes on inside a web browser. It is not really a general-purpose language to write arbitrary programs with; and although an ever-larger part of computing happens inside browsers in some way, it's still a pretty limited thing.

If you want to write standalone programs, you'll need to learn a different programming language. Almost all the available options have a way of supporting graphical programs that are quite different from how you do things in javascript, so you'll have to do a considerable amount of relearning.
>>
>>53978394
>.NET
>syntax
Yes, because there's only one .NET language
>>
>>53977424
Have you heard of Elixir?
>>
>>53978430
All the .net languages and conventions are shit.
>>
>>53978395
well, considering that I'm downloading visual studio anyway, i might as well go learn C++

does this site look good?
http://www.learncpp.com/
or is there a better site?
>>
>>53978394
>Plus my dislike for MS and their programming languages.
>>53978464
>All the .net languages and conventions are shit.

Is your reason for those opinion still stemming from the poor .NET malware?
>>
>>53978486
m8
http://programming-motherfucker.com/become.html#C / C++
>>
>>53978551

btw how the fuck did he get spaces in there without URL encoding?
>>
>>53978097
the problem is you're putting things in eventList instead of bankQueue, and not checking bankQueue when you need to be
>>
>>53978558
spa framework routing shit
>>
>>53978601
http://pastebin.com/iBwYXtG5

this was the psuedocode in the book which i think i followed to a T, but i'll look into it tomorrow
>>
>>53978763
i actually don't want to look into it tomorrow i want to do it tonight. is the psuedocode wrong, or is my implementation of it wrong?
>>
Thinking about making websites for small businesses. Anyone know any good website building websites?
>>
>>53978934
>>>/g/wdg
>>
In java should I use a try/catch or an or in a regular expression?
>>
>>53978898
Send help i want to login to a website and get some data while logged in

>Android
>>
>>53975386
never knew you were a weeb gtp
are there many 2d niggers?
>>
>>53978856
>>53978763
This pseudocode requires that you insert the departure event in the middle of the queue, at the right location based on its timing. You add it at the end instead, which is not what the pseudocode does.

For what it's worth, this pseudocode is a pretty stupid way of solving the problem. It isn't wrong, but there are much better ways of doing the same thing in an event-driven way.
>>
>>53978934
wix
>>
>>53979006
You should try to have it fail silently befor resorting to a try catch.
>>
>>53977770
well I mean it "works" but I want to get what's inside quote=""
>>
>>53979033
I'm confused at what you mean by fail silently?
>>
What's more secure, low-level 3d-graphics experience, or embedded systems experience?
>>
>>53979028
i changed processDeparture to this but it's still not working. i also tried messing with the < to make it >, >= and <= and neither of them worked
 
static void processDeparture(Event departureEvent){

System.out.println("Processing an departure event at time: " + time);

//process a departure event

//update the line by deleting the front customer
bankQueue.remove();
//update the event list
eventList.remove(eventList.lastIndexOf(departureEvent)); //Delete departureEvent from anEventList
if(!bankQueue.isEmpty()){
// customer at front of line begins transaction
Event newDeparture = new Event(time + bankQueue.poll().getTransactionLength(), 0, type.departure);

int departureSpot = 0;
while (newDeparture.getEventTime() > eventList.get(departureSpot).getEventTime()){
departureSpot++;
}
eventList.add(departureSpot, newDeparture); // Insert into anEventList a departure event that corresponds to
// the customer now at the front of the line and has
// currentTime = currentTime + transaction length
}
}
>>
>>53979071
it should take the load before crying rape
>>
>>53979098
Embedded systems
>>
>>53979028
wait so should i use a priority queue for the event list, since i apparently want it to be ordered by the time of the event? that'd handle some of the stuff for me right?
>>
File: hp48.jpg (69 KB, 582x793) Image search: [Google]
hp48.jpg
69 KB, 582x793
RPL is a really great language to have on a calculator. Instead of mucking about with TI-BASIC and programming menus you can write one-off programs in a functional language right on the command line. I remember it used to be really handy for things like homework problems that were repetitive, just type in the list, throw a quick program on the stack, and hit DOLIST.

<< DUP2
> << SWAP >> IFT
-> fst lst
<<
0
fst lst FOR i
i SQ +
NEXT
>>
>>


Share your math class programming stories, /g/
>>
>>53979146
>functional

awful.
>>
>>53979146
the only thing i've used the program functions on calculators for was saving equations for stats quizzes
>>
>>53979033
So you're using a regular expression, if you have no matches then don't crash. I don't really understand what you're doing, but fail silently basically means you don't crash at edge cases. Sort of how floats have NaNs.
>>
>>53979192
>functional meme meme

it's not purely functional but being functional makes it suited for your day-to-day calculator programs. Hell of a lot faster than ti-basic too
>>
File: 1457444204523.jpg (86 KB, 1032x696) Image search: [Google]
1457444204523.jpg
86 KB, 1032x696
It's addicting, that feeling when you create methods to help you achieve your goal.
>>
>>53979028
>>53979104
please senpai unfuck my shit up dont leave me alone here
>>
>>53979211
Sorry, meant to reply to >>53979071
>>
Is it ok to use jsoup in android to login to a website and then get data?
Thread replies: 255
Thread images: 39

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.