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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 331
Thread images: 34

File: 1480956343871.jpg (675KB, 940x822px)
1480956343871.jpg
675KB, 940x822px
What are you working on, /g/?
Old thread: >>58430378
>>
Functional
Programming
Best
Paradigm
>>
Fuck you for using an anime image
>>
>>58437763
>weakly typed OSs were a mistake
And yet somehow they won the market.

Such is cruel fate.
>>
>>58437790
>everything is strings
T. modern OS design
>>
File: 1482737841187.png (786KB, 1000x1300px) Image search: [Google]
1482737841187.png
786KB, 1000x1300px
>>58437777
quads don't lie
>>
>>58437777
First
Post
Best
Post
>>
>>58437777

This will never change
>>
File: tmp_2314-cc0Myey1232324639.jpg (51KB, 907x718px) Image search: [Google]
tmp_2314-cc0Myey1232324639.jpg
51KB, 907x718px
>>58437778
>not liking anime on a website made specifically to talk about anime
>>
File: attachment.jpg (362KB, 1280x720px) Image search: [Google]
attachment.jpg
362KB, 1280x720px
I am currently working on a pearl counter for the iPad of one of my bosses
>>
>Weakly typed OSs
This has literally no meaning.

In any case, the poster who claimed that .vimrc is not a valid filename in Windows is wrong.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

Windows may have some odd quirks, but requiring files to match the standard filename.extension format is not among them. Filenames are allowed to begin with periods .likethis, are allowed to have no periods at all like_this, and may have multiple periods .like.this

If filenames beginning with periods were not allowed, Git would not work on Windows at all, as all of the files associated with the repository are stored within a folder called .git
>>
working on a template class on php. nothing special really. just trying to replicate what i used (like smarty, raintpl and such) and make it as flexible as i can. i'm probably gonna port it to javascript when i can. i fucking hate all the js template engines i saw so wish me luck.
>>
File: 1459926416792.jpg (25KB, 263x263px) Image search: [Google]
1459926416792.jpg
25KB, 263x263px
>>58437854
>This has literally no meaning.
>>
>>58437860

Weak and strong typing are terms that can be applied to programming languages, not operating systems.
>>
>>58437886
It applies to anything with different kinds of values.
>>
>>58437860
>>58437886
>>58437915
You can't have "strongly typed" systems since files are just collections of bytes. You can't enforce an interpretation on all programs that read them. And if you do, you have a useless mess and not an operating system.
>>
>>58437931
>files are just collections of bytes
in a weakly typed system
>>
>>58437931
Types are specifications, not interpretations.
>>
>>58437778
At least you gave up wrapping it in code blocks, Rajesh.
>>
>>58437973
>>58437994
How would it make sense to prevent programs from writing arbitrary bytes to disk? And what purpose would it serve?
>>
>>58437853
>pearl counter
>not selling it as "anal bead counter" on apple app store
Countless apple users (aka: faggots) are dying to throw money at you so they could count anal beads before and after they put them up their asses.
>>
>>58438013
You don't. You just can't write arbitrary bytes and say that it's a certain type of file.
>>
>>58438013
bytes[]
could be its own file type
>>
I'm learning Ruby.

I'm actually starting to like it.

