[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: 313
Thread images: 34

File: meme.jpg (42KB, 600x600px) Image search: [Google]
meme.jpg
42KB, 600x600px
Special FRACTRAN edition.

What are you working on, /g/?

Old thread: >>60944120
>>
is the cost of golang GC worth it for a less pozzed community than rust has?
>>
Python is the best programming language for 99% of all real life use cases.
>>
why doesn't this work?

(define (length list)
(fold 1 + list))
>>
>>60947151
Neither of the two languages are ready to be put into production yet. Both are too annoying to use as hobby languages. Quite frankly they're both worthless, but golang has a better shot at becoming good.

>>60947167
t. someone who doesn't know shit about how the world works.
>>
>>60947167
and the other 1% of programming tasks are: implementing python.
>>
>>60947190
what should I use for web apps in production though? NOT PHP. I don't want ruby or any script stuff either desu.
>>
https://www.youtube.com/watch?v=EvtkPpZVaU
>>
Write a program RIGHT NOW that has two parallel threads battling for control over a variable.
Thread 1 increments it, then waits a given number of seconds.
Thread 2 decrements it, then waits a given number of seconds.
The program terminates after a given time.

GO!
>>
>>60947240
video gone.

who /kodes with karlie/?
>>
>>60947213
Probably C#, Java, nodejs or something like that unfortunately. I'd prefer golang but the chance of running into a situation where you get stucked because of language limitations is just too high.
>>
>>60947252
X=0
function incr() {
sleep 1
X=($X + 1)
incr
}
function decr() {
sleep 1
X=($X - 1)
decr
}
incr &
decr &
sleep 60
echo $X
exit
>>
>>60947260
https://www.youtube.com/watch?v=EvtkPpZVaU8
>>
>>60947202
>You know immediately what the code is doing
No I don't.
If anything I would assume that it's checking whether the two variables point to the same object, using the == as an iterative comparative is pretty fucking obtuse.
>>
>>60947113
> Copied from the last thread
Anybody have any experience with serverside chat programs? I originally went with XMPP, but it really is an outdated piece of shit. Most of the use cases aren't valid for modern chat applications.

I'm sick of reading/wrestling with the stupid XMPP protcol so I'm going to go ahead and write my own.

I'm torn between using Node.js and Python on the serverside. Is that a bad idea? I really don't care about scalability and overall performance as the chat app is going to have a very small user base.
>>
>>60947354
IRC is way simpler.
>>
>>60947151
>>60947213
Whats the deal with the Golang hype?
>>
>>60947252
func thread(chNum chan<- int, incr bool) {
for {
time.Sleep(time.Millisecond * 100)
if incr {
chNum <- 1
} else {
chNum <- -1
}
}
}

func main() {
chNum:= make(chan int)
go thread(chNum, true)
go thread(chNum, false)
start := time.Now()
var n int
for time.Since(start) < start+time.Seconds()*60 {
n += <-chNum
}
}
>>
>>60947384
People are actually giving it two seconds of time to play around with and finding that it's pleasant to work in, but it's underdeveloped as hell in terms of packages so people used to import disease are too confused to do anything
>>
>>60947364
yeah but IRC has even less featues than XMPP. I need to implement chat history, static roster, static group chat, and a bunch of other features that really are specific to my situation.
>>
>>60947426
BUT MUHH GENERICSS
>>
>>60947411
>used a channel instead of passing a variable reference
I'm a fucking idiot
>>
>>60947426
It has a garbage package system. And I wouldn't call it pleasant with all the if err != nil stuff.
>>
>>60947444
write your own IRC server
>>
>>60947461
The package system is stupid (relying on github? seriously?), setting up the environment is the worst experience I have ever fucking had with any language I've ever even heard of, and if you're not careful the if err != nil does get really out of hand.
But once you get used to handling errors in tiny chunks instead of giant, wrapped try/catch/finally blocks it's got some advantages.

you can also just ignore errors if you're feeling ballsy by using _ in place of err, unlike say Java or C# that will yell at you if you try and do unsafe behaviors.
>>
>>60947151
>preferring "no micro-aggressions" to gay technology
>comparing two languages which are nothing alike outside of their tokenizers
How about you just get back to /pol/ and stop programming entirely.
>>
>>60947475
Why go through all the headache of implementing a shitty standard when I can just write something up quick to work?
>>
File: women in code.png (761KB, 1205x1643px) Image search: [Google]
women in code.png
761KB, 1205x1643px
why can't women program, /g/?
>>
>>60947597
Why do anything at all? Why not just import irc in a python script thats 4 lines long and call yourself a programmer?
>>
>>60947486
>relying on github? seriously

It doesn't rely on any particular website.

>setting up the environment is the worst experience I have ever fucking had with any language I've ever even heard of,

Setting an environment variable in .bashrc is the worst experience you've ever had?
>>
>>60947274
>C#, Java
>stucked because of language limitations
Did you get dropped on your head as a baby? If you can't work around a language's limitations, you might be actually retarded. Node.js is a good choice over Go though. Same speed, less autism.
>>
>>60947613
Why can't heterosexuals program.*
ftfy
>>
>>60947620
>Setting an environment variable in .bashrc is the worst experience you've ever had?
I'm referring to the completely insane Gopath system, where all your projects have to be stored and developed inside that bizarre hierarchy, lest you don't want it to compile or run if you try and split it apart into packages.
>>
>>60947613
>smol pterodactyl
>the same dipshit that got fired from nintendo over gaymurg8 whining
Women.
>>
>>60947618
I'm talking about why implement the standard at all? If it doesn't have defined protocols for the features I want/need then it's pretty useless, correct?

At that point it's more worth my time to just write my own protocol.
>>
>>60947703
I didnt actually read your prior posts. If you're going to write a protocol then the language doesnt really matter, but both Javascript and Python are cancerous trash, especially for network based work, and you should avoid them if you can.
>>
>>60947660
Ah. I never break anything out to be used as a standalone package so I'm usually content to just have a folder of source files wherever and run go build.
>>
>>60947729
Another poster suggested I use Go, but I see a lack of support for a lot of the web-based protocols (no standard websocket implementation).

What do you suggest?
>>
>>60947687
>fired from nintendo over gaymurg8
It's better than that, anon. Back then it was found that she was moonlighting as a hooker, and Nintendo, a company that markets to children, for some reason decided they didn't want a literal whore working PR for them.
>>
>>60947759
I've ended up just lumping every separate file under the main package.
I also hate that packages are meant to be totally reusable chunks of code, instead of letting me separate and organize code within a specific project.

>>60947781
Go lacks a lot of official implementations of stuff, but the ease of its threading and its fairly robust HTTP package make it a decent choice.
https://jacobmartins.com/2016/03/07/practical-golang-using-websockets/

But if not that, Java, C#, C++ are all great choices with very well developed websocket libraries. C if you're feeling ballsy.
>>
>>60947781
If you're gonna use go I'd implement it over H titty pees.
>>
>>60947781
Why does it need to be part of the standard library?
>>
>>60948218
It doesn't have to be, but it would be a plus. Standard library usually means continued support, nice docs, gradual improvements, etc.
>>
>>60947703
>static roster
>static group chat
what do you mean by these
you can implement chat history in ircv3 using the server-time extension and clients that support it will automagically work
>>
>>60948313
The current favored implementation is part of a fairly longstanding collection of web programming packages in go, and has the blessing of the golang devs who haven't yet moved their version from experimental status into the standard library of the language.

https://godoc.org/github.com/gorilla/websocket

I think it has all those qualities you mentioned.
>>
>>60947384
It's basically C for webdev/servers with a GC
>>
@60947445
>MUHH
>>>/v/
>>
what's the difference in semantics in OOP languages between these two expressions?
foo.doOp();

and
doOp(foo)
>>
>>60949061

if doOp is a virtual function then that leads to a dynamic resolution at runtime.
>>
>>60947175
which dialect is this
>>
File: depressed2.jpg (17KB, 300x240px) Image search: [Google]
depressed2.jpg
17KB, 300x240px
require 'fiber'
require 'gosu'
module GRPG
class Scene
def initialize
@fiber = Fiber.new {loop {update}}
end
def update
Fiber.yield
end
def resume
@fiber.resume
end
def draw; end
def done?; end
def bring_out; end
def bring_in(data); end
end
class Overlay < Scene; end
class Transition < Overlay
def coming_back?; end
end
@scenes = []
def scene
@scenes.last
end
def open_scene(scene_class)
@scenes.push(scene_class.new)
end
def close_scene
@scenes.pop
end
def change_scene(scene_class, transition_class = nil)
bring_over = scene.bring_out
if transition_class
open_scene(transition_class)
current_transition = scene
Fiber.yield until scene.coming_back?
end
close_scene
close_scene if transition_class
open_scene(scene_class)
if transition_class
@scenes.push(current_transition)
Fiber.yield until current_transition.done?
end
scene.bring_in(bring_over)
end
def done?
@scenes.empty?
end
def update
scene.resume
close_scene if scene.done?
exit if done?
end
def draw
to_draw = []
@scenes.reverse_each do |drawing|
to_draw.push(drawing)
break unless drawing.kind_of?(Overlay)
end
to_draw.reverse_each(&:draw)
end
def start_game(title, scene_class)
open_scene(scene_class)
(Class.new(Gosu::Window) do
def initialize(title)
super 640, 480
caption = title
end
def update
GRPG.update
end
def draw
GRPG.draw
end
end).new(title).show
end
end
>>
File: 1490837231972.jpg (368KB, 840x700px) Image search: [Google]
1490837231972.jpg
368KB, 840x700px
>>60949295
>>
>>60949295
you should put another Fiber.yield in the loop after the call to update so you don't have to conclude every Scene#update override with Fiber.yield
>>
I have this in my program

 printf("Range of unsigned int is 0 to %d \n", UINT_MAX); 


The result I get is

 Range of unsigned int is 0 to -1 


That doesn't make sense. Why is this happening?
>>
>>60949340
thx breh
>>
File: yukari_mad.png (34KB, 111x189px) Image search: [Google]
yukari_mad.png
34KB, 111x189px
>>60947113
ARRRRGGHH F-FIRST FOR F-FORTRAN
>>
>>60949388
%u
>>
>>60949295
>>60949396
Also you forgot to prefix every method name in GRPG with "self"
>>
>>60949450
shit thx muh dude
is this better?
require 'fiber'
require 'gosu'
module GRPG
class Scene
def initialize
@fiber = Fiber.new {loop {update; Fiber.yield}}
end
def resume
@fiber.resume
end
def update; end
def draw; end
def done?; end
def bring_out; end
def bring_in(data); end
end
class Overlay < Scene; end
class Transition < Overlay
def coming_back?; end
end
@scenes = []
def self.scene
@scenes.last
end
def self.open_scene(scene_class)
@scenes.push(scene_class.new)
end
def self.reopen_scene(existing_scene)
@scenes.push(existing_scene)
end
def self.close_scene
@scenes.pop
end
def self.change_scene(scene_class, transition_class = nil)
bring_over = scene.bring_out
if transition_class
open_scene(transition_class)
current_transition = scene
Fiber.yield until current_transition.coming_back?
end
close_scene
close_scene if transition_class
open_scene(scene_class)
if transition_class
reopen_scene(current_transition)
Fiber.yield until current_transition.done?
end
scene.bring_in(bring_over)
end
def self.done?
@scenes.empty?
end
def self.update
scene.resume
close_scene if scene.done?
exit if done?
end
def self.draw
to_draw = []
@scenes.reverse_each do |drawing|
to_draw.push(drawing)
break unless drawing.kind_of?(Overlay)
end
to_draw.reverse_each(&:draw)
end
class GameInstance < Gosu::Window
def initialize(title)
super 640, 480
caption = title
end
def update
GRPG.update
end
def draw
GRPG.draw
end
end
def self.start_game(title, scene_class)
open_scene(scene_class)
GameInstance.new(title).show
end
end
>>
>>60949432
Thanks. Follow up question why would this work then?

 printf("Range of unsigned char is 0 to %d \n", UCHAR_MAX); 


I get

 Range of unsigned char is 0 to 255 
>>
>>60949613
yo computer fuked up my nig
>>
what do you guys do when you're bored? Vidya isn't cutting it.
>>
>>60949613
An int is wider than a char. Yes the %d indicates a signed value, but specifically it indicates a signed int, and the largest unsigned char can easily fit in a signed int without overflow.
>>
>>60949688
read
>>
>>60949613
%hhd will interpret the arg as a signed char and print -1.
>>
>>60949688
write tracker music
>>
>>60949295
>>60949561
regardless this won't do what you want
>>
>>60947384
It's basically hipsters migrating from Python. The idea behind go is to create a language that is even more basic than C. And since the biggest issue so companies like Google is that you cannot find 30000 competent programmers (in an environment where 100 other companies are trying to do the same), they think it's a great idea how to make morons productive. Kinda like Python, really. Of course it has its mandatory fuckups like any hipster language, but nobody cares because it's used by morons (i.e. same people who see no issue with server-side javascript).
>>
>>60949688
urethral sounding
>>
>>60949688
Anal masturbation.
>>
File: gXQDeIW.png (37KB, 781x581px) Image search: [Google]
gXQDeIW.png
37KB, 781x581px
Currently doing my exercise for implementing a Binary Tree in Java.

Writing the logic for deleting a Node surely was interesting...

But while I was writing it I really would have liked to have C++ References in Java.

But because I didn't had that and didn't want to work out some hacky over complicated way over reflection I just put the two child nodes into an array and worked with the indices.
>>
>>60949061
class Bar:
bars = 0
def __init__(self):
Bar.bars += 1
self.id = Bar.bars
print "Created object #%d of class Bar." % self.id
def doOp(self):
print "Object #%d is doing something." % self.id

def doOp(Foo):
print "Object #%d is doing something." % Foo.id

try:
Foo.doOp()
except Exception as e:
print e
try:
doOp(Foo)
except Exception as e:
print e

Foo = Bar()

try:
Foo.doOp()
except Exception as e:
print e
try:
doOp(Foo)
except Exception as e:
print e


No practical difference, but:
If Foo doesn't exist, then the doOp() functions still exist (in Python, everything is an object, including functions). Foo.doOp(), however, does not even exist until Foo does. So depending on what you want to do and how you like to handle errors, you might prefer one or the other. Foo.doOp() would be preferable if you're trying to stick to OOP.
>>
>>60949877

C++ references are shit. Either use pointers or use values.
>>
File: lel.jpg (1KB, 240x240px) Image search: [Google]
lel.jpg
1KB, 240x240px
>>60949764
fixed, the transition class's fiber was hogging the fdsorgaeh
i moved the scene switching code to the transition class's update method so that even though it hogs the hndgtnfhsg it won't be a probelm
>>
>>60949940
explain
>>
>>60949877
You can probably break this up into two procedures.
>>
>>60949940
But only a retard who can't understand languages other than C would do that.
>>
>>60949960
They are literally invisible state changes.
>>
>>60949977
References, except rvalue references as parameters and const references as parameters, do nothing but harm readability
>>
>>60949940
Why? From my understanding references are worked out by the compiler to pointers anyway. They are just easier to use while coding because you don't have to constantly de-reference them
>>
vector<T> stuff;


for (T t; cin>>t; stuff.push_back(t));

or
for (T t; cin>>t; ) stuff.push_back(t);


Is there any actual difference?
>>
>>60950056
Why don't you disassemble them and find out for yourself?
>>
File: z.gif (765KB, 222x148px) Image search: [Google]
z.gif
765KB, 222x148px
>>60949956
>uses ruby
>is a dumb frogposter
why am i not surprised
>>
>>60950078
>posts in /dpt/
>is a dumb animeposter
why am i not surprised
>>
>>60950021
>>60950038
How do they harm readability? What state do they change? You aren't explaining any of your reasoning.
>>
>>60950108
>posts in /dpt/
why am i not surprised
>>
>>60950181
>not suprised
why am i posting
>>
>>60950181
>posts
why am i not surprised
>>
How do i start to lear python?
>>
>>60950234
By reading a book. Try Automate the Boring Stuff with Python.
>>
>>60950234
Learn Lisp. Then write a big read macro so Lisp can parse Python.
>>
File: languages3.png (17KB, 522x384px) Image search: [Google]
languages3.png
17KB, 522x384px
Reminder that this is still true
>>
>>60950108
>complains about anime on a mongolian wood carving website
>>
>>60950318
Go has both good performance and fast development though.
>>
In managed languages like C# and Java, is avoiding unnecessary branching still important like it is in compiled languages?
Like in C if you can help it you should avoid branching because it's much slower when compiled, but C# and Java run in virtual environments so I don't know if they have the same performance hit
>>
>>60950329
Nope, it has neither.

It can never have good performance as long as it has a GC. It can never have good performance as long as it has a cripplingly limited and restrictive type system.
>>
>>60950343
>I don't want to actually look up benchmarks or read anything, so I'll just say garbage collection is inherently bad
>>
>>60950138

Value semantics should coincide with value syntax. Reference semantics should coincide with reference syntax.
y.mutate(); // Will this cause side effects elsewhere in the program? Who knows until you check the declaration of y.

doThing(x); // In plain C, I know this won't modify my x. You don't know that in C++ until you check the declaration of doThing.
doOtherThing(&x) // In plain C, the implication is that x will be modified. C++ should have stuck to this.

Reference semantics are dangerous and should be marked clearly with reference syntax. Obscuring action at a distance so you can save a few characters explicitly dereferencing is brain damaged and cancerous.
>>
How many languages should top programmers know?
>>
>>60950357
What are you talking about, garage collection IS inherently bad. What would you even do it for. Think about all the people who don't even have a place to live and you're just sitting on your ass fucking accumulating garages. You know, when you can only drive one fucking car at a time. Jesus christ.
>>
File: c_vs_go.png (38KB, 646x401px) Image search: [Google]
c_vs_go.png
38KB, 646x401px
>>60950357
https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=gcc
>>
Best resource for learning Python?
>>
>>60950340

If you're using a managed language, you don't care about performance enough to start avoiding branches.
>>
>>60950396

code academy, python website, books (learning python & then programming python)
>>
>>60950381
one of each
>>
File: 1497634991602.png (17KB, 337x372px) Image search: [Google]
1497634991602.png
17KB, 337x372px
I started to program to forget the feel of no gf.
>>
>>60950418

one of each what?
>>
File: go_is_trash.png (9KB, 230x173px) Image search: [Google]
go_is_trash.png
9KB, 230x173px
Holy shit, go is absolute trash, worse than useless
>>
>>60950386
>>60950388
Seems pretty damn performant to me.
No, it's not C levels fast, nothing is C levels fast except for C and ASM. Don't be obtuse.
And look at that memory usage. Seems like the GC is doing pretty fucking great.
>>
>>60950388
wtf i hate rob pike now
>>
>>60948371
I just got done implementing a websocket server in Go using that package and it couldn't have been simpler or more elegant. Shame it has to connect to an absolute mess of HTML and CSS on the client side.
>>
File: 1481933632025.png (18KB, 203x209px) Image search: [Google]
1481933632025.png
18KB, 203x209px
>>60950428
>>
>>60950422
lucky. I started to program last week to forget the fact my ex wife has my child

stop being a bitch, forget about women, learn to program, get paid get money
>>
>>60950396
Learning just Python, or learning how to program while incidentally using Python? I.e., are you new to programming?
>>
>>60950430
>nothing is C levels fast
Julia is pretty close.
>>
>>60950422
>tfw autistic misanthrope born with insane mathematical talent and no desire for companionship
>tfw there is no fw no gf
>>
>>60950430
I'm not being obtuse. C and C++ have good performance. Java and Go do not. You will note that the original image lists C, C++, and ASM as languages with good performance. Not Java. It doesn't matter that Go is about the same speed as or slightly faster than Java.
>>
>>60950430
Why are we now talking about garbage collection.
I thought we were talking about garage collection.
... Wait, I misread from the beginning. Shit
>>
File: DSC05477freigestellt.jpg (194KB, 600x569px) Image search: [Google]
DSC05477freigestellt.jpg
194KB, 600x569px
>>60950318
Is Java in, "good performance, Fast development, or neither?"
>>
>>60950467
>Learning just Python, or learning how to program while incidentally using Python?
Little of both. Knowing how to use Python is something would immensely help as an engineer, but I'm interested in the latter personally.
>I.e., are you new to programming?
Yes
>>
>>60950494
Good performance.
>>
>>60947190
>Neither of the two languages are ready to be put into production yet.
Kek, delusional
>>
>>60950494
Neither

>>60950502
Fuck off
>>
>>60950318
Ruby should be under "Fast development"
>>
>>60950518
No, it shouldn't. If it's the language you're most productive in then that merely says that you are a limited programmer.
>>
>>60950511
>Fuck off
But it's true though.
Java is about as fast as C when you write C-like Java.
And if you don't write C-like Java, you should have Java taken away from you.
>>
>>60950530
You should have Java taken away from you regardless
>>
>>60950530
What does C-like Java look like? I kind of get the feeling it doesn't exist.
>>
>>60950530
>Java is about as fast as C when you write C-like Java.
It is impossible to write C-like Java in general because Java lacks struct types.

Also https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=gcc&lang2=java
>>
>>60950527
I can write a kernel in C.
I can write a kernel more quickly in Ruby than I can in C.
It would be a very slow kernel.
>>
>>60950498
Try https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/
>>
>>60950527
>2017
>being this autistic
>>
>>60950388
Why don't you pick some one of your own size?
>>
>>60950569
You could write a kernel even faster in Haskell, Scheme, or Idris, including time spent fixing bugs.
>>
>>60950583
This matters why exactly?
>>
>>60950582
I already know that Go is slower than Rust. Your image tells me nothing new.
>>
>>60950582
Rust BTFO
>>
>>60950596
It's the reason that those languages are in the fast development category, and Ruby is not.
>>
>>60950616
I'd hardly call that BTFO
>>
>>60950617
Yeah but the cutoff point is wrong though.
>>
>>60950634
Agreed. More like Go BTFO, because it's several times slower than a language that only recently reached 1.0, despite having a worse type system and less safety.
>>
>>60950661
Why, because your favorite language is excluded?
>>
>>60950678
No, because it's ridiculous to restrict the label "fast development times" to languages that sport the fastest development times of all languages.
>>
>>60950363
Objecting to the syntax is a poor justification for overloading every value behind a pointer with a possible null value. In C there's also no way to decisively tell from the either the call site or the function signature whether the value will actually be changed, you just have to make that assumption due to it being passed by the address.
>>
>>60950704
Why is it ridiculous?
>>
>>60950714
Because just because a shade of red isn't fully saturated doesn't make it a shade of cyan.
>>
>>60950714
Just like good is not perfect, fast is not fastest.
>>
>>60950735
I'm not saying Ruby has slow development, just that it doesn't have fast development. It probably lies somewhere between the two.

Why are you so offended by this?

>>60950742
But good is distinct from mediocre.
>>
>>60950781
>it doesn't have fast development
I just don't agree with this though.
>>
i am currently building my own cpu from scratch using only nands
i already wrote an instruction set and implemented it into llvm
which i'll use to compile my compiler after I write a proper language
>>
>>60950798
Well that's just, like, your opinion, man.

Maybe it's a sign that I've grown to rely on the compiler as a crutch but in languages like Haskell I feel freer to move faster and be more reckless when writing code or refactoring because I know the compiler will likely catch my mistakes.

When using something like Python I feel I have to be much more cautious and constantly check and second-guess myself. Yes, tests help, but a good type system eliminates the need for a huge portion of tests, and writing tests is really, really tedious.

Scheme (and other lisps) get a pass though because their macros are so powerful.
>>
File: qt.jpg (35KB, 480x480px) Image search: [Google]
qt.jpg
35KB, 480x480px
I'm trying to learn how to use Spacemacs properly, but the keybindings simply doesn't make sense to me, using "Ctrl + W" to crop text and "Ctrl + /" to undo changes are just not right, not to mention some of them are quite hard to remember

Is it really worth to use Emacs over other text editors? I thought it was a good idea to try it since a lot of good programmers use it, but for now I'm faster using something like Sublime Text instead
>>
>>60950917
shut up ruby


also hi
>>
>>60950917
>a real human bean
>>
>>60950917
Have you tried vim?
>>
>>60947384
>quite fast
>doesn't get in your way
>close to what's already known to work well
>(although an accident) probably the best language to implement service programs
Really not surprised it caught so much attention. I wouldn't use it for anything else than network services though.
>>
>>60950704
>languages that sport the fastest development times of all languages
>One of the listed language's features is to have the longest build time since they Pyramids
>>
>>60950982
B-but I'm not ruby

>>60951012
Not yet, is there any particular reason to use it over Emacs?
>>
>>60951095
>is there any particular reason to use it over Emacs
Not this guy but I use vim, it's definitely longer to get used to than emacs. It's much lighter though. Try both and see which one you prefer.
>>
>>60950917
is this a girl or a girl (male)
i need to know for reasons
>>
>>60951118
It's actually a sexbot
>>
>>60951118
>>60951129
>>>/trash/
>>
>>60951117
Also vim users won't unironically suggest you buy "emacs pedals" to be more productive.
>>
>>60951129
that's horrifying
science has gone too far
>>
>>60951095
>Not yet, is there any particular reason to use it over Emacs?
Wrt the op, a lot of the commands in vim are mnemonic.
>>
>>60951117
Alright, thanks for the tip
>>
>>60951146
>the vim emacs debate again
>not using nano
>mfw
>>
>>60950056
std::copy(
std::istream_iterator<T>(std::cin),
std::istream_iterator<T>(),
std::back_inserter(stuff)
);
>>
File: avi.png (35KB, 136x122px) Image search: [Google]
avi.png
35KB, 136x122px
>>
>>60950917
It is really comfy and the keybinds make sense once you get used to them/read about them. It does not take long to get used to them.
>>
>>60951240
>>60951141
>>
File: 0.jpg (214KB, 1518x947px) Image search: [Google]
0.jpg
214KB, 1518x947px
Hi guys.
im trying to take the dimencion of 2 matrix's
one called matrizA.txt with
3 3
2 0 1
3 0 0
5 1 1
and matrizB.txt with:
3 3
1 0 1
1 2 1
1 1 0
and write "matrizC.txt" with the multiplication of A and B
but c++ crash before making the archive.
can someone help me?
>>
File: 1491944242584.png (3KB, 32x31px) Image search: [Google]
1491944242584.png
3KB, 32x31px
>>60951240
ftfy
>>
File: thisone.png (222KB, 521x469px) Image search: [Google]
thisone.png
222KB, 521x469px
>>60951271

hahahhaa
>>
In C, how hard would it be to write your own function for malloc?
>>
File: sachiko.png (323KB, 784x1008px) Image search: [Google]
sachiko.png
323KB, 784x1008px
Is this undefined behavior?

struct vec3d {
union {
struct { double x, y, z; };
double arr[3];
};
};
>>
Is Javascript supposed to be hard to learn? It sounded like scripting languages were supposed to be easy but this is making me want to die
>>
>>60951284
It's actually quite trivial but it depends on how effective you want it to be. K&R2 has some pages dedicated to that.
>>
>>60951292
No, why would it be?
>>
>>60951269
Any context on this? Is it just a textbook exercise?
>>
>>60951292
>Is this undefined behavior
How can a declaration be?
>>
>>60951239
Why is this better?
>>
>>60951269
>DevC++
Lmao

>windows
kek

>these variable names, that indention
wew
>>
>>60951269
DevC++ takes me back to the early 2000 man. Also you have a typo in your call to fprintf. Don't believe that's your problem though.
>>
>>60951284
It's not possible to do in purely strictly conforming C, if that's what you're asking. Otherwise it depends on your platform.

>>60951298
What exactly are you finding to be difficult?

>>60951310
Are you sure? I thought type punning was ALWAYS undefined behavior, though it's guaranteed to work as expected in any sane implementation.
>>
>>60951342
Not him but Dev is actually very widely used in Latin American compsci courses.

What do you use?
>>
>>60951360
>It's not possible to do in purely strictly conforming C
Yes, you can.
>>
>>60951284
Not hard at all given you know data structures and system calls. Memory allocators are more about the design than the implementation (although you obviously have to make sure there are no bugs as they can be rather problematic). Good things to begin would be to mmap a heap and use a linked list allocator. Then try something like red-black trees or AVL. Finally you can look into the actually used allocators.
>>
File: 1.jpg (202KB, 1523x947px) Image search: [Google]
1.jpg
202KB, 1523x947px
>>60951269
>>60951315
yeah its for college, we dont even use c++ for anything actually.
i just changed the fprintf.
any ideas?
>>
>>60951370
I don't use any IDE as I'm one of the vimtards from above, so you could say I use my shell. When I did my internship working on the SOFA framework I used QtCreator which worked fine but didn't feel like it was worth the resources
>>
>>60951401
Can you imagine going to college and paying to learn free online programming tutorials?
>>
>>60951299
>>60951360
>>60951382
I see. I'm doing some labs from CMU and I'm already having a hard time with the first lab. One of the later labs is malloc. Trying to gauge how difficult it is, because I think this is all beyond me.
>>
>>60951401
>/n
Put code on pastebin, don't feel like reading on a screenshot
>>
>>60951414
No, but I can imagine running a college that dies that. Lods of emone for nothing.
>>
>>60951318
int foo[*(unsigned long *)NULL)];
>>
>>60951415
It's normal to feel overwhelmed by such things if you just started. Most programmers wouldn't even ask themselves what happens when they call malloc (they probably believe it's magic or some shit). But it's a really rewarding exercise so I recommend you suck it up and try to go as far as you can.
>>
>>60951415
Everything will be beyond you, until it is not.
>>
>>60951421
https://pastebin.com/mdp3ypCZ
>>
>>60947113
Just flashing some led's on my arduino with a little 3x3 matrix

It's not quite as simple as you might think lol
>>
>>60951401
>jpg screenshot
When will you end yourself?
Where is the error output?
When will you move to a proper OS and editor?
>>
newfag to technology but studying really really hard..

I am trying to learn python and it seems like I need more expierence with command line usage in shell etc.


How should I practice how to use powershell bash etc?

Should I get arch on virtualbox and try to practice with that also?
>>
>>60951401
Why do people write C code like this?
No spaces anywhere and K&R braces, it's disgusting.
>>
>>60951459
dog chill
i dont like c++ its just for college
>>
>>60951373
No, because "purely strictly conforming C" means no external libraries, no inline assembler or other compiler extensions, and no dependence on implementation-defined behavior.
>>
>>60951415
>this nigger who knows absolutely nothing got into CMU but I didn't
They surely do a great job on selecting new undergrads, wow.
>>
rate my implementation of free

void free(void *ptr)
{
}
>>
>>60951452
You don't use fscanf like that. You're supposed to feel memory addresses which you're not doing in this code.
>>
>>60951481
And you can make malloc without any of that.
>>
>>60951487
That's actually what happens in the first phase of my kernel heap. I think most people use placement heap for hobby OSes.
>>
>>60951487
rate my implementation of malloc
void *
malloc (size_t size)
{
return 0;
}
>>
>>60951468
Play and learn as you go: http://overthewire.org/wargames/
>>
>>60951474
That's actually closer to Java brace style, K&R is similar but places the opening brace of function bodies (and ONLY function bodies) on its own line. However neither convention indents close parentheses an extra level.
>>
>>60951496
static char heap[1 << 31];
static char *ptr = heap;

void *malloc(size_t n)
{
void *result = ptr;
result += n;
return result;
}

void free(void *ptr)
{
}
>>
>>60951496
That's my point.
>>
>>60951484
You're assuming too much. The CS:App class material is freely available online to anyone. I go to one of UW's satellite campuses, not even for CS.
>>
>>60951523
>static char heap[1 << 31];
Enjoy the 2GB binary. Better just do a mmap.
>>
>>60951512
Thank you~

Have tits
>>
>>60951528
>you can't do it in purely strictly conforming C
>yes, you can
>That's my point.
???
>>
>>60951533
>Enjoy the 2GB binary
It will not produce a 2GB binary.
>>
>>60951496
How would you go by programming free() though? You would need direct access to the operating system to mark your memory address as free, is that possible with the standard C libraries?
>>
>>60951551
>syscalls are an "external library"
Pajeet pls
>>
>>60951468
Not Arch but something else that JustTwerksâ„¢. Then start using that vm for everything you can, especially the cli. You'll get used to it in no time.
>>
>>60951551
>You would need direct access to the operating system to mark your memory address as free
No, you do not.
You can either do something like >>60951523 or if you have a better implementation of malloc mark chunks as free.
>>
>>60951551
No you wouldn't since the program knows its heap.
>>
>>60951543
Yeah, I misread your post, thought you said can't. >>60951523 did provide an example of how it can be done, which I hadn't considered.
>>
>>60951551
>direct access to the operating system to mark your memory address as free
And that's not "standard C" because?
>>
>>60951563
They are, though. The whole point of the C standard library is that it's available EVERYWHERE, regardless of the underlying operating system. There's no fork() on Windows, so it can't be part of the standard library. But both Unix, Windows and just about every other OS out there can allocate memory and write stuff to the console, so you can have functions that do that. So it's true, any program that uses syscalls directly in any way (whether through OS headers, inline assembly, or assigning literal addresses to function pointers) is not strictly conforming. You can "use" syscalls indirectly through C library wrappers for those syscalls, but you can't leverage that to access other syscalls.

I'm not saying you should write non-trivial software in "strictly conforming C", because that's needlessly impractical. The point is though, that anything to do with hardware or underlying OS specifics is outside the jurisdiction of the C specification.
>>
i give up...learning shell is too hard ._.
>>
>>60951680
Why are you learning shell, anon?
>>
>>60951685
it's convenient
>>
>>60951659
That has nothing to do with being "strictly conforming" or not.
>>
>>60951680
What are you having trouble with?
It's really simple.
And if it had any semblace of variable scope, you could write entire applications in it.
>>
>>60951453
for instance, how to control brightness of all 9 leds - without interfering with each other (if possible) or using the interference pattern, on 6 pins
>>
>>60951701
Evidently not if you're giving up because it's too hard
>>
>>60951685
>>60951703
I need to learn how to use it if I m going to be a technology person.

Idek what im doing with that game site someone showed me earlier.

>>60951701
dont pretend to be me baka
>>
>>60951680
Do this >>60951512
>>
File: 1497620800981.png (113KB, 328x300px) Image search: [Google]
1497620800981.png
113KB, 328x300px
>>60950108
This is a website oriented towards japanese culture, and is modeled after a popular website in japan. As such, the inclusion of anise-related material is acceptable. The use of frogs, however, is not.

Dumb frog poster.
>>
>>60951749
Nevermind, do you need help with it? The first challenge of Bandit is just learning to connect to a site with ssh.
>>
>>60951744
Are you familiar with the unix philosophy?
You do all your useful work in shell scripts by piping multiple programs together.
Even the [ ] operators are an alias for the test command, which is a shell built-in command.
>>
>>60950318
> No rust.
Not very inclusive if you ask me. Please redo to include rust.
>>
>>60951769
im figuring it out.
I cant be babied literally twenty minutes in but i appreciate it~

>>60951778
I have zero expierence with programming and learning computer basics. I am studying for comptia A+ and I am also spending my free time studying side things like programming etc. A common theme in both is shell, bash, cmd, etc. I feel as if I should at LEAST learn the basics on how to navigate this as much as possible. I have never used unix before.
>>
>>60951744
>>60951571
>>
>>60951702
>"A strictly conforming program is one that does not depend on any implementation-defined, unspecified, or undefined behavior, that does not exceed any implementation limits, and that otherwise uses only the features of the language and library as specified in the Standard."

There is however a bit of ambiguity about "only the features of the language and library as specified in the Standard", in that it clearly forbids use of any extensions present in a particular implementation of the C standard library, but does it allow use of OTHER libraries? My assumption is that the answer is no, because A) it would make the limitation on library extensions meaningless and B) the whole point of strictly conforming seems to be that it is guaranteed to work on any conforming implementation, where windows.h or curses.h or whatever may not be present. Whereas a "conforming program" is merely one that can be compiled on a conforming environment, but not neccessarily ALL conforming environments.
>>
>>60951796
"e.g." specifies that the languages mentioned are only examples, not intended to be an enumeration of all languages. The absence of any mention of Rust is merely a symptom of a larger problem - it only addresses performance and development time, not correctness (which is the specialty of languages like Rust and Ada, and to a lesser extent Java and Visual Basic).
>>
>>60951796
Rust is not yet fast enough.
>>
>>60951880
Fast in terms of and in comparison to what, anon?
>>
>>60951882
In terms of performance? Compared to C and C++.

