Тёмный

Code Review: Elixir Lexer 

TheVimeagen
Подписаться 70 тыс.
Просмотров 39 тыс.
50% 1

LIVE ON TWITCH: / theprimeagen
Check out Teej!:
/ @teej_dv
/ teej_dv
Get in on Discord: / discord
Get in on Twitter: / theprimeagen
Got Something For Me to Read or Watch??:
/ theprimeagenreact

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 67   
@stephenreaves3205
@stephenreaves3205 Год назад
Shy: *writes beautiful tail-call recursion* Prime: "WHERES THE LOOP?!"
@madlep
@madlep Год назад
It’s pretty good, idiomatic elixir. Elixir culture is just generally big on docs. The @moduledoc and @doc attributes get compiled into the code, and are there to use in REPL etc to figure out how to use modules/functions without having to Google all the time. It’s pretty useful. The “markdown” bit in the function comments are actually inline doc tests - the “iex> …” is code to execute. The lines after are saying what the expected output is. These are picked up and run automatically when unit tests run. Again, encouraging docs, and also pretty handy. You wouldn’t write all the unit tests there, but more to show example usage - and have the examples actually be verified as working, and not some out of date mess. defp = private function, as opposed to def, which is public Prepending to a build singly linked list is to efficiently build up data when list nodes are immutable - prepend is O(1). Append is O(n) (cause you have to copy the whole thing). This pattern comes up all the time in immutable functional languages. read_identifier doesn’t prepend, because of an optimisation trick you can do in Erlang/Elixir where you build an “improper list” (aka iodata) of bytes, strings, lists in any combination. Then IO.iodata_to_binary flattens that improper list into a binary string. Only works for building binaries, and not actual lists. Agree with doing match on character as a case match in a single function, but that’s personal preference, and either way works. My default is different function heads for different logic, different case match calls to just handle different data.
@JohanStrandOne
@JohanStrandOne 4 месяца назад
thank you for this!
@tensorflaw
@tensorflaw Год назад
"why is it so weird"- it's a functional language. They all look like this
@GuitarWithBrett
@GuitarWithBrett 9 месяцев назад
It’s really not weird like other functional languages , Erlang is sort of its own thing in many ways then elixir makes syntax more “ruby-ish”. Elixir is more about managing the BEAM VM as That’s what the language was built for , not to be functional for functional sake like say Haskell for research
@jatlineur
@jatlineur 2 месяца назад
for oop user, i agree with you, so weird.
@jessejayphotography
@jessejayphotography Год назад
This is a great example of how Elixir can be shockingly easy to understand with just some basic functional paradigms, pattern matching, and special Erlang first class binary syntax.
@wojciechorzechowski2211
@wojciechorzechowski2211 6 месяцев назад
I work in Elixir professionally. I haven't been happier since!
@whisperscribe
@whisperscribe Год назад
I bet if you called José (Creator of Elixir) to a chat, he would gladly accept it (He also streams)
@andredasilva6807
@andredasilva6807 11 месяцев назад
do you know where? i just got into elixir
@whisperscribe
@whisperscribe 11 месяцев назад
@@andredasilva6807 he is on twitch, www.twitch.tv/josevalim There is a cool guy that teaches elixir on yt aswell www.youtube.com/@elixirmentor
@Redyf
@Redyf 11 месяцев назад
​@@andredasilva6807search fir José valim socials, maybe you will be able to find it. I want to get into elixir too, looks like a fun language to learn
@Deemo_codes
@Deemo_codes 9 месяцев назад
Elixir tends to be quite assertive in its function clauses. You see a "when is_whitespace(c)" and that clause will only ever fire on whitespace. So you then don't have to have anything in the function body that deals with other cases. The defp declares a private function so they can only be used internally within this module. It looked like every function was private apart from init. So init is your entry point into this module. It's really nicely written hats off to shy_ryan
@Deemo_codes
@Deemo_codes 9 месяцев назад
Also the compiler will complain if you put a function with the same name anywhere else in the file other than with its buddies
@DiluculoOrtus
@DiluculoOrtus 9 месяцев назад
The clause approach imo is why elixir doesn't need to be statically typed. It is basically whitelisting what kind of data and values and data structures will be handled by the module. If the data passed into the module does not meet the whitelist criteria, or if it is of a nature that causes the module to turn it into something that does not meet the criteria then you get a match error, you know where it happened and with the debugging tools you can easily get a trace of what happened.
@aghileslounis
@aghileslounis 11 месяцев назад
Real types are coming to Elixir core language, they are not just a superset like some other languages, and they are SOUNDED
@RafaelNoronhadeOliveiraSoveral
@RafaelNoronhadeOliveiraSoveral 5 месяцев назад
Lovely
@puspo-in
@puspo-in Год назад
finally, the primeagen write elixir!
@BboyKeny
@BboyKeny Год назад
Technically computer programs are proofs. Therefore computer scientists just skip every other step and force a proof through trail and error. Although with Denotational Semantics you can proof a program on paper, so I think it's possible for programmers to become more like mathematicians in terms of thinking.
@RafaelNoronhadeOliveiraSoveral
@RafaelNoronhadeOliveiraSoveral 5 месяцев назад
Is this an analogy or do you have any reference to the "program-proof equivalence"?
@leetaeryeo5269
@leetaeryeo5269 Год назад
Things have calmed down for me now, so I really need to get back to working on my Visual COBOL branch of this. It’s been fun to write and to watch these reviews.
@pookiepats
@pookiepats 6 месяцев назад
Try GOBOL
@bicunisa
@bicunisa Год назад
Pattern match with several functions is a good thing (tm).
@nomoredarts8918
@nomoredarts8918 Год назад
Every time he says like, toggle like button. Then see at the end if you like the video or not 😂
@dromedda6810
@dromedda6810 Год назад
the lord himself as the wallpaper is the best thing i've seen is some time
@salim444
@salim444 Год назад
can someone point me to the clojure clip they're talking about
@nickboyadjian367
@nickboyadjian367 Год назад
I want to see it too haha
@ath0006
@ath0006 Год назад
Me too!
@salim444
@salim444 Год назад
here is the vod. www.twitch.tv/theprimeagen/v/1844433659?sr=a&t=5042s
@thomvandenhil4717
@thomvandenhil4717 Год назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-SGBuBSXdtLY.html
@jimhrelb2135
@jimhrelb2135 Год назад
love the tpope in the background
@CodeTalker23
@CodeTalker23 Год назад
cmon where F# lexer?
@serdookr
@serdookr Год назад
I mean to be fair it would be almost identical to the ocaml one
@leetaeryeo5269
@leetaeryeo5269 Год назад
There’s one in the repo, but idk if he’s covered it or plans to
@typecraft_dev
@typecraft_dev Год назад
lexer? barely even know 'er
@JeremyAndersonBoise
@JeremyAndersonBoise Год назад
Obligatory
@quarteratom
@quarteratom 9 месяцев назад
This is nice. Only would have been better with Erlang syntax.
@ujjal147
@ujjal147 11 месяцев назад
cond >> multiple function heads usually in Elixir
@fullhalfadder
@fullhalfadder 18 дней назад
Why are they reviewing code they’re not familiar with?
@GuitarWithBrett
@GuitarWithBrett 2 месяца назад
This is painful
@marcusrehn6915
@marcusrehn6915 10 месяцев назад
Elexer
@thetylde
@thetylde 9 месяцев назад
Is there any repo link? 👀
@ankk98
@ankk98 9 месяцев назад
This is harder to understand than I thought.
@connormc711
@connormc711 7 месяцев назад
The hate in this video is unreal from tj
@MaxCoplan
@MaxCoplan Год назад
ALexir
@sunclausewitz2707
@sunclausewitz2707 Год назад
Why does it need to be so cryptic and Perl like.
@sullivan3503
@sullivan3503 Год назад
This isn't really that cryptic if you've used any other functional languages. The only really weird thing here is the binary string.
@blacktipe9922
@blacktipe9922 Год назад
then u better dont look at erlang haha
@JeremyAndersonBoise
@JeremyAndersonBoise Год назад
@@sullivan3503 Totally agree with you here. I understood it fine, and I haven't looked at Elixir in years.
@DMSBrian24
@DMSBrian24 Год назад
What the fuck is going on
@DMSBrian24
@DMSBrian24 Год назад
Thanks, I hate this
@quarteratom
@quarteratom 9 месяцев назад
They are reviewing how beautiful code can be.
@sacredgeometry
@sacredgeometry Год назад
I just thew up a little looking at that code.
@franciscoflamenco
@franciscoflamenco Год назад
it's beautiful code and you just have bad taste.
@rationalityfirst
@rationalityfirst Год назад
weak minded
@sacredgeometry
@sacredgeometry Год назад
​@@rationalityfirst It's called taste. It's unfortunate that you cant buy it otherwise you could use those pennies you earn shaking your ass down the docks to afford yourself some perspective.
@jessejayphotography
@jessejayphotography Год назад
With some basic understanding of functional programming, pattern matching, and Elixir style the code is shockingly understandable to even an intermediate Elixir programmer.
@SimonBuchanNz
@SimonBuchanNz Год назад
I've seen a functional language before so there's not much weird here other than the specific literal syntax.
@32gigs96
@32gigs96 Год назад
Imagine carrying the entire BEAM vm on ur back for a lexer. Elixir should not be used outside of distributed systems
@BrunoArrais1
@BrunoArrais1 Год назад
It's a exercise my man, take it easy
@fenkraken
@fenkraken Год назад
Imagine doing that for JVM. Oh wait, people do that?.. Actually it would be so much better if people stopped doing that, so kinda agree with you in general case.
@stevenhe3462
@stevenhe3462 Год назад
Haha Gradle daemon.
@muhammadsulthanmazaya2388
@muhammadsulthanmazaya2388 Год назад
BLAZINGLY FAST, FIRST!
Далее
whats wrong with new devs?
37:08
Просмотров 313 тыс.
Scams In Software Engineering
31:44
Просмотров 767 тыс.
БЕЛКА СЬЕЛА КОТЕНКА?#cat
00:13
Просмотров 1,4 млн
Code Review: CPP
12:29
Просмотров 64 тыс.
Interview With Sr Rust Developer | Prime Reacts
15:01
Просмотров 566 тыс.
Code Review: Clojure Lexer
12:55
Просмотров 24 тыс.
From $erverless To Elixir | Prime Reacts
22:34
Просмотров 110 тыс.
Memory Optimization
12:36
Просмотров 38 тыс.
From Meth To Netflix
10:30
Просмотров 819 тыс.
Gleam for Impatient Devs
8:46
Просмотров 64 тыс.
Erlang Programming Language - Computerphile
16:05
Просмотров 253 тыс.
Code Review: Ocaml
35:52
Просмотров 34 тыс.