[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: 41

What are you working on, /g/?

Old thread: >>59295944
>>
File: 1455855521252.jpg (46KB, 569x802px) Image search: [Google]
1455855521252.jpg
46KB, 569x802px
Tell me about the NSA!!!
Why do they shill C?
>>
rate my rust fizzbuzz
activate.
prepare functions : num (x) (x) , fizz (x) (x mod 3) , buzz (x) (x mod 5).
prepare list of Int : [1...10000000000000]. ----- compiler : optimize -----
assign : last prepare := n.
make : tuple => (fizz x, buzz x).
assign : last make := t.
call functions in tuple : t.
assign : last call functions in tuple := c. ----- compiler : inline, optimize -----
check if c :
(0,0) ---> fizzbuzz!!!. ----- compiler : optimize -----
(0,_) ---> fizz.
(_,0) ---> buzz.
_ ---> num (future n). ----- compiler : optimize -----
run multiple times : (iterate n) ∧ c (current n).
run on each n : print result of last : check if.
return to os : 0.
deactivate.
>>
>>59301859
What language?
>>
>>59301859
>OS
not!portable
>>
>>59301898
*not portable

crossing the wrong memes
>>
>>59301892
My dialect of rust.
>>59301898
sorry, should have been
return to _ : 0.
>>
>>59301859
>
----- compiler : optimize -----

Disgusting syntax.
>>
>>59301921
What should it be? it looks pretty nice I think.
>>
>>59301756
Tell me about the buffer, why does he use the length?
>>
What music do you listen to when you program?
>>
>>59302165
The Well-Tempered Clavier
>>
File: a0320892916_5.jpg (115KB, 700x700px) Image search: [Google]
a0320892916_5.jpg
115KB, 700x700px
>>59302165
Vaporwave
>>
I'm looking for a book that'll make me a better programmer, should I check out SICP or is it outdated?
>>
>>59301859
FizzBuzz that is computed at read-time:
(set-dispatch-macro-character #\# #\f
(lambda (stream c1 c2)
(declare (ignore stream c1 c2))
`(loop for i from 1 to 100 do
(format t "~a ~:[~;Fizz~]~:[~;Buzz~]~%" i (zerop (mod i 3)) (zerop (mod i 5))))))
>>
>>59302215
Eval/Apply logic will never be out of date, yet K&R presents more concrete examples that show how typical programming problems can be solved with such a minimalist and rigid language as C.
Lisp is minimalist too, but you kind of get lost when it comes to practical use cases. You practically create a new language every time you solve a problem with it.
>>
>>59302215
It's not outdated. Pick up an algorithms book and write code.
>>
>>59302385
>You practically create a new language every time you solve a problem with it.
Wrong.
>>
>>59302385
>You practically create a new language every time you solve a problem with it.

*tips fedora
>>
>>59302392
Which book(s)?
>>
>>59302385
>You practically create a new language every time you solve a problem with it.
What do you mean?
>>
>>59302412
The Algorithm Design Manual and CLRS
>>
>>59302527
Thanks, I'll look into them.
>>
finally pushed my shit to github
>>>https://github.com/jwt27/libjwdpmi
r8/h8/evalu8
>>
What happened with functional programming?
It's not like it's popular as it was anymore.
>>
void main()
{ printf(" __.....__, \n");
printf(" .--/~ ~-._ /`\n");
printf(" .~ ' ~-' L,\n");
printf(" /\ --.\n");
printf(" ` `\n");
printf(" .-~~ `.`\n");
printf(" ,' \`\n");
printf(" ' \ / \n");
printf(" | ,' \ . . ` \n");
printf(" | ' ` | ` |\n");
printf(" `| \ | | |; \n");
printf(" | \_ | / '' \n");
printf(" ` ,' `._ |_/ |/ \n");
printf(" \ __ ~--. /-.`. `. ;\n");
printf(" . '.>' ` /_.'' ,`>. L/\n");
printf(" `. _/`t .d ~~ d L_./\n");
printf(" | /.\\ ''' Y |/\n");
printf(" , ' | > \ ~ .~ L|\n");
printf(" '~-~ ` \`| / \ ,-.\n");
printf(" `-. `. `| `-- |`.__)|\n");
printf(" ,~ `- . ' '\n");
printf(" , ` `-. .' `-.\n");
printf(" / ,' | ~~--._.-' _ |\n");
printf(" | / | | \ |\n");
printf(" | | \--. |'\n");
printf(" ` __../ ~~--.._ |\n");
printf(" \ ..-~~ \~`._ _/ ~ '\n");
printf(" `. / `. \ ~~~~~/ , /\n");
printf(" / ~-.`-. \ / _-~.'\n");
printf(" -. `-. \ / .-~_-~\n");
printf(" \ `-. ~--\ /_.--~~.~~\n");
printf(" `. `-.__ ---~~~~ /\n");
printf(" `. _. . / 'Eiko Magami'\n");
printf(" ~~ `. _/ `. .' (from Project A-Ko)\n");
printf(" / ~| \ ~~ --- Dov Sherm

while (1);
}
>>
>>59302722
all fads die eventually
>>
>>59302722
People who fell for the meme realized that no one paradigm is the only right solution to every single problem.
>>
File: 1457728085180.png (307KB, 500x500px) Image search: [Google]
1457728085180.png
307KB, 500x500px
Am I a set?
>>
>>59302787
Don't forget {code} tags, nigra
>>
>>59302840
Does the set of all sets contain itself?
>>
File: 1447819090410.jpg (25KB, 500x500px) Image search: [Google]
1447819090410.jpg
25KB, 500x500px
>>59302958
If I am a set of all sets, do I contain myself?
>>
>>59302958
only on sundays
>>
>>59303010
Yes, but if you add the condition that you only contain sets which aren't members of themselves, you have Russell's paradox.
>>
Why is it so hard for python fags to provide a working example of an HTML parser?

It should be like 5 lines, but all the examples i've tried have fucked up.

picture related is from https://www.quora.com/How-do-I-install-urllib-and-urllib2-for-Python-3-3-2
>>
File: 1481101192134.gif (239KB, 500x419px) Image search: [Google]
1481101192134.gif
239KB, 500x419px
Am I a category?
>>
>>59303163
You're an object and I'm going to point at you
>>
>>59303126
Use Perl, it's the language for parsers.
>>
>>59303228
pls no bully
>>
File: Pipimi_Points.png (134KB, 439x519px) Image search: [Google]
Pipimi_Points.png
134KB, 439x519px
>>59302175
Great taste anon. Want to join my startup?
>>
>>59302183
How does vaporwave differ from vaporware?
>>
>>59303667
They do not. It's all in your head.
>>
who here vapes dat maryjane while they program?
>>
>>59302385
Not really no.
You tend to start out with the old "every data structure is a hash-table if you look hard enough" approach and after you have some ramshackle solution up and running, you tend to go back and rebuild with better more specialized structures, classes etc.

What's actually interesting is how people tend to start writing their previous language in Lisp. Java and C# programmers will make classes, Javascript programmers will use assoc lists, etc. and then they will use either the loop, or recursive tools to iterate, until they figure out mapcar, and then they figure out macros, etc.

Interestingly enough, I'd say that Java 8 is probably the langauge that's easiest to transition to lisp from.
Reader macros are analogous to java serialization, which they already know about.
They already use streams so mapcar and friends are no stranger, they appreciate quicklisp, quickproject and strict guidelines for how to create projects...
>>
File: 1443322561145.gif (568KB, 240x291px) Image search: [Google]
1443322561145.gif
568KB, 240x291px
>>59303769
Me. I also watch anime while doing so.
>>
>>59302722
It's being absorbed into the current practice and soon you'll see 40 000 curryniggers writing "functional code" that is anything but functioning, and people will then rail against FP just the same as they rail against OOP.
>>
>>59304098
At least it doesn't necessarily have to be garbage, it will be in most cases though. Unlike OOP which is simply defined as "garbage".
>>
Good books on AI development? Language agnostic please.
>>
Writing a mud/engine. It has some neat features like allowing multiple connections and windows so that you can see your inventory and stuff in one window and the game in another.

One question though. I know many muds allow you to connect over telnet. Right now my game is just raw TCP. Would it bring any benefits if I switch to telnet or is just TCP ok?
>>
Playing around with Haskell.

 
class Heap h where
empty :: (Ord a) => h a
singleton :: (Ord a) => a -> h a
merge :: (Ord a) => h a -> h a -> h a
pop :: (Ord a) => h a -> Maybe (a, h a)

insert :: (Ord a) => h a -> a -> h a
buildheap :: (Foldable t, Ord a) => t a -> h a
heapfoldl :: (Ord a) => (b -> a -> b) -> b -> h a -> b

insert xs x = merge (singleton x) xs
buildheap xs = foldl insert empty xs
heapfoldl operator init heap =
case (pop heap) of
Nothing -> init
Just (popped, newheap) -> heapfoldl operator (operator init popped) newheap


data LeftHeap a = Empty | Node a (LeftHeap a) (LeftHeap a)

instance Heap LeftHeap where
empty = Empty
singleton x = Node x Empty Empty

merge Empty x = x
merge x Empty = x
merge heapx@(Node x xs1 xs2) heapy@(Node y ys1 ys2)
|(x >= y) = Node x xs2 (merge xs1 heapy)
|otherwise = Node y (merge ys2 heapx) ys1

pop Empty = Nothing
pop (Node x heapA heapB) = Just (x, merge heapA heapB)


buildLeftHeap :: (Foldable t, Ord a) => t a -> LeftHeap a
buildLeftHeap xs = buildheap xs

heapsort :: (Ord a, Foldable t) => t a -> [a]
heapsort xs = heapfoldl (flip (:)) [] (buildLeftHeap xs)


Is there a way to use buildheap directly by specifying one implementation instead of creating an auxiliary function?
>>
Just woke up, last thread and the previous one really were shitty huh
>>
>>59303769
Weed can make me have breakthroughs with new concepts or help me think of ways to implement things, but it can also make me code lazily as fuck and end up having to rewrite everything later. It's a bit like Ballmer's peak.
>>
>>59304168
>buildLeftHeap xs = buildheap xs
There is literally no need to use buildLeftHeap
If you mean that you specifically want it to use LeftHeap, because it would be ambiguous, you can do two things:
1) Type casting / asserting
(buildheap xs :: LeftHeap a)
2) using the extension TypeApplications
buildheap xs @(LeftHeap a)
3) Using a proxy parameter
data Proxy a = Proxy