In terms of development? Compared to Haskell and Lisp.
>>
>>60951705
unsigned long time1 = 0;
unsigned long time2 = 0;
unsigned long time2b = 0;
unsigned long time3 = 2000; // ~500Hz

unsigned long stime1 = 0;
unsigned long stime2 = 0;

int countsec = 1000000 / time3; //100 step/sec
int cstep = 0;

boolean freq(int bval){
time1 = (time3 / 100 ) * bval;
boolean fstep = false;
time2 = micros();
if(time2<(time2b + time1)) fstep = true;
if(time2>(time2b + time3)) time2b = time2;
return(fstep);
}

boolean simptimer(long xmillis){
boolean fstep = false;
stime2 = micros();
if(stime2>(stime1+xmillis)){ fstep = true; stime1 = stime2;}
return(fstep);
}


int xcount;
int ycount;
boolean xhigh;

int xpin[10];
int ypin[10];

bool xpval[10];
bool ypval[10];


void setup() {
int x1[] ={3,5,7};
int y1[] ={8,6,4};
initpins(3, x1, y1, true);
cleardisp();
}

int b1 = 10;
int b2 = 10;
int b3 = 10;

void loop() {
if(simptimer(125000)){
b1 += random(20)-9;
if(b1>40) b1=40;
if(b1<0) b1 = 0;
b2 += random(20) - 9;
if(b2>30) b2=30;
if(b2<0) b2 = 0;
b3 += random(20) - 9;
if(b3>20) b3=20;
if(b3<0) b3 = 0;
}
bool highlo1 = freq(b1);
bool highlo2 = freq(b2);
bool highlo3 = freq(b3);
setdisp(1,0, highlo1);
setdisp(2,1, highlo2);
setdisp(0,2, highlo3);
updatedisp();
}

