[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: 36
File: himegoto.webm (3 MB, 720x405) Image search: [Google]
himegoto.webm
3 MB, 720x405
old thread: >>53628171

What are you working on, /g/?
>>
>>53633479
Kid, you need a fuckin' hobby other than wearing your mother's clothing.
>>
>>53633479
kill yourself
>>
>>53633479
I'm working on a Hime feet tickling image generator in Haskell.
>>
>>53633479
I need help, I just made this and I don't understand what's going on.

public class Mortgage
{
private static final int PROMOTION_LOAN = 100_000,
PROMOTION_PERIOD = 30;
private static final double PROMOTION_RATE = 7.5;
private static int last_account_number = 3_745_000;
private int account_number = 0,
loan_amount = 0,
loan_period = 0;
private double annual_interest_rate = 0;


public void Mortgage(double annual_interest_rate, int loan_period, int loan_amount)
{
account_number += last_account_number;
}

public Mortgage(int loan_period, int loan_amount)
{
annual_interest_rate = PROMOTION_RATE;
Mortgage(annual_interest_rate, loan_period, loan_amount);
}

public Mortgage(int loan_amount)
{
annual_interest_rate = PROMOTION_RATE;
loan_period = PROMOTION_PERIOD;
Mortgage(annual_interest_rate, loan_period, loan_amount);
}

public Mortgage()
{
annual_interest_rate = PROMOTION_RATE;
loan_period = PROMOTION_PERIOD;
loan_amount = PROMOTION_LOAN;
Mortgage(annual_interest_rate, loan_period, loan_amount);
}

public int getAccountNumber()
{
return account_number;
}

public double getAnnualInterestRate()
{
return annual_interest_rate = 0;
}

public int getLoanAmount()
{
return loan_amount;
}

public int getLoanPeriod()
{
return loan_period;
}

public double monthlyPayment()
{
double monthly_interest_rate = getAnnualInterestRate() / 1_200;

return getLoanAmount() * monthly_interest_rate /
(1 - (Math.pow(1 / (1 + monthly_interest_rate), getLoanPeriod() * 12)));
}

public double totalLoanPayment()
{
return monthlyPayment() * (getLoanPeriod() * 12);
}
}
>>
>>53633487
This nigga programs ascii raymarchers and even made that ElDorito thing just for fun
https://gist.github.com/Wunkolo/249646f7a922ee045c70
>>
>>53633533
Posting your problem might actually be helpful.
>>53633536
nigga stop im freakin out
>>
Is this code bad? I started learning toward the end of December. I tried doing this problem with just a simple list but I realized that it'd get long as hell once the numbers got big (and it did), so I switched to a dict. Is there a better way to do this that doesn't involve really advanced/unnecessary stuff? Just looking to improve.

>You are given a string s composed of letters and numbers, which was compressed with some algorithm. Every letter in s is followed by a number (possibly with leading zeros), which represents the number of times this letter occurs consecutively. For example, "aaaaaaaabbbbbbcc" would be given as "a8b6c2".
>Decompress s, sort its letters and return the kth (1-based) letter of the obtained string.

def Expand_It(s, k):
import re
length = 0
count = 0

s = filter(None, (re.split('(\d+)', s))) # convert s to list
t = {}
for i in range(0, len(s), 2): # consolidate s into dict, {letter:count}
if s[i] not in t:
t[s[i]] = int(s[i+1])
else:
t[s[i]] += int(s[i+1])
for key in sorted(t): # calculate total decompressed length, letter at position 'k'
length += t[key]
if count < k:
count += int(t[key])
letter = key
else:
break
if k > length:
return -1
else:
return letter
>>
>>53633540
Mirrors only reflect left-to-right but not up-and-down
>>
>>53633551
Yeah I know.
I opened my window. it's snowing out. i feel better.
>>
File: output.webm (2 MB, 640x480) Image search: [Google]
output.webm
2 MB, 640x480
I made a solar system!

I don't know how to display things in perspective view yet, that's why it looks weird.
>>
>>53633517
kill yourself samefag
>>
File: 1372447691649.jpg (96 KB, 399x399) Image search: [Google]
1372447691649.jpg
96 KB, 399x399
Is there a structured design process for AI? I'm in a course for it this semester and the professor literally doesn't teach.

The last project I spend way too much time trying to implement as I went rather than actually designing a solid agent, and I want a good form to collect my thoughts on the process.
>>
>>53633421
Thanks. Should I change my major to CE? Or would I be fine with a CS degree? It seems like Penn State has an alright curriculum.
>>53633426
W-what?
>>
>>53633579
Lookin' good man, glad you kept at it.
>>
im gonna be taking a test real soon, wish me luck
>>
>>53633551
>>53633575
Actually, mirrors don't reflect anything at all. They show a direct projection of your face. You think they reflect horizontally, because other people usually "rotate" around horizontally to get in front of you and see your face.

It's the other people who see you wrong.
>>
File: 1447454158480.jpg (114 KB, 710x549) Image search: [Google]
1447454158480.jpg
114 KB, 710x549
>>53633625
gl hf
hope it isn't positive.
>>
File: so far.png (167 KB, 834x1686) Image search: [Google]
so far.png
167 KB, 834x1686
>>53633533
>>53633540
These are the related pages.

I just don't know if I've done it right so far.
>>
>>53633544
p-please respond
thanks
>>
+}>++>+++>++++>+++++>++++++)>+++++++>++++++++++'@<)@<<<<<}@@>}>>)@>>)@<}<)@}>>>>)++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'$<<<<<}$>>>)>'@<<<}@
>>
>>53633544
>s = filter(None, (re.split('(\d+)', s))) # convert s to list
I'm pretty sure re.split returns a list anyway, you don't need to convert it. And if you did, just use list(...) instead of a useless filter

>everything else
Indexing into lists is generally not very "pythonic". Sometimes it's necessary but I don't think it's needed here. You could probably squeeze everything down to a few lines with slicing and list comprehensions.
>>
>>53633595
The word AI has meant different things during different decades in 20th and 21st century.
Modern AI is Machine Learning. The most general form of Machine Learning is Reinforcement Learning.
For example this is state of art RL agent: http://arxiv.org/abs/1602.01783
>>
>>53633700
you're given a string s, I use re.split and filter to parse it into letter-number-letter-number-etc
then i put that into a dict
>>
>>53633700
>>53633724
forgot to mention: the filter gets rid of empty entries
>>
>>53633705
well, we aren't going too deep at the moment. Just an agent that uses minmax to play blokus.
>>
Implement atoi in the language of your choice, post your time <program> and time it took you to complete
>>
>>53633761
here you go kid, have fun with your homework
int atoi(const char *nptr) 
{
/* don't include negative values this doesn't see them */
size_t len = strlen(nptr);
size_t i, j = 0;
int total;
for (i = len - 1; i >= 0; i--)
{
if (nptr[i] >= '0' && nptr[i] <= '9')
total += (nptr[i] - 30) * pow(10, j++);
}
return total;
}
>>
>>53633761
>do my homework for me pls
Also what's time <program>
>>
>>53633819
not conforming to standard.
>>
#!/bin/bash
function() {
#do shit to $var
}
dir=/path/to/dir
find $dir -print | xargs var=$1; function

does not want it what I want it to do
that is find all files, set each of those files as a variable, then execute function using that variable
the function is executing, that's good, but the variable isn't being set

xargs: var=: No such file or directory


#!/bin/bash
function() {
#do shit to $var
}
dir=/path/to/dir
find $dir -print | xargs bash -c "var=$1; function"


just passes the no such file or directory errors onto the function itself
how do I use the output of find as a variable in my function?
>>
>>53633826
>>53633819
I am self teaching C and I would like to see how other people do it :-)
>>
File: 1458467661376.gif (8 KB, 456x350) Image search: [Google]
1458467661376.gif
8 KB, 456x350
>>53633679
>>53633533
bump
>>
Just got rb Whitaker book on c#, looks nice and better than the head first outdated shit
>>
Any books that /dpt/ could recommend me in software design? not technical design, but the appearence and feel of the software. I'm horrible at it i'm sad at this point
>>
Oops, didn't realize the last thread was done, reposting.

