[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: 330
Thread images: 32

This is /dpt/, the best subreddit of /g/

Umaru-chan edition, the best of all editions.

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

code of conduct:
no racism
no insult
no sexual harassment
no gender discrimination

wat r u working on, anon-chan ?
>>
File: akari~nn.png (522KB, 519x697px) Image search: [Google]
akari~nn.png
522KB, 519x697px
I just made my first CGI script in C.
It's a comment board!

http://45.32.93.98/board.cgi
Please try it out and don't break it pls.
>>
>>56220025
First for Racket
>>
Third for this thread was posted too early
>>
Is it better to do

if()
{
}


Or

if() {
}

?
What do most companies prefer?
>>
>>56220106
the second one

C# uses the first one though so that it won't look too much like java
>>
>>56220106
Most companies prefer B.
>>
>>56220106
Companies prefer being flexible enough to adapt to whatever standard they tell you to adopt. There's probably going to be more rules than curly brackets.
>>
>>56220157
But isn't A easier to see and debug?
>>
>>56216413
Everything is easy in Python(tm)
import tkinter as tk
import qrcode as qr
import sys

root = tk.Tk();

root.withdraw();

image = qr.make(root.clipboard_get())
image.save(sys.argv[1])
>>
>>56220106
Second is better because of how most editors implement code folding, where it hides the lines starting at the one after the opening bracket, and ending at the one with the closing bracket.

So
if() {
}


becomes
if() {


whereas
if()
{
}


becomes

if()
{


I think the latter looks silly and wastes space.
>>
>>56220226
Alright, makes sense. Thanks ;)
>>
>>56220208
Actually it isn't, consider a 3-level block of code:
function Foo()
{
if()
{
if()
{
}
}
}


Look how easy it is to see where things end and start.
>>
C++ >>>>>>>> java >>>>>>>> C# >>>>>>>> D >>>>>>>> rust >>>>>>>> go >>>>>>>> C >>>>>>>> python >>>>>>>> javascript >>>>>>>> php >>>>>>>> lisp >>>>>>>> haskell
>>
>>56220258
There, I deposited your 500 rupees of the day, Pajeet Panaymandha
>>
File: 1.jpg (103KB, 1080x664px) Image search: [Google]
1.jpg
103KB, 1080x664px
#ProgrammerLife
>>
>>56220199
yep, style guides and coding standards for each language. the bigger the company, the more rigid and exhaustive the guides.
>>
>>56220106
I use whatever the gofmt tool wants me to use
>>
>>56220301
If anything, I adapt the Airbnb guidelines to my code in whatever the language I'm in.
>>
>>56220258
Why did you have to use so many larger-than symbols between each entry in your tier listing?
>>
>>56220106
Nobody should accept the parenthesis next to the keyword without a tasteful space between
if (...) {
...
}
>>
>>56220324
There's 88 ">" in there, convert 88 USD to Rupees, and you get around 500.
>>
>>56220324
Because you overload >> in C++ to read from stdin
>>
>>56220324
""""""""larger-than symbols""""""""
>>
File: AAAAAAAAAAAAA.gif (247KB, 480x430px) Image search: [Google]
AAAAAAAAAAAAA.gif
247KB, 480x430px
>>56220061
>not even 5 minutes and some guy is trying to XSS my ass with embedded script tags

i hate you people
>>
>>56220324
((((((((((((extremely jewish))))))))))))
>>
File: 1465096543319.png (1MB, 1512x1072px) Image search: [Google]
1465096543319.png
1MB, 1512x1072px
>>56220369
Actually it's been 26 minutes, anon


also I almost got embedded images to work before you took the site down
>>
File: qr.webm (1MB, 1366x768px) Image search: [Google]
qr.webm
1MB, 1366x768px
>>56220217

bound it to alt+q with .i3/config and a 2line bash ""script""
>>
>>56220384
How were you doing that?
>>
>>56220258
Nice blog
>>
is there a way to turn off info file generation when building gcc/binutils

good god i fucking hate texinfo
>>
>>56220258
>go >>>>>>>> C++, java, C#, D, rust, C, python, javascript, php, lisp, haskell
FTFY
>>
>>56220106
if expr
then expr
else expr
>>
>>56220369

Tell me, did your server randomly call exit()?

rubyist@Overmind:~/scratch$ ./a.out
address of exit: 0x400460
rubyist@Overmind:~/scratch$ irb
irb(main):001:0> require "net/http"
=> true
irb(main):002:0> msg = ("A" * 250) + "\x60\x04\x40\x00"
=> "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`\u0004@\u0000"
irb(main):003:0> require "uri"
=> false
irb(main):004:0> uri = URI.parse("http://45.32.93.98/board.cgi")
=> #<URI::HTTP http://45.32.93.98/board.cgi>
irb(main):005:0> response = Net::HTTP.post_form(uri, { "Submit" => msg })
Net::OpenTimeout: execution expired
from /usr/lib/ruby/2.3.0/net/http.rb:880:in `initialize'
from /usr/lib/ruby/2.3.0/net/http.rb:880:in `open'
from /usr/lib/ruby/2.3.0/net/http.rb:880:in `block in connect'
from /usr/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
from /usr/lib/ruby/2.3.0/net/http.rb:878:in `connect'
from /usr/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
from /usr/lib/ruby/2.3.0/net/http.rb:852:in `start'
from /usr/lib/ruby/2.3.0/net/http.rb:584:in `start'
from /usr/lib/ruby/2.3.0/net/http.rb:508:in `post_form'
from (irb):5
from /usr/bin/irb:11:in `<main>'
>>
>>56220500
And now it's a Ruby-senpai rapes the newfag episode.
>>
>>56220500
i don't know what made you think that

no
>>
>>56220454
>
>>
>>56220526

It likely didn't do anything. I mean, that virtual address assumes OP is

a.) Using 64-bit Linux
and
b.) Using the same version of libc as me (if he was using something like musl, it might be in a different virtual address).

It would also assume OP has a buffer on the stack of exactly 250 characters, and no other stack variables, thus causing exit to corrupt the return address. That said, I was able to access the site before this, and not after, so I'm curious is OP is a dumbass or something.
>>
>>56220575
he took the site down on his own dood
>>
>>56220258
What is haskell even used for? I'm supposed to learn haskell this semester but i don't see the point.
>>
>>56220622
Haskell is the missing piece of the triad:

JS + Rust + Haskell

For a better programming world!
>>
>>56220592

Smart man.
>>
Absolute beginner here. I know nothing at all.

What's the best language to start with in my adventure?

Before you ask,im doing this for game programming. Go ahead, laugh
>>
>>56220687
Learn C. It's a quick language to learn, and will teach you to program safely. After you master C, it is a breeze to switch to popular game programming languages, like C++, C#, and Java. However, if you learned one of those three first, it might be harder to switch to another. This is because they all derive from C.
You can even do game programming in C itself, but it is a bit harder.

I recommend "C Primer Plus" by Stephen Prata. It starts from the bottom and puts you at a good position, and is an easy read.
>>
>>56220574
>
>>
>>56220725
>Learn C. It's a quick language to learn, and will teach you to program safely.
>C
>safely
heh, wat
>>
>>56220687

I recommend every beginner to start with C, due to its relative simplicity, along with the fact that it forces the beginner to learn a little bit about how computers actually work, rather than letting a runtime manage most things. After that, it goes onto whatever is relevant to your field of interest. For game development, C++ and Lua are rather popular. C++ will be easier if you already know C, but you should make sure not to delude yourself into thinking they're the same language. C++ is not a strict superset of C, and there are many ways in C++ to approach a problem more efficiently than one would in C, by leveraging work done at compile time (i.e. RAII, templates).

>>56220725