void initpins(int counts, int ixpin[], int iypin[], bool ixhigh){
xcount = counts;
ycount = counts;
for(int i=0; i<xcount; i++){ xpin[i] = ixpin[i]; pinMode(ixpin[i], OUTPUT); }
for(int i=0; i<ycount; i++){ ypin[i] = iypin[i]; pinMode(iypin[i], OUTPUT); }
xhigh = ixhigh;
}

void cleardisp(){
for(int i=0; i<xcount; i++){ xpval[i] = !xhigh; }
for(int i=0; i<ycount; i++){ ypval[i] = xhigh; }
}

void setdisp(int x, int y, boolean onot){
xpval[x] = xhigh == onot;
ypval[y] = !xhigh == onot;
}

void updatedisp(){
for(int i=0; i<xcount; i++){ digitalWrite(xpin[i], xpval[i]); }
for(int i=0; i<ycount; i++){ digitalWrite(ypin[i], ypval[i]); }
}
>>
>>60951809
Good. It does try to make you self-sufficient early on, so don't get discouraged. Use the man command whenever you don't understand something.
>>
>>60951891
>bool
>boolean
>>
>>60951890
>In terms of performance?
Rust lies between C and C++.
>>
>>60951435
Wouldn't compile. Array lengths have to be compile time constants
>>
>>60951907
https://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=rust&lang2=gpp