>heapfoldl
>empty
You can just make the heap foldable.
If it's necessary, you can make it a constraint
class Foldable h => Heap h where ...
>>
>>59303769
I lose all ability to do math so it never ends up working out that well
>>
File: confusion.png (680KB, 727x682px) Image search: [Google]
confusion.png
680KB, 727x682px
>>59303163
Am I a von Neumann universe?
>>
>>59304217

same, thats why i only vape a little bit of body high type. If i smoke a lot of sativa or whatever the head high shit is called i wouldnt even be able to Hello World.
>>
>>59304427
I wonder if just vaping some CBD or at least low THC strains would be nice.
>>
>>59304427
>>59304458

Degeneracy
>>
>>59304535
people still tripfag in 2017?
>>
i once made a calculator in school in visual studio, by following a guide of course, never felt that i learnt anything though because i always just followed the steps

how do u understand programming?
>>
>>59304632

first step is to rid yourself of any M$ programming langues or IDE's, then buy "C Primer" to git gud.
>>
>>59304650
what IDE do you recommend for Windows programming C? I need something for a shared PC at work.
>>
>>59304535
we out here smokin penises
>>
>>59304730

ok just VS then I guess

C# it is
>>
What's the most redpilled way to learn programing for someone with 90 Iq?
>>
>>59304750
i got a check i got a check
>>
>>59304788
u dont
t. 95 iq
>>
>>59304251
1) was my first reflex but it does not typecheck. I get an error where it can't match t a1 with t a. That's why I made buildLeftHeap to begin with. Will consider 2 and 3.


Making the heap foldable does not typecheck, because Foldable does not have an Ord a requirement while the pop operation and by extension heapfoldl does.
>>
>>59304831
You might need to enable ScopedTypeVariables
>>
>>59304831
>Making the heap foldable does not typecheck, because Foldable does not have an Ord a requirement while the pop operation and by extension heapfoldl does.
Can you not fold if elements aren't ordered?
Normally it's just that you can't insert if elements aren't ordered
>>
>>59304788
ASP.NET web development
>>
>>59304831
Ah, I did manage to get 1) working, but that required the ScopedTypedVariables language extension and some forall annotations.
>>
>>59304822
but I will be starving in a couple of years if i don't find a way to survive.
200$ is what I would be making monthly if I got a job in my shithole country
>>
Can someone here help me with a small SQL query? I know jackshit about SQL and my googlefu is not working

I want to calculate the time difference between 2 consecutive rows

MyTable looks like this

id timestamp
1 13:08:02
2 13:05:58
3 13:03:30

SELECT * A.id, A.timestamp, (B.timestamp - A.timestamp) AS timedifference
FROM MyTable A INNER JOIN MyTable B ON B.id = (A.id + 1)



This works but it doesn't insert the values into the "timedifference" column, it just shows me the results of the query.

I try adding UPDATE MyTable at the start and a bunch of other things but it gives me syntax errors please help me anons it's just for a small project
>>
GIve me one reason why reddit-spaced code isn't much more readable.
def AddHydrusCredentialsToHeaders( credentials, request_headers ):

if credentials.HasAccessKey():

access_key = credentials.GetAccessKey()

request_headers[ 'Hydrus-Key' ] = access_key.encode( 'hex' )

else:

raise Exception( 'No access key!' )


def AddHydrusSessionKeyToHeaders( service_key, request_headers ):

session_manager = HydrusGlobals.client_controller.GetClientSessionManager()

session_key = session_manager.GetSessionKey( service_key )