(I actually need it for my job. No, it's not webdev stuff.)
>>
>>58437854
>>58437886
>>58437931
>>58438013

And secondary and primary memory aren't that different.
An OS is a piece of software too, it is a program (that has sub-programs).
So the same things that apply to the programs you'd write, make even more sense when it comes to OSs.
>>
>>58438106
>No, it's not webdev stuff.
What is it then?
>>
>>58438138
it'd be ruby on rails if it was webdev stuff. but since he's learning plain ruby, i'm guessing it's for something else.
>>
File: 1484153144371.jpg (78KB, 500x281px) Image search: [Google]
1484153144371.jpg
78KB, 500x281px
You guys don't program all day do you?

what other hobbies do you have?
>>
>>58438138
Prototyping, system customization (shellscripts proved to be too limited), GUI stuff and so on. We also use C for certain tasks.

It's a Linux-only shop, not even Macs in sight.
>>
>>58438240

dota 2
>>
>>58438240

watching football
playing football manager
>>
>>58438240
electronics, math, going out and drinking on Fridays
>>
This thread is pathetic. It is not about programming. It's just a bunch of computers illiterates and first semesters memeing about whatever they just learned.

A quick search shows that most arguments used here are not original and have been copied from some trendy tech blog or other shit site.

The only real programming questions I have seen so far are from beginners(it's fine to be a beginner btw).

This entire site is shit and I don't know why anyone would regularly come here.
>>
File: regurgitate unmerited hype.png (10KB, 755x86px) Image search: [Google]
regurgitate unmerited hype.png
10KB, 755x86px
What did he mean by this?
>>
>Programming tutorial starts
>Narrator has Indian accent
>>
>>58438350
where do you go then?
>>
File: 1483996513582.jpg (204KB, 576x768px) Image search: [Google]
1483996513582.jpg
204KB, 576x768px
>>58438350
Not an argument
>>
>>58438362
see >>58437777
>>
>>58438362
Why would you edit that (You) in there? I made the post he replied to.
>>
>>58438240
video games
masturbation
cooking
>>
>>58438240

When I'm not programming or doing some other busywork, I'm typically either playing vidya or shitposting.
>>
>>58437778
why you gotta incite violence
>>
>>58438405
What the fuck? This just happened, there's no great meme for you to take credit for. Why would you even pretend to be me?
>>
File: maki-pepe.png (122KB, 640x890px) Image search: [Google]
maki-pepe.png
122KB, 640x890px
>>58438365
>not reading a book
>>
>>58438366
To your moms house.

>>58438367
Your mom didn't think so.


KEK GET REKT NERDS
>>
>>58438607
>reading books
>>
>>58438607
Maki is not a pepe
>>
>>58438625
>learning from videos
Enjoy being an incompetent wagecuck.
>>
>>58438640
>unemployed hobbyist trying to lecture highly paid professionals
>>
File: FatPepe.jpg (274KB, 1500x1000px) Image search: [Google]
FatPepe.jpg
274KB, 1500x1000px
>>58438664
>highly paid professional
>trying to learn programming from a youtube video
>>
>>58438686
Your pepe is a nerd.

MOM
>>
>>58438703
>dismissing because of a source and not of the contents
>implying im that youtube video guy
>>
>>58438686
Pepe is shit
Maki is not
therefore maki is not pepe
>>
File: IsisAirStrikePepe.png (463KB, 1200x975px) Image search: [Google]
IsisAirStrikePepe.png
463KB, 1200x975px
>>58438720
>dismissing because of a source and not of the contents
>implying there is high quality material on video

>implying im that youtube video guy
You are. Your damage control have no power here. Pic related, me on the left.
>>
File: ready_to_kill.png (176KB, 560x530px) Image search: [Google]
ready_to_kill.png
176KB, 560x530px
>>58438749
YOUR MAKI IS A SLUT

>>58438763
apologize
>>
>>58438804
YOUR SLUT IS NOT EVEN MAKI
>>
Java is pure.
>>
File: RLMS.gif (737KB, 700x393px) Image search: [Google]
RLMS.gif
737KB, 700x393px
>>58438826
BUT YOU MOM IS A SLUT

MAKI

>>58438844
pure shit
>>
>>58438844
Pure shit.
>>
>>58438844
>Java is pure shit.
ftfy
>>
>>58438855
>>58438860
>>58438861
java isn't pure shit
java is dirty shit
>>
>>58438855
EVERYONE CAN BE ANYONE SO WHY NOT FOLLOW YOUR DREAM AND BECOME A FAGGOT
>>
File: GayPepe.jpg (12KB, 225x225px) Image search: [Google]
GayPepe.jpg
12KB, 225x225px
>>58438888
BECAUSE I'M NOT YOUR DAD

REKT
>>
>>58438888
That's not true
>>
File: FeministPepe.jpg (45KB, 680x689px) Image search: [Google]
FeministPepe.jpg
45KB, 680x689px
>>58438917
I'm triggered. Apologize.
>>
File: bowden.jpg (6KB, 198x255px) Image search: [Google]
bowden.jpg
6KB, 198x255px
>>58438933
no
>>
% or .format?
>>
>>58438993
>%

ewwww
>>
>>58438993
If we're talking about this for python, whichever one isn't """pythonic"""
>>
How do you make installer for your project in Visual Studio 2017 community? Cmon, this shit is supposed to be pretty straight forward process...
>>
>>58439022
.format is pythonic as fuck
>>
File: fds.jpg (19KB, 306x306px) Image search: [Google]
fds.jpg
19KB, 306x306px
>People unironically use JavaScript's new classes even though it's just syntactic sugar for prototypes and it still requires you to use the problematic 'this' keyword.

Why do people insist on using shitty parts of a language?
>>
>>58439351
How is "this" problematic? I've never programmed in js but picked it up eventually and understanding how it works took me maybe an hour.
>>
>>58439351
People are so indoctrinated they can't imagine programming without classes even if they have something equivalent.
>>
>>58439351
>People unironically use JavaScript
Get the fuck out of here you stupid fucking frogposter >>>/g/wdg/
>>
is python the most intuitive language?
>>
>>58439560
There is no such thing as "the most intuitive" language without lots of context.
>>
>>58439032
Depends on the project's type I guess, I used MSI for WPF.
>>
>>58438855
>>58438860
>>58438861
Wrong, Java is the best programing language in existence.
>>
>>58439742
yaasssss, preach it sista!!
>>
>>58439372
Because the value of 'this' isn't always the same, say you add a forEach loop in your constructor, the value of 'this' won't refer to your object so you have to use ugly workarounds like call, bind, and apply.

It's just not worth the hassle, even when you fully understand it, it's something you will keep tripping over. Why use the 'this' keyword when you don't have to? The only instance I can think of is when you're creating like over 10,000 objects and the extra performance you get from prototypes is necessary.
>>
is calculating an index for a 1d array out of an x and y value more efficient than using a 2d array?
>>
>>58439856
What do you think a 2d array does?
>>
>>58439864
x: geht the pointer two the array on this position
y: direct access to the value of said array
>>
>>58439856
I would think it'd be identical either way.
>>
File: Nonogram.png (109KB, 960x1053px) Image search: [Google]
Nonogram.png
109KB, 960x1053px
>>58437759
Started making a Nonogram game.
>>
>>58439884
2D arrays aren't necessarily 2 layers of indirection (jagged arrays). In C or C++ it's equivalent to just using a 1D array.
>>
>>58439926
top meme
>>
File: 1462665702455.png (54KB, 311x311px) Image search: [Google]
1462665702455.png
54KB, 311x311px
>>58439926
>rust
>>
>>58439977
thanks
>>58439991
>implying
>>
>>58440008
>impl {
>>
>>58440029
struct ying;

impl ying {
>>
Why do you think that go is bad?
>>
>>58440053
The abstraction facilities of C with the memory management facilities of Java.
>>
>>58440053
someone post the copypasta
>>
>>58440061
The fact that so many books still name the Beatles as “the greatest or most significant or most influential” rock band ever only tells you how far rock music still is from becoming a serious art. Jazz critics have long recognized that the greatest jazz musicians of all times are Duke Ellington and John Coltrane, who were not the most famous or richest or best sellers of their times, let alone of all times. Classical critics rank the highly controversial Beethoven over classical musicians who were highly popular in courts around Europe. Rock critics are still blinded by commercial success. The Beatles sold more than anyone else (not true, by the way), therefore they must have been the greatest. Jazz critics grow up listening to a lot of jazz music of the past, classical critics grow up listening to a lot of classical music of the past. Rock critics are often totally ignorant of the rock music of the past, they barely know the best sellers. No wonder they will think that the Beatles did anything worthy of being saved.
>>
>>58440053
- GC.
- No generics.
- Outdated type system.
- No ADT.
- No pattern matching.
- Not enough functional stuff.
- No RAII/IDisposible/Context managers.
- Ugly syntax.
- The most retarded and unsafe error handling story after C.
- Structurally typed interfaces instead of proper interfaces/type classes/traits.
- NIH infrastructure with authors spending years reinventing stuff instead of using LLVM.
- Community comprised of mostly python-kiddies.
Overall the language was designed to be as simple as possible and then even more simple so Google can train code-monkeys on an industrial scale, the only good thing about it being coroutines.

>>58440061
got you senpai, wasn't that hard to find in the archives
>>
File: 1470828515872.jpg (47KB, 474x479px) Image search: [Google]
1470828515872.jpg
47KB, 474x479px
>>58440134
>no anime image
>>
>>58440207
not a weeb so i didnt have any smug anime pic to post along with the pasta for extra points, sorry
>>
File: 1453648836231.png (681KB, 840x720px) Image search: [Google]
1453648836231.png
681KB, 840x720px
>>58440226
>he only has one smug anime girl image
>>
>>58437759
So what's the advantage of learning C over C++, or vice versa
>>
I appreciate all anime posters
>>
>>58440285
zero buddy
>>
>>58440287
C is a simple and concise language with no real feature bloat over it's 45 year history.
Your knowledge will carry over to any modern language.

C++'s biggest mistake was being C compatible, and gets progressively more bloated every 4 years. It's gotten so bad that the creator himself has attempted to redefine a C++ Core language that ignores nearly all C++ features because using all the features is the fastest way to shoot yourself in the foot.
>>
File: 83421.png (14KB, 203x248px) Image search: [Google]
83421.png
14KB, 203x248px
>>58440332
>he only has two smug anime girl images
>>
>>58440384
not saving them bud
post something better those are all shit
>>
How do I put data from a SQL query into a model object when I fetch columns from multiple different tables? Wouldn't that mean I have to create multiple model objects and return all of them inside a wrapper object?
>>
File: 145348924782357.png (670KB, 1252x1010px) Image search: [Google]
145348924782357.png
670KB, 1252x1010px
>>58440409
>>
File: file.png (586KB, 1919x1024px) Image search: [Google]
file.png
586KB, 1919x1024px
JUST
>>
>>58440598
This never would have happened if you had used a good language
>>
>>58440598
so what's happening here then?
>>
>>58440623
like?
>>
>>58440644
Rust :^)
>>
>>58440414
some frameworks let you specify which table each field of your model object comes from and how to join the tables. some frameworks wont, you'd have to read the documentation.
>>
>>58440665
>Panics
>Panics if low >= high.

k
>>
What are some important yet vulnerability ridden applications I can use to test my bug hunting abilities?
>>
Torus = Circle2
>>
>>58440707
>Undefined behavior
>Undefined behavior if low >= high

k
>>
>>58440726
flash, java
>>
all errors must be caught and ignored silently
>>
>>58440727
Torus = Circle^2
>>
>>58440728
what's your point?
>>
>>58440734
Forgot to specify in my OP: I'd prefer if the application is Open Source in C like OpenSSL.
>>
>>58440749
Undefined behavior is worse than panicking.

If you want safe index, you can use vec.get(idx)
>>
>>58440772
i never claimed that the way C++ handles it is alright
you've claimed that it wouldn't happen in rust
when in fact it would

and it has nothing to do with vectors
>>
>>58440360
What's a good book to read to learn C?
>>
> get in an argument with guy in class about how slowly he writes code
> say I can learn basic c++ templates and implement a linked list in 30 mins
> takes 40 mins

I'm a disgrace
>>
int independence; // declaration of independence
>>
how the fuck does a bitmask work?
>>
>>58440783
Panicking is not undefined behavior, it only happens when encountering an unrecoverable error, such as index out of bounds.

Vectors are just dynamic arrays, so it also applies to them.
>>
>>58440598
What's going on?
>>
>>58440841
>Panicking is not undefined behavior
thanks man

> it only happens when encountering an unrecoverable error, such as index out of bounds.
> Vectors are just dynamic arrays, so it also applies to them.

you're fucking retarded, how about you stay on the topic if you want to argue anything?
>>
>>58440831
http://rick-hawkins.blogspot.pt/2010/11/bitmasks-how-fuck-do-they-work.html
>>
File: 1483891660679.jpg (38KB, 421x313px) Image search: [Google]
1483891660679.jpg
38KB, 421x313px
just started learning JS while I decide if C or C++
>>
>>58440831
take the integer 1
0 OR 0x7F would be
00000000
01111111 OR
-----------------
01111111
>>
I hate how appealing languages like Rust and Haskell are to spergs. They try to defend it and shill it everywhere they can while not understanding it, so they just embarrass themselves and project a bad image.
>>
>>58440893
>Rust

https://github.com/rust-lang/rust/issues/38869
>>
>>58440922

Looks like a false flag to me.
>>
>>58440812
You're stupid. It's not how fast you can write code. It's about how safe the code you can write.
>>
>>58440922
This has yet to be funny, stop posting it
>>
>>58440982
>It's about how safe the code you can write.
Thank you for the insight Pajeet.
>>
>>58440988
I see that you're in denial.
>>
Learning C and have a question:
How would I use getc after scanf?
>>
>>58440997
About what?
>>
>>58441011
You don't
>>
>>58441011
getc is just a shorthand for fgetc

figure it out, the entire C standard library is in your man pages

type in "man 3 fgetc" in your terminal
>>
>>58441011
>use scanf
>then use getc
I don't get the question
>>
>>58441011
instead of
scanf("%d", &num);

do
scanf("%d\n", &num);

which will also consume the \n character you entered
>>
00000000 00000000 11111111 11111111
is 0xFFFF, right?
>>
You have ten minutes to make a function to convert an integer into roman numeral, or mods will permanently attach non-anime image to your posts.
>>
>>58441052
Why don't you plug it into a binary-hex converter and find out
>>
>>58441052
No, that would be 0xFF
>>
>>58441052
0xFF
>>
>>58441066
who the fuck still uses roman numerals
if you want something like this, you have to pay me
>>
>>58440744
Circle = +/- sqrt(Circle)
>>
>>58441031
About how your a code monkey who produce a lot of bugged code.
>>
>>58441066
took me 30 seconds to google it:

from collections import OrderedDict

def write_roman(num):

roman = OrderedDict()
roman[1000] = "M"
roman[900] = "CM"
roman[500] = "D"
roman[400] = "CD"
roman[100] = "C"
roman[90] = "XC"
roman[50] = "L"
roman[40] = "XL"
roman[10] = "X"
roman[9] = "IX"
roman[5] = "V"
roman[4] = "IV"
roman[1] = "I"

def roman_num(num):
for r in roman.keys():
x, y = divmod(num, r)
yield roman[r] * x
num -= (r * x)
if num > 0:
roman_num(num)
else:
break

return "".join([a for a in roman_num(num)])


white write it myself if i can reuse existing code?
>>
File: roman_numeral.png (15KB, 656x138px) Image search: [Google]
roman_numeral.png
15KB, 656x138px
>>58441091
It's a challenge, to prove you actually have a brain, you know.

Here's my solution, so you will know it's not homework problem.
>>
>>58441070
>>58441074
>>58441075
yes see here >>58441059
my bad
>>
>>58441106
>your
No, that's you, Pajeet. I prove that my code is correct.
>>
>>58441066
Matlab
function str = num2roman(x)
assert(1 <= x && x <= 3999);

numbers = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
letters = {'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'};

str = '';
num = x;
for i=1:numel(numbers)
while (num >= numbers(i))
str = [str letters{i}];
num = num - numbers(i);
end
end
end
>>
>>58441106
That wasn't me...

Anyway, I know it's not about speed. A linked list for a CS162 class is trivial, though, which is why I was giving him shit
>>
>>58441125
I'm not going to look up how to read roman numerals past 10 just to do your homework, retard.
>>
>>58441058
thanks for the answer,
i tried that but it will asks for two inputs in a row instead of printing first
scanf("%d\n", &choice);
printf("input is %d\n", choice);
c = getc(stdin);
>>
>>58441122
>>58441125

does it do
_
M
>>
>>58441137
>I prove that my code is correct.
Let me lol.
>>
what is better?
if foo == true:
function()

or just calling the function with the if block on the whole function like
def function()
if foo == true:
actually_do_the_function
>>
>>58441091
>who the fuck still uses roman numerals
Apple
Square Enix
Rockstar Games
>>
>>58441183
>boolean == true
redundant senpai
>>
>>58441183
If you do the test each time you call the function the second is better. If it depends the first is better. If you call the function only once here, it doesn't matter.
>>
>>58441122
ROMANZ = (
('M', 1000),('CM', 900),
('D', 500),('CD', 400),
('C', 100),('XC', 90),
('L', 50),('XL', 40),
('X', 10),('IX', 9),
('V', 5),('IV', 4),
('I', 1)
)

def toRoman(n):
result = ""
for numeral, integer in ROMANZ:
while n >= integer:
result += numeral
n -= integer
return result
>>
>>58441196
how so?

>>58441216
I'm calling the function several times a second
>>
>>58441245
>how so?
if foo == true:
function()

ITS THE SAME AS
if foo:
function()
>>
>>58441059
Yes, because 00000000 00000000 11111111 11111111 is:

1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 + 1024 + 2048 + 4096 + 8192 + 16384 + 32768 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0


Which is:
65535

Which is:
65535 % 16 = 15
65535 / 16 = 4095

4095 % 16 = 15
4095 / 16 = 255

255 % 16 = 15
255 / 16 = 15

15


Which is:
(0x) FFFF (because 15 = F in hex)
>>
>>58441245
>I'm calling the function several times a second
You didn't read me. Do you do the test each time you call it?
>>
>>58441245
Do the first one then so you don't constantly set up a stack frame only to have to immediately tear it down again
>>
>>58441163
For that, you have to flush the output buffer.

scanf("%d\n", &choice);
printf("input is %d\n", choice);
fflush(stdout);
c = getc(stdin);


When you execute printf the contents are not actually printed immediately, but placed in a buffer. Each call adds to the buffer until the program reaches a point where it decides to flush the buffer (actually send the contents to the terminal and clear it). In cases where you want to control when this happens, you can use fflush or use non-buffered IO functions.
>>
>>58441262
q.e.d
>>
>>58441265
yes
>>
>>58441298
How many times did you write the call? I don 't give a shit about how many times the called is made during run, but how many times you write it in your code.
>>
>>58441330
once
>>
>>58441341
So you don't give a fuck.
>>
>>58441341
First one
>>
>>58441396
don't be so rude
>>
What would be the fastest data structure to search if I had 3 very large sets of (different) words? Hash table?
>>
>>58441494
Trie
>>
>>58441183
NameError: name 'true' is not defined
>>
>>58441494
search in what way? if you mean you have a large set of words and you want to see if a specific word is in the set, yes a hash table will be very fast. many languages have hash sets built in that use an underlying hash table
>>
>>58441066
Install-Package RomanNumeral


RomanNumeral IntToRomanNumeral(int input)
{
return new RomanNumeral(input);
}
>>
How could I improve this?

Input looks always like this:

3
ab d da a
dda a a a
a flsdfffda

cases = int(input()) # how many lines will be scanned for vowels
vowels = "aouiey"
vowelcounter = 0


while (cases != 0):

vowelcounter = 0
a = str(input())
a.split()
for i in a:
if i in vowels:
vowelcounter += 1
cases -= 1
print(vowelcounter, end=' ')
>>
>>58441774

I also wrote it for C

#include <stdio.h>

int main(void) {

char array[1000] = {0};


int N;
printf("how many lines?\n");
scanf("%d ", &N);

int i;
int i2;
int counter[1000] = {0};

for(i2=0; i2<N; i2++) {

memset(&array[0], -1 , sizeof(array));
fgets(array, 1000, stdin);


for(i=0; i<1000; i++) {


if (strchr("aeiouy", array[i]) != NULL) {

counter[i2] = counter[i2] + 1;

}

}

}


for(i=0;i<N;i++){

printf("%d ", counter[i] - 1);
}

return(0);
}
>>
>>58441808
}

}

}