I second this Anon's recommendation of C Primer Plus.
>>
>>56220725
What edition?
>>
>>56220622
it's a general purpose language, so pretty much everything

get a head start
http://www.seas.upenn.edu/%7Ecis194/spring13/lectures.html
>>
>>56220741
You don't learn safety if there are no dangers.
>>
File: complex algorithms.jpg (71KB, 808x617px) Image search: [Google]
complex algorithms.jpg
71KB, 808x617px
>>56220025
I have been following K&R to learn C but it is hard to stay motivated, I think I need a project to keep me interested. All of my projects before were just simple ones like a python twitter bot (just spams one message) or web scraper. Any interesting projects at a lower skill level that I could write in C? I can't just default to writing something to pull from a webpage this time because it's, well, C.
>inb4 programming isn't for you
I enjoy it a lot, just need to find something fun to write before I get back to K&R.
Any ideas?
>>
>>56220748
The most recent you can get your hands on, of course. The latest edition is available for free online, last I checked.
>>
>>56220769
you have to know that what you are learning is not safe in the first place, and not all books will teach you that...
>>
>>56220784
Thanks anon for the help anon! Sorry for asking, but what site did you find it on? If anything, ill just use tpb or torrentse
>>
File: idt entry generation.png (27KB, 500x178px) Image search: [Google]
idt entry generation.png
27KB, 500x178px
By golly, I think it might be working.
>>
>>56220817
>IDT
That's where I burned out on building an OS. Keep going anon, you can do it.
>>
>>56220817
Congratulations!
>>
>>56220772
Game hack bot
>>
>>56220622
people make compilers with it and that's about it

not even serious compilers though, just toy ones as an exercise or for fun
>>
>>56220905
Would be cool. Thanks.
>>
When do you know it's time to "specialize"?
I'm learning python and my goal is to learn all things related to data and how to get it, when do I know I'm ready to start ?
>>
Why do i get an intent error on this?
after i type what i want done it ends the program aka <Terminated>
what do?
>>
>>56220930
start with single player I guess, you will learn about memory, offsets, hooking etc.
>>
>>56220945
1. your indentation is shit
2. you're in highschool
>>
>>56220948
I need to learn more C before I do it but it's quite an exciting goal to look forward to. Excactly what I needed
>>
>>56220959
While those are both true,
that doesnt help me.
What can i do better?
Any tips to become neater or anything?
>>
>>56220945
First of all, stop using Java.
Second, STOP using Java.

And third, STOP USING JAVA.

It'll make your life easier if you learn Rust or C++ instead.
>>
So... let's say that I want to learn how to code. Where should I start?
>inb4 rainbow socks and estrogen
>>
>>56220992
I know, /g/ hates java but its my summer assignment. I plan to learn C next, then python.
>>
>>56220945
>those comments
Stop, please. Comments are for explaining parts of code that aren't directly understandable. They are not for literally rewriting obvious lines of code in English.
>>
>>56221016
Im aware, but i do that to get in the habit of writing them.
>>
>>56220998
https://docs.oracle.com/javase/tutorial/
>>
>>56221002
First order of business is to make comments only when the code you wrote needs one.
>>
>>56220998
See
>>56220725
>>56220742

TL;DR: Learn C, read C Primer Plus.
>>
>>56221031
Pajeet pls
>>
>>56220945
what's the error? show the 'problems' tab
>>
>>56220945
Choice.equals(Multiply)

you're comparing Choice to the Double variable Multiply. You might want to try
Choice.equals("Multiply")
instead.
>>
>>56221047
I have no clue, thats my problem.
It runs fine but as soon as you type divide or multiply it just ends the program without an error.

(Also the 953 errors are from when i switched all my old programs over but havent bothered to organize them to their correct folders. Im working on this at the moment)
>>
>>56220297
Kill yourself
>>
>>56221064
tried that, still get the same error
>>
>>56221070
One: Close your shit
Two: Your issue probably lies on line 38 and 47
>>
File: akari2.jpg (58KB, 514x524px) Image search: [Google]
akari2.jpg
58KB, 514x524px
Rate my UTF-8 converter!
char *utf8_rewrite(char *str)
{
/* %E5%88%9D%E9%9F%B3%E3%83%9F%E3%82%AF => 初音ミク*/
unsigned i, j;
for (i = 0; str[i]; i++)
{
if (str[i] == '%')
{
for (j = 1; j <= 2; j++)
str[i] = (str[i] << 4) | hex_value(str[i+j]);
memmove(&str[i+1], &str[i+3], strlen(str)+1);
}
}
return str;
}
>>
>>56221039
Isn't C kind of dated? Not trolling btw.
>>
>>56221083
this works fine for me

Scanner s = new Scanner(System.in);
if(s.nextLine().equals("foo")) {
System.out.println("foo");
}
>>
>>56221110
true
learn C++14
>>
>>56221110
LISP and FORTRAN are older, but people still use them.
>>
>>56221110
yes start with java and then learn C++

also see >>56220258 for how good/useful the languages are
>>
>>56221143
almost no one uses them

some people learn lisp with sicp but it's not like they actually end up using lisp for anything serious
>>
>>56220992
Chill out retard, java is the best language
>>
>>56221167
Here's your 450 Rupees, pajeet
>>
>>56221156
There's tons of ancient scientific stuff still in FORTRAN. And the COBOL boogeyman is still extant.

So is MUMPS, a true abomination among languages:
http://thedailywtf.com/articles/A_Case_of_the_MUMPS
>>
>>56221104
that looks extremely unsafe
>>
>>56221175
Not an argument
>>
>>56221110

C is very old, but it makes up a large amount of code in our infrastructure. If you wanted to, for example, understand how the Python interpreter works, you would need to know C.
>>
>>56221193
There's no need to argue, it's already decided upon, pajeet.
>>
>>56221178
uni teaches cobol for the information systems track. I guess its for people who want to learn it so they can translate it to a more modern language.
>>
>>56221194
C is very easy to pick up if you already know other C-like languages, but i think it's a waste to learn it as your first language, you can pick up java in literally a week, with C there is so much C-specific bullshit and gotchas surrounding it that aren't fundamental to learning programming
>>
Is Crystal a worthwhile replacement to Ruby or a pure meme, or somewhere in between?
>>
>>56221178
>MUMPS

Oh shit...

Appendix 7: An example of "traditional" M coding style

%DTC
%DTC ; SF/XAK - DATE/TIME OPERATIONS ;1/16/92 11:36 AM
;;19.0;VA FileMan;;Jul 14, 1992
D I 'X1!'X2 S X="" Q
S X=X1 D H S X1=%H,X=X2,X2=%Y+1 D H S X=X1-%H,%Y=%Y+1&X2
K %H,X1,X2 Q
;
C S X=X1 Q:'X D H S %H=%H+X2 D YMD S:$P(X1,".",2) X=X_"."_$P(X1,".",2)
K X1,X2 Q
S S %=%#60/100+(%#3600\60)/100+(%\3600)/100 Q
;
H I X<1410000 s="" %h="0,%Y=-1" q="" s="" %y="$E(X,1,3),%M=$E(X,4,5),%D=$E(X,6,7)" s="" %t="$E(X_0,9,10)*60+$E(X_"000",11,12)*60+$E(X_"00000",13,14)" toh="" s="" %h="%M">2&'(%Y#4)+$P("^31^59^90^120^151^181^212^243^273^304^334","^",%M)+%D
S %='%M!'%D,%Y=%Y-141,%H=%H+(%Y*365)+(%Y\4)-(%Y>59)+%,%Y=$S(%:-
1,1:%H+4#7)
>>
>>56221247

Crystal is still in Alpha, and its standard library has yet to be standardized. Make of it what you will.
>>
>>56221230
>you can pick up java in literally a week
Sure, if you're already a programmer.
>>
>>56221283
no i mean from scratch if you're not retarded
>>
>>56221289
I've tutored beginners. Java is awful as a first language. Python, for example, is worlds better.
>>
>>56221230
Java isn't a good beginner language either because right off the bat you're forced to use OOP. There's also no stack allocation except primitives and the pointers themselves, so beginners will just see all this "new" crap everywhere.

And let's look at writing to a file
 PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));