Sometimes it does.
>>
>>60951922
Not in GNU C or C99
>>
>>60951762
Because she is a gross bat.
If the bat face was gone, I would do.
But the bat face is there, so it's not.
>>
>trying to learn javascript from book
>ok now just install this npm module
>entire next chapter is full of calls to this one specific version of this npm module instead of explaining what it does

why do people do this?
>>
>>60947113
Guys, I finally figured out how to break out of two loops instead of just one

vector<vector<float> > image;
image.resize(100);
for(auto &vec: image)
{
vec.resize(100);
}

image[20][10] = 10;

try
{
for(auto vec: image)
{
for(auto flt: vec)
{
if(flt == 10)
{
cout << "Value " << flt << " found\n";
throw 20;
}

}
}
}
catch (...) {}

Simple, right?
>>
>>60952065
ur joking mate?
>>
>>60952083
How else are you supposed to do it?
>>
>>60952110
goto
>>
thanks for the help.

I still couldnt figure shit out but at least i tried.

Thanks everyone~
>>
>>60952169
Gotos are evil, anon
>>
File: Chart.png (92KB, 704x854px) Image search: [Google]
Chart.png
92KB, 704x854px
>>60952065
>>60952169
>gotos
C++ is like 30 years behind the technology
    mother_loop: foreach (n; array)