request_headers[ 'Cookie' ] = 'session_key=' + session_key.encode( 'hex' )
>>
>>59304943
No terminating semicolon?
>>
>>59304943
>This works but it doesn't insert the values into the "timedifference" column, it just shows me the results of the query.
what
>>
File: query.jpg (89KB, 564x605px) Image search: [Google]
query.jpg
89KB, 564x605px
>>59305061
>>59305025

What I mean is I want to UPDATE the values of the column called "timedifference"

When I run the code it shows me pic related (left)

But then when I go into the actual database the values aren't there like in pic related (right)
>>
(crossposting from the other thread)

Hey /dpt/, yet another retarded beginner here

could someone familiar with functional programming tell me how to make this more idiomatic and /or efficient?

type Config = {
Server: string
User: string
}

let ParseConf =
File.ReadAllLines("D:\conf.ini")
|> Array.map (fun (i:string) -> i.Split('|'))
|> Array.map (fun i -> { Server = i.[0]; User = i.[1]; })


thanks in advance lads
>>
>>59304881
The heapfoldl method here is essentially equivalent to folding over the sorted list of elements of the heap, popping them one at a time. You need to be able to compare the elements in order to repair the heap property after popping the biggest element.
>>
>>59305228
looks pretty idiomatic
i'd call ParseConf parseConf though
>>
>>59305228
Combine the maps into one.
>>
>>59302958
yes.
>>
>>59305264
>>59305387

Thanks very much anons, I got it
>>
File: c96ffa58e2f1f32011d0a19b5e643061.png (855KB, 848x1200px) Image search: [Google]
c96ffa58e2f1f32011d0a19b5e643061.png
855KB, 848x1200px
Starting with SICP using Racket.
Let there be memes.
>>
>>59305627
What does this image have to do with programming or anime?
Nothing
Delete it
>>
who here names their parameters funny stuff to fuck with future programmers one youre a old man?
>>
>>59305658
I don't name parameters, they're inanimate objects not fucking dolls
>>
>>59305649
Racket is cute too.
>>
>>59305669

b-but muh readability
>>
>>59305669
>OOP
>>
>>59305851
Are you a 5 year old girl?
No?
Then you shouldn't be naming parameters
>>
>>59305861
object is a C technical term
>>
>>59305873
and C is an OOP language
>>
Is anyone here familiar with parallelism/concurrency (specifically with regards to SFTP)?

From what I have read it appears that it is possible to execute SFTP commands asynchronously (ie. upload and download at the same time). I would like to take it a step further and also connect to multiple different SFTP servers concurrently. Is this also possible?

Just a yes or no is enough so that I know I am not wasting my time trying, though of course some general direction would be greatly appreciated
>>
So I'm doing a homework assignment and it turns out the only way I can think of to accomplish it is to reference a local variable that's outisde of the scope (c++) but that's not possible unless I'm missing something
>>
>>59306320
You can't make it global or pass it as a parameter?
>>
>>59306301
Open up multiple connections?
>>
Is lead developer something you can fake it till you make it position?
>>
>>59306333
Prof has specifically said any homework assignment that uses a global variable gets a 0, no questions asked.

I'm probably retarded, but I don't think passing it as a parameter would work - the assignment is you have a selection sort algorithm and you have to make it so the program displays an iteration of every time the sorting of the array happens.

I've tried passing as a parameter but I get expected primary-expression before ']' token" error.
>>
>>59306410
Well yes, I understand that much. I suppose I ought to have been a bit more specific. My question is rather about the feasibility of a "double parallelism" approach. Would it make much difference to do both, or would I hit diminishing returns quickly? Would it scale well, or would I run out of threads (is that even a thing? I have a surface level understanding of parallelism)

To be clear: I'm talking about opening multiple connections (for async up/down) to multiple different servers in parallel
>>
>>59306450
Post your code. If it's too long for here use pastebin
>>
File: 1487550646729.jpg (84KB, 648x720px) Image search: [Google]
1487550646729.jpg
84KB, 648x720px
What is happening here?
import std.stdio;

int[] cubeandsquare(immutable int arg){
int[] result;
result.length = 2;

result[0]=arg^3;
result[1]=arg*arg;

return result[];
}


void main(){
int i = 25;
int[] arr = cubeandsquare(1);
writeln("Cube: ", arr[0], " and square: ", arr[1]); //prints "Cube: 2 and square: 1"

}
>>
>>59306523
^ is not exp, is it?
and you're calling with 1, not i
>>
>>59306506
http://pastebin.com/66i9T2Qr
>>
>>59306523
C U T E
U
T
E
>>
>>59306558
^ is bitwise XOR
>>
>>59306576
I know namespaces are generally looked down elsewhere, but the prof says you're supposed to use it else its points off, so weird stupid things like that are just following instructions
>>
>>59306523
>>59306558
^^ is exp, ^ is xor
>>
>>59306491
>would it scale well
There's only one way to find out: test it yourself. It's hard to say what's best if I don't know the specifics.
This might be interesting: https://www.psc.edu/index.php/hpn-ssh.
>>
>>59306558
Oh got it, I'm going blind
>>
>>59305658
>anyone will use your shitty software
>>
File: 1451278923691.jpg (148KB, 500x458px) Image search: [Google]
1451278923691.jpg
148KB, 500x458px
So I started my intership yesterday and damn I feel depressed.
Is it normal to understand only 5% of what people are saying ? They talk in devs slang wich I'm not accostumed to and it's like they really expect me to understand all that.
I feel retarded and don't if I really am because people told me it was like that for them too. But since these people expected me to understand, I don't know anymore.
>>
>>59306874
Just google it mate

Programming might not be for you if you can't handle the jargon eventually
>>
>>59306874
>not undestading the jargon
You're fucked, you're absolutely fucked and there's no hope for you at this point.
>>
>>59306874
You're at an internship to learn, ask questions and google shit
>>
>>59302958
>no, because a set of all sets is proven to be impossible
>>
>>59306954
not proven to be impossible, but it is an axiom of ZFC to avoid Russel's paradox

>ZFC does not allow for the existence of a universal set (a set containing all sets)
>>
>>59306900
>>59306906
Well it's not the jargon in itslef but the amount of technical words these people are spitting by sentences.
I fucked up by faking understanding what they were saying to me but tomorrow, I'll just accept to pass as a retard and tell them.

>>59306928
Fuck it, I will.
>>
>>59307077
can you provide an example of something you didn't understand?

/g/ is here to help!
>>
>>59307093
go dive on your head mate
>>
File: qw.png (12KB, 500x607px) Image search: [Google]
qw.png
12KB, 500x607px
>>59307106
>>
File: 1480227650761.png (216KB, 400x470px) Image search: [Google]
1480227650761.png
216KB, 400x470px
>>59307093
Well, I know I'll just have to familiarise with shits like Git Bash and Vue.js and all I'll need for that is time.
And in the last 20 minutes of today, a guy gave me a little exercice that I didn't manage to finish but I didn't really have time to focus on it. I just needed to get it out of my chest