what the fuck is this? the beginner is just going to get turned away. Learning to program is dangerous if the beginner mistakes syntax as being programming.
>>
>>56221312
kys

>>56221319
stay delusional idiot
>>
>>56221312
you and all the people you tutored are retarded, java is fucking easy
>>
File: idkwid.jpg (44KB, 455x290px) Image search: [Google]
idkwid.jpg
44KB, 455x290px
 import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

i know what i want to do. but ZERO programming background. read 10 books on programming, java, android. watch 100s of video tutorials.
and i'm still just:
>ok i wanna have people log in with google+, how the fuck do i do that - search, that's not right, search more, wow that's too complicated, search more, hmm ctrl+c/ctrl+v
>ok, now i gotta look up how to use vector images
and so on...
how fuck am i? or is this normal?
>>
>>56220945
>that indentation
>those capitalization conventions
>>>>>>>>PajeetLang
>shitty IDE like eclipse

hun use this https://google.github.io/styleguide/javaguide.html
>>
why do I even come to this fucking thread? people here see themselves as elite programmers, yet it's clear that they are terribly out of touch with reality...
very, VERY related:
>>/56220676
>>
>>56221325
>>56221329
Fuck I'm an OOP fag and even I have to recommend that you fucking kill yourself you fucking faggot
>>
>>56221351
>>56220676
ftfm
>>
>>56221351
it's the same story all across 4chan, it's all trash

>there are people in /dpt/ who UNIRONICALLY use haskell
>>
>>56221367
>I literally cannot handle people using a different language than I
>>
>>56221383
*than me
>>
>>56221383
>taking the memes seriously
just some good ol fun here bud
>>
>>56221391
Literally doesn't matter
>>
>>56221395
haskell is seriously shit
>>
>>56221367
I love Haskell
>>
>>56221421
you're a stupid fag
>>
>>56221345
u just suck
leave here at once
>>
>>56221417
Someone a few threads ago asked how to convert ascii hex strings to decimal and some haskell autist wrote up 6 posts worth of tutorials on how to "SIMULATE" a state machine in haskell.
>>
>>56221417
Elaborate, and I don't want to see the words "pretentious community"
>>
>>56221438
It's like Rust but even more academic
>>
>>56221433
fuck off, faggot
at least i'm not a virgin with micro penis
>>
File: 1468472224634.jpg (61KB, 990x557px) Image search: [Google]
1468472224634.jpg
61KB, 990x557px
>>56221438
>I don't want to see the words "pretentious community"
>>
>>56221437
They asked how to statefully write a function that takes only the highest bit every 8 bytes

I gave him both a very simple non-stateful solution and an explanation on how you can emulate state by passing and returning an extra variable
>>
>>56221345
you're everything wrong about the mobile app market, you don't know shit and you'll end up releasing some half broken lazy piece of trash
>>
>>56221460
>>56221437
HahahaHAHAHA
>>
>>56221460
you wrote 10000 characters worth of shit to simulate something that can be done in 5 lines of C.
>>
>>56221467
no. i'm tirelessly working on it. and i won't release until it's solid. i'm dedicated. just didn't have cs in school and this rural area doesn't have any programmers or else i think i could find a mentor.