wew lad
>>
>>58441774
>>58441808

vowels s = sum [ 1 | c <- s, c `elem` "aouiey" ]

main = do
cases <- readLn
results <- replicateM cases (vowels <$> getLine)
print results
>>
>>58441774
off the top of my head

>a.split() does nothing here
>instead of "while (cases...)" do "for i in range(0, cases)" and remove case -= 1 junk
>replace input with raw_intput, read the docs to find out why
>>
>>58441868

thanks
>>
File: 134234.jpg (140KB, 425x282px) Image search: [Google]
134234.jpg
140KB, 425x282px
hey /g/, I'm a beginner trying to find a way to write a program in python like this:

I want it to load as in a terminal, kind of like old-school text-adventures. When you run it, it gives you some opening script, and then you can use some basic commands to do things, mainly running python files, and maybe a way to organize the particular directory they're in, as well as launch them in an editor, if I choose. I want to have it as my interface for running web scrapers, and looking at their results.

I tried out the click package, but it doesn't seem to fit my needs. Does anyone here know of a a way to create something like this?
>>
>>58441888
ncurses?
>>
File: 1483930295515.jpg (5KB, 228x221px) Image search: [Google]
1483930295515.jpg
5KB, 228x221px
>>58441888
>When you run it, it gives you some opening script, and then you can use some basic commands to do things, mainly running python files, and maybe a way to organize the particular directory they're in, as well as launch them in an editor, if I choose. I want to have it as my interface for running web scrapers, and looking at their results.
Sounds a lot like bash.
>>
>>58441848