But thanks m8
>>
>>59307093
Ow and yeah, most of the things I didn't understand, I can't even remember what they were.
It was something about the app (the project I'll be working on) running tests on something and putting the results on a page.
>>
>>59303475
Sure, but I program only in Lisp.
>>
>>59307476
It's not a problem.
>>
I hope programming socks is just a joke, right?
>>
File: 1485644540393.png (316KB, 683x623px) Image search: [Google]
1485644540393.png
316KB, 683x623px
>>59308580
>just a joke
>>
What are the best books for learning C++?

I know you all hate C++, but I'm applying to a job that would prefer some familiarity in it, so I'm trying to brush up on it for the interview.
>>
>>59308651
They say Stroustrup's book is good.
>>
>>59308651
>I know you all hate C++,
Don't fall for the memes. If it's a technical interview with people who don't mess around you might want to skim through the standard documents too.
>>
>>59302165
>>59302175
This desu.
Art of fugue requires too much attention.
>>
>>59308632
What's so fun about that?
>>
>>59308814
It's not about fun, it's about programming capability

Report back on if they actually help or if it's just a meme
I won't be joining in
>>
How come there is so many languages that can be used to write native Windows programs?
Do they all compile straight into binary?
>>
File: problem.jpg (52KB, 716x535px) Image search: [Google]
problem.jpg
52KB, 716x535px
I posted this in last thread, didn't get answers
>>
How would I read the hex values of a PNG?

I have the following code, but I don't know why it's not printing anything:

#include <iostream>
#include <fstream>


std::string f_path = "/Users/r/Desktop/d.png";


int main()
{
std::ifstream image_file;
image_file.open(f_path);
int a, b, c;
while(image_file >> std::hex >> a >> b>>c)
{
std::cout << a << b<< c <<"\n";
}
}


Okay, so I changed the "int"s to std::string and it prints out the thing in pic related

Anyone know why I get things like "\211" followed by PNG
>>
>>59302787
You're too old for anime.
Also your shit dose not compile, so I made it compile, and it did not werk.
0/10
>>
>>59306874
Give examples.
>inb4 "object oriented programming"
>>
>>59308889
https://www.w3.org/TR/PNG/
>>
File: 1488889759776.jpg (16KB, 400x400px) Image search: [Google]
1488889759776.jpg
16KB, 400x400px
>>59301737
rate my next year's uni contract :

-Real-time Embeded C POSIX shit
-Kernel programming on Multi threaded CPUs
-JAVA EE + BIG DATA
-IOS apps programming (SWIFT + Objective C)
-Android apps programming (java)
>>
>>59309125
>contract
Maybe you should add an English class as well
>>
>>59308888
Honor my get, respond to this
>>
>>59301756

Tell me about computers

why haven't you killed yourself
>>
  Write a program that calculates with how many zeros the factorial of a given number ends. Examples:
N = 10 -> N! = 3628800 -> 2
N = 20 -> N! = 2432902008176640000 -> 4


WAT DO
>>
What's a good way to practice my programming skills
>>
>>59309471
class faggot
{
static void Main()
{
Console.WriteLine("Put a integer nigga:");
int n=int.Parse(Console.ReadLine());
int k = 0;
int trailing_zero = 0;
while (Math.Pow(5,k)<n) {
k++;
trailing_zero +=n/(int)(Math.Pow(5, k));
}
Console.WriteLine(trailing_zero);
}
}
>>
>>59309479
Programming.
>>
File: 1479596863096.png (20KB, 640x480px) Image search: [Google]
1479596863096.png
20KB, 640x480px
>his language is case sensitive
>>
>>59309471
zerosInFac = length . takeWhile (== '0') . reverse . show . product . enumFromTo 1
>>
>>59309542
TOPLEL wtf is this
>>
>>59309579
[1.. n] = enumFromTo 1 n
product = the product
show = to string
reverse = reverse string
takeWhile (== '0') = take characters from the string while they are equal to '0'
length = length of a string

pretty obvious desu
>>
>>59309516
>>59309471

How does this work, can anyone explain?
>>
>>59309606
yea, try that for big factorials
>>
>>59309630
10k is less than half a second, do you need bigger?
>>
File: 207534059511653.jpg (79KB, 1024x816px) Image search: [Google]
207534059511653.jpg
79KB, 1024x816px
Anyone know of a 'command prompt' style text editor?

i want to write asm without faggoty colours.
>>
>>59309684
install emacs
>>
>>59309608
you're beyond saving

give up now
>>
>>59309516
how did you possibly know this?
>>
is java harder than c++?
>>
>>59309739
No. Java was designed to be so easy that even code monkey pajeets could learn it.
>>
>>59309739
Harder? No, but Java is worse than C++
>>
>>59309739
Learn Lisp.
>>
>>59302328
There's an easier way to get it at read time.
'(#.(your-stuff-here))

and it will be evaluated at read time
>>
>>59309739
C++ is harder than Java, but that's like saying the shits you have when you're constipated are harder than the shits you have when you have dysentery. Sure, one's harder than the other, but in both cases you're uncomfortable and dealing with complete shit. Fuck OOP.
>>
>>59301859
>----- compiler : optimize -----
why not have this on every line?
>>
>>59304063
Well said
>>
>>59309795
unfortunately it has to be java
>>
>>59303126
beautifulsoup/bs4 is all you'll ever need. If you're coming from ruby it's basically nokogiri with lxml
>>
>>59301859
>>59301913
This is nothing like Rust.
There's not enough punctuation.
>>
>>59304959
I'm all for newlines spread around your code but use it to designate off sections of your code, not between every line.
>>
File: 1478515711750.png (27KB, 302x61px) Image search: [Google]
1478515711750.png
27KB, 302x61px
>>59306576
Not sure I understand the issue. Your code compiles and runs. Do you just mean you want to print `number` on line 19?
>>
>>59306576
Ok, ignore my other reply >>59309979
So you want to display the whole array each time you make a swap? Just put a call to displayArray in the outer loop of selectionSortArray.
>>
>>59306576
Here, I did your homework for you kid http://0x0.st/yu_.cpp
>>
Why can't you write a kernel in Python?
>>
>>59309812
Ah, good catch, thanks. I've been getting caught up trying to learn how to work with the read macro functions - and writing unreadable FORMAT format strings. :)
>>
>>59310078
But you can. You can write a kernel in any language given enough effort.
>>
>>59310078
You need to be able to directly address memory so you can pull the memory region map from the bios, so you know what special addresses correspond to the framebuffer, busses, devices, etc...
>>
>>59310157
>You need to be able to directly address memory so you can pull the memory region map from the bios, so you know what special addresses correspond to the framebuffer, busses, devices, etc...
You can do that in python senpai. Just need to setup a stack and minimal kernelspace to run the virtual machine. It's gonna be slow as balls though.
>>
File: 023d46e436d6977afd2205b2f2890841.jpg (644KB, 1915x917px) Image search: [Google]
023d46e436d6977afd2205b2f2890841.jpg
644KB, 1915x917px
working on a website for a mid term
how does this look /g/?

suggestions?
>>
>>59310193
Looks fine by me but make sure it's responsive.
>>
>>59310193
I miss old PowerPoint too.
>>
>>59310193
If it's not all text, it's shit.
>>
>>59310238
blame the rubric
needed to put places we have visited/would visit.
>>
>Retards can't do C++
>Boss wants me to convert API to python to cater to retards

Sometimes I wonder why the fuck did I even choose this job. Fuck you too.
>>
>>59310287
C++ is trash.
>>
>>59310311
Retard spotted.
>>
>>59310311
Yeah sure C++ is trash but Python is fucking hot garbo.
>>
>>59310311
Who the fuck comes on here, sees someone mention C++, and decides it's absolutely imperative they let everyone know what they think of C++?
>>
>>59310316
Au contraire, you have become brain damaged via repeated exposure to C++. You do not understand this because you program in C++. The only cure is an immediate lobotomy.
>>
>>59310337
I don't dispute that.
>>59310357
C++ deserves to be replaced.
>>
>>59310397
My job requires me to code in C++ so I code in C++. I am not about to lose a comfy paying job to debate and force a change in language. The management does. They are changing to Python which is even more hot garbage.
>>
>>59310359
Typical retard.
>>
How do I learn how to program?

I want to learn HolyC, no other language is worth my time.
>>
>>59310451
Sucks for you, then, friendo. Get used to being a pythonista.
>>
>>59306301
>>59306491
That is totally possible.

It might make sense but it depends heavily upon your network. If you have multiple NICs and probably multiple other stuff too then it could make sense.

The best strategy to eke out max parallelism would be to have a bunch of computers in different locations with different networks as in torrenting.

>>59307371
Let me guess. You're a Windows developer and you got a position in a Linux shop?
>>
>>59310454
It's okay. Someone has to maintain the legacy code written in trash languages.
>>
>>59310287
Why not ask for a better programming language than Python? Nobody got fired for using Java (besides than you have interoperability with Clojure or whichever other JVM language you want.)
>>
>>59308889
Open in binary mode you mong.
>>
In Java, can I treat an Integer object as an int primitive for all intents and purposes? Like:
public class Node {    
Integer number;
int frequency
Node left;
Node right;

public Node () {
}
}

Node faggot = new Node();
faggot.number = 69;
faggot.frequency = 69;
>>
Can you guys help me with this
I have to do this:
How many numbers? 8

Input 8 numbers:

1 2 3 4 5 6 7 8

How many place you want to move? 4

Now, they are:

5 6 7 8 1 2 3 4

#include <stdio.h>
move(int array[20], int n, int m){
//write your code here
}
void main(){
int number[20], n, m, i;
printf("How many number?");
scanf("%d", &n);
printf("Input %d numbers:\n", n);
for (i = 0; i < n; i++){
scanf("%d", &number[i]);
}
i = 0;
printf("How many place you want to move?");
scanf("%d", &m);
move(number, n, m);
printf("Now, they are: \n");
for (i = 0; i < n; i++){
printf("%d ", number[i]);
}
getchar();
getchar();
}
>>
>>59310523
Nope. It's an object.
>>
>>59309715
>>59309684

screw that!

D
BOX
S
>>
>>59310553
_B_
DOS
_X_
>>
>>59310542
What I meant to say is if I could use it with operations as if it were an int.
int meme = faggot.number + faggot.frequency;
>>
Bike shedders needed, help me name something
>>
>>59310523
no but you can CAST THAT SHIT
>>
>>59310506
>Why not ask for a better programming language than Python?
Cause the retards aren't natural programmer as so management wants a user friendly language. That is what we get for hiring retards.
>>
>>59308888
N is always the largest of your constants, so your loop will depend on the size of n.

You could use multiple loop counters (i, j, k) and a condition to only loop for a subset of n times.
Make sure you inc/dec all the counters.

Gonna make that block real fucking messy, and although you'll use "fewer loops" the complexity is still O(n).

Don't bother, that's why nobody responded m8.
>>
File: thanks mr shark.png (675KB, 740x836px) Image search: [Google]
thanks mr shark.png
675KB, 740x836px
>>59310464
http://lmgtfy.com/?s=d&q=Learn+HolyC

Ignore those koran classes lol

thanks mr shark
>>
>>59310564
You need to use .IntValue() on them.
>>
>>59310571
Wafflestump
Finklebooger
CoppleFlocker
SlibSnocker
StippyDooder
SlapBickle
FweckPweddy
>>
File: old.png (63KB, 246x184px) Image search: [Google]
old.png
63KB, 246x184px
I really need to learn all the GTK programming? I mean, I can just use a GTK designer and call it a day.
>>
>>59309125
>BIG DATA
>IOS apps
>Android apps

T R A S H
>>
>>59310599
thanks mr shark
>>
>>59308888
It looks fine in terms of efficiency, also look up "sum" in the dictionary please
>>
>>59309536
>implying not being able to use "SomeThing" as class name and "something" as object isn't fucking annoying
>>
>>59310646
It really annoys me that you're too retarded to name fucking variables.
>>
>>59310673
I name all my variable a1, a2, ... aN
>>
>>59310673
Do you only make programs that print hello world?

Why should I bother to properly name an object that is going to be the only instance of a class?

Do you just have a bunch of tmp1, tmp2, tmp3, tmp999 etc?

>>59310706
Not me, although they did basically have the exact same thought as me, just before I was about to hit post.
>>
>>59310706
Okay, Pajeet.
>>
File: S7XRKjB.png (8KB, 455x267px) Image search: [Google]
S7XRKjB.png
8KB, 455x267px
>>59310531
try this
>>
>>59310716
Are you taking the piss?
>tmp1, tmp2,...
>What's an array?

Name variables based on what you're using them for, like an actually intelligent person.
>>
File: 1488902966043.gif (1004KB, 500x375px) Image search: [Google]
1488902966043.gif
1004KB, 500x375px
>>59310722
Wow, so you give your variables cool names, you are so superior, anon.
>>
File: 1440246538429.png (304KB, 722x768px) Image search: [Google]
1440246538429.png
304KB, 722x768px
cmd
if [ $? -ne 0 ]; then

Or
if ! cmd; then
>>
File: 1484186110965.jpg (23KB, 490x480px) Image search: [Google]
1484186110965.jpg
23KB, 490x480px
>>59310761
>he doesn't name his variables m_ki_ap_xxx_el1teSniperIndex_xxx
how many hours have you been programming?
>>
tfw 2 lazy to turn my thoughts into code
wish i could just hire a pajeet to write all the boilerplate for me :/
maybe ill switch languages again and just write macros in Scheme to write 90% of the compiler for me
>>
>>59310803
>boilerplate
Macros are your Pajeet, though.
>>
>>59310553
>>59310563
Not a text editor.

>>59310706
1978 called, they want their naming conventions back
>>
>>59310762
cmd && do_thing

:^)
>>
File: 1341619539905.jpg (107KB, 613x533px) Image search: [Google]
1341619539905.jpg
107KB, 613x533px
>>59310706
What the fuck are you implying?
>>
#include <stdbool.h>
>>
>>59310848
Haskell doesn't have the necessary features to generate my code for me. not even sure Scheme would help out... much of it is more boilerplate in the sense of "obvious code" than repetitive code. my type inference algorithm is just too large for me to write in one sitting lol
>>
I have a list of words, and I have to fit them into as few lines as possible, given a line cap, with one space between each word. Is there an algorithm for this? I think it's pretty simple, sorta like the bin packing problem but far simpler cause only one dimension.