also, check your privilege
>>
>>56221474
let proc (param,state) = (return, newstate)
let proc2 (param,state) = (return, newstate)
let (result1, state') = proc (someParam, initialState)
let (result2, state'') = proc (otherParam, state')
let (finalresult, finalstate) = (result1 + result2, state'')

anyway, someone else has already done it for you
all you need to do is

do
x <- get
proc x
put 3
modify (+12)
>>
>>56221502
learn how to fucking program, you can do it on your own without a mentor

android is a clusterfuck in and of itself but you can learn that too
>>
>>56221460
>converting ascii hex string to decimal
>C
>atof() and a for loop
>haskell
>write 10 page academic paper that still doesn't give a solution to the problem
>>
>>56221532
It's not converting an ascii hex string to decimal if it keeps only the highest bit is it?

It's not my fault you expect the language to do everything for you, if you hate it that much use IORefs or STRefs
>>
>>56221524
yeah, nothing in life has come as easy as it does for most folks.

oh well
>>
>>56221543
programming is one of the hardest things you could possibly do, get a job at starbucks or do some web dev if you want something easy
>>
>>56221230

Java is what i started with, moved to C, then C++

i'd say it was a pretty smooth transition, just don't use web resources because they're pajeet garbo doggo

just use books
>>
>>56221551
i would have mastered this shit had there been classroom setting while growing up

age 35 just starting into it, whish i was in big city where i could take a community college class for cheap
>>
File: 1426548231392.png (141KB, 800x600px) Image search: [Google]
1426548231392.png
141KB, 800x600px
>>56221571
a school still can't do the learning for you, hence the cs grad memes, you have to get involved yourself, and it takes time, you can't expect to make a million dollar app from day 1, it can take years to obtain professional-tier skills
>>
>>56220406
Hand crafted post requests with ajax (XMLHTTPRequest)
>>
>>56221590
any good coding learning materials that are not language specific?

i think if i get a handle on the jist of programming as a art/science, translating into the language needed would be easier
>>
>>56221555
I think one should always learn the basics of C before C++
>>
>>56221680
y?
>check'd
>>
>>56221555
books written by Pajeets - kek
>>
>>56221730
I'm guessing "pajeet" is some slang to refer to Indian programmers. Why so much hate toward them? Are they shitty programmers?

So, what I'm getting form this thread is "start with Java or C++, but don't touch C". Is there any value in learning C for modern programming? Is there things that C can do and C++ can't?
>>
File: 1311195529158.png (6KB, 281x215px) Image search: [Google]
1311195529158.png
6KB, 281x215px
>>56220817
Got interrupts sort of working, keyboard interrupt fires and handler gets called, but it will only fire once, even though I send an EOI.
>>
>>56221790
nono
start with python, then pick any language from there (C++ or Java if you aim to be productive).
>>
>>56221867
>>>/b/
>>
>>56221867
which one do you want? I feel generous tonight.
>>
>>56221449
maybe u are lol

give it a try for a few days
>>
>>56221329
>>56221325
Pajeet and Rajesh sure are upset huh
>>
>>56221345
You're just not smart enough for programming. You can read all you want, but if you can't think very well, you will never make a good app. This may sound a bit harsh, but it's the reality.
>>
File: apu-nahasapeemapetilon.jpg (104KB, 1280x544px) Image search: [Google]
apu-nahasapeemapetilon.jpg
104KB, 1280x544px
do not be bad talking my people
i shall be fuck on your head
we are many, and may rise in revolt against your racist self
>>
>>56221993
that's not it. i'm a fucking genious.
don't know shit about fixing cars either, but i never tried, no experience, no interest.
don't know shit about applying eyeliner, using tampons, or flying an F-16.
anything i do have interest in, and opportunity to learn, i master relatively quickly. from kuk sool, to kung fu, from english to french and spanish, cooking to real estate, carpentry to hospitality, from sanitation to regional management. i've done even more. never failed a test. ( one thing i never learned is finding a chick who's into me for more than 2 years, but oh well)
maybe you are good at programming, and only that. how do you like being a one-trick pony?
>>
>>56221345
You want Python:


import solution;
runSolution()
>>
File: startpage5.webm (2MB, 800x450px) Image search: [Google]
startpage5.webm
2MB, 800x450px
Holy shit converting/scaling video codecs with VLC is a fucking nightmare.

Rate my start page (work in progress).
>>
>>56221858
>start with python
https://www.youtube.com/watch?v=xkZPs2K8_e8
>>
https://www.youtube.com/watch?v=cW-gpS_mQtk
>>
Python friends: Why use tox if you have travis?
>>
>>56222136
Very nice
>>
>>56221953
you're the idiot who thinks java is hard lol
>>
File: 1410477089432.png (817KB, 440x752px) Image search: [Google]
1410477089432.png
817KB, 440x752px
>>56222169
ty anon means a lot
>>
>>56221790
>Is there things that C can do and C++ can't?
No largely anything you write in C will work in C++ with no editing at all. I think it's silly to think of them as separate. Programming in C is trivial once you've learned C++. Throw away classes, templates, and all the C++ libraries and you pretty much have C.

The benefit to pure C is doing performance critical stuff without the overhead. Like in my environment a vector has a 24 byte overhead. I found it useful to throw that away when dealing with an array of a maximum of 5 values of 2 byte size. I had to keep track of the size of the array myself but since I was handling 3 million classes with that array in them at a time in an often repeated part of my program it was worth the extra effort. In the end it was all being done in a class so I got the same level of abstraction and a 70% reduction in the amount of memory I had to read.

That ability to throw away the C++ library way of doing things for part of a problem and do it in a C style is what I like about C++.
>>
File: 1443738621478.jpg (353KB, 1000x1000px) Image search: [Google]
1443738621478.jpg
353KB, 1000x1000px
>>56221805
Fuck yeah, figured it out, wasn't sending EOI on key release interrupts.
Time to set up a keymap.
>>
>>56222136
Learn ffmpeg. Site is very nice.
>>
writing the spaghettiest spaghetti I've ever written
>>
>>56222136
Can I have that when it's finished?
Will it be customizable?
It looks great.
>>
>>56212756
* (defun arr-type (type n)
(let ((arr (make-array n :element-type type)))
(type-of arr)))

ARR-TYPE
* (arr-type 'number 5)

(SIMPLE-VECTOR 5)
* (arr-type 'fixnum 4)

(SIMPLE-ARRAY FIXNUM (4))
* (arr-type 'bit 5)

(SIMPLE-BIT-VECTOR 5)


Feels good to use a real language with real dependent type facilities.
>>
>>56220106
K&R style, the former for functions, the latter for everything else.
>>
File: IMG_0323.jpg (783KB, 2592x1728px) Image search: [Google]
IMG_0323.jpg
783KB, 2592x1728px
HERRO GEE
please maek algorithm which lights up red blue and green LEDs according to current temperature
thanks
>>
>>56222738
>MUH types

This board is borderline retarded
>>
>>56220500
kek his is down...
>>
>>56222798
For what mic?
>>
File: output.webm (2MB, 260x462px) Image search: [Google]
output.webm
2MB, 260x462px
r8
>>
>>56223167
I actually like this. Keep going
>>
>>56222738
Of course you can have dependent types in a language where types don't matter and are just random expressions. We're talking real languages here skiddo, not an old Python with no libraries.
>>
File: 2016-08-23 02-51-10.webm (788KB, 1364x768px) Image search: [Google]
2016-08-23 02-51-10.webm
788KB, 1364x768px
time manager coming along

still haven't done the actual XML work that needs doing (inserting and deleting records on the fly because it's so complicated) but it's much more functional than it was at least
>>
>>56223295
Do you have to click every date to check when you have stuff to do or there are some kind of annotations on calendar?
>>
>>56223295
wait, did you just reinvented the calendar?
>>
>>56220061
rip
>>
File: prolog-tree2.png (41KB, 767x717px) Image search: [Google]
prolog-tree2.png
41KB, 767x717px
> it is a real tree
>>
>>56223368
yes I did
probably a huge waste of time but it's good practice with the gui work and it'll be a nice reference for future stuff

>>56223363
yes
but the way it works is you create objects and place them in arrays. Then you can call them back when something updates and say rightTiles[num].config(text='Appointment at 3:00') so the capability is there to put in that sort of thing

Its just the code is so convoluted I want to wrap up other features first
>>
>>56222092
Lol found the sperg
>>
anyone here ever written anything non-ai related in prolog?
>>
>>56223468
I did hello world.
>>
>>56223478
did you implement fizzbuzz for /g/ cred too?
>>
>>56223412
How do I add proper bark to my data structures?
>>
>>56220396
>>56220217
Here's the reverse

#!/usr/bin/env python3

import pyscreenshot as ss
fn = 'shot.png'
ss.grab_to_file(fn)

from PIL import Image
import zbarlight

with open(fn, 'rb') as image_file:
image = Image.open(image_file)
image.load()

codes = zbarlight.scan_codes('qrcode', image)

import sys
if not codes:
print("no QR code detected", file=sys.stderr)
else:
for code in codes:
try:
print(str(code, 'utf-8'))
except UnicodeDecodeError:
print(code)

import os
os.remove(fn)
>>
>>56223412
jesus fuck I can just feel the confusion of students at the uppermost times being straight above rather than to the side already
>>
File: k programming language.jpg (152KB, 739x1772px) Image search: [Google]
k programming language.jpg
152KB, 739x1772px
>>56221276
you are but a sweet summer child...
>>
give me a challenge doable in an hour or less

need algorithm practice
>>
>>56223584
Implement a self-balancing Red-Black-tree container with support for insert(key, element), find(key) and remove(key) in your language of choice.
>>
>>56222798
Ok so I'm just going to dump my thought process here.
RGB
[0-255, 0-255, 0-255]
Hot -> cold
Green -> yellow -> red
Green = [0, 255, 0]
Yellow = [255, 255, 0]
Red = [255, 0, 0]

Ok now I have to combine this with the temperature.
Temperature is a float from 0 to 1, with 0 being cold and 1 being hot.
If the temperature is >0.5, it should have a color of [0, 255, 0] to [255, 255]. So let's write some code

if temp > 0.5:
color = [x, 255, 0] //TODO: x

If I divide temp by 0.5 (multiply by 2), I have a number that ranges from 1-2.
If I subtract 1 from that, I have a new number from 0-1. Call that number n.
I have to get x = 0 at n = 1 and x = 255 at n = 0. I have to invert n, so let's call c = 1 - n.
Now I have c = 1 -> n = 255
c = 0 -> n = 0
Seems like multiplicating by 255 to me. So let's go back to the code.

if temp > 0.5:
# n = temp * 2 - 1
# c = 1 - n
# x = 255*c
# x = 255(1 - (temp*2-1))
# x = 255(1−2*temp+1)
# x = 255(2-2*temp)
# x = 510-510*temp
color = [510-510*temp, 255, 0]

Okay, now yellow to red.

temp = 0 -> [255, 0, 0]
temp = 0.5 -> [255, 255, 0]
Seems like multiplicating by 510 to me

END RESULT

if temp > 0.5:
color = [510-510*temp, 255, 0]
else:
color = [255, temp * 510, 0]
>>
>>56223631
Just do a linear interpolation between the values?
>>
>>56223729
Didn't think about that, damn I'm dumb. The end result is the same though.
>>
>>56223631
You might want to look into first order logarithmic filters. low-pass for green and high-pass for red. I honestly don't know if that will be more natural looking.
>>
>>56223584
>algorithm
>hour or less
Design and implement a type generic data structure that acts as a stack, and has all normal stack operations (push(e), e <- pop()) available in O(1) time, but also a e <- max() operation that returns the value of the maximum element in the stack and runs in O(1) time.

If you don't know a language that you can easily write type generic code in, write a well written argument for adding some system for doing so to the language developers during your time.
>>
Do you guys listen to anything while working?
>>
>>56222092
wtf. Actually admitting to not learning the basics of life.
>>
>>56223915
Anime and Video games soundtracks. Today I'm listening to Sayonara Zetsubou Sensei.
>>
>>56223915
To your mom's moaning as I pound her pussy.
>>
>>56223915
Yes, of course.

Mostly prog with emphasis on the instrumentals so it's not too much in the way of my thought process.
>>
>>56223915
I've been listening to christian worship music for the last 4 hours
I'm atheist but it's soothing and good background noise

prefer music without focus on lyrics
>>
>>56223915
You literally do not need to be into anime to benefit from this board
>>
>>56223915
I usually listen to video game soundtracks (most often Skyrim's) or to some metal, but I prefer to avoid anything with lyrics, I can't focus otherwise.
>>
>>56223915
If I have to sit and think about something I prefer no sound, but if I'm just pounding shit out I listen to whatever I'm interested at that point.
>>
File: brackets.png (318KB, 2026x1303px) Image search: [Google]
brackets.png
318KB, 2026x1303px
I'm trying to figure out how to even start on this. I guess use a stack and count the pops for longest valid bracket chain, but then how the fuck do you figure out which ones to rotate?
>>
>>56224000
>how the fuck do you figure out which ones to rotate?
Decision tree. Much like solving a sudoku puzzle. K limits the maximum depth of the decision tree. Every solution you find store the value if it is larger than the current maximum.
>>
>>56224000
yes that's more of a logical problem innit

well you know that if you have an odd number (1,3,5) then you can only have n-1 pairings, like 5 parenthesis only makes 4 pairings

then you should go through and count opening brackets, then closing brackets

)()()()() is 4,5

then count matches of opening to closing (I think it shouldn't matter the order)

then count the difference between opening and closing and the difference you can make up between finished parenthesis and counted opening/closing brackets should be how much the k will matter

I explained poorly but that's the basic idea I think
>>
>>56224094
or 2 pairings I mean, whoops
>>
File: jpg.png (29KB, 741x746px) Image search: [Google]
jpg.png
29KB, 741x746px
$ ./program.exe
test1
test2
test3
test4


CURRENT: test2
ADDED NEW1 TO CURRENT POSITION
test1
test2
test3
NEW1
test2

Aborted (core dumped)


Is there any obvious reason why my linked list is shitting itself whenever I run this function to add a new element at a certain point? current is just a pointer to one of the nodes. Everything else is working until I run this function and it looks fine to me.
>>
>>56223792
You can use this if you want

#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>

typedef unsigned char uchar;

struct led {
uchar r, g, b;
};

size_t avg(size_t x, size_t y) {
return x/2 + y/2 + (x%2 & y%2);
}

uchar lerp(uchar base, uchar target, double progress) {
return (uchar)(progress * ((long)target-base)+base);
}

struct led temp2col(double temp) {
double temps[] = {
0,
10,
25
};
size_t count = sizeof temps / sizeof *temps;
assert(count > 1);
struct led cols[] = {
{r: 0, g: 255, b: 0 },
{r: 255, g: 255, b: 0 },
{r: 255, g: 0, b: 0 }
};
if (temp <= temps[0]) {
return cols[0];
} else if (temp >= temps[count-1]) {
return cols[count-1];
}

/* Binsearch */
size_t lo = 0, hi = count-1;
while (lo <= hi) {
size_t mid = avg(lo, hi);
double val = temps[mid];
if (val < temp) {
lo = mid + 1;
} else if (val == temp) {
return cols[mid];
} else {
hi = mid - 1;
}
}
if (lo > 0) {
--lo;
}

struct led base = cols[lo];
struct led target = cols[lo+1];
double progress = (temp - temps[lo]) / (temps[lo+1] - temps[lo]);
return (struct led){
r: lerp(base.r, target.r, progress),
g: lerp(base.g, target.g, progress),
b: lerp(base.b, target.b, progress)
};
}

int main(int argc, char **argv) {
if (argc < 2) {
fputs("Supply argument", stderr);
return 1;
}
struct led r = temp2col(atof(argv[1]));
printf("(%u, %u, %u)\n", r.r, r.g, r.b);
}


You can easily add new colors by extending the two arrays.
Translating this to python should be straight forward too
>>
>>56224123
I might create a web demo of it later so you can actually see what color values it outputs
>>
>>56224050
>>56224000
Explanation:

You have a string of length 6 and K of 3. Pick one of the 6 positions and rotate it. Test the maximum length and update the global maximum if necessary. Take the resultant string and do the same operation and test again, then again. Now you've rotated three times and can't do any more. Go back the previous operation and choose the next location to rotate (excluding already rotated positions). Continue on until all possible combinations of rotations have been exhausted. You'll have your answer.
>>
>mfw I had to do all these unit tests in java thanks to state and side effects
WOW
>>
>>56224113
current->get_prev() after current->set_prev(new_node) returns new_node instead of the actual prev that you're trying to access

result: current->set_next(current)

(I think)
>>
>>56224159
I'm fairly that would take an exponentially long time to calculate

test every single possible permuation is going to take a long time regardless
>>
>>56224113
is current head and tail global variable?
are they pointers?
>>
here's a good one
https://projecteuler.net/problem=79
>>
>>56224050
>>56224159
I actually understand this, but doesn't that have an insane time complexity? It's actually testing every possible fork for every root rotation, up to K nodes. Supposedly there's a way with worst case being O(N*N)
>>
>>56224175
Ah, that looks like it. I probably should have realized that. I made the new node point to itself it looks like
>>
>>56224231
I actually meant O(N) there
>>
>>56224150
>>56224123
https://jsfiddle.net/szp70opf/
>>
>>56224197
head and tail are member variables of the list class. They are pointers to the first and last node of the list.

>>56224175
>>56224239
I fixed that up but something is still wrong with the links. I must have messed up somewhere in because they end up pointing to the wrong place.
>>
>>56224113
Not related to your problem, but jesus, fix those comments.

x++; // increment x

is literally the textbook example of a bad comment.
>>
>>56224382
I only put that in there because my lecturer put the exact same thing in and they're always picky as fuck about not having enough comments
>>
>>56224191
>>56224231
It would be O (n^K).

>>56224254
That might be possible. It's not obvious.
>>
>>56224382
This.

If someone submitted a change with something like that I'd walk over to their desk and shit on their keyboard.

Metaphorically.
>>
File: 1471120613083.png (56KB, 625x333px) Image search: [Google]
1471120613083.png
56KB, 625x333px
>>56224415
Pajeet? Is that you?
>>
>>56224565
OOP is pretty bad
>>
>>56224216
At first glance this feels a bit harder that 5% diff rating but I think this might work:
/**
* Create a 2D array in which every login attempt gets a row and it's digits
* are spread over the columns, the column size will have to be at least the
* size of the passphrase:
*
* 2D Array: Attempts:
* +-+-+-+-+-+-+
* | |3|1| |7| | 1st
* +-+-+-+-+-+-+
* |5| |1|2| | | 2nd
* +-+-+-+-+-+-+
* |5| | |2| |8| 3rd
* +-+-+-+-+-+-+
*
* Since we do not know the exact passphrase from the beginning the Array must
* change from time to time. From the above example we know that the passphrase
* could be 531278, but we cannot say for sure that '5' is the first and '3'
* the second character. If we get a 4th attempt containing '351' we could add
* it in two ways:
*
* +-+-+-+-+-+-+-+-+
* | |3| | | | |5|1| 1st way
* +-+-+-+-+-+-+-+-+
*
* thus not altering the rest of the table but adding two more columns or:
*
* +-+-+-+-+-+-+
* |3|5|1| | | | 2nd way
* +-+-+-+-+-+-+
*
* switching the first two columns but not extending the 2D array which is
* the favorable outcome.
*/
>>
Why are functions in OOP languages so fucking terrible? In C, everything is call by value. If you want to pass by reference, you can do that easily by passing a pointer to the value you want to change. This makes it easy to see whether a function mutates its arguments or not.

Having call by sharing (passing an objects value means passing a reference to the object) and unironically calling it call by value instead of call by reference is one of the most evil things someone could possibly do.

Why is it that C has the sane default while supposedly high level languages have the insane default? In python this leads to closures being mutable. If a function foo(x) is defined as closure foo(x) = foo2(x,const), and const is mutable, you can have shit like
>>foo(1)
[1]
>>foo(1)
[1,1]

because the closure mutates its enclosed argument. I'm okay with this being allowed if I pass a pointer to const, but this should not be default behaviour. Telling whether or not a function is pure should not be unnecessarily difficult.
>>
>>56224599
>generalizing about object-oriented languages
>uses Python as the example

objects != structs

In something like C#, the behavior is the same as C when working with structs.

Otherwise, you can design your object to be resilient to potential mutations like that.
>>
>>56220025
Working on my depression so I get my med so I can continue working on my project on Java and continue college without all the feeling of apathy.
Oh yeah, I changed my parents WiFi name into a very obscene insult.
>>
>>56224599
>allows a constant to be mutable
>complains that a function using this constant is not pure

What the fuck am I reading?

That's like trying to do physics and allowing some chucklefuck decide the value of pi based on the time of day.
>>
So... having some awkwardness with .NET on Linux. The problem is either with the CoreCLR, with Powershell, or with the Mono C# Compiler.

Say I have a file Foo.cs:

using System;

public static class Foo
{
public static void bar()
{
Console.WriteLine("Hello World");
Console.Clear();
}
}


When compiled with:
mcs -t:library Foo.cs


The result is a Foo.dll with no errors. When I load it into powershell like so:
add-type -path Foo.dll


Again, no errors. When I attempt to run the function bar():
Exception calling "bar" with "0" argument(s): "Method not found: 'Void System.Console.Clear()'."
At line:1 char:1
+ [Foo]::bar()
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : MissingMethodException


Error due to a lack of such a method, despite it being part of the .NET standard. Moreover, when I attempt to clear the screen by:
[Console]::Clear()


No problem. The screen is cleared. If I remove Clear() but keep the WriteLine() statement, it will print Hello World normally.

So the question here to ask is... what is broken?
>>
>>56224622
Anon, Python is the poster child for languages whose main point is to use code written by somebody else. Hence, you will occasionally have to deal with poorly documented code written by someone else, and you will have to figure out which functions in a library are pure or not.

In a sane language, functions as opposed to methods should do a deepcopy of their arguments by default, because that would naturally push people to write pure functions even when they are being lazy, and it'd make closures non-crap. Want to avoid deepcopy for performance reasons? Pass a reference or use a method.
>>
>>56224686
This is the only thing I could find referencing the issue:
https://github.com/dotnet/corefx/issues/4636

This is a stale issue that's been closed, but it references some System.Console contracts that worked on Linux, but not on Windows (irony?). Clear() was one of them.
>>
>>56224751
>Python is the poster child for languages whose main point is to use code written by somebody else
Stopped reading here.

There's a reason why most large enterprise applications are written in Java, C#, and C++.
>>
>>56224682
Well sadly, mutable is default in many OO languages and there's not a lot you can do about it if you want to use all features. Lots of libraries work by mutating their arguments and returning an error code. Doing pure stuff is quite hopeless.
>>
File: mastermind-board-game.png (234KB, 500x393px) Image search: [Google]
mastermind-board-game.png
234KB, 500x393px
>>56224597
that reminds me of that game where you guess the pegs go by elimination

same principle here
>>
>>56224793
>Well sadly, mutable is default in many OO languages

Are you implying that literally everything should be implicitly declared as a read-only constant?

What does this have to do with that shitty contrived example of a poorly written function not being "pure"?
>>
>>56224756

Well, I'm right now using an older version of the CoreCLR, which Microsoft explicitly stated is required to get Powershell to work. I do not know how it is that Clear() cannot be called from a DLL, but can be called from within Powershell itself, however.

Should I just open up a bug report?
>>
>>56224823
>an older version of the CoreCLR, which Microsoft explicitly stated is required to get Powershell to work
Elaborate on this, please.

I'm about to start developing in .NET Core where possible so I can ship my code to other OS's.
>>
>>56224773
But these languages are way too inconvenient for anything numerical. Only C++ has good mature and free scientific computing libraries, but that's mainly because it's fast enough that people put up with its quirks. It could be better or much worse and people would still write in it or maintain existing code, Fortran is a great example of this.

Short of spending 2.5k dollars for Mathematica, Python is the best scientific computing platform available for quick prototyping, mostly because it is the easy memelanguage that people write software in because its easy so there are a lot of libraries.

Which leads you to the question whether you are better off using a library that someone spent several years implementing the wrong way, or attempting to implement and debug your own the right way over a few weeks. Usually it's the former, which is where bad language defaults are a huge PITA.
>>
>>56222136
Lichess is way better than chess.com.
>>
Can someone show me a python course they'd recommend? I was going to learn php but decided to learn python as my first language. Is this a good choice? Im so overwhelmed with all these programming languages. Eventually i want to learn python/ruby, java, javascript, php, C, swift, and sql. A little over ambitious?
>>
I wanna study programming but I cant decide which language I should choose, C#, C or C+?
>>
>>56225087
>All these languages
You can't just learn a language syntax and some of its core libs and call it a day.

Lile what are you even planning to use programming for?
>>
>Decide to try out Xamarin because it seems like it'd be interesting
>The documentation and samples are all massively out of date and deprecated
>FindViewById<T>(int id); is a thing that actually exists
>Even on my i7 building and testing on the emulator takes 20 seconds

How do android devs even cope? I have to assume that doing this in Java in Android Studio is infinitely less garbage.
>>
>>56225130
What do you wanna make/work on?
>>
>>56225130
Depends on what you want to do.

For a complete beginner, C# is easily the easiest language to get in to out of those three.

Or I could meme you and recommend C, knowing that it'll likely make you hate programming.
>>
>>56224820
Damn straight. Immutable should be the default, mutable stuff should ideally have to be declared. This isn't what I was arguing though. What I was arguing for is that functions should not mutate their inputs unless this is made explicit in their type (taking a pointer to the input as their argument).
>>
just a question for people who have actually worked on decent sized projects with other people. when you use build tools like maven, gradle, etc do you include the configuration files/build scripts in version control?
>>
>>56225135
>I have to assume that doing this in Java in Android Studio is infinitely less garbage.
You'd be wrong to assume that.

Android dev in general is hell.

Xamarin is nice if you're already familiar with .NET, but I'm not sure I'd use it over Java for Android dev if I was a complete beginner. Bonus points for being able to deploy to iOS and OSX on the same codebase.
>>
>>56225135
I haven't used Xamarin. But in java it's (cast) findviewbyid(int id) so i guess its about the same.
>>
>>56225130
>C#
Has value in the marketplace, can get you jobs and easily puts up a fight with most lower level languages in terms of performance and has an incredibly fast dev cycle - there's very little you can't do with C# at this stage

>C++
Ancient, unfriendly and horrendously slow dev cycle - people still stick up for it because they have to defend the horrible choice they made in learning it as a first language.

>C
If you want to work in embedded systems or develop applications at a literal snails pace then go right ahead and waste your time on C.
>>
>>56225201
Oh boy, I can't wait for all the memeing you're about to get.

I completely agree with you, though.
>>
>>56225179
>hat I was arguing for is that functions should not mutate their inputs unless this is made explicit in their type
Pass by value is default in C#. The function does not modify the object unless you've given the object its own self-mutating method that can be called from anywhere.
>>
>>56225188
I'm quite comfortable with .NET and C# generally, I've played with Winforms, WPF, NancyFX and Unity when I wasn't working on little lib/API projects.

So far nothing I've done has prepared me for dealing with massively out of date documentation, an antiquated workflow and what can only be described as bizarre design decisions.

Quite who came up with this API I'll never know, but they deserve some form of severe beating.
>>
>>56225179
>Damn straight. Immutable should be the default, mutable stuff should ideally have to be declared.
You're insane.

The average program contains 10 times more mutable fields than immutable.
>>
>>56225130
If you find low-level debugging fun, C is the best choice.

If you want to deal with utterly incomprehensible obscure bugs due to some obscure language feature, C++ is the best choice.

If you want to spoil the fun with code that has errors only because you were a retard, C# is the best choice.
>>
Never said i wanted to learn then, call it a day.
Hopefully get a job, wanted to start up a website and some android and ios applications.
Its just so overwhelming not knowing which programming language i want to start with. I want to start a new chapter in my life where im completely obsessed with anything coding. I want to change my life from a life of manual labor.
>>
in lisp how can i turn the list
((N (S (V A) (V B)))) 
into
(N (S (V A) (V B)))
>>
>>56220369
>someone is helping me find bugs
>he is bad because of that
>>
>>56225299
>how do I remove parentheses?
You can't do this in Lisp. You can only add parentheses
>>
>>56225281
If you want the most job prospects available, pick one of the big 4: Java, C#, C++, Python. I recommend C# if only because it's the best of both worlds of beginner-friendly and massive amounts of jobs.

You should learn basic SQL eventually.

Learn Javascript if you want to get into Webdev.
>>
>>56225243
What I read from this is that you haven't spent much time thinking about how many mutable fields you can eliminate.

For example, recursive functions allow looping entirely without mutable fields, and are equally efficient in languages with tail call elimination.

The fact that there are languages like Haskell or Clojure where everything is indeed immutable unless you go out of your way to mutate them should be a clue.
>>
>>56225305
is this a joke?
>>
>>56225281
I probably should have asked in the stupid question thread. Sorry.
Ill stop
>>
>>56225201
C/C++ still has higher performance than C#

So certain applications still benefit from being written in it. Things like vidya games or anything that requires a lot of calculations. It's the difference between your scientific simulation taking only a day instead of a week to calculate.

Can you even use SIMD in C#?
>>
>>56225299
(car l)
(first l)
(pop l)
(nth l 0)
(elt l 0)
(aref (make-array 1 :initial-contents l) 0)
(elt (make-array 1 :initial-contents l) 0)
(car (coerce (make-array 1 :initial-contents l) 'list))
(first (coerce (make-array 1 :initial-contents l) 'list))
;; ...
>>
>>56225331
>C++ still has higher performance than C#
Not in all cases, and it massively varies on the implementation.

>Can you even use SIMD in C#?
Yes, they added it within the past year, if I remember correctly.

I would say that given enough time, a C++ application will generally be faster than a C# application, but the specific areas of speedup are few and far in-between, and the development time is an order of magnitude longer.

C++ still absolutely has a place in gamedev, but it's being rapidly replaced by other languages in non-engine dev.
>>
>>56225331
>C
Sure
>C++
Not so much.
Like for like, C# either performs as good as or better than C++ - even here C++ is still slower to develop for.

If you want to make the kinds of optimisations that puts C++ ahead of C# the extra time you're investing starts to get out of hand pretty fast. Outside of performance critical applications that have the man-hours to get the job done, there's literally no excuse to use C++ over C# anymore.

As a beginner C# is an infinitely superior choice unless you're specifically looking to get into corporate game dev or academia at which point C++/C become options.
>>
>>56225375
(nth l 0)

is incorrect. nth uses a 1-based index, and the args are in the opposite order.
>>
>>56225392
No wait it's not 1-based. But it is the other way around.
>>
>>56225384
Also, I specifically excluded C from my post, because C and C# are not comparable in most cases; they are languages for different purposes.
>>
>>56225375
>this is how to get the head of a 1 element list in Lisp
>>
>>56225299
>>56225375
Jesus fucking christ.
>>
>>56225392
You're right, just looked it up.
>>
Are any of these books good for a beginner?
https://www.humblebundle.com/books/joy-of-coding-book-bundle

I want to learn some code in my spare time at uni, and I'm a complete beginner. If there are better alternatives, I'd appreciate being pointed towards them.
Also sorry if this is the wrong place to post this, never been on /g/ before and this seems as good a place as any.
>>
>>56224834

https://github.com/PowerShell/PowerShell/blob/master/docs/building/linux.md

>The version of .NET CLI is very important; you need a recent build of 1.0.0 (not 1.0.1).
>Previous installations of DNX, dnvm, or older installations of .NET CLI can cause odd failures when running. Please check your version and uninstall prior any prior versions.
>>
>>56225299
>>56225375

in haskell this is just
head (list)
>>
>>56225384
>Not in all cases
Name a case where C# is faster.

>it massively varies on the implementation
Not really. What implementations are you thinking of? If you're talking about real compilers people actually use then I can't think of any pair of C# and C++ implementations where C# is faster.
>>
>>56225390
You can write C++ that's just as fast as C code, since C++ Is basically C with a bunch of added features.
The added overhead usually comes from the standard library.

Anyway, since i'm mostly in gamedev myself I'm biased for C++, I still prefer it for anything non gui related.
>>
>>56225468
or just
head list
>>
>>56225448
LYAH is fun. I think I had a brief look at "Automate the Boring Stuff" at some point and it seemed like a cool angle to take for an introductory programming book. Haven't looked at any of the others.
>>
>>56225468
>>56225497
Nobody asked how you do it in Haskell though. The request was how you do it in Lisp.
>>
>>56225541
It was a joke
>>
File: 1471950560441.jpg (268KB, 1920x1080px) Image search: [Google]
1471950560441.jpg
268KB, 1920x1080px
When this comes out, I'll finally be one of you
>>
>>56225541
I found out how to do it it was just (car list)
>>
>>lisp is so abstract
>car and cdr literally stand for "contents of address of register number" and "contents of decrement of register number"
>>
>Java is a consumer application software design language
>C++ is machine engineering language
Is there any truth to this? Asking for a friend.
>>
>>56225758
No
Also, both Java and C++ are shit.
What is "machine engineering language" even supposed to mean? First time I hear such a bs.
>>
>>56225802
I think he means machine engineers use it
>>
>>56225299
(car l)

>>56225811
First time I hear such a term. Sounds like made-up bullshit.
>>
I'm trying to implement type generic data structures in C. It's easy enough to do with a macro that defines new functions with the type suffixed. The issue is type generic calls. Any idea how to do this, ideally without making the user specify the type.
>>
>>56225830
You can't with macros. At best you could achieve a very limited few instances, specified at compile time.
>>
>>56220297
>Code with Karlie right?
>>
>>56225870
>.java

Java confirmed for girls' language
>>
>>56220297
is that xml?
>>
>>56225087

>Eventually i want to learn python/ruby, java, javascript, php, C, swift, and sql. A little over ambitious?

The first few language are by far the hardest..

I'd say start with python since it will give you results fast. It's a "small" and clean language.

Then learn C. This will be a littel bit of a shock, because now you see that every Python statement is like multiple lines of code in C. You also have to allocate memory yourself. It's a little bit hard in the beginning, but C is a very rewarding since it's a fundamental language and once you know it, every other language (exept C++) will be easier. So be brave and work yourself through K&R.

Next: Java.
Java and C are not even optional for programmers, they are the common ground every programmer should know. C and Java are have most jobs. And now (coming from C) you'll notice how cool it is that you don't have to fuck arround with memory. With java you can build huge stuff, you can build everything. But it's a verbose language, so if you don't want to get super deep in it, it's OK.

Congratiulations! With Python, C and Java you are already a dangerous man a know a big deal.

Now Ruby. Python and Ruby have a lot of common ground. But Ruby has a lot of very funky stuff hidden inside, so it's actually a lot more complicated than python, but you won't notice that at first. Study it well.

Now Javascript:
The good news is, if you know Ruby you can learn JS in maybe 2 days, because there's almost no concept in JS that's not in Ruby. It's more like you have to learn the "quirks" or JS, i.e. using "===" instead of "==", or the "this" statement (you can find it in many langauges) is very wierd in JS.

If you know JS and Ruby, Swift will take you only a few days to "learn", but eventually you will start to mix syntax up (was this JS? Or Ruby? Or Python?). So don't take your time.

PHP.. just don't. There's nothing in it that's not 100 times better in Ruby.

SQL - definately! Databases are super fun.
>>
niggers. Im stuck.

Im attempting to make a thread-safe static(global) list in C#. I thought I wanted a singleton, but that shit sucks dick.

This is the shit I made. It sucks. How the fuck do I make it better?
   public sealed class ForvoList
{
private static readonly List<ForvoResource> list = new List<ForvoResource>();
private static readonly object objLock = new object();
private ForvoList() { }

public static void Add(ForvoResource resource)
{
if (list.Contains(resource))
{
//Find the index, and replace it.
int index = list.FindIndex(x => x == resource);
lock (objLock)
{
list[index] = resource;
}
}

lock(objLock)
{
//Add the object
list.Add(resource);
}
}
>>
>>56225802
If you don't know the term, then how can you know it doesn't apply to C++?
>>
>>56225980
1: This term does not exist
2: It's easy to know if a term, made up or not fits a language
>>
>>56225964
>Java and C are not even optional for programmers, they are the common ground every programmer should know. C and Java are have most jobs.
Stop grouping Java and C in this respect.

C does not even come close to having the most jobs. Only Java holds this title.

C#, C++, Python, and Javascript all have more jobs than C.
>>
>>56225312
Principle of least privilege implies function arguments should be constant bindings if such a thing is available, I agree.

Agreed: looping constructs are so unintuitive and cornercased when compared to recursive functions. Just let me change devices and I'll cone back with an examole that struck me today.
>>
NEW THREAD!!

>>56226097
>>
File: 1454278176197674710.png (67KB, 1000x665px) Image search: [Google]
1454278176197674710.png
67KB, 1000x665px
>>56226015
Made up or not, you need to know the definition to know what does it apply to.
>>
>>56226106
>2: It's easy to know if a term, made up or not fits a language
>>
File: John_McAfee_Belize.jpg (138KB, 620x372px) Image search: [Google]
John_McAfee_Belize.jpg
138KB, 620x372px
new thread : >>56226133
>>
>>56221590
I did that in C, do I fit in yet?
int main(int argc, char** argv)
{
uint32_t size = atoi(argv[1]);
uint32_t offset = 0;

char row[size];

for(uint32_t i = 0; i < size; ++i) {
for(uint32_t j = 0; j < size; ++j) {
row[j] = ' ';
}
row[offset] = '*';
row[size - (offset + 1)] = '*';

for(uint32_t j = 0; j < size; ++j) {
putchar(row[j]);
}
putchar('\n');

++offset;
}

return 0;
}
>>
>>56225830
You can use C11's _Generic, but it's probably not going to be a very clean solution.
>>
>>56226105

bitch you gotta wait until 310 or it doesn't count
>>
>>56226138
Fuck off
>>
>>56226161

pull up, nigger
>>
>>56226126
In case if "machine engineering language" was defined as any turing complete language, then it will apply to C++ and you were wrong. So it's not easy to know if made up term fits a language.
>>
>>56225966
>How the fuck do I make it better?

First of all, why does your method replace when it is simply called "Add"?

Consider using a
ConcurrentBag
or any of the other thread-safe data structures.
>>
>>56226182
It clearly could not have been defined to that.
>>
Is it possible to export a dictionary into a database in Python?

Essentially I've got a dictionary of key - value pairs, e.g. Name, Age, Date of Birth etc, and I'd like my program to export the data into a database where each user has these values stored and the data can be sorted.

Any ideas how/what I should use to do this?
>>
File: ASSn.png (59KB, 636x689px) Image search: [Google]
ASSn.png
59KB, 636x689px
>>56226301
FUCKING USE GOOGLE REEEEEE
>>
>>56226023

>C does not even come close to having the most jobs.

Tiobe ranks 20% of all projects Java, 10% of all projects C.

I checked it a local job portal which lists about 3,500 Java jobs and about 1,000 C delloper jobs.


>C#, C++, Python, and Javascript all have more jobs than C.

They are pretty equal. Also C is a good fundamental, "C and Java" or "C and C++" or "C and C#" are much better combinations than for example "C++ and Java".

Just lookup any jobsite, ther's plenty of jobs for C devellopers or where C is a requirement.
>>
>>56226310

>mySQL

I've literally never used mySQL before, how do you actually use it?

I only want a local database, nothing online.
>>
>>56226344
Tiobe is not an indicator of jobs.

Please go look at any jobs posting site and type C Developer, C# Developer, C++ Developer, and Python Developer.

You may be surprised by what you see!
>>
>>56226301
If you don't need anything fancy just use pickle.
>>
>>56226373
Take sqlite if you want a local database, and get a clue.
>>
>>56226344
>Tiobe

Their dataset is completely fucked and overrepresents C massively due to a shoddy method of deciding whether it's C.

They count a ton of references to C++/C# as C projects.

Tiobe doesn't even measure number of jobs, either. All those CS101 projects are weighted in.
>>
>>56226394
>>56226410

Read my post again, I wrote:
>I checked it a local job portal which lists about 3,500 Java jobs and about 1,000 C delloper jobs.
>>
>>56226536
I'm not saying that C doesn't have any jobs. It has a fair amount.

That being said, it has significantly fewer jobs than the other languages I mentioned, combined with the fact that many C jobs are filled by 30+-year-olds who have been working with it for a long time in order to maintain legacy applications.

I was pointing out the folly in grouping it with Java as a comparable job-hunting languages. C# and Java are not mutually exclusive, and there is little to no job overlap between them, as you suggested.
>>
>>56226145
You can optimize it further. Using putchar to print your row is a missed opportunity. Either printf a row with size+1 chars and row[size] = '\n', or don't even use the row and call either putchar(' ') or putchar('*') depending on the offset.

Here the two versions, I use two indexes for the the two "*":
void print_X_putchar(int n)
{
int x1 = 0;
int x2 = n-1;
int i;

if (n < 1)
return;

do {
for (i = 0; i < n; i++)
if (i == x1 || i == x2)
putchar('*');
else
putchar(' ');

putchar('\n');
x1++; x2--;
} while (x2 >= 0);
}


void print_X_string(int n)
{
int x1 = 0;
int x2 = n-1;
int i;

char *line = malloc(n+1); // n char and \n
if (line == NULL) {
perror("malloc");
return;
}
memset(line, ' ', n);
line[n] = '\n';

if (n < 1)
return;

// first line
line[x1] = '*';
line[x2] = '*';
printf("%s", line);

while (x2 >= 1) {
line[x1] = ' ';
line[x2] = ' ';
x1++; x2--;
line[x1] = '*';
line[x2] = '*';
printf("%s", line);
}

free(line);
}


Of course the second one is blazing fast with big inputs.For n=100000, 15s with the string version versus 1m30s with the putchar version.
Thread posts: 330
Thread images: 32


[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.