child_loop: foreach (i; array_2)
if (i == certain_value)
break: mother_loop;


>>60951929
True. See picture.
>>
>>60952202
#define jump goto

for(auto vec: image) {
for(auto flt: vec) {
if(flt == 10) {
cout << "Value " << flt << " found\n";
jump after_loops;
}
}
}
after_loops:;

>>
File: smug_ran3.png (467KB, 1000x1000px) Image search: [Google]
smug_ran3.png
467KB, 1000x1000px
>>60952202
How to spot a pajeet:
>afraid of goto
>>
hey
>>
>>60952253
fatty
>>
File: 1496477496578.png (15KB, 879x554px) Image search: [Google]
1496477496578.png
15KB, 879x554px
>>60952224
>rust
Enjoy being slightly more relevant than Haskell and less relevant than Lisp.
Fucking Lisp. How are you less relevant than fucking Lisp
>>
>>60952281
Is that supposed to be an argument?
>>
>>60952302
Popularity, believe it or not, is a benefit to using a language. You know, some people actually like getting paid to program.

And if you have any errors. Just write

$Language $error_number stack overflow
into google. Can't do that, that well with Rust
>>
>>60952322
What is an IRC channel?
What is a forum?
>>
>>60952332
>in order to be able to use my language you need to use an outdated program for a obscure instant messaging method to ask for help
L M A O
>>
>>60947175
Unless this is some weirdass Scheme dialect, you are using fold wrong.