I read a thread on stackoverflow and it says raw_input() was changed to input() in python 3.

input() in python 3 always returns a string while in python 2 it returned a python expression
>>
>>58441940

ops quoted wrong guy
>>
>>58441909
Looks interesting! How much of a learning curve is there?
>>
>>58441888
lmao why are you reimplementing bash
>>
>>58441994
2000%, ncurses is shit use termbox instead
>>
>>58441066
I got it in Java
public static synchronized char[] numToRoman(Integer a){
//TODO: write this
}
>>
How do I see how standard C libraries are implemented in gcc?
>>
>>58442123
You want to look at the glibc source code
>>
>>58442123
glibc is the standard GNU C library.
GCC does not ship its own one.
>>
>>58442123
"the standard c library" by plauger
>>
>>58442151
I really don't think he does...
>>
/loop macro/ master race
>>
>>58442154
Fair point
>>
File: anime23619.gif (1MB, 480x270px) Image search: [Google]
anime23619.gif
1MB, 480x270px
Does anyone else get this icky feeling when talking to webdevs or reading what they post on the internet? Like they actually have absolutely no idea what they're really talking about, just repeating what they heard elsewhere, or faking it until you believe they know anything?

It's that hollow kind of feeling you get when the lights are on but nobody's really inside. It's like a whole culture built on faking actual knowledge and spouting buzzwords to mask it. Surely millions of webdevs around the world can't all be psychopaths... right guys?
>>
>>58442198
How would you know they don;t know what they're talking about unless you too are a web dev?
>>
>>58442198
post in wdg plz
>>
>>58442198
>>>/g/wdg
>>
>>58442211
I tried learning some react.js and javascript and that's my impression after reading some tutorials and articles, and forum posts.