I know you could do first fit to do an estimate, but is there a way to solve this without brute forcing?
>>
>>59310903
#include <conio.h>
>>
>>59310599
thanks mr shark
>>
>>59310929
>my type inference algorithm is just too large for me to write in one sitting lol
must be a shitty algorithm lol
>>
>>59310930
sounds NP-hard lol
>>
>>59310929
Could sell your soul to the devil and use Common Lisp.
>>
I just installed linux on my old gay men machine and I'm gonna use this AMD R9 280x for OpenCL

shit will be comfy
>>
>>59310946
>>59310929
Oh wait are you writing this in C++ or something lol
That would be hell. I implemented a pretty complete Hindley Milner along with the AST (it converts untyped expressions into typed expressions) in ~500 LOC.
Doing that in C++ would be horrible
>>
>>59310940
#include <thighhighs.h>
>>
>>59310946
it's kinda hacky in some ways but seeing as I'm the first one to attempt it I don't really see how I could improve it. that said, by one sitting i mean 30 minutes - 1 hour, which probably isn't even long enough to implement all of Algorithm W from scratch. im nearing 300 LoC just for the type checker itself, not to mention all the data types involved in it, pretty printers, and parsers I'm using so I would say I'm not doing too bad. I have a pretty clear idea of where I'm going to go with it but I have to clean up some rough edges in my plan before sitting down and finishing off the rest of it.
>>59310973
haven't used CLisp since ~2013 and I'm not planning on having to learn the whole thing all over again. plus the algorithm is not so straight forward that it's a matter of generating the code. all i could really do is some kind of pseudocode->actual code system to translate my inference rules into something that I can compile
>>59311017
I'm using Haskell at the moment, although it's already getting pretty unwieldy. I'm right around 700 LoC currently but that's after multiple rewrites of each individual part and I still have yet to do any of the heavy lifting for my algorithm (namely, constraint checking for session types hasn't actually been implemented and I haven't even finished all the basic Hindley-Milner rules)
>>
>>59310853
No. Rest of the script is evaluated regardless of command failure.
>>
>>59311058
Just a question, is it annoying to carry around monads doing this kind of thing in Haskell? Every time I try to see what it's like to implement compiler stuff in Haskell I end up getting frustrated by having to have a bunch of monad shit get in the way just for simple error throwing.
So your algorithm is based on Hindley Milner? What kind of type system do you have? I'm curious. I've been thinking about implementing a sort of local types algorithm, which can infer a lot less programs than Hindley Milner, but has some advantages.
Anyways good luck with this.
>>
>>59311109
Not him but I've done similar
Monads don't really get in the way imho, and in some cases they make things cleaner.
>>
H-Hi can someone help me out I'm learning c# and I don't understand why you would ever hide a method when you can just override it?
>>
File: Capture.png (128KB, 1920x1080px) Image search: [Google]
Capture.png
128KB, 1920x1080px
>>59310531
I got this error (picture)
#include <stdio.h>
move(int array[20], int n, int m) {
for (int mov = 0; mov <m; mov++) {
int *last = array + n - 1;
int lastValue = *last;
for (int *i = array + n - 1; i > array; --i) {
*i = *(i - 1);
}
int *i = *(i - 1);
*i = lastValue;
}
}
void main() {
int number[20], n, m, i;
printf("How many number?");
scanf("%d", &n);
printf("Input %d numbers:\n", n);
for (i = 0; i < n; i++) {
scanf("%d", &number[i]);
}
i = 0;
printf("How many place you want to move?");
scanf("%d", &m);
move(number, n, m);
printf("Now, they are: \n");
for (i = 0; i < n; i++) {
printf("%d ", number[i]);
}
getchar();
getchar();
}
>>
File: vomit.jpg (90KB, 650x650px) Image search: [Google]
vomit.jpg
90KB, 650x650px
>>59311164
>Using visual studio
>Microsoft pushing their non-standard shit
>>
>>59311164
void move
>>
>>59311164
check line 9 again
int* i = array;
>>
File: Capture.png (10KB, 1853x126px) Image search: [Google]
Capture.png
10KB, 1853x126px
Got different errors now
>>59311196
Whats a better free program
>>59311197
void move(int array[20], int n, int m) {
for (int mov = 0; mov <m; mov++) {
int *last = array + n - 1;
int lastValue = *last;
for (int *i = array + n - 1; i > array; --i) {
*i = *(i - 1);
}
int *i = *(i - 1);
*i = lastValue;
}
}