It's
(foldl/foldr function initial-accumulator-value list)


Like:
(define (len xs)
(foldl (lambda (acc x) (+ acc 1)) 0 xs))
>>
>>60952281
lisp is actually good compared to trashkell and shitty rust
>>
>>60952369
Where did I mention an "outdated program" in my previous post?

How is a language forum and IRC "obscure"?
>>
r8 my code
https://pastebin.com/raw/Wv0pCe0d
>>
New to programming.

Currently I only know Python, rate my list of [to-learn] languages

>Java
>JS
>Kotlin
>C and its derivatives
>Ruby
>>
>>60952391
>How is a language forum and IRC "obscure"?
If you have to ask, you're already too far gone

Also
>irc
>not outdated technology
>>
>>60952405
fucking trash, go isn't on that list
>>
File: 1415497475227.gif (123KB, 480x270px) Image search: [Google]
1415497475227.gif
123KB, 480x270px
>>60951964
D:
>>
>>60952397
that's pretty fucking ugly
>>
>>60952397
import std.stdio;
void main()
{
double dollar;
readf(" %s", &dollar);

immutable string[4] coins = ["Quarter(s)", "Dime(s)", "Nickel(s)", "Penny(/ies)"];
immutable double[4] coins_in_dollars = [0.25, 0.1, 0.05, 0.01];

import std.conv;
auto rest = dollar;
int[string] dollar_in_coins;
foreach (index, coin; coins)
{
dollar_in_coins[coin] = (rest/coins_in_dollars[index]).to!int;
rest -= (coins_in_dollars[index])*dollar_in_coins[coin];
}

writeln(dollar_in_coins);
}
>>
>>60952418
How would you improve it?
>>
>>60952407
So how is IRC "obscure"?
>>
>>60952405
All shit, literally, ever single one.