>>58442216
>>58442217
I'm not gonna shit talk them in their faces, come on
>>
>>58442226
typical weeb pussy ass faggot
>>
>>58442245
I'm not a weeb, and there's no point in coming into a thread just to insult people in it
>>
>>58442198
>Does anyone else get this icky feeling when talking to webdevs or reading what they post on the internet? Like they actually have absolutely no idea what they're really talking about, just repeating what they heard elsewhere, or faking it until you believe they know anything?

That's 99% of developers, just take a look at the Java community
>>
>>58442198
I dont get why you would write desktop apps instead of just throwing your application on a server so everyone can access it. non-webdev seems dumb to me
>>
>>58442198
>>58442283
This is true of anyone casual enough to actually be paid to write code they wouldn't otherwise.
>>
>>58442328
You can do some stuff on the desktop that you can't in a web browser still.
>>
File: 1462298075878.jpg (25KB, 355x369px) Image search: [Google]
1462298075878.jpg
25KB, 355x369px
>>58442245
fite me
>>
One of the perks of working on Go these past years has been the chance to have many great discussions with other language designers and implementers, for example about how well various design decisions worked out or the common problems of implementing what look like very different languages (for example both Go and Haskell need some kind of “green threads”, so there are more shared runtime challenges than you might expect). In one such conversation, when I was talking to a group of early Lisp hackers, one of them pointed out that these discussions are basically never dogmatic. Designers and implementers remember working through the good arguments on both sides of a particular decision, and they’re often eager to hear about someone else’s experience with what happens when you make that decision differently. Contrast that kind of discussion with the heated arguments or overly zealous statements you sometimes see from users of the same languages. There’s a real disconnect, possibly because the users don’t have the experience of weighing the arguments on both sides and don’t realize how easily a particular decision might have gone the other way.
>>
>>58442387
Go away
>>
>>58442387
Language design and implementation is engineering. We make decisions using evaluations of costs and benefits or, if we must, using predictions of those based on past experience. I think we have an important responsibility to explain both sides of a particular decision, to make clear that the arguments for an alternate decision are actually good ones that we weighed and balanced, and to avoid the suggestion that particular design decisions approach dogma. I hope the Reddit AMA as well as discussion on golang-nuts or StackOverflow or the Go Forum or at conferences help with that.