>>53632221
>Come to think of it I could just copy the entire album tree and find each flac file

find ALBUM/ -name '*.flac' -type f | while read line; do bname="$(basename -s .flac \\"$line")"; ffmpeg -i "$line" FFMPEG_OPTS /OUTPUT_DIR/"$bname".EXT; done


This will let you do an entire album at a time. If you wanted to do an entire artist then you'd have to get the parent directory name of each file and run mkdir -p on your other output location, and add to the output filepath.
>>
>>53633819
alright, I fixed it so it actually works now
int atoi(const char *nptr)
{
size_t len = strlen(nptr);
int total = 0;
int j = 0;
int i;
for (i = len - 1; i >= 0; i--)
{
if (nptr[i] >= '0' && nptr[i] <= '9')
total += (nptr[i] - '0') * pow(10, j++);
}
if (nptr[0] == '-')
return -total;
else
return total;
}


$ ./atoi
string: -18322943 - number collected: -18322943
>>
>>53634116
That sounds more like UI/UX over software design. Software design is shit like adapter patterns, factories, observer/observable, etc. UI/UX is how humans interact w/ your software products.
>>
Been working on this and for the life of me I cannot figure it out. It's the first time we are learning about implementation in my java class. What i'm trying to do is be able to add a number to an arraylist, and, before it's added, if would be the new lowest or highest number sets it as that. This is what I have so far and it's not working.