>>60952411
Go is shit too so it would fit right in.
>>
>>60952411
>Dubs checked

What would I use go for?
>>
>>60952426
program it in a language that's actually useful
>>
>>60952332
Any rust nntp server? I am not aware of any usenet group.
>>
>>60952434
Then give me a non shit language bitchboi
>>
>>60952433
https://www.merriam-webster.com/dictionary/obscure
>>
>>60952253
Well, at least pajeets didn't goto fail jajaja
>>
>>60952436
I developed a web app with golang that i was able to put on my portfolio which got me a job. I think it is pretty useful.
>>
>>60952450
Idris
Haskell
Scheme
Mercury
>>
>>60952464
You got a job that's not in the language you were working on?
How on earth is that useful?
>>
>>60952467
you forgot lambdaprolog
>>
>>60952435
Same exact stuff you would use python for, and more. Mostly web apps though.
>>
>>60952476
Have you actually used it? How is it?
>>
>>60952475
It got me a job, I would say that is pretty useful.
I used it to get me a job. Therefore, useful.
>>
>>60952453
>dark, dim the obscure dusk of the shuttered roomb : shrouded in or hidden by darkness
N/A

> not readily understood or clearly expressed; also : mysterious
Nothing mysterious about IRC


> relatively unknown: such asa : remote, secluded an obscure villageb : not prominent or famous an obscure poet
IRC is a well known technology. Otherwise you wouldn't know what I meant by IRC
>>
>>60952475
>you built a nice house with snap-on branded tools, but we only work with makita in this company so fuck off
>>
>>60952448
I don't use "usenet". I only use Forums and the IRC
>>
>>60952532
Forums are cancerous.
>>
>>60952322
>stack overflow
Some people don't kode
>>
>>60952537
Stack overflow is literally the 9gag of programmers
>>
>>60952502
The only reason why I know what IRC is, is that I hang out with you nerds
>>
>>60952475
>learning languages is DIFFICULT man and can't be done in more than 5 days!
>>
>>60952549
Is stackoverflow a forum?
>>
>>60952556
You are right
>>
>>60952555
Good for you
>>60952567
A form of cancer
>>
I just had a good idea.

Run something like
youtube-dl --download-archive liked_videos.txt --ignore-errors --add-metadata --sleep-interval 10 --max-sleep-interval 60 "your liked videos playlist"

on cron.

Never have to deal with removed or made private videos again.
>>
new thread >>60952630

>>60952630
>>60952630
>>
>>60947354
PYthon would be simplest
>>
File: 1495191530540.jpg (64KB, 437x437px) Image search: [Google]
1495191530540.jpg
64KB, 437x437px
>>60947289
>>60947411
TFW no mutex
Thread posts: 313
Thread images: 34


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

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


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