But we need help from everyone. Remember that none of the decisions in Go are infallible; they’re just our best attempts at the time we made them, not wisdom received on stone tablets. If someone asks why Go does X instead of Y, please try to present the engineering reasons fairly, including for Y, and avoid argument solely by appeal to authority. It’s too easy to fall into the “well that’s just not how it’s done here” trap. And now that I know about and watch for that trap, I see it in nearly every technical community, although some more than others.
>>
What's the deal with FizzBuzz?
>>
>Error: package ‘nigger’ was built before R 3.0.0: please re-install it


wat do?
>>
>>58442435
It's the only thing that /dpt/ can actually implement.
>>
>>58442435
It's a simple programmer litmus test.
If you've heard of it, you're already better than 99% of college educated programmers.
If you haven't heard of it, and you can't shit out a solution in 20 minutes, you're a literal retard and shouldn't be allowed near a computer.
>>
>>58442435
Know why it's just called FizzBuzz?
because Fizz Buzzed Spazz
>>
>>58442387
>>58442410
And yet what they finally shat out was still Go.
>>
>>58442456
>If you've heard of it, you're already better than 99% of college educated programmers.
i refuse to believe this is true

it's barely more than a hello world
>>
>>58442487
Basically, it tests to see if you can think on your feet.
It tricks you into thinking there's a clean solution for it, but there isn't.
You have to handle 4 cases to produce the correct answer in the most straightforward implementation.
>>
remember that 99,5% of programing job applicants cant program their way out of a wet paper bag
>>
>>58442511
>4 cases

multiple of 3, multiples of 5, multiples of both 3 and 5, what else? 0?
>>
>>58442571
else print number
>>
>>58442571
>multiples of both 3 and 5
You can drop this case if you can handle strings
>>
>>58442571
Why is this even discussed, what the fuck.
>>
>>58442544
exit(1);
>>
>>58442571
>notsureiftrollingorjuststupid.jpg
>>
>>58440874
C++
much easier to learn than C
>>
>>58442623

I always thought C++ is just C with extra stuff
>>
>>58442623
>>58442633
C++ is a bloated, poorly designed clusterfuck.
Don't use it for any purpose.
>>
>>58442617
>>58442603
>>58442592
>>58442583
nvm, i forgot you have to print normal numbers if they're not divisible by either

at any rate i fail to see how it's possible to graduate from a university and fail to do it
>>
>>58442650
You just failed to do it. Have you graduated from a university?
>>
>>58442662
i did not fail, i just thought you only have to print fizz, buzz, and fizzbuzz, and skip other numbers, but then looked up the full instructions
>>
>>58440207
>ohio
>>
>>58442571
rate my fizzbuzz :3
#include <stdio.h>

main(){
int i=1;
do
{
if ( !(i%3) || !(i%5) ){
if (!(i%3)) printf("Fizz");
if (!(i%5)) printf("Buzz");
putchar('\n');
}else printf("%d\n",i);
}while(i++<100);
}
>>
>>58442387
Go is one of the most poorly technically conceived langugaes I can think of in recent memory. I mean.. in proportion to the amount of resources that went behind it..

One of the biggest questions they really should have asked themselves before making Go was:
>why?
>>
>>58442722
>implicit int
>No indentation
>do while instead of for
2/10
>>
>>58440949
>Looks like a false flag to me.
Spoilers: It is.
https://users.rust-lang.org/t/how-do-we-combat-the-apparent-culture-of-racism-and-sexism-in-rust/8754
Compare the usernames. This guy has no idea how to shitpost and get away with it.
>>
File: dont touch.png (355KB, 555x770px) Image search: [Google]
dont touch.png
355KB, 555x770px
>>58442745
They already explained why, it's for google recruits who are too stupid for systems programming.

So they just made a neutered C with none of the benefits.
>systems language with no pointer arithmetic
>>
File: 1483730818833.png (160KB, 373x345px) Image search: [Google]
1483730818833.png
160KB, 373x345px
>>58442696
So you got it right, then?
>>
>>58442774
>Garbage collected
You cannot call Go a "systems language" in any sense.
>>
>>58442774
I don't think they're so clueless that they intended Go to be a systems language, and I doubt they attempt to use it that way.
>>
>>58442774
Exactly. Like.. they should have had a *good* answer to that question.

If that was really their genuine answer to "why go?", then I guess Go was just a big troll langugae the whole time.
>>
>>58442754
>implicit int
Why do you need floats?
>>
I want to take essentially a bitmap and do an affine transformation to make fake perspective. I do this in the web browser with canvas:

https://collinoswalt.com/affine.html