public class MeasurableSet implements Measurable
{
ArrayList<Measurable> measurable;
Measurable min;
Measurable max;

MeasurableSet()
{
measurable = new ArrayList<Measurable>();
}

//mutator to add a new Measurable object to the MeasurableSet .
//Set min if the object is smaller than any previously seen object,
//max if the object is larger than any previously seen object.
void add(Measurable m)
{
if(m.getMeasure() < min.getMeasure())
{
min = m;
}
else if(m.getMeasure() > max.getMeasure())
{
max = m;
}
measurable.add(m);
}
>>
>>53634166
>pow
>strlen

and still non-conforming.
>>
>>53634251
also just to add to that, I also have this interface

public interface Measurable 
{
int getMeasure();
}
>>
>>53634252
nonconforming to what, anon?
>>
>>53634308
To the C standard, which defines what atoi exactly does.
>>
>>53634314
is it supposed to return as soon as it finds a non-numeric number?
>>
>>53634251
>>53634277
You are using an interface. When you say
class Nigger implements Watermelon

It means that 'Nigger' has to implement all of the functions in 'Watermelon'. Your class has not implemented the 'getMeasure' function, so it will not compile. That is what a java interface is.
>>
>>53634251
what isnt working anon?
>>
>>53634251
MeasurableSet is not itself a Measurable (what would its measure be?), it only deals with other Measurable objects. So MeasureableSet should not implement Measurable.
>>
>>53634323
>non-numeric number

It's also supposed to skip whitespace at the beginning, and accept + as a sign.
>>
>>53634251
public class MeasurableSet extends ArrayList<Measurable> {
Measurable min;
Measurable max;

@Override public boolean add(Measurable m) {
if (min == null || m.getMeasure() < min.getMeasure()) {
min = m;
}
if (max == null || m.getMeasure() > max.getMeasure()) {
max = m;
}

return super.add(m);
}
}

public interface Measurable {
int getMeasure();
}

as other are saying, measurableset doesn't implement measurable (nor should it, it seems.)

it would be better to subclass the arraylist and override the add method to do the logic you want
>>
>>53634251
>>53634324
>>53634329
>>53634333

Let me clarify more specifically by posting the full MeasurableSet.java. What isn't working in particular is that when I run it from a main method it tells me that there is an error with
if(m.getMeasure() < min.getMeasure())

specifically it says that there is an exception.

Among Measurable, and measurableset.java there are 3 other classes associated besides the main that are all return numbers.

MeausrableSet.java
import java.util.ArrayList;
import java.util.stream.IntStream;
import java.util.*;
import java.io.*;
import static java.lang.System.*;

public class MeasurableSet implements Measurable
{
ArrayList<Measurable> measurable;
Measurable min;
Measurable max;

MeasurableSet()
{
measurable = new ArrayList<Measurable>();
}

//mutator to add a new Measurable object to the MeasurableSet .
//Set min if the object is smaller than any previously seen object,
//max if the object is larger than any previously seen object.
void add(Measurable m)
{
if(m.getMeasure() < min.getMeasure())
{
min = m;
}
else if(m.getMeasure() > max.getMeasure())
{
max = m;
}
measurable.add(m);
}

// accessor to return the min object
Measurable getMin()
{
return min;
}

// accessor to return the max object
Measurable getMax()
{
return max;
}

// accessor to return the Measurable objects in the MeasurableSet
//whose Measurable value is greater than or equal to floor, and less
//than or equal to ceiling
ArrayList<Measurable> getMiddle(int floor, int ceiling)
{
ArrayList<Measurable> x = new ArrayList();
for(Measurable i: measurable)
{
if (i.getMeasure() >= floor)
{
if (i.getMeasure() <= ceiling)
{
x.add(i);
}
}
}
return x;
}

@Override
public int getMeasure() {
// TODO Auto-generated method stub
return 0;
}


}
>>
>>53634369
I wouldn't extend ArrayList<Measurable>. A few problems with that.
1. Its not a set, though this was already a problem in the initial design.
2. (more importantly) You expose other methods that break encapsulation, for example:
MeasurableSet m = new MeasurableSet();
m;
m.addAll(myList); // <-- bug! add() not guaranteed to be called, so min and max are not properly set
>>
>>53634442
Ah, that's something else entirely. min and max are initialized to null; when they are null, the check `if(m.getMeasure() < min.getMeasure())` breaks. You probably need to build the possibility of min (and max) being null into that check. And more generally, think about what your class should do when it is empty.

Your MeasurableSet still shouldn't be a Measurable though.
>>
>>53634488
well yeah, I was going off what he had. the poor naming excluded. t'was giving him a hint/starting point and letting them finish their homework on their own.
>>
>>53634122
>piping find into while read
wow that absolutely works
find "$dir" -name *.flac | while read FLAC; do encode; done

You helped me solve my puzzle. When I become a wizard I will be sure to repay you.
>>
>>53634496
so are you saying that I should initialize them? and if so should I just initialize them to 0?

also what do you mean that MeasurableSet still shouldn't be a Measurable ?
>>
>>53634546
the much bigger problem is encapsulation breaking. I would never extend anything from the collections api for this reason.
>>
>>53633724
>>53633735
Here's my solution:

#!/usr/bin/python
import re
from collections import defaultdict

def decompress(s, k):
partsList = re.split('(\d+)', s)
letters = defaultdict(int)
for letter, number in zip(partsList[::2], partsList[1::2]):
letters[letter] += int(number)
result = ''
for letter in sorted(letters.keys()):
result += letter * letters[letter]
print result
return result[k]

Input:
s = 'a2b3c4'
print s
print decompress(s, 1)
s = 'a2x5a2b3b2c03'
print s
print decompress(s, 4)
s = 'a0002b5a23c3d2z1'
print s
print decompress(s, 27)

Output:
a2b3c4
aabbbcccc
a
a2x5a2b3b2c03
aaaabbbbbcccxxxxx
b
a0002b5a23c3d2z1
aaaaaaaaaaaaaaaaaaaaaaaaabbbbbcccddz
b
>>
>>53634563
if(min == null || (m.getMeasure() < min.getMeasure()))
// same for max check

public class MeasurableSet
//delete the obviously IDE-generated getMeasure() method
>>
>>53634608
Works and I don't get an error anymore, My gratitude is infinite.

Also for whatever reason it's just simply printing out a pair of brackets for the getmiddle function instead of telling me the appropriate information, any ideas as to why?

public class Main 
{

public static void main(String[] args)
{
MeasurableSet mobj1 = new MeasurableSet();

Word word1 = new Word("Love");
Word word2 = new Word("Hate");

Wall wall1 = new Wall(10, 20);

Field field1 = new Field(15, 30);

mobj1.add(word1);
mobj1.add(word2);
mobj1.add(wall1);
mobj1.add(field1);

System.out.print(mobj1.getMax());

System.out.print(mobj1.getMiddle(10, 15));


}

}

What is prints out
Word: Hate[]
>>
>>53634683
post Wall, Word and Field classes.
>>
>>53634683
Gladly.

Wall.java
public class Word implements Measurable
{

private String myWord;

public Word(String word)
{
myWord = word;
}

public String getWord()
{
return myWord;
}

public String toString()
{
return "Word: " + myWord;
}

public int getMeasure()
{
int vowels = 0;
int length = myWord.length();
for(int i = 0; i < length; i++)
{
String j = myWord.substring(i, i + 1);
if(j.equalsIgnoreCase("a") == true)
vowels++;
else if(j.equalsIgnoreCase("e") == true)
vowels++;
else if(j.equalsIgnoreCase("i") == true)
vowels++;
else if(j.equalsIgnoreCase("o") == true)
vowels++;
else if(j.equalsIgnoreCase("u") == true)
vowels++;
}
return vowels;
}

}


wall.java

public class Wall implements Measurable
{

private int height;
private int length;

public Wall(int len, int hgt)
{
length = len;
height = hgt;
}

public int getHeight()
{
return height;
}

public int getLength()
{
return length;
}

public String toString()
{
return "Wall length:" + length + " height:" + height;
}

public int getMeasure()
{
int calc = (height * length);
return calc;
}

}
>>
>>53634732
>>53634773
Meant to say word for that first one, but here is the last one, wouldn't let me fit it previously

field.java

public class Field implements Measurable
{

private int length;
private int width;

public Field(int len, int wid)
{
length = len;
width = wid;
}

public int getLength()
{
return length;
}

public int getWidth()
{
return width;
}

public String toString()
{
return "Field length:" + length + " width:" + width;
}

public int getMeasure()
{
int calc = ((2 * width) + (2 * length));
return calc;
}

}
>>
>>53634773
>>53634801
print out getMeasure() for each of your wall, field, and word objects. Are any between 10 and 15?
>>
Damn, why didn't anyone tell me that Rust automatically degenerates references to pointers?
>>
Going to start learning C++ for the next two weeks, what's the best IDE.
>>
>>53634885
emacs
>>
>>53634885

visuel stuodi
>>
>>53634885
vim
>>
>>53634885
vim
>>
>>53634814
Figured it out after printing those out, should've thought about that.

Seriously thank you so much man you're a fucking lifesaver, i'd kiss you if I could, also appreciate the fact you didn't berate me for not knowing much about programming. Cheers mate.
>>
If I just want to learn the basics of programming to get started, is Python the best to begin with?
Any recommended tutorial/guides etc?
>>
>>53634949
google "the matrix"
>>
File: it's right there.png (88 KB, 1394x867) Image search: [Google]
it's right there.png
88 KB, 1394x867
Why can't it see the Mortgage method? It's right there.
>>
>>53633579
>>53634949
Doesn't really matter what you start with, what's important is that you get started. Most modern languages have similar syntax. Java Javascript python c++ are all good to start with.
>>
File: losing hope.png (63 KB, 1241x911) Image search: [Google]
losing hope.png
63 KB, 1241x911
>>53635055
If I make it void, there are no errors but then I can't use it from inside another class.
>>
>>53635055
>>53635177
>JGrasp
>>
who wants to collab
>>
File: 1442693379798.png (1 MB, 1295x827) Image search: [Google]
1442693379798.png
1 MB, 1295x827
C# vs Java?
What is better for a (kind-of)beginner to learn?
>>
>>53635177
Make it static nigger child.
>>
>>53635256
Im kinda wanting to know it too but more for empregability, what should i get first? c++ or c#?
>>
>>53635274
Made it static and this happened

>>53635284
It's supposed to be a constructor
>>
>>53635315
>empregability
i'd say c++ desu
fully OO languages have a lot of weird fucking quirks
>>
>>53635332
wow i just made a new word mixing 2 languages, its employability, sorry senpai
>>
>>53635371
in that case, c# or java
or go full webdev and learn javascript+html+css+php+the latest meme, probably ruby or python
>>
>>53635383
Thanks for the advice, i'll check wdg for some resources and search for some c# tutorials/books.
>>
>>53635055
Mortgage(...); // <-- bug! missing new keyword

new Mortgage(...); // working as intended

please post your whole code next time, the mistake would be obvious
>>
>>53633533
how do you post with syntax highlight and everything?
>>
>>53635474
< code > < / code >
>>
>>53635442
Oh wow. Thanks. I am dumb.

It needs new in front of each method call because it's a new object every time. Right?
>>
>>53635414
webdev shit pays more and jobs are more prevalent but /g/ will laugh at you, idk if that's important to you
>>
>>53635483
no problem, Claude
>>
File: 1458423728720.gif (1 MB, 500x393) Image search: [Google]
1458423728720.gif
1 MB, 500x393
>>53635511
>Claude
>>
File: nemosroom.jpg (126 KB, 1000x661) Image search: [Google]
nemosroom.jpg
126 KB, 1000x661
Why is Python considered strongly typed when you never explicitly declare the type of your variables?
>>
File: static.png (77 KB, 1195x923) Image search: [Google]
static.png
77 KB, 1195x923
>>53635320
repost
>>
>>53635497
i just need a job be able to continue to pay for uni , my actual contract ends later this year and i need to get a job asap then. I can actually care for what /g/ thinks of me later
>>
>>53635552
static typing = you know the variables at compile time
strong = types dont change at run time (for example by being cast to another type or by coercion).

So you can see that a weakly typed could also be statically typed and vice versa. That said, I dont consider python to be strongly typed because of stuff like this:
>>> if [2]: print "Hello"
...
Hello
>>> if "0": print "Hello"
...
Hello
>>> if 0: print "Hello"
>>>
>>
>>53635552
Strongly typed does not mean dynamically typed. Dynamic typing just means that a variables type isn't known until run time, and you never specify types for them in the code itself. Strong vs. Weak type indicates the "malleability" of the type: basically how willing the compiler/interpreter is to fudge the types to make certain operations work without error.

Python is dynamically typed because you never declare variable types, but relatively strongly typed because it won't autocast a lot of variables for you, for instance "a" + 1 will fail because they are two different types. In contrast, a weakly typed language like Javascript will just perform a string concatenation there and not actually care about the types too much.
>>
>>53635622
There are very very few weakly typed languages.
You have to go back to the 60s and 70s to see what a weakly typed language was like.
Weak typing was a way to get some of the benefits of dynamic typing without implementing dynamic type system logic.
Now that dynamic type systems are well understood, there's no reason for weak types.
Almost every modern language is strongly typed, so the only part that matters is the static-dynamic spectrum.
Python is an example of a language with an extremely dynamic type system
>>
>>53635696
C
>>
Okay, so... I'm on Spring break. What the fuck should I program for this week I've got off?

>>53635552

You are confusing strong vs weak typing with static vs dynamic typing.

Strong typing more or less means types are not readily converted between each other. Strong typing is somewhat on a scale, however. Some languages are more "strong" than others. Ada and Haskell are perhaps the strongest, while languages like JavaScript and Perl might be some of the weakest. Python and Ruby are roughly as strong as C++, in that some numeric operations can be done without an explicit cast (i.e. floating point <---> integer), and converting anything to a boolean, but most type conversions are not automatic, and will result in a type error. If you try to do something silly, such as adding a string and a number, you'll get an error. Meanwhile, if you try to do the same thing in JavaScript, which was designed not to crash, it'll just chug along and produce some sort of result, even if it makes little sense.

Static typing is what you're thinking of. In statically typed languages, the type of an object is assigned at compile time and never changed. Meanwhile, in dynamically typed languages, it is assigned at runtime and may change over time. Some languages, such as C#, may blur the line here a little bit by being "mostly" statically typed, but allowing some dynamic typing in the runtime. These are called "gradually typed".

In a strong, dynamically typed language, this is legal:
x = 5
x = "hello"


But this is not:
x = "6"
y = x + 7
>>
>>53635782
>Ada and Haskell are perhaps the strongest

Ada is strongly typed to the degree that it's actually annoying.
>>
>>53635806

I am well aware. My school taught it as an introductory programming language until recently.
>>
>>53635833
>My school taught it as an introductory programming language

Jesus. I'm sure that leaves some emotional scars.
>>
>>53635696
interesting - some examples I could research?
>>
>>53635866

It was a pain in the ass, and at times, I wished I had C++ to work with instead, but it wasn't too bad.

I tried to find some of my old Ada assignments. Didn't find too many.
>>
>>53635582
Second part

I'm getting

MortgageTest1.java:6: error: non-static method toString() cannot be referenced from a static context
Mortgage.toString();
^
MortgageTest1.java:8: error: non-static method toString() cannot be referenced from a static context
Mortgage.toString();
^
MortgageTest1.java:10: error: non-static method toString() cannot be referenced from a static context
Mortgage.toString();
^
MortgageTest1.java:12: error: non-static method toString() cannot be referenced from a static context
Mortgage.toString(); }