>>59311220
Like this
void move(int array[20], int n, int m) {
for (int mov = 0; mov <m; mov++) {
int *last = array + n - 1;
int lastValue = *last;
for (int *i = array + n - 1; i > array; --i) {
*i = *(i - 1);
}
int* i = *(i - 1);
*i = lastValue;
}
}

I get the same error and this as well
1>------ Build started: Project: Project1, Configuration: Debug Win32 ------
1> hello.c
1>c:\users\jose\documents\visual studio 2015\projects\project1\project1\hello.c(9): warning C4047: 'initializing': 'int *' differs in levels of indirection from 'int'
1>c:\users\jose\documents\visual studio 2015\projects\project1\project1\hello.c(9): error C4700: uninitialized local variable 'i' used
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
>>
>>59311314
>Whats a better free program
GCC (available in MinGW if you're stuck on Windows), Emacs or Notepad++ if you want just an editor, as for IDEs you can look into Dev-C++ and Code::Blocks (both of which come with their own versions of MinGW), I think some of the Java IDEs support C/C++ too.
>>
i swear to god i am going to kill myself. i just deleted my reply twice in a row holy fuck
>>59311109
so it's kind of weird, on the one hand it really does make it a lot easier, especially with the simple code. things like keeping track of all the variables that each function returns become 10x simpler (and clearer) because the monad can do it for me. on the other hand, more complicated parts of the algorithm take more effort (especially when I need to change something about how it's working internally, like I need to add a new state to the monad and end up redesigning half my approach). It's definitely the right choice if you're implementing a well understood algorithm, although it does get in the way a little bit when trying to experiment with new algorithms/making regular changes to your code that completely redo your entire approach.
>So your algorithm is based on Hindley Milner? What kind of type system do you have?
The type system itself is based on Hindley-Milner only because that's the least invasive base I can use for my algorithm. what I'm actually implementing doesn't have much to do with the HM part (and could essentially be thought of as its own separate type system to a certain degree). basically, I'm working on an implementation of multiparty session typing (for an introduction see: http://simonjf.com/2016/05/28/session-type-implementations.html, especially the section about Scribble). the idea is basically a type system that allows you to formalize the communications between N (>=2) message-passing systems. this is what Scribble already does, but my approach is slightly altered because I'm adapting it to work in a context where you can infer types (the idea being that my final language will essentially be like Erlang in terms of brevity but allow for checking your processes against one another statically to find inconsistencies in your logic).
{CONT}
>>
>>59311109
>>59311383
as an example of what my types might look like:
type Server =
forall c < ...!{start : ~> ...?{ok : ~> Eps, err : ~> Eps}}.
[client : c]
?client{start : ~> !client{ok : ~> Eps, err: ~> Eps}}

This essentially describes a system where a server has an unknown client connect to it and send a "start" message, and the server then replies with either "ok" or "err" before closing the connection. The syntax is kinda weird, so "<" is kind of subtyping for session types and the "..." is a "gap" in the type (which can either be empty or involve communications with another session that are invisible to the server, like the client might be talking to a second server in the "..." portions of the type). ! and ? are obviously send and receive (AKA choose and offer) and serve a number of choices (like start, ok, err) that each lead (~>) to their own branch in the type (so a different choice here can cause the protocol to change to satisfy that). "Eps" is the end type (for epsilon, i.e. close the session) and the [ ] syntax just means an implicit parameter (since the client's variable is implicit/unknown to the server beforehand). not sure if I missed anything, but I can talk more about this in the next reply if you have any questions.
>>
File: 1423076106594.png (325KB, 382x417px) Image search: [Google]
1423076106594.png
325KB, 382x417px
how to finish started projects
>>
>>59311314
the right hand side should be array not *(i-1) the position of the asterisk doesnt matter
>>
>>59311403
Step 1: Finish them.
>>
File: 1461128093201.webm (311KB, 240x426px) Image search: [Google]
1461128093201.webm
311KB, 240x426px
>>59311407
Thank you Anon you're the Best! Have this Funny snek and 10 internets!
>>
File: ph.d_in_rape_science.jpg (49KB, 859x640px) Image search: [Google]
ph.d_in_rape_science.jpg
49KB, 859x640px
>>59311403
Reward yourself for small goals that you achieve. For example I turn on my vibrator for 2 minutes when I get sensible plots.
>>
>>59311492
Do you Crossdress while you code
>>
>>59311492
what kind of vibrator? Need recommendations here cmon
>>
Is there literally any advantage to using python 2 over python 3?
>>
>>59311401
the algorithm itself is pretty simple, it's basically just mapping out the branches of each individual session (pretty trivial, as the types you'll see in the Scribble code are not far off from what my language will look like) and then creating the dependencies to that as constraints (so even though the session definition for Server doesn't have a client type to resolve to specifically, it has the constraint for it to match that was pretty simple to infer). originally, this was going to be based on duality (which is a pretty standard approach for binary sessions), but this doesn't work beyond 2 processes (i.e. multiparty sessions). so instead I have to basically perform my own constraint checking here for gaps (...) and based on the target of an operation (!target{...} or ?target{...}). constraints are really weird because they don't match directly to the actual type system, so I have to perform weird kinds of checks (basically recursively searching an inferred type for some kind of match) and this actually involves ignoring the other session's constraints on its type variables (as that would cause endless recursion). so instead what I'm doing is building up the type constraints and waiting till the instantiation site to start matching the constraints (by basically analyzing the dependency order between each declared session). e.g:
let db = spawn Database
let server = spawn Server db # Depends on db
let client = spawn Client server # Depends on server
# So... check client against server then server against db, because I need 2 exact types to compare when checking constraints
>>
>>59311542
the only other weird part of the algorithm is that each "target" must be a named value at the type-level, so that made me implement weird things like named parameters
(server : s) -> client
and implicit parameters
[client : c] server
, which are basically just there for specifying the target within the ! or ? clause. it's really weird because it makes me think of parameters without values to go with them and deal with some interesting type level computations, but i'm trying to stay sane here lol
>>
Is this an okay attempt at webgl?
http://producer-sips-55501.bitballoon.com/
>>
>>59310599
thanks mr shark
>>
>>59311196
devenv is unironically fine
>>
>>59308651
I learned alot just by reading everything on cppreference.com
>>
    char array[10];

int i = 0;
printf("Introduce an element to the array: ");
scanf("%c",&array[0]);
printf("\n");
printf("Introduce another element to the array: ");
scanf("%c",&array[1]);

printf("\n%c\n",array[1]);


Why is this acting so weird? It only prompts me to insert data on the first scanf and then it skips the second and the array doesn't print anything on the screen.

What the fuck is scanf doing?
>>
>>59311737
If you don't print a newline to the terminal the output probably isn't flushed, find a way to flush stdout and it'll probably work as you expect
>>
>>59303769
sorry but im already gay
>>
>>59310193
I would say get more creative.
Also make sure it works on all devices/screens, do proper stylesheets etc.
>>
Why bother with dependent types when you can check things at runtime and throw exceptions if something is wrong? There, I just made years of research obsolete.
>>
>>59311859
post your bleepis then you homo
>>59311916
>waiting for something to come up at runtime when it can all be guaranteed before your program ever runs
you've clearly never dealt with large programs in production
>>
>>59311922
It's called automated testing, you should do it sometime
>>
I have to program pascal's triangle in fucking 8086 assembly. Is it going to be as much of a pain in the dick as I'm already preemptively feeling.
>>
>>59311926
8^===D
>>
>>59311944
I know, it's erection-inducing when you first start using a language with good IDE support and libraries.
>>
>>59311916
They're fun.
>>
Is C actually used nowadays? Specifically in Big Data and AI (The fields I'm interested in).
>>
>>59311931
8086 assembly is only used for embedded systems and writing BIOS/bootloaders, so I'm not sure why pascal's triangle would be neccessary in that environment.
>>
>>59311997
No C is deprecated, don't let CIA shills tell you otherwise. Rust is the future.
>>
>>59311158
bumpe
>>
>>59301737
How do I become less of an autist when it comes to reading code?

Even with my own code, once I'm past even just 100 lines I feel like all the code just overwhelms me to read through.

Maybe I have ADD or something.
>>
>>59311931
You're hosed.
>>
>>59312170
>>Maybe I have ADD or something.
SPEED BRO
>>
I was going to ask this on the stupid questions thread, but I figured it could be better here.
What does it take to develop a programming language?
Let's say a country like India or Turkey wants to develop its own programming language for strategic reasons.
How long would it take to be completed? What kind of investments would it take? The idea is to develop an easy to use yet powerful language.
>>
>>59311997
Yes but not for these. C shines in embedded and system programming.
>Big Data
Much bigger use of DSL like R or SQL dialects. That being said the implementation of the numerical libraries you're calling from say R or Python are usually written in C or C++. So it depends whether you wanna be on the mathematical or scientific side of things.
>AI
"AI" doesn't mean anything anymore since the field that it used to describe when the term was coined is now known to be unreachable. C++ is king of the game for the implementation of large computational software which machine learning, natural language processing and other subfields rely on.
>>
>>59312242
It's easy to develop a programming language. It's hard to develop certain parts of a compiler: A good optimizer, a good register allocator, and a good UI that prints better error messages than "syntax error." It's especially hard to do these things if you want it to function in an IDE. But most of all, it's hard to write good libraries.
>>
>>59311505
Yes.
>>59311531
My ex bought it for me. It was from a local sex shop.
>>
>>59312242
>What does it take to develop a programming language?
There are two aspects when creating a programming language, the theory and the implementation. First comes the theory usually.
First you want to decide what features you want from your language, you have to decide what sort of abstract machine it operates on. In the case of C this is a machine which has space for global symbols, local variables with fixed lifetime (a "stack") and variables with user-managed lifetime (the "heap"). Note those are merely names and don't necessarily refer to the data structure (esp. for the heap). This abstraction is even stronger for functional languages.
You want to specify what the input will look like. This means the "words" or lexemes, this means which sequences of characters are keywords, which are identifiers, literals, delimiters... Then you define how you need to arrange those words in a way that makes sense in your language, this is called the grammar (more familiarly the syntax).
You then need to define what happens when you use specific grammatical constructs on lexemes. This can either be properly defined through Hoare logic, or a bit simpler but still very powerful with operational semantics.

Then you need to implement all this shit.
Usually the tokens are recognized by a very simple finite automaton (think how regex engines work). The grammar requires a bit more involved kind of parsing, depending on which category the grammar belongs to. For C-family languages the main open source implementations (clang and gcc) use a technique called recursive descent parsing. Popular parsers are LALR(1)/LR(1)-generated parsers by tools such as GNU Bison or Menhir.
This usually gives a tree output, called the abstract syntax tree. This is good because it's the most convenient data structure to check the validity of a program (here formalizing the operational semantics help a lot).
Then it's changed into various forms of intermediate representations, too numerous to cite.
>>
>>59312481
RTL and flow control graph are two very popular ways to represent and transform the input for optimization and proper output generation. This called the middle end pass. By the way the thing up to the AST verification is usually called the front-end. Finally you need to find some way to deal with the hardware restriction of your target architecture (instruction set, amount of registers with register allocation). Once you're done it is very straightforward to generate assembly for your target architecture (back-end).
>>
>>59312521
Also the amount of time and money you have to put into developing a language is probably impossible to estimate for a general purpose language, just look at the most popular ones, 20 years after C++, Java, C and Fortran still get revisions.
>>
>>59312589
Scheme is a very simple general purpose language that works perfectly well.
>>
Coming up with a Fraction class and am having a bit of trouble with the "Rule of Three"

Is this the correct way of doing a copy assignment operator?
Fraction& Fraction::operator=(const Fraction& src)
{
if(this != &src)
{
deepCopy(src);
}
std::cout << *this << std::endl;
return *this;
}
>>
>>59301737
What the fuck is "bash" syntax? I need to make a simple shell for an assignment, and the only instructions are
When invoked it should produce a prompt: $
Your program should utilize standard “bash” syntax

The first one is trivial, but I'm not sure what I'm supposed to do to achieve "bash" syntax. The obvious answer is "syntax like bash," but I wasn't aware that bash had any particular "syntax" beyond just parsing inputs.
What the fuck do you think this means?
>>
>>59313275
It's impossible not to have syntax. Things like having the program first followed by spaces and then options which may are may not be optional, the "-" stuff are all syntax. The fact that you feel that bash "has no syntax" means that you are already familiar with bash syntax and expect terminals to operate like that and would probably have designed it like that anyway.
>>
>>59313316
Thanks, that makes a lot of sense.
Another question, though: Are there any shells that don't use bash syntax? I've only used a couple, but they all generally operate the same. Is there a shell with the equivalent of reverse Polish notation or something?
>>
>>59313379
I forget which, but one of the shells to one of those Math environments that I used in college (I don't think it was Matlab) had some pretty weird terminal syntax. But almost all of them use Bash-like syntax.
>>
>>59312170
One step at a time!

Commit to fully understanding a procedure or a class or control flow or whatever abstraction technique your language uses. Keep notes and build your understanding of the system, piece by piece.
>>
>>59313275
It means your "program" shouldn't produce any errors when run.
>>
I need to download 800 pictures, they're numbered from 1 to 800, there sure should be a way to make a dowload loop via cmd, right?
>>
Do you listen to programming ASMR while you code?
https://www.youtube.com/watch?v=dl9W7HYS6OY
>>
>>59313596
Of course. You can do this with anything that can concatenate strings (read: almost everything). A for loop with something like $location + i + $filetype
Or whatever fits the format.
>>
Is there a reason why you can't use enums as array indexes in Java? I've tried reading about it online but all the explanations are retarded and the solutions seem like over-engineering.
>>
>>59313648
I believe it's just another instance of Java protecting you against yourself, regardless of whether or not you know what you're doing.
>>
>>59302165
asmr, but only the weird stuff
>>
>>59313639
I hope it won't try to donwnload $i.jpg or something.
>>
>>59313275
>The obvious answer is "syntax like bash," but I wasn't aware that bash had any particular "syntax" beyond just parsing inputs.

Like bash, your shell should be poorly conceived and result in stupid looking scripts.
>>
>>59313688
It shouldn't, but I don't fully understand how Windows-land handles shit like this.
>>
>>59313711
(You)
>>
>>59313275
Call the professor an idiot and implement your shell using a lisp syntax.
>>
Been coding on NetBeans for a while now.
At uni now, have to use VS2015.
I'm getting an error on 1 line that worked on NB.
Var1 += var2
Var1 is std::chrono::system_clock::time_point
Var2 is std::chrono::nanoseconds

It says there's no conversion.
What do?
>>
>>59313760

Thnx.
>>
>>59313856
Post code fag and use code tags
>>
>>59313856
>At uni now, have to use VS2015.
>What do?
Change universities. Why the fuck would you be forced to use a specific IDE?
>>
>>59313886
I'm on my phone because my uni apparently doesn't like 4chan.

It's c++, and it says that there is no acceptable conversion between them.

This exact cpp file worked on NetBeans

>>59313856
>>
>>59313922
Can't install things on uni computers.
My computer is hardware fucked at the moment. So I figured I'd try theirs
>>
>>59302165
1980s New Wave.
>>
>>59313931
Check the C++ standard applied by the compiler. What you're trying to do is possible only beginning with C++11.
>>
DESIGNATED
>>
>>59302165
Usually whatever's on R/a/dio. I don't watch anime, but the weebs have great taste in music.
>>
>>59313987
SHITTING
>>
>>59313972
Thanks, I figured it'd be something like that.
I've tried forcing c++14 everywhere I could ado arguments. But it still doesn't work. I'll just give up now haha
>>
>>59314004
>>59314112
IDE
>>
New thread:

>>59314495
>>59314495
>>59314495
>>
New Thread
>>59314510
>>59314510
>>59314510
>>
>>59310706
pls dont
>>
>>59302787
Is this what autism looks like?
Thread posts: 330
Thread images: 41


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