but it gets slow with pretty much anything bigger than 32x32 pixels. I want to transform 256x256 pixel images like the SNES did in mode7. Is javascript just simply not fast enough or am I not doing the transformation efficiently enough?
>>
>>58442623
How is c++ easier to learn than C? C has like less than 30 keywords and basically no standard library.

Modern C++ requires
>autistic workflow for compiling, linking, managing libraries, getting code completion and other expected features in a proper IDE
>requires finding, installing, and choosing 3rd party libraries

C++ is a good language that isn't suited for learning or teaching programming because of the added steps in workflow and the choices that the programmer needs to make in order to use the language to its fullest.

Learning C++ as your first language is like learning to run roleplaying games through GURPS. Its retarded and the only reason to do it is so you can say you started with C++ because you think that makes you look more intelligent or cool or something.

Well...

C++ could be a good starter language if you're learning programming from someone in your immediate family and he/she loves C++ and you have immediate access to experience in person troubleshooting and help. You'll waste a lot of time asking easy to answer/fix questions for stupid shit while learning stuff that has nothing to do with programming at all and is more just weird quirks of C++ workflow and development.

[spoiler]Everything I just typed was regurgitated information I've gathered from watching game dev youtube videos. Is it accurate at all? I installed c++ and learned some of it from Bjarnes C++ programming book but it seemed like old retarded outdated C++ and I just switched to using Lua instead and I like Lua a lot.[/spoiler]
>>
>>58442804
It has nothing to do with floats.
It's to do with main.
>>
>>58442822
IIRC ANSI C implicitly makes main function to be integer.
>>
>>58442840
Yes, implicit int, as I said.
However, why the hell are you using C89 for new code, in 2017?
>>
>>58442840
ANSI C implicitly makes every function to be an integer
>>
>>58442857
Thanks for letting me know you have no opinions of your own and you just parrot what other people tell you.
>>
>>58442857
muh portability for some abandoned platform
>>
>>58442773
A senior programmer does not have a GitHub. Never had one. Red flag or not?
>>
The worst part of C is having to surround function bodies with braces. Instead, all global declarations should come before the first function, and function definitions should start with a unique keyword that ends the previous function. Also, you shouldn't be able to call a function before it's been defined. Recursion was a mistake.
>>
>>58442818
No spoilers on /g/. I wonder where you could possibly be from?
>>
how would you implement a modulus?

i know you can do like

mod(a, b)
rem = 0
while(a <= b)
--- a -= b //bounds check too
return rem

but thats silly
>>
>>58442880
What the fuck are you talking about?
I know C, and I regularly use C11. Both GCC and Clang, other only relevant C compilers, support it and even default to it.

>>58442882
It bothers me that some people unironically think this.
>>
>>58442892
Huge red flag IMO. Github is pretty standard even for people who aren't in the industry and just code as a hobby. That and it's retarded easy to implement a git workflow.
>>
>>58442892
Maybe like many of us, he doesn't want to be part of a SJW hellhole.
>>
>>58442892
No. Github is honestly boring. Idk why I should put my projects up on it other than for stupid recruiters. Also if he's older he might have put some stuff on sourceforge when it was still the most popular choice.
>>
>>58442914
>It bothers me that some people unironically think this.
Elaborate
>>
>>58442914
Explain why anyone should bother with C11-specific functionality.
>>
>>58442936
Have never seen an mbed compiler that supports C90+ desu
>>
>>58442898
return ((a/b) - floor(a/b)) * b
>>
>>58442896
/vg/ mainly

I browse a lot of boards though, /tg/, /sp/, /a/, /fit/, /lit/, /gif/, /wsg/ mainly. This has nothing to do with /g/ or programming though. Sorry I forgot /g/ didn't have spoilers.
>>
>>58442892

Maybe just ask him why?

I keep all my stuff in btibucket and use GitHub to find stuff from others.

But I would expect a SeniorDev to know Git. If not, he can still be an outstanding programmer, but then you need to get him fit for git in a few days. Depends on the "complete package"..
>>
>>58442978
Why are you assuming he doesn't know git just because he doesn't have a public github? github is just one of many, many different ways to use git.
>>
>>58442953
Most of the stuff C11 adds is pretty niche.
Most of the interesting stuff in added in C99.
Just remember, THIS is invalid C89:
#include <stdio.h>
#include <string.h>

int main()
{
char buf[32];
fgets(buf, sizeof buf, stdin);
size_t len = strlen(buf);
}


>>58442936
Most people are not writing software for weird old embedded systems that only have ancient compilers.
Most people are not writing software that needs to work on obscure ancient operating systems.

Limiting yourself because of things you're not even targeting is just fucking stupid.
>>
>>58442818
>>autistic workflow for compiling, linking, managing libraries, getting code completion and other expected features in a proper IDE
>>requires finding, installing, and choosing 3rd party libraries

And how that differs from C? :thinking:
>>
void becomeChad(bool hasFacialAesthetics, int heightStartsWith, long long moneyInBank, bool eatsPizza, bool chiseledJawLine) {
if (!hasFacialAesthetics) {
hasFacialAesthetics = true;
}
if (heightStartsWith == 5) {
heightStartsWith = 6;
}
moneyInBank *= 1000000000000000;
if (!eatsPizza) {
eatsPIzza = true;
}
if (!chiseledJawLine) {
cout << "consider plastic surgery" << endl;
}
}


>tfw you can't call this on yourself
>tfw no gf
>>
>>58443006
>:thinking:
Are you fucking serious?
Get out of here.
>>
>>58442978
Just cause he doesn't have a personal github doesn't mean he doesn't know git
>>
I learned the syntax and fundamentals of C and jumped on Python

pls tell me I'm doing it right
>>
>>58442978
>But I would expect a SeniorDev to know Git.
>implying github is the only way to use git

I use BitBucket, and even if I didn't, I've got a personal git repo, cloud hosted with my own domain, plus plenty of projects to show off.