for

public class MortgageTest1
{
public static void main(String[] args)
{
Mortgage ab = new Mortgage(6.0,20,200_000);
Mortgage.toString();
Mortgage ac = new Mortgage(20,200_000);
Mortgage.toString();
Mortgage ad = new Mortgage(200_000);
Mortgage.toString();
Mortgage ae = new Mortgage();
Mortgage.toString(); }
}

class Mortgage
{
private static final int PROMOTION_LOAN = 100_000,
PROMOTION_PERIOD = 30;
private static final double PROMOTION_RATE = 7.5;
private static int last_account_number = 3_745_000;
private int account_number = 0,
loan_amount = 0,
loan_period = 0;
private double annual_interest_rate = 0;
private String result = "";

public String toString()
{
String result = "Account number: " + getAccountNumber() +
"\nLoan amount: " + String.format(",.2f%",getLoanAmount()) +
"\nYears: " + getLoanPeriod() +
"\nAnnual rate: " + String.format(".1f%",getAnnualInterestRate());
return result;
}

[other code]
}
>>
>>53636161

I'm beginning to think you don't quite get this whole 'class' thing.
>>
>>53636161
non-static methods should be invoked on instances.
Mortgage ab = new Mortgage(6.0,20,200_000);
Mortgage bc = new Mortgage(11,23,null);
Message.toString() // <-- bug! Which message do you care about

Mortgage ab = new Mortgage(6.0,20,200_000);
Mortgage bc = new Mortgage(11,23,null);
ab.toString(); // the compiler knows we care about ab

read an introduction to java desu
>>
>>53636188
I just remembered. and I don't think I got it

and now I've got

    at java.util.Formatter.checkText(Formatter.java:2579)
at java.util.Formatter.parse(Formatter.java:2565)
at java.util.Formatter.format(Formatter.java:2501)
at java.util.Formatter.format(Formatter.java:2455)
at java.lang.String.format(String.java:2940)
at Mortgage.toString(MortgageTest1.java:30)


from

   public static void main(String[] args)
{
Mortgage ab = new Mortgage(6.0,20,200_000);
System.out.print(ab.toString());
Mortgage ac = new Mortgage(20,200_000);
System.out.print(ac.toString());
Mortgage ad = new Mortgage(200_000);
System.out.print(ad.toString());
Mortgage ae = new Mortgage();
System.out.print(ae.toString()); }
>>
>C++
>create a "class Object{...}" with a "ToString" function
"have all my objects inherit it and implement it itself

>4 extra bytes of v-table for all my objects now

BLOAT
>>
>>53636226
now you are on your own padawan
>>
>>53636226
Same thing with

public class MortgageTest1
{
public static void main(String[] args)
{
Mortgage ab = new Mortgage(6.0,20,200_000);
Mortgage ac = new Mortgage(20,200_000);
Mortgage ad = new Mortgage(200_000);
Mortgage ae = new Mortgage();

ab.toString();
ac.toString();
ad.toString();
ae.toString();
}
}