Not having a GitHub isn't really a red flag unless you're looking for someone active in a particular community.
>>
>>58443024
>C and Python

No, you're not doing it right at all.
>>
>>58443024
>quitting C

doing it right
>>
>>58443024
Python is garbage.
>>
>>58443046
>he MUST know some autistic languages nobody uses but I learned or he's a NOOB!!!!
>>
>>58443062
I know this is bait but you can't possibly call one of the comfiest, fastest (to write), most powerful languages around "garbage" and provide 0 reasons.
>>
>>58443064
People use C and C++ everyday though
>>
>>58443064
>implying I don't use a language that has more jobs than either of those
>>
>>58443002
Stop playing dumb.
If you were seriously required to write strict C89, you could just declare size_t len at the top and be done with it.

Otherwise, you could just use GNU C, which is just pre-standardized C99.
>>
>>58443083
Good thing he called Python garbage, instead of whatever language you're talking about
>>
>>58442774
thats the cutest picture i have seen this year
>>
>>58442812
you give your transformation and your (untransformed) image to the gpu with a shader and not by doing some cpu shit or whatever you are trying.
>>
>>58443024

You're doing fine. If you ever get curious, you may consider grabbing the source code to the Python reference interpreter and checking out how it works.
>>
>>58443097
I am talking about Python, what are you dense? Everybody uses it and everybody loves it. Are you stuck in 1990?
>>
>>58443113
I dunno, are you stuck in Hell?
>>
>>58443024
Yep, I quit my daytime C++ government job, where we were developing some military ( I guess it was classified ) computer vision stuff and moved to SF, after year of searching good paying C/C++ job I found some startup that needed a CV guy, and guess what ? Working with Python is nice and relaxing, easy. What we do now is using C++ stuff that are wrapped with Python.

Not to mention if you ever want to do ML you are going to learn Python anyway... I mean C is great and stuff, but ML in C is time consuming as fuck.
>>
>Python is cool because it's Turing-complete and...umm...comfy...and everybody uses itm it's 2017
>>
>>58443113
>Everybody uses it and everybody loves it.
only retards and non-programmers.
>>
>>58443124
What country?
>>
>>58443094
>If you were seriously required to write strict C89, you could just declare size_t len at the top and be done with it.
Yes, I know. But I picked an extremely simple situation that one would think works.
There is all sorts of other, useful shit they added in C99.
Designated initialisers.
Variadic macros.
Well-defined division/modulo (was implementation defined for negative numbers in C89).
Restrict pointers.
and so on.

>GNU C
If you're so worried about portability, why on earth would you do one of the least portable things you can do?
Fucking idiot.
>>
>>58443113

>Everybody uses it and everybody loves it
C'mon man, some of us have other preferences. I don't touch it unless I need some specific Python library, like Scikit-Learn or whatever.
>>
>>58443136
Linux kernel uses gnu c and it's pretty portable.
>>
>>58443118
>>58443130
Yeah and everyone who wants to get stuff done quickly and effectively, and scientists, and machine learning experts, and pretty much all people who ever touched programming. Meanwhile (you) just keep whining without giving any good reasons. Leave and stop trolling.
>>
>>58443164
it's portable in the sense that it compiles anywhere GCC exists, but it ONLY compiles on GCC and no other compiler.
>>
>>58443164
>it's pretty portable
No it's not. Good luck trying to get that shit to compile on something other than GCC.
Clang has still been struggling with that shit for years.
>>
New thread:

>>58443173
>>58443173
>>58443173
>>
>>58443177
clang should be able to compile it now or in near future or at least that what they are aiming for.
>>
>>58443136
None of those things are strictly necessary.
Stop complaining.
>>
File: java.jpg (131KB, 739x710px) Image search: [Google]
java.jpg
131KB, 739x710px
>>58439742
>>
>>58443170
>Yeah and everyone who wants to get stuff done quickly and effectively
Python is terrible at that compared to other langugaes though. That's why it's hated so much by good programmers.
>>
>>58443135
USA, California, San Francisco
>>
>>58443130
>Having PhD in mathematics and trying to be efficient with your time is being retard and non-programmer

Ok guy, go back to scripting websites now.
>>
>>58443170
If you actually think Python is good in any situation then you should get some help.
I recommend lurking more.
>>
>>58442745
Do you think that a language maximizing type safety, abstraction capabilities and statelessness is the most desirable?
>>
>>58443200
None of the shit any language does is "strictly necessary".
Why don't we all just program turing machines?

But really, C99 adds a lot of useful features, including ones that aid optimisation and make the language nicer to use in general.
It doesn't violate the 'spirit of C'. It doesn't bloat the language like C++.
>>
>>58443208
You seems to know a lot, would you be nice and actually show some proof ?
>>
>>58443229
Being a mathematician doesn't imply being a good programmer
>>
>>58443269
>
>>
>>58443235
>useful features
No. They're totally useless.
>>
>C IS GOOD
>C++ IS BEST
>OMG PYTHON SUCKS
>iasdjasiojsa

Aside from Java, everything is good. And it has its fields.

Go do Data Science with C/C++ you'll get fired the first month, for not finishing any project, even half way through.
>>
>>58443315
>everything is good
But that's wrong, commie
>>
>>58442456
for i=100,1,-1 do 
if(i % 5 == 0 and i % 3 == 0)
then
print("fizzbuzz")
elseif(i % 5 == 0)
then
print("buzz ")
elseif(i % 3 == 0)
then
print("fizz ")
else
print(i)
end
end


job pls?
>>
>>58443471
I won't hire someone who can't use an indenter.
>>
>>58437759

In openGL with GLFW3 how do I draw pixels on the screen

im making a ray tracer so they need to be exact pixels
Thread posts: 331
Thread images: 34


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.