class Mortgage
{
private static final int PROMOTION_LOAN = 100_000,
PROMOTION_PERIOD = 30;
private static final double PROMOTION_RATE = 7.5;
private static int last_account_number = 3_745_000;
private int account_number = 0,
loan_amount = 0,
loan_period = 0;
private double annual_interest_rate = 0;
private String result = "";

public String toString()
{
return String.format("Account number: " + getAccountNumber() +
"\nLoan amount: " + String.format(",.2f%",getLoanAmount()) +
"\nYears: " + getLoanPeriod() +
"\nAnnual rate: " + String.format(".1f%",getAnnualInterestRate()));
}
>>
File: I CANT CODE FOR SHIT.png (75 KB, 912x1007) Image search: [Google]
I CANT CODE FOR SHIT.png
75 KB, 912x1007
being absolutely annihilated trying to turn this basic delay plugin into a ping pong delay. Wish I knew SIMPLE maths.
>>
Anybody know rust here?
What's the point of doing
&*x
? What does that mean?
>>
>>53636481
why not just x?
>>
>>53636282
>>53636287
I got it, just move the %s in front.
>>
>>53636498
http://cglab.ca/~abeinges/blah/too-many-lists/book/second-iter.html
pub fn iter(&self) -> Iter<T> {
Iter { next: self.head.map(|node| &*node) }
}
>>
Can someone explain function pointers to me?
int doublef(int a)
{
return 2*a;
}

void map(int (*func)(int), int arr[], int len)
{
int i;
for (i = 0; i < len; ++i)
arr[i] = func(arr[i]);
}

So can I call this using
map(&doublef, arr, 20);
? The compiler won't stop yelling at me so I mustve fucked up.
>>
>>53636547
Did you try
map(doublef, arr, 20);
?
>>
>>53636559
I just did.
Fuck it, let me post the whole code, I don't know what I'm doing wrong
#include <stdio.h>

int doublef(int);
void map(int (*func)(int), int arr[], int len);

int main(void)
{
int arr[] = {6, 17, 9, 19, 6, 6, 14, 11, 9, 1, 9, 6, 17, 16, 12, 5, 18, 7, 11};
map(/*&*/doublef, arr, 20);
int i;
for (i = 0; i < 20; ++i)
printf("%d\n", arr[i]);

return 0;
}
// rest is in last post
>>
Is there a Lisp with a standard library like Python?
>>
>>53636576
What's the error message say?
Protip: always read error messages, and always post them when asking for help
>>
>>53636604
map.c: In function `main':
map.c:10: parse error before `int'
map.c:11: `i' undeclared (first use in this function)
map.c:11: (Each undeclared identifier is reported only once
map.c:11: for each function it appears in.)

Line 10 is the int i; declaration. I don't know why it's complaining abt that.
>>
>>53636618
The following code:
#include <stdio.h>

int doublef (int x)
{
return x * 2;
}
void map (int (*func)(int), int arr[], int len)
{
int i;
for (i = 0; i < len; ++i)
arr[i] = func(arr[i]);
}

int main(void)
{
int arr[] = {6, 17, 9, 19, 6, 6, 14, 11, 9, 1, 9, 6, 17, 16, 12, 5, 18, 7, 11};
map(doublef, arr, 20);
int i;
for (i = 0; i < 20; ++i)
printf("%d\n", arr[i]);

return 0;
}

Compiles perfectly for me.

$ cc --version
cc (GCC) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ make blah
cc blah.c -o blah

$ blah
<numbers>
>>
>>53636640
I copypasted your code and it fails to compile for me. I guess it's my compiler then?
λ gcc --version
egcs-2.91.57
>>
>>53636666
Use a sane C compiler?
$ mingw32-gcc --version ; mingw32-gcc blah.c -o p1
mingw32-gcc.exe (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ clang --version ; clang blah.c -o p2
clang version 3.5.2 (tags/RELEASE_352/final)
Target: i386-pc-windows-cygnus
Thread model: posix
$ gcc --version ; gcc blah.c -o p3
gcc (GCC) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>>
File: 1442803817321.jpg (294 KB, 1024x768) Image search: [Google]
1442803817321.jpg
294 KB, 1024x768
>>53636707
I've had so much fucking trouble getting a compiler set up on this system, I got this version of gcc from some literally who site ever since mingw took a shit on my face.
I really don't want to have to fire up my linux vm just to write a little toy program.
>>
>>53636707

Update your compilers, noob.
Rubyist@Tardis MINGW64 ~/CS
$ gcc --version
gcc.exe (tdm64-1) 5.1.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>>
Not really related to programming, but how many of you guys use iOS or Android?

http://strawpoll.me/7159627

I'm thinking about trying iOS. So far the phones I've had are Samsung Galaxy S3, LG G3, and Nexus 6.

I'm deciding between three phones for my next phone:
1. Samsung Galaxy S7/E
2. iPhone 6S/Plus
3. Nexus 6P

Leaning towards Galaxy S7 cause of camera, battery, performance, looks. Cons are touchwiz, slow AF OS updates.

iPhone 6S leaning towards because performance, camera, battery, try out iOS, grass is greener. Cons are not very customizable, don't like the design as much as material design.

Nexus 6P leaning towards because performance, camera, pure Android, quick updates. Cons are not as good battery life.

I want your guy's opinion cause you guys aren't super retarded. Sure some are, but majority I respect other programmers opinions and would like to see why some programmers think Android is better, or iOS is better.
>>
>>53636798
i come to /dpt/ specifically to ignore shitty consumer garbage like this post. please make a separate thread for your phone concerns. this is the daily programming thread,not the daily whatever-the-fuck-you-want-to-talk-about thread.
>>
>>53636777
You on windows? I used cygwin, it's seamless.

>>53636791
Ur right I really should
>>
>>53636816
Fuck off pussy bitch I do exactly what I want and nothing else. If you don't like it ignore it, it's one post.
>>
>>53636835
your gay phone shit is no better than the traps and weeaboos fighting over the op image. stop derailing the thread
>>
File: ss+(2016-03-22+at+06.59.43).png (10 KB, 367x211) Image search: [Google]
ss+(2016-03-22+at+06.59.43).png
10 KB, 367x211
>>53636791
Maybe another day
>>
File: 1458001194127.png (36 KB, 816x530) Image search: [Google]
1458001194127.png
36 KB, 816x530
>>53636867
>>
>>53636892
I have debian on another partition and I literally never use it because
> it doesn't work with my volume buttons, I had to write lik
> Skype is shit so I can't talk to my gf (don't fucking talk to me about Tox)
> F.lux doesn't work and I can't change my screen brightness at night
> I already have a perfectly functioning development environment on my windows: Sublime with vim plugins, unix emulation on cygwin and all the compilers and interpreters I need (gcc, clang, rust, ocaml, haskell, lua, etc.)

There's no reason for me to go back to digging through wikis and online forums looking for help on features that already work on normal operating systems.
Just because GNU + Linux was designed well doesn't mean the software on top of it was (I'm looking at you, pulseaudio)
>>
>>53636973
*lik -> like a hundred lines of code to get a hacky replacement for my volume keys
>>
>>53636973
funny, I always end up googling how to get my windows to act more like linux
especially for development
>>
>>53636188
>>53636188
im fucking dying anon thankyou
>>
>>53636867

Free software and Windows have never played well, alas.
>>
>>53634585
Thanks for posting it
>>
>>53629295
black lagoon
>>
Haskell is a beautiful language.
>>
I'm learning Java iterators. It's awful.
>>
>>53636226
Would you look at that parenthesis at the end... is that shitty ass positioning a standard or something? fauk
>>
>>53637384
just use streams lmao
>>
>>53635055

Did a little bit of stack overflow searching for you. Here's the problem: Java isn't going to let you call your constructor from itself like that.

Instead of doing this:
Mortgate(annual_interest_rate, loan_period, loan_amount);


It should look like this:
this(annual_interest_rate, loan_period, loan_amount);


Related link:
https://stackoverflow.com/questions/9838105/why-doesnt-java-allow-recursion-in-constructor
>>
File: xKiTB6U.png (94 KB, 812x318) Image search: [Google]
xKiTB6U.png
94 KB, 812x318
finally unb&
>>53635782
>>53635806
I'm not that familiar with Ada, but I think it's pretty safe to say that something like Coq has the strongest typing
>>53637358
took a while for the syntax to grow on me, but yeah, it's one of the best I've seen
>>
File: Screenshot_20160323_154050.png (30 KB, 421x584) Image search: [Google]
Screenshot_20160323_154050.png
30 KB, 421x584
rewriting my instruction set / vm / assembler
is this good? All I really want it to do is work with signed 32 bit integers, and maybe I'll add floats 'natively' later if I can't figure out how to implement them with the logical operators and shit

I know fuck all about machine code / assembly but I though if I have branches to non-immediate locations I could do functional shit with it

r8
(sorry I made it tiny I had to fit it on one screen)
>>
>>53636481
Basically this is dereferencing x, then immutably referencing it with the &. For example this code will fail because of the dereference then immutable reference:
fn test(x: &mut i64) {
test2(&*x);
}

fn test2(x: &mut i64) {
println!("{}", x);
}

fn main() {
let mut x = 5;
test(&mut x);
}


I will admit that I'm also a bit new to Rust, but I believe that in the case of http://cglab.ca/~abeinges/blah/too-many-lists/book/second-iter.html you have to do that because of Rc utilizing deref coercions(https://doc.rust-lang.org/book/deref-coercions.html). Basically by dereffing the Rc gives you access to the data itself, not the Rc, which you then rereference with the &. If you did nothing, you'd only have access to the Rc itself which is not what you want.
>>
File: 1458704371084[1].png (588 KB, 1440x810) Image search: [Google]
1458704371084[1].png
588 KB, 1440x810
>>53635782
opencv program that detects if an image is anime, like this one
>>
>>53637485
fairly ordinary/10
don't know how often the branch immediate will be used
>>
File: 1458695649991[1].jpg (188 KB, 1440x810) Image search: [Google]
1458695649991[1].jpg
188 KB, 1440x810
>>53637529
also like this, but this would be harder I think
>>
>>53637511
>by dereffing the Rc gives you access to the data itself, not the Rc, which you then rereference with the &. If you did nothing, you'd only have access to the Rc itself which is not what you want.
I think I started to realize that was the case but wasn't entirely sure. Thanks.
>>
>>53637540
I was under the impression that that was kind of the default

plus it would be nice, for simple loops
_loopbegin:
do something
bgzi rx _loopbegin


rather than
loadi ry _loopbegin
_loopbegin:
do something
bgz rx ry

for every loop

saves 1 register, and 1 instruction

(assuming _labels are purely understood by the assembler, and replaced with their locations during assembly)
>>
>>53637471

If Ada isn't the strongest typed language, it'll at least give Coq a run for its money.

>>53637485

Hrm... curious, will this assembly language feature fixed width opcodes, or variable width opcodes?

In any case, it's fairly basic, but will do for a simple ISA. Later, you may consider a standard for handling things like interrupts, some basic semantics for how to handle I/O (via direct memory access, specialized I/O instructions, or a combination of the two), and maybe some instructions for dealing virtual memory and dealing with various privileges.

>>53637529

Would require some machine learning algorithms, and as I'm discovering, that shit just ain't my niche.
>>
>>53635782
While I personally agree with you on your definitions of strong vs weak typing, they are just words and words mean whatever people use them to mean. Unfortunately, "strong typing" and "weak typing" are used so sporadically and inconsistently that their meanings are up to their author.
It's better to limit your vocabulary to "static" vs "dynamic", and to talk about implicit casting, well, explicitly.
>>
>>53637638
currently fixed width opcodes because it's simpler to implement
It is very simple, but only because my knowledge of instruction sets extends to having read the MIPS instruction table on wikipedia, and nothing else

>Later, you may consider a standard for handling things like interrupts, some basic semantics for how to handle I/O (via direct memory access, specialized I/O instructions, or a combination of the two), and maybe some instructions for dealing virtual memory and dealing with various privileges.
that seems more like OS stuff
wouldn't it be better for a (theoretical) OS to implement these as part of some big library, and when you want to do any of those things, just call a function? I don't know anything about operating systems either desu
>>
>>53635782
>Strong typing more or less means types are not readily converted between each other.
Not so. Even lossy conversions like float to integer and object to string can be strongly typed.

Strong typing means that types are defined by their operations, which provide an abstraction over the implementation. Weak typing means that the same values can be interpreted in different ways (type punning).

Look at C and most assembly languages, which are weakly typed languages. The same value (sequence of bytes) could mean false, 0, the null pointer, or the empty list (another interpretation of null), depending on how it is interpreted. Similar ideas are found in set theory and untyped lambda calculus.

Strongly typed languages may define 0, false, and empty list as distinct values. Then any "punning" from integer to list would be undefined because no integer is equal to any list.

You shouldn't think of + as being different from any other function. Some languages let you overload it so you can write
"6" + 7
just like you can write
add("6", 7)
. There is no weak typing or conversions present here. This is no different than having a function called add in the standard library.
>>
Learning Vulkan.
>>
File: terrifying.gif (3 MB, 230x173) Image search: [Google]
terrifying.gif
3 MB, 230x173
>>53637461
Yeah, I figured that out 20 minutes ago. Thanks for the effort, though.

>>53637406
I forgot to edit that. Was hastily c+p'd and it ended up there.

>>53637129
glad i could provide entertainment

Anyway, is it worth the time to do this:

      System.out.printf("%-10s %d %n%-10s $%,.2f %n%-10s %d %n%-10s %.1f %n", "Account#:", constr_1.getAccountNumber(),
"Loan:", constr_1.getLoanAmount(),
"Years:", constr_1.getLoanPeriod(),
"Rate:", constr_1.getAnnualInterestRate());


instead of:

      System.out.printf("Account#: " + constr_1.getAccountNumber() + "\n" +
"Loan: " + String.format("$%,.2f",constr_1.getLoanAmount()) + "\n" +
"Years: " + constr_1.getLoanPeriod() + "\n" +
"Rate: " + constr_1.getAnnualInterestRate());


?

I don't think it is, imo. But I can see for scenarios where there are lots of lines of strings that need to have the same spacing that this could be useful in.
>>
>>53637746
Or using '+ operator as data as well, like in Lisp or Scheme
>>
>>53637657

There is a reason I have noted that there is a bit of a spectrum with strong and weak typing. They are, as you suggest, rather subjective, although with some languages, whether they fit within the category of "strong" or "weak" is often well understood, even if not objective. For this, I gave the most extreme examples. No one would ever argue that Ada is not strongly typed, or that JavaScript is not weakly typed.

>>53637703

>having read the MIPS instruction table on wikipedia

Have a more complete manual
https://imagination-technologies-cloudfront-assets.s3.amazonaws.com/documentation/MD00087-2B-MIPS64BIS-AFP-06.04.pdf

>that seems more like OS stuff
That's instructions and semantics that an OS is going to need to have if it wants to be implemented on your architecture

>and when do you want to do any of those things
This might take another post...
>>
>>53637794
that second one's supposed to be println instead of printf
>>
>>53637133

So just a little history lesson into MinGW.

https://en.wikipedia.org/wiki/MinGW

>In 2005, MinGW-w64, was created by OneVision Software under clean room design principles, since the original MinGW project was not prompt on updating its code base, including the inclusion of several key new APIs and the much needed 64-bit support. In 2008, OneVision then donated the code to Kai Tietz, one of its lead developers, under the condition that it remain open source. It was first submitted to the original MinGW project, but refused under suspicion of using non-public or proprietary information. For many reasons, the lead developer and co-founder of the MinGW-w64 project, Kai Tietz, decided not to attempt further cooperation with MinGW.

>MinGW-w64 provides a more complete Win32 API implementation

And etc.

Usually, forks aren't better than the original but in this case, it is because of all the improvements that make life much easier. It has a retard-proof installer which you should have no problems with. I've had plenty of problems with the original MinGW project though.

https://sourceforge.net/projects/mingw-w64/

If you want something command line based and want Clang to work alongside MinGW-w64 without all the trouble of doing it yourself (which it is), use MSYS2.

https://msys2.github.io/
>>
File: coq.png (32 KB, 549x635) Image search: [Google]
coq.png
32 KB, 549x635
>>53637638
>If Ada isn't the strongest typed language, it'll at least give Coq a run for its money.
doubtful, Coq is all one big type system, basically
>>53637746
>Not so. Even lossy conversions like float to integer and object to string can be strongly typed.
yeah, this is correct. in dependently typed languages you can encode this behaviour pretty trivially. for example, Idris has support for strongly typed implicit coercions http://docs.idris-lang.org/en/latest/tutorial/miscellany.html#implicit-conversions. Coq and Agda can probably express this without any extra language features.
strong vs. weak typing is how thoroughly it's checked by the compiler. so in C, it's just ignoring the fact that they're different types while with Idris's implicit conversions it's going to very specifically type check that part of your code according to the strongly typed conversion you've defined.
>>
Okay, reasons for extending your ISA...

First off, if you want to have any sort of programs at all, you need a system of handling I/O. The simplest way of doing this is by using memory mapped I/O. Basically, you take a section of your address space and have your memory controller trap those addresses, so that a write to it isn't sent to RAM, but rather, sent to some other device (for your simulator, you might say, let the buffer from 0x1000 to 0x2000 be sent to your console device). An alternative to this is explicit I/O instructions. As an example, x86 has the IN and OUT instructions for dealing with ports. It can also typically use interrupts to handle basic disk I/O if it is still operating in real mode.

Beyond that, the "OS specific" stuff, is actually what your ISA is providing so that operating systems can be developed on it. This would take a lot more time, but is useful if you want a more feature complete ISA. Idea is that we would like to have a rather feature complete ISA that can do things like talking to network devices, disks, etc... but we don't want user processes to flub everything up. So we introduce a couple of privilege modes. The operating system handles everything at the most privileged level, and handles any actual writes to these devices, and the user processes sit at a less privileged level, causing a protection fault if they try and do anything stupid. If they want to do anything like writing to the filesystem, send messages to other processes, or print crap to the console, they execute what is called a syscall instruction (or an interrupt in some ISAs), and the OS determines from its parameters what to do.
>>
>>53637829

Mate, I've been using MinGW for a few years. I know about MSYS2. I've been meaning to switch over to it, but that would involve getting rid of my current set up, fucking with my %PATH% values, and a few other things. Nonetheless, the version of MinGW-w64 that I am using is fairly stupid simple to work with.
>>
File: not_today.webm (1 MB, 720x404) Image search: [Google]
not_today.webm
1 MB, 720x404
Ask your much beloved programming literate anything (IAMA).

>>53635782
>But this is not:
>x = "6"
>y = x + 7
Operator overloading is not weak typing at all. Weak typing is when you can break the soundness of the type system.

For example

char b[4] = {'a','b','c','d'};
float *f = b;


is weak typing because the contract that *f is a float, that f is a pointer to float, is broken.
>>
If I know C, should Assembly be easy to learn effectively?

>inb4 portable assembly funny haha joke
>>
File: 1428149537051.png (96 KB, 612x727) Image search: [Google]
1428149537051.png
96 KB, 612x727
>>53638152
assembly is easy (just a set of instructions) but programming in assembly is tedious and should be avoided at any cost.
>>
Is there an idiomatic way of implementing the 'interfaces' concept from OOP in C?
I'm thinking header files, and swapping out the c file underneath, but that's probably wrong, huh? And it's only compile time.

The context is that I have a program that's supposed to be hitting up an i2c bus, but during unit testing and stuff I'd prefer it to be reading and writing two different text files.
>>
>>53638288
>>53638240
I don't know dude, maybe you made a mistake somewhere that isn't here?
>>
Im really stupid sometimes

before
System.out.println(shape3.toString()+"\nPerimeter: "+shape3.getPerimeter()+shape3.getArea());

after
System.out.println(shape3.toString()+"\nPerimeter: "+shape3.getPerimeter()+"\nArea: "+shape3.getArea());
>>
>>53638165
Read this comic like the weeblord I am and didn't even notice I was doing it wrong.
>>
>>53633742
>>53633819

int atoi(const char a){

return a-48;
}
>>
how do i increment x just for display purposes, i dont want to actually increment it.

System.out.println("Enter the length of side "+x);
>>
>>53638496
or java increment x without incrementing value
>>
>>53638496
(x + 1)

it might be time to step away from the keyboard
>>
File: kirino2.jpg (248 KB, 2337x1694) Image search: [Google]
kirino2.jpg
248 KB, 2337x1694
>>53638496
System.out.println("Enter the length of side "+(x+1));

My little anon can't be this stupid.
>>
>>53638539
huh i thought i did that. or i actually did (++x), but it didnt work
>>
>string received from servlet via httpurlconnection is behaving as an empty string when i try to do anything with it, but i can print out every character it's supposed to contain using charAt()

What the fuck? Any Java/Android wizards know what might be wrong here? I'm not sure how this is possible..
>>
>>53634585
not OP but I was gonna implement this (for fun) in a similar way but i think the way you implemented it works under the assumption that each number can only be a single digit, which I feel like is an invalid assumption. Otherwise, very clean code there.
>>
>>53638563
you probably did
"String" + x + 1

which won't work. You need the parenthesis
>>
File: Capture.png (7 KB, 732x184) Image search: [Google]
Capture.png
7 KB, 732x184
Do this for me
>>
>>53638586
buy an unreal engine licence
>>
>>53638592
Unreal is free now senpai.
>>
>>53638575
>>53634585
nvm, I realize that the regex takes care of multiple digits per number. Good work
>>
Date date = new Date();
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss a");

System.out.println(dateFormat.format(date.getTime()));

if (dateFormat.format(date.getTime()).contains("2016/03/23")) {
System.out.println("Happy Birthday to me");
}


I was just working on this.
>>
I'm still a noob but I come from a C background. I'm starting to learn java and the string/variable concatenation with the + operator just triggers me and seems really wrong. Any of you more experienced programmers have any grievances with this for some legitimate reasons?
>>
>>53638586
I'll do it for 10 bucks
>>
>>53638627
k ill mail u 10 bucks, give me your address
>>
Someone help me start with the square, itll be easy/fun

case's':
System.out.println("Enter side length ");
int userIn5 = scan.nextInt();
int[] sides4 ={userIn5,userIn5,userIn5,userIn5};

Square shape4 = new Square(4,sides4,userIn5,userIn5);
System.out.println(shape4.toString()+"\nPerimeter: "+shape4.getPerimeter()+"\nArea: "+shape4.getArea());
for(int j: )
System.out.println("*");
break;
>>
>>53638638
Nah chill I only take paypal
>>
File: 1445120682610.png (78 KB, 249x250) Image search: [Google]
1445120682610.png
78 KB, 249x250
What's the most widely used AI library nowadays?
>>
>>53638615
hpy bd anon
>>
>>53638693
thx
>>
>>53638374
Are you stupid?
You have to convert the whole string into a number.
>>
What percentage of programmers cannot implement FizzBuzz/BizzBuzz/etc.?
>>
So if I want to only do a task when a new entry has been made to a SQLite database, should I hash the database and compare the hashes or requery it and check for changes? Assuming the database is sub-1MB and only uses one table. I'm thinking hashing will be slower but I've got no idea. Using Python (I know) so the change callback isn't an option.
>>
>>53638829
divide the total number of webdev and crud developers by the total population of the programming workforce

there you go
>>
File: 2000px-FFmpeg_icon.svg.png (401 KB, 2000x2000) Image search: [Google]
2000px-FFmpeg_icon.svg.png
401 KB, 2000x2000
I'm writing a piece of software that needs to be able to decode arbitrary audio formats and encode Opus and MP3 audio. Though simply calling ffmpeg using exec, using the stdin/stdout feature, would be the simplest, I'm wary of doing this. However, the C API behind ffmpeg (libav*) is pretty messy and poorly-documented, and I haven't been able to get a working solution for what I need to do.

What's my best bet? Is it okay to use exec in this way? Will it be significantly slower than if I were using the C API directly?
>>
>>53638860
Hey, programmers shouldn't be expected to be able to do that kind of abstract algebra. Who actually uses modulus anyways?
>>
>>53638920
why can't you look at the source code for ffmpeg and use the same libav calls they use?
>>
>>53638926
kek
>>
>>53638926
You need considerable amounts of math in order to do anything even remotely fun or substantial.

I know you're being facetious, but being a dumb CRUD developer drone is truly no better than being a janitor.
>>
>>53638937
The main reason is that the command-line tool is generalized to audio and video streams, and extracting the relevant code is hairy (ffmpeg.c alone is almost 4500 LOC).
>>
>>53638951
>trying this hard to feel superior to someone
>anyone
>please
>i have self worth
>>
>>53638957
just do it
write your own self-contained programs rather than shit that relies on not only libav, but ffmpeg as well
btw, if your file operations take less time than the overhead provided by spawning a new process, then exec is going to slow you down considerrably
>>
File: preface.png (233 KB, 1366x768) Image search: [Google]
preface.png
233 KB, 1366x768
Hey DPT, I'm making a programming manual. This is what I've got for a preface so far. Any thoughts?

>>53638926

FizzBuzz does not need abstract algebra, or the modulus operator. You can implement it with just a loop, a few if statements, addition, and reassignment of variables. Instead of checking if a number modulo 3 or 5 is 0, you instead reset a counter to 0 if it is equal to 2 or 4. A moron with only a week or so of experience writing JavaScript could implement that.

If you can't do FizzBuzz, it shows you are incapable of basic problem solving, and are unfit for the job of programming.
>>
After years of programming in Java (mostly shitty J2ME/Android games) I wanted to learn a new, promising language. Which one has future?
>>
>>53639036
C
>>
>>53633479
You need medical help.
>>
>>53639064
Prostate exams are important after all!
>>
>>53639038
I know the basics of C. Is it really a modern language which will give me money some day?
>>
>>53639162
If you want money I see a lot of .NET, Java, and web related technologies. It really depends on where you live.
>>
>>53638999
>foodsteps

wat
>>
>>53639162
Not that guy.

C/C++ will pretty much never not be relevant unless someone manages to iterate further on C and keep the speed it has. I hear Go is the next big thing for serverside but it looks fugly as all hell. Python is my favorite language for smaller scripting and is deceptively powerful but slower when you're doing any heavy math.

If you're a kool kid do Clojure or something.
>>
>>53638999
Your preface reads like a skiddie hacking tutorial.
Also, unless you provide some of your actual programming tutorial pages, I can't form a worthwhile opinion on your writing.
>>
Let's say i'm a big shot freelancer developer in my third world country. I made this awesome app that sold gorillions throughout the world and now i'm rich. Being rich, i wish to leave this shit hole of a country.

Would it be possible to be a canadian citizen? Considering i will not be directly joining the work force as a freelancer.
>>
>>53639236
Thanks. Is there a place where I can compare shitload of different languages such as Ruby, Haskell and others I don't give a shit about?
>>
>>53638999
>1366x768
>>
>>53633479
Anyone here have any experience with Javascript? Can you turn this into a bookmarklet compatible string?

var suffix = window.location.pathname;
window.location.replace("https://archive.li" + suffix)


I know fuck all js.
>>
>>53639322
Syntax wise? I'd say just wikipedia them. Performance wise? https://attractivechaos.github.io/plb/ looks good but overall I generally class languages in compiled (usually very fast) vs interpreted (slower but not necessarily slow). They all also have strong and weak points for computation so it's better to evaluate based on case rather than overall, especially for interpreted languages.
>>
How hard is it to write simple JS userscripts if I only know C?

I just want to autoplay gifs on 4chan.
>>
>>53639212
Goddammit, it's a typo.

>>53639240
I haven't implemented the programming sections yet. I'm writing this damn thing from start to finish in order, and the preface exists solely to put everything into context. I was just curious to hear what people's opinions on it were so far.

The idea is going to be to teach programming through C, and to show all of the ways for the programmer to fuck things up while doing so. I also intend to introduce some basic concepts of computer architecture along the way so programmers can walk into other languages with a frame of reference for how everything works.

I am curious, what parts most remind you most of a "skiddie hacking tutorial"?

>>53639338

I get it, my display sucks. I could have paid more for a better one, but I valued a graphics card more than I valued a decent resolution.
>>
>>53639367
I meant future-potential wise, I think Wikipedia can't tell me that
>>
>>53638999
retarded. the rust programming language is both low level and safe. C is obsolete and disappearing
>>
>>53639404
That's a very hard question with no solid answers. The languages that have the best future prospects are the ones that have been around the longest. The rest is just speculation. I personally think Go will kill Node for serverside but I only think that because Node is a fucking disaster whereas Go is just very ugly and childproofed. Ruby is apparently already taking a turn for the worse market-share wise and I know nothing about Rust besides that it looks very incredibly powerful but too low-level for plebs. In regards to other applications such as mobile or regular PC software, just pick something. Mobile seems to be tending towards webapps that auto-format and have native capabilities though weird frameworks but I honestly don't know enough about it to say for sure.

Do a lot of googling.
>>
>>53639446
Rust is slowly dying and tearing itself apart through infighting and sjw bikeshedding
Go never even had a chance.
It's ugly as hell and excels at nothing.
Not even google uses it, and they fucking wrote it.
That's how much faith google has in their own language.
>>
>>53639446
The day C disappears is the day someone makes an objectively faster alternative to C and all existing legacy C software is rewritten to this magical new language.
>>
>>53639483
>excels at nothing
It excels at being pretty fast and sufficiently "easy" that idiots can't break it too badly. I give it credit where credit is due.
>>
>>53639498
>I don't know what I'm talking about - the post
C isn't fast, the implementations are.
>>
>>53639530
when talking about C, you also talk about it's implementations
C is just a specification
>>
File: 1457241187940.jpg (126 KB, 666x728) Image search: [Google]
1457241187940.jpg
126 KB, 666x728
>>53639530
>titling your post with greentext
>>
>>53639384

JS is piss easy to learn overnight if you already know any other programming language, especially C.

>>53639446

The point isn't simply to teach low level code. The point is to teach low level code through a lens that shows the myriad of ways in which mistakes can be made in doing so, and the precautions one must make in doing so. To effectively teach this in Rust would require extensive use of unsafe blocks, which is not idiomatic Rust. Moreover, it is my desire to use a bottom up approach with abstraction. C provides a minimal level of abstraction. Further languages may learned from a lens of asking "well, what does an equivalent C program do here?" and "how does this abstraction allow me to avoid the mistakes of prior generations?"

Also, hate to break it to you, but neither C nor C++ are disappearing. No one is going to rewrite Nginx or CPython in Rust any time soon.
>>
Doom source code saves the day again.
Was trying to make menus as simple as possible code-wise and fucked up by overthinking.
>>
File: 1458546951680.jpg (47 KB, 474x479) Image search: [Google]
1458546951680.jpg
47 KB, 474x479
>>53639530
C in inherently faster than most other languages in most situations.
>>
File: 1452440181424.png (395 KB, 575x429) Image search: [Google]
1452440181424.png
395 KB, 575x429
>java

not gonna lie, was my first too, but those were the times back when i was playing fucking "Run-Escape from java cancer".

my reasons for quitting it back then was the graphics limitations and performance.


Now only performance since i don't really do 2D/3D shit

Not to mention the code looks disgusting for me now, literally nested turds
>>
Just finished a big chunk of work on the parser for my C compiler. Now it can parse almost all expressions (still haven't done compound initialisers and a few other things). Here's a simple example:

978 ^ ((3 >> 4) * 23) & 23 - 32


results in:

AST_BIT_XOR(AST_INT_LITERAL(978), AST_BIT_AND(AST_MULTIPLY(AST_RIGHT_SHIFT(AST_INT_LITERAL(3), AST_INT_LITERAL(4)), AST_INT_LITERAL(23)), AST_MINUS(AST_INT_LITERAL(23), AST_INT_LITERAL(32))))

Yes, this format is butt-ugly, I just wrote it up quickly to make sure the parser was working.
>>
>>53639483
https://golang.org/doc/faq#Is_Google_using_go_internally
>>
>>53639483
>Rust is slowly dying and tearing itself apart through infighting and sjw bikeshedding
mozilla next engine is written in rust, dropbox is moving to rust, janestreet is also interested in rust (janestreet is the reason ocaml is still alive), rustc's git has more activity than gcc's git, but, yeah, it's totally dying.

>>53639498
>an objectively faster alternative to C
performances wise, rust is already catching c.

>>53639552
which is totally retarded for learning programming. programming is not about writing code for a specific machine, it's about abstraction, engineering, problems solving,... things at which C is really bad.

>To effectively teach this in Rust would require extensive use of unsafe blocks, which is not idiomatic Rust.
separating unsafe code from safe code is one of the main purpose of rust. using unsafe blocks when it's needed is idiomatic.
>>
>>53637485
finally got around to finishing it
$ < foo.vma ./vm2 -a -r       
[loadi, 0, 7, 0]
[7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[loadi, 1, 2, 0]
[7, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0]
[mul, 0, 0, 1]
[14, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0]

and it works
it's a combined assembler and vm (-a = assemble, -r = run)
>>
>>53639777
Could you be any more of a shill?
>>
>>53639777
>programming is not about writing code for a specific machine, it's about abstraction, engineering, problems solving
Regardless of how much people like to pretend otherwise, at the end of the day your code needs to be executed on actual hardware. Closing your eyes, putting your fingers in your ears and using ever more abstract languages won't make it go away.

Sure, you don't have to care about it 100% of time time, but people ignoring it wholesale is why most software today is so fucking slow and memory-intensive.
>>
>>53639777

>programming is not about writing code for a specific machine

I'm not teaching any specific machine. The book focuses on computer architecture in general, but does not focus on any particular instruction set or OS platform.

And while it is true that programming is about abstraction, it is important to understand what that abstraction actually means. People don't write code for arbitrary Turing Machines. In fact, there isn't a single real Turing Machine in existence because infinite tape is not a thing that can exist. What we are programming for is computers that follow a Von Neumann architecture. A CPU, memory, and some associated I/O devices. Ignoring the reality of what we are programming for is not a healthy mindset for a programmer. Abstractions are tools, but you still need to see the bigger picture.
>>
>>53638691
Anyone?
>>
>>53639898
AI is a big field. Can you be more specific?
>>
>>53639871
>there isn't a single real Turing Machine in existence
Sure there are. There just isn't a universal Turing Machine.
>infinite tape
A program that requires infinite tape will not halt. I think you mean unbounded tape.

That's enough of me being pedantic.
>>
>>53639836
sure, that's why everyone is still programming in C, amiright ?

>>53639871
c's types being machine types, you can not write safe low level code without involving any details from the targeted machine. that's why any low level code written in C is an unreadable mess. you don't even know what you are talking about.
>>
>>53639931
>sure, that's why everyone is still programming in C, amiright ?
C still finds lots of use.

>any low level code written in C is an unreadable mess
>I can't read C
>Therefore nobody can read C
Good one, idiot.
>>
>>53639795
I also changed my branching instructions slightly
I'll let it speak for itself
loadi    r0 6 ; base
loadi r1 3 ; exp
loadi r2 1 ; ans

beginloop:
mul r2 r2 r0
dec r1
gti r3 r1 0 ; set r3 to r1 > 0 ? 1 : 0
bri r3 beginloop ; go to beginloop if the value in r3 is nonzero


I feel like this is more flexible
gti    r3 r1 0
lti r4 r1 100
and r3 r3 r4
bri r3 wherever ; go to wherever if r1 is in (0, 100)


now to try some functional shit
>>
>>53639945
>C still finds lots of use.
In enterprise, everyone who could move away from C dit it, Google even made its own programming language to do that. the truth is that C is a programming language for the programming techniques of the past, it's a programming language that has been made to specifically program the shittiest computer of its era (PDP).

The story of C:
CPL is a great programming language but too big for my crappy computer, let's rip it to a new pl named BCPL (Richards)
BCPL is a shit programming language and still too big for my crappy computer, let's rip it to a new pl named B (Thompson)
B is a even more shit and still too big for my super crappy computer (PDP), let's rip it to a new pl named C (Ritchie)

Seriously, C is a shame to any programming language theorist and you guys are a disgrace.
>>
>le C is not used in the industry meme
>>
>>53640033
>C is a shame to any programming language theorist
>programming language theorist
>programming language
>theorist
Found your problem.
>>
>>53640033
>"I just did my first Haskell paper at university": the post
Thread replies: 255
Thread images: 36

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.